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

Method SetSelectionScalarsToOutput

Filters/Modeling/vtkSelectPolyData.cxx:656–803  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

654
655//------------------------------------------------------------------------------
656void vtkSelectPolyData::SetSelectionScalarsToOutput(vtkPointData* originalPointData,
657 vtkCellData* originalCellData, vtkPolyData* mesh, vtkIdList* edgePointIds,
658 vtkIntArray* pointMarks, vtkPolyData* output)
659{
660 vtkPoints* inPts = mesh->GetPoints();
661 vtkIdType numPts = inPts->GetNumberOfPoints();
662
663 vtkNew<vtkFloatArray> selectionScalars;
664 selectionScalars->SetName(this->SelectionScalarsArrayName);
665 selectionScalars->SetNumberOfTuples(numPts);
666
667 // "Boundary" here refers to a polyline that connects the loop point positions.
668
669 // Compute signed distance to loop for non-boundary points.
670 vtkIdType numLoopPts = this->Loop->GetNumberOfPoints();
671 for (vtkIdType pointId = 0; pointId < numPts; pointId++)
672 {
673 if (this->CheckAbort())
674 {
675 break;
676 }
677
678 if (pointMarks->GetValue(pointId) == 0)
679 {
680 // boundary point, we'll deal with these later
681 continue;
682 }
683
684 // Not an edge point.
685 double x[3];
686 inPts->GetPoint(pointId, x);
687 double closestDist2 = VTK_DOUBLE_MAX;
688 for (vtkIdType i = 0; i < numLoopPts; i++)
689 {
690 double x0[3];
691 double x1[3];
692 this->Loop->GetPoint(i, x0);
693 this->Loop->GetPoint((i + 1) % numLoopPts, x1);
694 double t;
695 double xLoop[3];
696 double dist2 = vtkLine::DistanceToLine(x, x0, x1, t, xLoop);
697 closestDist2 = std::min(dist2, closestDist2);
698 }
699 // Set signed distance
700 double closestDist = 0.0;
701 if (pointMarks->GetValue(pointId) < 0)
702 {
703 closestDist = -sqrt(closestDist2);
704 }
705 else
706 {
707 closestDist = sqrt(closestDist2);
708 }
709 selectionScalars->SetComponent(pointId, 0, closestDist);
710 }
711
712 // Compute signed distance to loop for boundary points.
713 vtkIdType numMeshLoopPts = edgePointIds->GetNumberOfIds();

Callers 1

RequestDataMethod · 0.95

Calls 15

CheckAbortMethod · 0.80
minFunction · 0.50
sqrtFunction · 0.50
GetPointsMethod · 0.45
GetNumberOfPointsMethod · 0.45
SetNameMethod · 0.45
SetNumberOfTuplesMethod · 0.45
GetValueMethod · 0.45
GetPointMethod · 0.45
SetComponentMethod · 0.45
GetNumberOfIdsMethod · 0.45
AllocateMethod · 0.45

Tested by

no test coverage detected