MCPcopy Create free account
hub / github.com/Kitware/VTK / SplitMesh

Method SplitMesh

Filters/General/vtkIntersectionPolyDataFilter.cxx:455–633  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

453
454//------------------------------------------------------------------------------
455int vtkIntersectionPolyDataFilter::Impl ::SplitMesh(
456 int inputIndex, vtkPolyData* output, vtkPolyData* intersectionLines)
457{
458 vtkPolyData* input = this->Mesh[inputIndex];
459 IntersectionMapType* intersectionMap = this->IntersectionMap[inputIndex];
460 vtkCellData* inCD = input->GetCellData();
461 vtkCellData* outCD = output->GetCellData();
462 vtkIdType numCells = input->GetNumberOfCells();
463 vtkIdType cellIdX = 0;
464
465 //
466 // Process points
467 //
468 vtkIdType inputNumPoints = input->GetPoints()->GetNumberOfPoints();
469 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
470 points->Allocate(100);
471 output->SetPoints(points);
472
473 //
474 // Split intersection lines. The lines structure is constructed
475 // using a vtkPointLocator. However, some lines may have an endpoint
476 // on a cell edge that has no neighbor. We need to duplicate a line
477 // point in such a case and update the point ID in the line cell.
478 //
479 vtkSmartPointer<vtkPolyData> splitLines = vtkSmartPointer<vtkPolyData>::New();
480 splitLines->DeepCopy(intersectionLines);
481
482 vtkPointData* inPD = input->GetPointData();
483 vtkPointData* outPD = output->GetPointData();
484 outPD->CopyAllocate(inPD, input->GetNumberOfPoints());
485
486 // Copy over the point data from the input
487 for (vtkIdType ptId = 0; ptId < inputNumPoints; ptId++)
488 {
489 double pt[3];
490 input->GetPoints()->GetPoint(ptId, pt);
491 output->GetPoints()->InsertNextPoint(pt);
492 outPD->CopyData(inPD, ptId, ptId);
493 this->BoundaryPoints[inputIndex]->InsertValue(ptId, 0);
494 }
495
496 // Copy the points from splitLines to the output, interpolating the
497 // data as we go.
498 for (vtkIdType id = 0; id < splitLines->GetNumberOfPoints(); id++)
499 {
500 double pt[3];
501 splitLines->GetPoint(id, pt);
502 vtkIdType newPtId = output->GetPoints()->InsertNextPoint(pt);
503
504 // Retrieve the cell ID from splitLines
505 vtkIdType cellId = this->PointCellIds[inputIndex]->GetValue(id);
506
507 double closestPt[3], pcoords[3], dist2, weights[3];
508 int subId;
509 vtkCell* cell = input->GetCell(cellId);
510 cell->EvaluatePosition(pt, closestPt, subId, pcoords, dist2, weights);
511 outPD->InterpolatePoint(input->GetPointData(), newPtId, cell->PointIds, weights);
512 this->BoundaryPoints[inputIndex]->InsertValue(newPtId, 0);

Callers 1

RequestDataMethod · 0.45

Calls 15

SplitCellMethod · 0.95
GetPolysMethod · 0.80
AllocateEstimateMethod · 0.80
SetPolysMethod · 0.80
InsertNextIdMethod · 0.80
GetCellEdgeNeighborsMethod · 0.80
InsertCellPointMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
ComputeNormalFunction · 0.50
NormalizeFunction · 0.50
DotFunction · 0.50

Tested by

no test coverage detected