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

Method SampleLineAtEachCell

Filters/ParallelDIY2/vtkProbeLineFilter.cxx:1051–1128  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1049
1050//------------------------------------------------------------------------------
1051vtkSmartPointer<vtkPolyData> vtkProbeLineFilter::SampleLineAtEachCell(
1052 const vtkVector3d& p1, const vtkVector3d& p2, vtkDataObject* input, const double tolerance) const
1053{
1054 std::vector<vtkDataObject*> inputs = vtkCompositeDataSet::GetDataSets<vtkDataObject>(input);
1055 if (vtkMathUtilities::FuzzyCompare(p1[0], p2[0], tolerance) &&
1056 vtkMathUtilities::FuzzyCompare(p1[1], p2[1], tolerance) &&
1057 vtkMathUtilities::FuzzyCompare(p1[2], p2[2], tolerance))
1058 {
1059 vtkNew<vtkLineSource> line;
1060 line->SetPoint1(p1.GetData());
1061 line->SetPoint2(p2.GetData());
1062 line->Update();
1063 return vtkPolyData::SafeDownCast(line->GetOutputDataObject(0));
1064 }
1065
1066 // Add every intersection with all blocks of the dataset on our current rank.
1067 vtkNew<vtkLocalProbeLineMerger> localMerger;
1068 for (std::size_t dsId = 0; dsId < inputs.size(); ++dsId)
1069 {
1070 if (auto* ds = vtkDataSet::SafeDownCast(inputs[dsId]))
1071 {
1072 localMerger->AddInputData(0, this->IntersectCells(p1, p2, ds, tolerance));
1073 }
1074 else if (auto* htg = vtkHyperTreeGrid::SafeDownCast(inputs[dsId]))
1075 {
1076 localMerger->AddInputData(0, this->IntersectCells(p1, p2, htg, tolerance));
1077 }
1078 }
1079 localMerger->Update();
1080
1081 // Merge polyline from all MPI processes
1082 constexpr int MPI_COMMUNICATION_TAG = 2022;
1083 int procid = 0;
1084 int numProcs = 1;
1085 if (this->Controller)
1086 {
1087 procid = this->Controller->GetLocalProcessId();
1088 numProcs = this->Controller->GetNumberOfProcesses();
1089 }
1090
1091 vtkNew<vtkRemoteProbeLineMerger> merger;
1092 merger->P1 = p1;
1093 merger->P2 = p2;
1094 merger->Tolerance = tolerance;
1095 merger->SegmentCenters = (this->SamplingPattern == SAMPLE_LINE_AT_SEGMENT_CENTERS);
1096 vtkSmartPointer<vtkPolyData> output;
1097 if (procid != 0)
1098 {
1099 // Satellite nodes send their local polyline
1100 this->Controller->Send(localMerger->GetOutput(), 0, MPI_COMMUNICATION_TAG);
1101
1102 // Even though we don't need to merge the intersections on satellite nodes
1103 // we still want valid data attributes information on output of each nodes
1104 output = vtkSmartPointer<vtkPolyData>::New();
1105 auto* localPD = localMerger->GetOutput()->GetPointData();
1106 for (int i = 0; i < localPD->GetNumberOfArrays(); ++i)
1107 {
1108 localPD->GetAbstractArray(i)->Reset();

Callers 1

Calls 15

IntersectCellsMethod · 0.95
GetNumberOfProcessesMethod · 0.80
GetAbstractArrayMethod · 0.80
FuzzyCompareFunction · 0.50
NewFunction · 0.50
SetPoint1Method · 0.45
GetDataMethod · 0.45
SetPoint2Method · 0.45
UpdateMethod · 0.45
GetOutputDataObjectMethod · 0.45
sizeMethod · 0.45
AddInputDataMethod · 0.45

Tested by

no test coverage detected