Cut a section of input at each centerline point and store it in output, with its properties both on output and on the centerline point. The section arrays are created here, so the array names must be set; cell data arrays already on output are kept. Points are visited in the order of the centerline cells and of the points in each cell; a point shared by several cells is visited once. A point gets no section if ComputeSectionPlane returns false for it or the plane does not cut input. Progress is reported from 0 to 1 over the points. If an abort is requested, it returns before all points are visited.
260{
261 vtkNew<vtkPoints> outputPoints;
262 vtkNew<vtkCellArray> outputPolys;
263
264 output->SetPoints(outputPoints);
265 output->SetPolys(outputPolys);
266 vtkPoints* centerlineSectionPoints = outputPoints;
267 vtkCellArray* centerlineSectionPolys = outputPolys;
268
269 int numberOfCenterlinePoints = this->
Centerlines->GetNumberOfPoints();
270
271
272
273 vtkNew<vtkDoubleArray> centerlineSectionAreaArray;
275 vtkNew<vtkDoubleArray> centerlineSectionMinSizeArray;
277 vtkNew<vtkDoubleArray> centerlineSectionMaxSizeArray;
279 vtkNew<vtkDoubleArray> centerlineSectionShapeArray;
281 vtkNew<vtkIntArray> centerlineSectionClosedArray;
283
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);
289
290 vtkNew<vtkDoubleArray> centerlineAreaArray;
292 vtkNew<vtkDoubleArray> centerlineMinSizeArray;
294 vtkNew<vtkDoubleArray> centerlineMaxSizeArray;
296 vtkNew<vtkDoubleArray> centerlineShapeArray;
298 vtkNew<vtkIntArray> centerlineClosedArray;
300
301 vtkDataArray* centerlineArrays[] = {centerlineAreaArray, centerlineMinSizeArray, centerlineMaxSizeArray, centerlineShapeArray, centerlineClosedArray};
302 for (vtkDataArray* centerlineArray : centerlineArrays)
303 {
304 centerlineArray->SetNumberOfTuples(numberOfCenterlinePoints);
305 centerlineArray->Fill(0.0);
306 this->
Centerlines->GetPointData()->AddArray(centerlineArray);
307 }
308
309
310
311 std::vector<bool> visited(this->
Centerlines->GetNumberOfPoints(),
false);
312
313 const vtkIdType progressInterval = std::max<vtkIdType>(numberOfCenterlinePoints / 100, 1);
314 vtkIdType numberOfVisitedPoints = 0;
315
316
317
318 CrossingCells crossingCells(input);
319 vtkNew<vtkPolyData> sectionInput;
320
321 vtkNew<vtkIdList> cellPointIds;
322 for (vtkIdType cellId=0; cellId<this->
Centerlines->GetNumberOfCells(); cellId++)
323 {
324 this->
Centerlines->GetCellPoints(cellId,cellPointIds);
325 for (vtkIdType i=0; i<cellPointIds->GetNumberOfIds(); i++)
326 {
327 vtkIdType pointId = cellPointIds->GetId(i);
328 if (visited[pointId])
329 {
330 continue;
331 }
332 visited[pointId] = true;
333
334 if (numberOfVisitedPoints % progressInterval == 0)
335 {
336 this->UpdateProgress(static_cast<double>(numberOfVisitedPoints) / numberOfCenterlinePoints);
338 {
339 return;
340 }
341 }
342 numberOfVisitedPoints++;
343
344 double origin[3], normal[3];
346 {
347 continue;
348 }
349
350 vtkNew<vtkPolyData> section;
351 bool closed = false;
352 if (crossingCells.CanSelect())
353 {
354 crossingCells.Select(origin,normal,sectionInput);
356 }
357 else
358 {
360 }
361
362 section->BuildCells();
363 if (section->GetNumberOfCells() == 0)
364 {
365
366 continue;
367 }
368
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++)
373 {
374 vtkIdType sectionPointId = centerlineSectionPoints->InsertNextPoint(sectionCellPoints->GetPoint(k));
375 centerlineSectionPolys->InsertCellPoint(sectionPointId);
376 }
377
379 double sizeRange[2];
381
382 centerlineSectionAreaArray->InsertNextValue(area);
383 centerlineSectionMinSizeArray->InsertNextValue(sizeRange[0]);
384 centerlineSectionMaxSizeArray->InsertNextValue(sizeRange[1]);
385 centerlineSectionShapeArray->InsertNextValue(shape);
386 centerlineSectionClosedArray->InsertNextValue(closed);
387
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);
393
394 this->
ProcessSection(input,pointId,sectionId,section,origin,normal,closed);
395 }
396 }
397}
static double ComputeBranchSectionArea(vtkPolyData *branchSection)
static double ComputeBranchSectionShape(vtkPolyData *branchSection, double center[3], double sizeRange[2])
virtual void ExtractSection(vtkPolyData *input, double origin[3], double normal[3], vtkPolyData *section, bool &closed)
virtual void ProcessSection(vtkPolyData *input, vtkIdType pointId, vtkIdType sectionId, vtkPolyData *section, double origin[3], double normal[3], bool closed)
virtual bool ComputeSectionPlane(vtkIdType cellId, vtkIdType cellPointIndex, double origin[3], double normal[3])