37 vtkDataArray* groupIdsArray = centerlines->GetCellData()->GetArray(groupIdsArrayName);
39 int numberOfCells = centerlines->GetNumberOfCells();
40 vtkIdType maxGroupId = -1;
43 for (i=0; i<numberOfCells; i++)
45 vtkIdType groupId =
static_cast<int>(groupIdsArray->GetComponent(i,0));
46 if (groupId > maxGroupId)
57 vtkDataArray* groupIdsArray = centerlines->GetCellData()->GetArray(groupIdsArrayName);
59 vtkDataArray* blankingArray = NULL;
61 if (blankingArrayName)
63 blankingArray = centerlines->GetCellData()->GetArray(blankingArrayName);
66 int numberOfCells = centerlines->GetNumberOfCells();
68 groupIds->Initialize();
71 for (i=0; i<numberOfCells; i++)
73 vtkIdType groupId =
static_cast<int>(groupIdsArray->GetComponent(i,0));
77 vtkIdType current_blanked =
static_cast<int>(blankingArray->GetComponent(i,0));
78 if (blanked != current_blanked)
83 groupIds->InsertUniqueId(groupId);
104 vtkDataArray* groupIdsArray = centerlines->GetCellData()->GetArray(groupIdsArrayName);
105 int numberOfCells = centerlines->GetNumberOfCells();
107 groupCellIds->Initialize();
110 for (i=0; i<numberOfCells; i++)
112 vtkIdType current_groupId =
static_cast<int>(groupIdsArray->GetComponent(i,0));
113 if (current_groupId != groupId)
117 groupCellIds->InsertNextId(i);
123 vtkDataArray* groupIdsArray = centerlines->GetCellData()->GetArray(groupIdsArrayName);
124 int numberOfCells = centerlines->GetNumberOfCells();
126 groupCellIds->Initialize();
129 for (i=0; i<numberOfCells; i++)
131 vtkIdType current_groupId =
static_cast<int>(groupIdsArray->GetComponent(i,0));
132 if (current_groupId != groupId)
136 int currentNumberOfGroupCellIds = groupCellIds->GetNumberOfIds();
137 bool duplicate =
false;
139 for (j=0; j<currentNumberOfGroupCellIds; j++)
141 double currentCellFirstPoint[3], currentCellLastPoint[3];
142 double cellFirstPoint[3], cellLastPoint[3];
143 vtkCell* cell = centerlines->GetCell(groupCellIds->GetId(j));
144 cell->GetPoints()->GetPoint(0,currentCellFirstPoint);
145 cell->GetPoints()->GetPoint(cell->GetNumberOfPoints()-1,currentCellLastPoint);
146 cell = centerlines->GetCell(i);
147 cell->GetPoints()->GetPoint(0,cellFirstPoint);
148 cell->GetPoints()->GetPoint(cell->GetNumberOfPoints()-1,cellLastPoint);
149 if ((vtkMath::Distance2BetweenPoints(currentCellFirstPoint,cellFirstPoint) <
VTK_VMTK_DOUBLE_TOL) &&
150 (vtkMath::Distance2BetweenPoints(currentCellLastPoint,cellLastPoint) <
VTK_VMTK_DOUBLE_TOL))
160 groupCellIds->InsertNextId(i);
166 vtkDataArray* centerlineIdsArray = centerlines->GetCellData()->GetArray(centerlineIdsArrayName);
167 int numberOfCells = centerlines->GetNumberOfCells();
169 centerlineCellIds->Initialize();
172 for (i=0; i<numberOfCells; i++)
174 vtkIdType currentCenterlineId =
static_cast<int>(centerlineIdsArray->GetComponent(i,0));
175 if (currentCenterlineId != centerlineId)
179 centerlineCellIds->InsertNextId(i);
185 vtkDataArray* centerlineIdsArray = centerlines->GetCellData()->GetArray(centerlineIdsArrayName);
186 vtkDataArray* tractIdsArray = centerlines->GetCellData()->GetArray(tractIdsArrayName);
187 int numberOfCells = centerlines->GetNumberOfCells();
189 centerlineCellIds->Initialize();
190 vtkIdList* centerlineTractIds = vtkIdList::New();
193 for (i=0; i<numberOfCells; i++)
195 vtkIdType currentCenterlineId =
static_cast<int>(centerlineIdsArray->GetComponent(i,0));
196 if (currentCenterlineId != centerlineId)
200 centerlineCellIds->InsertNextId(i);
201 vtkIdType currectTractId =
static_cast<int>(tractIdsArray->GetComponent(i,0));
202 centerlineTractIds->InsertNextId(currectTractId);
205 int numberOfCenterlineCellIds = centerlineCellIds->GetNumberOfIds();
211 for (i=0; i<numberOfCenterlineCellIds-1; i++)
213 if (centerlineTractIds->GetId(i) > centerlineTractIds->GetId(i+1))
215 vtkIdType tmp = centerlineTractIds->GetId(i+1);
216 centerlineTractIds->SetId(i+1,centerlineTractIds->GetId(i));
217 centerlineTractIds->SetId(i,tmp);
218 tmp = centerlineCellIds->GetId(i+1);
219 centerlineCellIds->SetId(i+1,centerlineCellIds->GetId(i));
220 centerlineCellIds->SetId(i,tmp);
226 centerlineTractIds->Delete();
231 vtkDataArray* groupIdsArray = centerlines->GetCellData()->GetArray(groupIdsArrayName);
232 int numberOfCells = centerlines->GetNumberOfCells();
234 vtkIdType cellId = -1;
236 for (i=0; i<numberOfCells; i++)
238 vtkIdType current_groupId =
static_cast<int>(groupIdsArray->GetComponent(i,0));
239 if (current_groupId != groupId)
257 vtkDataArray* blankingArray = centerlines->GetCellData()->GetArray(blankingArrayName);
258 int blanking =
static_cast<int>(blankingArray->GetComponent(cellId,0));
259 int isBlanked = blanking == 1 ? 1 : 0;
265 upStreamGroupIds->Initialize();
266 downStreamGroupIds->Initialize();
268 vtkDataArray* centerlineGroupIdsArray = centerlines->GetCellData()->GetArray(groupIdsArrayName);
269 vtkDataArray* centerlineIdsArray = centerlines->GetCellData()->GetArray(centerlineIdsArrayName);
270 vtkDataArray* centerlineTractIdsArray = centerlines->GetCellData()->GetArray(tractIdsArrayName);
272 int numberOfCenterlineCells = centerlines->GetNumberOfCells();
275 for (i=0; i<numberOfCenterlineCells; i++)
277 vtkIdType branchGroupId =
static_cast<int>(centerlineGroupIdsArray->GetComponent(i,0));
279 if (branchGroupId != groupId)
284 vtkCell* centerlineBranch = centerlines->GetCell(i);
285 if (centerlineBranch->GetCellType() != VTK_LINE && centerlineBranch->GetCellType() != VTK_POLY_LINE)
290 vtkIdType branchCenterlineId =
static_cast<int>(centerlineIdsArray->GetComponent(i,0));
291 vtkIdType branchCenterlineTractId =
static_cast<int>(centerlineTractIdsArray->GetComponent(i,0));
294 for (j=0; j<numberOfCenterlineCells; j++)
296 vtkIdType currentBranchCenterlineGroupId =
static_cast<int>(centerlineGroupIdsArray->GetComponent(j,0));
297 vtkIdType currentBranchCenterlineId =
static_cast<int>(centerlineIdsArray->GetComponent(j,0));
298 vtkIdType currentBranchCenterlineTractId =
static_cast<int>(centerlineTractIdsArray->GetComponent(j,0));
300 if (currentBranchCenterlineGroupId == branchGroupId)
305 if (currentBranchCenterlineId != branchCenterlineId)
311 if (currentBranchCenterlineTractId == branchCenterlineTractId - 1)
313 upStreamGroupIds->InsertUniqueId(currentBranchCenterlineGroupId);
316 if (currentBranchCenterlineTractId == branchCenterlineTractId + 1)
318 downStreamGroupIds->InsertUniqueId(currentBranchCenterlineGroupId);
326 double point0[3], point1[3];
327 vtkPoints* centerlineCellPoints = centerlines->GetCell(cellId)->GetPoints();
328 centerlineCellPoints->GetPoint(subId,point0);
329 centerlineCellPoints->GetPoint(subId+1,point1);
331 interpolatedPoint[0] = (1.0 - pcoord) * point0[0] + pcoord * point1[0];
332 interpolatedPoint[1] = (1.0 - pcoord) * point0[1] + pcoord * point1[1];
333 interpolatedPoint[2] = (1.0 - pcoord) * point0[2] + pcoord * point1[2];
338 vtkDataArray* array = centerlines->GetPointData()->GetArray(arrayName);
339 int numberOfComponents = array->GetNumberOfComponents();
340 vtkIdType pointId0 = centerlines->GetCell(cellId)->GetPointId(subId);
341 vtkIdType pointId1 = centerlines->GetCell(cellId)->GetPointId(subId+1);
342 double* tuple0 = array->GetTuple(pointId0);
343 double* tuple1 = array->GetTuple(pointId1);
346 for (i=0; i<numberOfComponents; i++)
348 interpolatedTuple[i] = (1.0 - pcoord) * tuple0[i] + pcoord * tuple1[i];
354 mergingPoints->Initialize();
355 int numberOfCells = centerlines->GetNumberOfCells();
357 for (i=0; i<numberOfCells; i++)
359 vtkCell* centerline = centerlines->GetCell(i);
360 int numberOfCenterlinePoints = centerline->GetNumberOfPoints();
361 int previousMergeStatus = -1;
362 int mergeStatus = -1;
363 for (j=0; j<numberOfCenterlinePoints; j++)
366 centerline->GetPoints()->GetPoint(j,point);
367 for (k=i+1; k<numberOfCells; k++)
369 vtkCell* currentCenterline = centerlines->GetCell(k);
370 int numberOfCurrentCenterlinePoints = currentCenterline->GetNumberOfPoints();
371 double closestPoint[3];
375 double* weights =
new double[numberOfCurrentCenterlinePoints];
376 currentCenterline->EvaluatePosition(point,closestPoint,subId,pcoords,dist2,weights);
377 if (dist2 < tolerance*tolerance)
385 if (j>0 && mergeStatus != previousMergeStatus)
387 mergingPoints->InsertNextPoint(point);
388 previousMergeStatus = mergeStatus;
static void FindAdjacentCenterlineGroupIds(vtkPolyData *centerlines, const char *groupIdsArrayName, const char *centerlineIdsArrayName, const char *tractIdsArrayName, vtkIdType groupId, vtkIdList *upStreamGroupIds, vtkIdList *downStreamGroupIds)