From 52f26364fd8f6e45fbf2643b192372845dee18e5 Mon Sep 17 00:00:00 2001 From: papush! Date: Wed, 30 Mar 2022 09:36:00 +0200 Subject: [PATCH] show the mesh and id of the point farthest from the other mesh --- src/main.cc | 2 ++ src/max_distance_filter.cc | 12 ++++++++++-- src/max_distance_filter.h | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index 482a21a..d3c9261 100644 --- a/src/main.cc +++ b/src/main.cc @@ -142,6 +142,8 @@ int main(int argc, char **argv) { maxDistanceFilter->Update(); std::cerr << "Max distance: " << maxDistanceFilter->GetMaxDist() << "\n" + << "Max dist point id: " << maxDistanceFilter->GetMaxId() + << " in " << (maxDistanceFilter->GetMaxInput() == 0 ? "tetMesh\n" : "polyMesh\n") << "Average min angle: " << dihedralAnglesFilter->GetAverageMinDegrees() << "\n" << "Min min angle: " << dihedralAnglesFilter->GetMinMinDegrees() << "\n"; diff --git a/src/max_distance_filter.cc b/src/max_distance_filter.cc index 84409fb..c97f405 100644 --- a/src/max_distance_filter.cc +++ b/src/max_distance_filter.cc @@ -51,7 +51,11 @@ vtkTypeBool MaxDistanceFilter::RequestData(vtkInformation *request, double vec[3]; double dist; closestPolyMeshPoint(input2, point, tree2, links2, vec, &dist); - MaxDist = std::max(dist, MaxDist); + if (dist > MaxDist) { + MaxDist = dist; + MaxId = i; + MaxInput = 0; + } } for (vtkIdType i = 0; i < input2->GetNumberOfPoints(); i++) { vtkIdType nCells = links2->GetNcells(i); @@ -61,7 +65,11 @@ vtkTypeBool MaxDistanceFilter::RequestData(vtkInformation *request, double vec[3]; double dist; closestPolyMeshPoint(input1, point, tree1, links1, vec, &dist); - MaxDist = std::max(dist, MaxDist); + if (dist > MaxDist) { + MaxDist = dist; + MaxId = i; + MaxInput = 1; + } } return true; } diff --git a/src/max_distance_filter.h b/src/max_distance_filter.h index 6ecf0e8..a85ea03 100644 --- a/src/max_distance_filter.h +++ b/src/max_distance_filter.h @@ -14,9 +14,13 @@ public: vtkInformationVector **inputVector, vtkInformationVector *outputVector) override; vtkGetMacro(MaxDist, double); + vtkGetMacro(MaxId, vtkIdType); + vtkGetMacro(MaxInput, vtkIdType); protected: double MaxDist; + vtkIdType MaxId; + vtkIdType MaxInput; };