261 vtkNew<vtkPoints> outputPoints;
262 vtkNew<vtkCellArray> outputPolys;
264 output->SetPoints(outputPoints);
265 output->SetPolys(outputPolys);
266 vtkPoints* centerlineSectionPoints = outputPoints;
267 vtkCellArray* centerlineSectionPolys = outputPolys;
269 int numberOfCenterlinePoints = this->
Centerlines->GetNumberOfPoints();
273 vtkNew<vtkDoubleArray> centerlineSectionAreaArray;
275 vtkNew<vtkDoubleArray> centerlineSectionMinSizeArray;
277 vtkNew<vtkDoubleArray> centerlineSectionMaxSizeArray;
279 vtkNew<vtkDoubleArray> centerlineSectionShapeArray;
281 vtkNew<vtkIntArray> centerlineSectionClosedArray;
284 output->GetCellData()->AddArray(centerlineSectionAreaArray);
285 output->GetCellData()->AddArray(centerlineSectionMinSizeArray);
286 output->GetCellData()->AddArray(centerlineSectionMaxSizeArray);
287 output->GetCellData()->AddArray(centerlineSectionShapeArray);
288 output->GetCellData()->AddArray(centerlineSectionClosedArray);
290 vtkNew<vtkDoubleArray> centerlineAreaArray;
292 vtkNew<vtkDoubleArray> centerlineMinSizeArray;
294 vtkNew<vtkDoubleArray> centerlineMaxSizeArray;
296 vtkNew<vtkDoubleArray> centerlineShapeArray;
298 vtkNew<vtkIntArray> centerlineClosedArray;
301 vtkDataArray* centerlineArrays[] = {centerlineAreaArray, centerlineMinSizeArray, centerlineMaxSizeArray, centerlineShapeArray, centerlineClosedArray};
302 for (vtkDataArray* centerlineArray : centerlineArrays)
304 centerlineArray->SetNumberOfTuples(numberOfCenterlinePoints);
305 centerlineArray->Fill(0.0);
306 this->
Centerlines->GetPointData()->AddArray(centerlineArray);
311 std::vector<bool> visited(this->
Centerlines->GetNumberOfPoints(),
false);
313 const vtkIdType progressInterval = std::max<vtkIdType>(numberOfCenterlinePoints / 100, 1);
314 vtkIdType numberOfVisitedPoints = 0;
318 CrossingCells crossingCells(input);
319 vtkNew<vtkPolyData> sectionInput;
321 vtkNew<vtkIdList> cellPointIds;
322 for (vtkIdType cellId=0; cellId<this->
Centerlines->GetNumberOfCells(); cellId++)
324 this->
Centerlines->GetCellPoints(cellId,cellPointIds);
325 for (vtkIdType i=0; i<cellPointIds->GetNumberOfIds(); i++)
327 vtkIdType pointId = cellPointIds->GetId(i);
328 if (visited[pointId])
332 visited[pointId] =
true;
334 if (numberOfVisitedPoints % progressInterval == 0)
336 this->UpdateProgress(
static_cast<double>(numberOfVisitedPoints) / numberOfCenterlinePoints);
342 numberOfVisitedPoints++;
344 double origin[3], normal[3];
350 vtkNew<vtkPolyData> section;
352 if (crossingCells.CanSelect())
354 crossingCells.Select(origin,normal,sectionInput);
362 section->BuildCells();
363 if (section->GetNumberOfCells() == 0)
369 vtkPoints* sectionCellPoints = section->GetCell(0)->GetPoints();
370 int numberOfSectionCellPoints = sectionCellPoints->GetNumberOfPoints();
371 vtkIdType sectionId = centerlineSectionPolys->InsertNextCell(numberOfSectionCellPoints);
372 for (
int k=0; k<numberOfSectionCellPoints; k++)
374 vtkIdType sectionPointId = centerlineSectionPoints->InsertNextPoint(sectionCellPoints->GetPoint(k));
375 centerlineSectionPolys->InsertCellPoint(sectionPointId);
382 centerlineSectionAreaArray->InsertNextValue(area);
383 centerlineSectionMinSizeArray->InsertNextValue(sizeRange[0]);
384 centerlineSectionMaxSizeArray->InsertNextValue(sizeRange[1]);
385 centerlineSectionShapeArray->InsertNextValue(shape);
386 centerlineSectionClosedArray->InsertNextValue(closed);
388 centerlineAreaArray->SetValue(pointId,area);
389 centerlineMinSizeArray->SetValue(pointId,sizeRange[0]);
390 centerlineMaxSizeArray->SetValue(pointId,sizeRange[1]);
391 centerlineShapeArray->SetValue(pointId,shape);
392 centerlineClosedArray->SetValue(pointId,closed);
394 this->
ProcessSection(input,pointId,sectionId,section,origin,normal,closed);
401 vtkNew<vtkIdList> cellPointIds;
402 this->
Centerlines->GetCellPoints(cellId,cellPointIds);
403 const vtkIdType numberOfCellPoints = cellPointIds->GetNumberOfIds();
405 this->
Centerlines->GetPoint(cellPointIds->GetId(cellPointIndex),origin);
410 normal[0] = normal[1] = normal[2] = 0.0;
411 double neighborPoint[3], direction[3];
412 for (vtkIdType step : {-1, 1})
414 for (vtkIdType j=cellPointIndex+step; j>=0 && j<numberOfCellPoints; j+=step)
416 this->
Centerlines->GetPoint(cellPointIds->GetId(j),neighborPoint);
417 vtkMath::Subtract(neighborPoint,origin,direction);
418 double distance = vtkMath::Normalize(direction);
421 normal[0] += step * direction[0];
422 normal[1] += step * direction[1];
423 normal[2] += step * direction[2];
429 return vtkMath::Normalize(normal) > 0.0;