From 0ce873df20f344e03419cd9b678ced24501f55d4 Mon Sep 17 00:00:00 2001 From: lavenklau Date: Sun, 25 Jun 2023 10:31:28 +0800 Subject: [PATCH] fix meshing problem: 1. incorrect vertex indexing in convex hull computation; 2. remove potential sliver in CGAL generated mesh by using ODT and minumus angle bound. 3. improve the distance tolerence in dumbSnap3D. --- src/lib/isosurface_inflator/CGALClippedVolumeMesher.cc | 3 ++- src/lib/isosurface_inflator/ConvexHullTriangulation.cc | 2 +- src/lib/isosurface_inflator/PostProcess.cc | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/isosurface_inflator/CGALClippedVolumeMesher.cc b/src/lib/isosurface_inflator/CGALClippedVolumeMesher.cc index 59cad6e..80379b8 100644 --- a/src/lib/isosurface_inflator/CGALClippedVolumeMesher.cc +++ b/src/lib/isosurface_inflator/CGALClippedVolumeMesher.cc @@ -156,7 +156,8 @@ mesh(const SignedDistanceRegion<3> &sdf, // Mesh generation // std::cout << "Making mesh..." << std::endl; BENCHMARK_START_TIMER("make_mesh_3"); - C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria); + C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, CGAL::parameters::features(domain), + CGAL::parameters::odt(), CGAL::parameters::perturb(0, 20), CGAL::parameters::exude(0, 20)); // CGAL sometimes returns an empty mesh for some patterns due to // insufficient initialization: // https://github.com/CGAL/cgal/issues/2416 diff --git a/src/lib/isosurface_inflator/ConvexHullTriangulation.cc b/src/lib/isosurface_inflator/ConvexHullTriangulation.cc index b2b2fd5..5798328 100644 --- a/src/lib/isosurface_inflator/ConvexHullTriangulation.cc +++ b/src/lib/isosurface_inflator/ConvexHullTriangulation.cc @@ -44,7 +44,7 @@ void convexHullFromTriangulation(const PointCollection &points, for (size_t i = 0; 3 * i < indexBuffer.size(); ++i) { hullElements[i].resize(3); for (size_t lv = 0; lv < 3; ++lv) { - hullElements[i][lv] = newVertexId[indexBuffer[i * lv + lv]]; + hullElements[i][lv] = newVertexId[indexBuffer[i * 3 + lv]]; } } } diff --git a/src/lib/isosurface_inflator/PostProcess.cc b/src/lib/isosurface_inflator/PostProcess.cc index 20e5baa..189ce1d 100644 --- a/src/lib/isosurface_inflator/PostProcess.cc +++ b/src/lib/isosurface_inflator/PostProcess.cc @@ -125,7 +125,8 @@ void postProcess(vector &vertices, << "WARNING: smartSnap3D failed--probably nonsmooth geometry at cell interface. Resorting to dumbSnap3D." << std::endl; std::cerr << "(" << e.what() << ")" << std::endl; - dumbSnap3D(vertices, meshCell, opts.facetDistance); + // dumbSnap3D(vertices, meshCell, opts.facetDistance); + dumbSnap3D(vertices, meshCell, 2 * opts.domainErrorBound); } BBox snappedBB(vertices); if (N == 2) {