------------------------------------------------------------------------------
| 1049 | |
| 1050 | //------------------------------------------------------------------------------ |
| 1051 | vtkSmartPointer<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(); |
no test coverage detected