From fbd29ab314d63a07bbb2add5e7b43ee5c4594a1e Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Mon, 31 Jul 2017 15:01:22 +0200 Subject: [PATCH] additional parameter added to remesher --- .../trimesh_voronoi_remesh.cpp | 6 ++--- vcg/complex/algorithms/voronoi_processing.h | 2 +- vcg/complex/algorithms/voronoi_remesher.h | 26 ++++++++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/apps/sample/trimesh_voronoi_remesh/trimesh_voronoi_remesh.cpp b/apps/sample/trimesh_voronoi_remesh/trimesh_voronoi_remesh.cpp index 3280e7a0..573d014d 100644 --- a/apps/sample/trimesh_voronoi_remesh/trimesh_voronoi_remesh.cpp +++ b/apps/sample/trimesh_voronoi_remesh/trimesh_voronoi_remesh.cpp @@ -70,15 +70,15 @@ int main( int argc, char **argv ) } tri::UpdateBounding::Box(startMesh); - float samplingRadius = startMesh.bbox.Diag() * 0.01f; + float samplingRadius = startMesh.bbox.Diag() * 0.005f; if (argc == 3) { try { samplingRadius = stof(string(argv[2])); } catch (exception &) {} } - std::cout << "using sampling radius: " << samplingRadius << std::endl; - auto remeshed = Remesher::Remesh(startMesh, samplingRadius, 75.0); + std::cout << "Remeshing using sampling radius: " << samplingRadius << std::endl; + auto remeshed = Remesher::Remesh(startMesh, samplingRadius, 50.0, 0.0); tri::io::ExporterPLY::Save(*remeshed,"Full.ply",tri::io::Mask::IOM_VERTCOLOR|tri::io::Mask::IOM_WEDGTEXCOORD ); diff --git a/vcg/complex/algorithms/voronoi_processing.h b/vcg/complex/algorithms/voronoi_processing.h index c8b72346..7fc83e58 100644 --- a/vcg/complex/algorithms/voronoi_processing.h +++ b/vcg/complex/algorithms/voronoi_processing.h @@ -1224,7 +1224,7 @@ static int RestrictedVoronoiRelaxing(MeshType &m, std::vector &seedPo area[fi->V(i)]+=a3; } - assert(m.vn > (int)seedPosVec.size()*20); +// assert(m.vn > (int)seedPosVec.size()*20); int i; ScalarType perturb = m.bbox.Diag()*vpp.seedPerturbationAmount; for(i=0;i(original, vcg::math::ToRad(borderCreaseAngleDeg)); - Allocator::CompactEveryVector(original); - UpdateTopology::FaceFace(original); - UpdateFlags::FaceBorderFromFF(original); - UpdateFlags::VertexBorderFromFaceAdj(original); + if (creaseAngleDeg > 0) + { + CreaseCut(original, vcg::math::ToRad(creaseAngleDeg)); + Allocator::CompactEveryVector(original); + UpdateTopology::FaceFace(original); + UpdateFlags::FaceBorderFromFF(original); + UpdateFlags::VertexBorderFromFaceAdj(original); + } // Mark the non manifold border vertices as visited on the input mesh // TODO maybe optimize this @@ -218,7 +225,7 @@ public: std::vector ccs = splitCC(original); if (ccs.empty()) { - return RemeshOneCC(original, samplingRadius, borderCreaseAngleDeg); + return RemeshOneCC(original, samplingRadius, borderAngleDeg); } // Multiple CCs @@ -226,7 +233,7 @@ public: for (size_t i=0; i(); @@ -238,6 +245,8 @@ public: return ret; } +protected: + /// /// \brief RemeshOneCC the function that remeshes a single connected component mesh preserving its boundary (consistently for eventually adjacent meshes). /// \param original the mesh @@ -448,7 +457,6 @@ public: return finalMeshPtr; } -protected: static inline void ExtractMeshBorders(Mesh & mesh, EdgeMeshType & sides) { RequireFFAdjacency(mesh);