From 44c32a0b02076466e33f79d6aec42c366dfcc262 Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Sat, 5 Jan 2019 13:01:50 +0100 Subject: [PATCH] added tolerance parameter to quickhull --- vcg/complex/algorithms/convex_hull.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vcg/complex/algorithms/convex_hull.h b/vcg/complex/algorithms/convex_hull.h index 1739ff9b..5be5fa8f 100644 --- a/vcg/complex/algorithms/convex_hull.h +++ b/vcg/complex/algorithms/convex_hull.h @@ -166,8 +166,9 @@ public: "The quickhull algorithm for convex hulls" by C. Bradford Barber et al. ACM Transactions on Mathematical Software, Volume 22 Issue 4, Dec. 1996 */ - static bool ComputeConvexHull(InputMesh& mesh, CHMesh& convexHull) + static bool ComputeConvexHull(InputMesh& mesh, CHMesh& convexHull, ScalarType distTolerance = 0) { + assert(distTolerance >= 0); vcg::tri::RequireFFAdjacency(convexHull); vcg::tri::RequirePerFaceNormal(convexHull); vcg::tri::Allocator::CompactVertexVector(mesh); @@ -187,7 +188,7 @@ public: for (size_t j = 0; j < convexHull.face.size(); j++) { ScalarType dist = (mesh.vert[i].P() - convexHull.face[j].P(0)).dot(convexHull.face[j].N()); - if (dist > 0) + if (dist > distTolerance) { listVertexPerFace[j].push_back(&mesh.vert[i]); if (dist > furthestVexterPerFace[j].second) @@ -223,7 +224,7 @@ public: { int indexF = vcg::tri::Index(convexHull, nextF); ScalarType dist = (vertex->P() - nextF->P(0)).dot(nextF->N()); - if (dist < 0) + if (dist < distTolerance) { borderFace.push_back(indexF); fp->SetB(ii); @@ -294,7 +295,7 @@ public: if (!(*vertexToTest[ii]).IsV()) { float dist = ((*vertexToTest[ii]).P() - (*fi).P(0)).dot((*fi).N()); - if (dist > 0) + if (dist > distTolerance) { tempVect.push_back(vertexToTest[ii]); if (dist > newInfo.second)