55{
60
62 vtkIdList* centerlineGroupCellIds = vtkIdList::New();
63
68
69 double averagePoint[3];
70 averagePoint[0] = averagePoint[1] = averagePoint[2] = 0.0;
71 double averageNormal[3];
72 averageNormal[0] = averageNormal[1] = averageNormal[2] = 0.0;
73 double averageTangent[3];
74 averageTangent[0] = averageTangent[1] = averageTangent[2] = 0.0;
75 double weightSum = 0.0;
76
77 int numberOfCenterlineCells = this->
Centerlines->GetNumberOfCells();
78 for (int i=0; i<numberOfCenterlineCells; i++)
79 {
80 int centerlineGroupId = static_cast<int>(centerlineGroupIdsArray->GetComponent(i,0));
81 if (centerlineGroupId != groupId)
82 {
83 continue;
84 }
85
86 centerlineGroupCellIds->Initialize();
87 centerlineGroupCellIds->InsertNextId(i);
88
90 {
91 int centerlineId = static_cast<int>(centerlineIdsArray->GetComponent(i,0));
92 int centerlineTractId = static_cast<int>(centerlineTractIdsArray->GetComponent(i,0));
93
94 for (int j=0; j<numberOfCenterlineCells; j++)
95 {
96 if (j==i)
97 {
98 continue;
99 }
100
101 int adjacentCenterlineGroupId = static_cast<int>(centerlineGroupIdsArray->GetComponent(j,0));
102 int adjacentCenterlineId = static_cast<int>(centerlineIdsArray->GetComponent(j,0));
103 int adjacentCenterlineTractId = static_cast<int>(centerlineTractIdsArray->GetComponent(j,0));
104 int adjacentBlanking = static_cast<int>(blankingArray->GetComponent(j,0));
105
106 if (adjacentBlanking == 0)
107 {
108 continue;
109 }
110
111 if (adjacentCenterlineGroupId == centerlineGroupId)
112 {
113 continue;
114 }
115
116 if (adjacentCenterlineId != centerlineId)
117 {
118 continue;
119 }
120
121 if (!((adjacentCenterlineTractId == centerlineTractId - 1) ||
122 (adjacentCenterlineTractId == centerlineTractId + 1)))
123 {
124 continue;
125 }
126
127 centerlineGroupCellIds->InsertNextId(j);
128 }
129 }
130
132
136
137 vtkCell* polyLine = this->
Centerlines->GetCell(centerlineCellId);
138
139 if (polyLine->GetCellType() != VTK_LINE && polyLine->GetCellType() != VTK_POLY_LINE)
140 {
141 continue;
142 }
143
144 double radius = 0.0;
146 double weight = radius * radius;
147 double centerlinePoint[3];
149
150 averagePoint[0] += weight * centerlinePoint[0];
151 averagePoint[1] += weight * centerlinePoint[1];
152 averagePoint[2] += weight * centerlinePoint[2];
153
154 double centerlinePoint0[3], centerlinePoint1[3];
155 polyLine->GetPoints()->GetPoint(centerlineSubId,centerlinePoint0);
156 polyLine->GetPoints()->GetPoint(centerlineSubId+1,centerlinePoint1);
157
158 if (vtkMath::Distance2BetweenPoints(centerlinePoint0,centerlinePoint1) <
VTK_VMTK_DOUBLE_TOL)
159 {
160 if (centerlineSubId > 0)
161 {
162 polyLine->GetPoints()->GetPoint(centerlineSubId-1,centerlinePoint0);
163 }
164 else if (centerlineSubId+1 < polyLine->GetNumberOfPoints()-1)
165 {
166 polyLine->GetPoints()->GetPoint(centerlineSubId+2,centerlinePoint1);
167 }
168 }
169
170 double tangent[3];
171 tangent[0] = centerlinePoint1[0] - centerlinePoint0[0];
172 tangent[1] = centerlinePoint1[1] - centerlinePoint0[1];
173 tangent[2] = centerlinePoint1[2] - centerlinePoint0[2];
174
175 averageTangent[0] += weight * tangent[0];
176 averageTangent[1] += weight * tangent[1];
177 averageTangent[2] += weight * tangent[2];
178 double normal[3];
180
181 averageNormal[0] += weight * normal[0];
182 averageNormal[1] += weight * normal[1];
183 averageNormal[2] += weight * normal[2];
184
185 weightSum += weight;
186 }
187
188 averagePoint[0] /= weightSum;
189 averagePoint[1] /= weightSum;
190 averagePoint[2] /= weightSum;
191 vtkMath::Normalize(averageNormal);
192 vtkMath::Normalize(averageTangent);
193
194 double projectedPoint[3];
195 vtkPlane::ProjectPoint(point,averagePoint,averageTangent,projectedPoint);
196
197 double positionVector[3];
198 positionVector[0] = projectedPoint[0] - averagePoint[0];
199 positionVector[1] = projectedPoint[1] - averagePoint[1];
200 positionVector[2] = projectedPoint[2] - averagePoint[2];
201 vtkMath::Normalize(positionVector);
202
203 double normalPoint[3];
204 normalPoint[0] = averagePoint[0] + averageNormal[0];
205 normalPoint[1] = averagePoint[1] + averageNormal[1];
206 normalPoint[2] = averagePoint[2] + averageNormal[2];
207
208 double projectedNormalPoint[3];
209 vtkPlane::ProjectPoint(normalPoint,averagePoint,averageTangent,projectedNormalPoint);
210
211 double projectedNormal[3];
212 projectedNormal[0] = projectedNormalPoint[0] - averagePoint[0];
213 projectedNormal[1] = projectedNormalPoint[1] - averagePoint[1];
214 projectedNormal[2] = projectedNormalPoint[2] - averagePoint[2];
215 vtkMath::Normalize(projectedNormal);
216
217 double cross[3];
218 vtkMath::Cross(positionVector,projectedNormal,cross);
219
220 double tangentDot = vtkMath::Dot(averageTangent,cross);
221
223
224 if (tangentDot < 0.0)
225 {
226 angle *= -1.0;
227 }
228
229 metricArray->SetComponent(pointId,0,angle);
230
231 centerlineGroupCellIds->Delete();
232 tube->Delete();
233}
static void InterpolatePoint(vtkPolyData *centerlines, int cellId, int subId, double pcoord, double interpolatedPoint[3])
static void InterpolateTuple1(vtkPolyData *centerlines, const char *arrayName, int cellId, int subId, double pcoord, double &interpolatedTuple1)
static void InterpolateTuple3(vtkPolyData *centerlines, const char *arrayName, int cellId, int subId, double pcoord, double interpolatedTuple3[3])
static double AngleBetweenNormals(double normal0[3], double normal1[3])
virtual double GetLastPolyBallCellPCoord()
virtual void SetInput(vtkPolyData *)
virtual void SetPolyBallRadiusArrayName(const char *)
virtual void SetInputCellIds(vtkIdList *)
virtual void SetUseRadiusInformation(int)
virtual vtkIdType GetLastPolyBallCellId()
static vtkvmtkPolyBallLine * New()
double EvaluateFunction(double x[3]) override
virtual vtkIdType GetLastPolyBallCellSubId()
char * CenterlineIdsArrayName
vtkPolyData * Centerlines
char * CenterlineGroupIdsArrayName
char * CenterlineTractIdsArrayName
#define VTK_VMTK_DOUBLE_TOL