From 70afbbcdfcbd4e51ea3ebbda3f7e6daf59dfcb77 Mon Sep 17 00:00:00 2001 From: papush! Date: Thu, 24 Mar 2022 15:13:57 +0100 Subject: [PATCH] fix mesh distance computation --- src/closest_polymesh_point.cc | 1 - src/max_distance_filter.cc | 4 ++++ src/project_surface_points_on_poly.cc | 3 +-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/closest_polymesh_point.cc b/src/closest_polymesh_point.cc index 2f552ce..7053093 100644 --- a/src/closest_polymesh_point.cc +++ b/src/closest_polymesh_point.cc @@ -15,7 +15,6 @@ vtkIdType findClosestPoint(const double *point, vtkPointSet *pointSet) { minPoint = i; } } - std::cerr << "closest: " << minPoint << "\n"; return minPoint; } diff --git a/src/max_distance_filter.cc b/src/max_distance_filter.cc index 6732a98..84409fb 100644 --- a/src/max_distance_filter.cc +++ b/src/max_distance_filter.cc @@ -44,6 +44,8 @@ vtkTypeBool MaxDistanceFilter::RequestData(vtkInformation *request, links2->BuildLinks(input2); MaxDist = 0; for (vtkIdType i = 0; i < input1->GetNumberOfPoints(); i++) { + vtkIdType nCells = links1->GetNcells(i); + if (nCells == 0) continue; double point[3]; input1->GetPoint(i, point); double vec[3]; @@ -52,6 +54,8 @@ vtkTypeBool MaxDistanceFilter::RequestData(vtkInformation *request, MaxDist = std::max(dist, MaxDist); } for (vtkIdType i = 0; i < input2->GetNumberOfPoints(); i++) { + vtkIdType nCells = links2->GetNcells(i); + if (nCells == 0) continue; double point[3]; input2->GetPoint(i, point); double vec[3]; diff --git a/src/project_surface_points_on_poly.cc b/src/project_surface_points_on_poly.cc index 6988c7d..be8b1a2 100644 --- a/src/project_surface_points_on_poly.cc +++ b/src/project_surface_points_on_poly.cc @@ -82,7 +82,7 @@ void ProjectSurfacePointsOnPoly::moveSurfacePoint( auto affectedPoints = removeSurfacePoints(pointsInRadius, isSurface); // tetMeshKdTree->FindPointsWithinRadius(distance * RadiusScale, point, affectedPoints); - if(distance > 0) for (vtkIdType j = 0; j < affectedPoints->GetNumberOfIds(); j++) { + for (vtkIdType j = 0; j < affectedPoints->GetNumberOfIds(); j++) { vtkIdType affectedPointId = affectedPoints->GetId(j); double affectedPoint[3]; tetMesh->GetPoint(affectedPointId, affectedPoint); @@ -97,7 +97,6 @@ void ProjectSurfacePointsOnPoly::moveSurfacePoint( double motion[3] = {direction[0], direction[1], direction[2]}; double factor = 1. - std::sqrt(dist2) / (distance * RadiusScale); vtkMath::MultiplyScalar(motion, factor); - //std::cout << std::sqrt(dist2) << " " << (distance * radiusScale) << " " << factor << "\n"; motionVectors[affectedPointId * 3 + 0] += motion[0]; motionVectors[affectedPointId * 3 + 1] += motion[1]; motionVectors[affectedPointId * 3 + 2] += motion[2];