From cde06c708841b8e76c49eb38c7768091e3eadaca Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 5 Mar 2015 15:45:14 +0100 Subject: [PATCH] remove weight calculator from the public API of fairing it is still available internally --- .../CGAL/Polygon_mesh_processing/fair.h | 31 ++++++------ .../include/CGAL/triangulate_hole.h | 49 +++++++++++++++++-- .../Polyhedron_demo_fairing_plugin.cpp | 2 +- 3 files changed, 60 insertions(+), 22 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/fair.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/fair.h index 8fc0b02670f..4d7f89bfc46 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/fair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/fair.h @@ -18,21 +18,33 @@ namespace Polygon_mesh_processing { @tparam SparseLinearSolver a model of `SparseLinearAlgebraTraitsWithPreFactor_d`. If \ref thirdpartyEigen "Eigen" 3.2 (or greater) is available and `CGAL_EIGEN3_ENABLED` is defined, then an overload of `Eigen_solver_traits` is provided as default parameter. - @tparam WeightCalculator a model of `FairWeightCalculator` and can be omitted to use default Cotangent weights @tparam PolygonMesh must be a model of `MutableFaceGraph` @tparam InputIterator iterator over input vertices @param pmesh polygon mesh to be faired @param vertex_begin first iterator of the range of vertices @param vertex_end past-the-end iterator of the range of vertices - @param weight_calculator function object to calculate weights, default to Cotangent weights and can be omitted @param continuity tangential continuity, default to `FAIRING_C_1` and can be omitted @return `true` if fairing is successful, otherwise no vertex position is changed @todo accuracy of solvers are not good, for example when there is no boundary condition pre_factor should fail, but it does not. - \todo WeightCalculator should be a property map */ + template + bool fair(PolygonMesh& pmesh, + InputIterator vb, + InputIterator ve, + Fairing_continuity continuity = FAIRING_C_1 + ) + { + typedef CGAL::internal::Cotangent_weight_with_voronoi_area_fairing Weight_calculator; + return fair + (pmesh, vb, ve, Weight_calculator(pmesh), continuity); + } + + // use non-default weight calculator + // WeightCalculator a model of `FairWeightCalculator`, can be omitted to use default Cotangent weights + // weight_calculator a function object to calculate weights, defaults to Cotangent weights and can be omitted template bool fair(PolygonMesh& pmesh, InputIterator vertex_begin, @@ -60,19 +72,6 @@ namespace Polygon_mesh_processing { (pmesh, vb, ve, weight_calculator, continuity); } - //use default WeightCalculator - template - bool fair(PolygonMesh& pmesh, - InputIterator vb, - InputIterator ve, - Fairing_continuity continuity = FAIRING_C_1 - ) - { - typedef CGAL::internal::Cotangent_weight_with_voronoi_area_fairing Weight_calculator; - return fair - (pmesh, vb, ve, Weight_calculator(pmesh), continuity); - } - //use default SparseLinearSolver and WeightCalculator template bool fair(PolygonMesh& pmesh, diff --git a/Polygon_mesh_processing/include/CGAL/triangulate_hole.h b/Polygon_mesh_processing/include/CGAL/triangulate_hole.h index 6df2b4d704d..8900dddac2f 100644 --- a/Polygon_mesh_processing/include/CGAL/triangulate_hole.h +++ b/Polygon_mesh_processing/include/CGAL/triangulate_hole.h @@ -116,7 +116,6 @@ namespace Polygon_mesh_processing { one can pass `CGAL::Default()` as `solver`. @tparam SparseLinearSolver a model of `SparseLinearAlgebraTraitsWithPreFactor_d` - @tparam WeightCalculator a model of `FairWeightCalculator` @tparam PolygonMesh must be model of `MutableFaceGraph` @tparam FaceOutputIterator iterator holding `boost::graph_traits::%face_descriptor` for patch faces. @tparam VertexOutputIterator iterator holding `boost::graph_traits::%vertex_descriptor` for patch vertices. @@ -125,7 +124,6 @@ namespace Polygon_mesh_processing { @param border_halfedge a border halfedge incident to the hole @param face_out iterator over patch faces @param vertex_out iterator over patch vertices without including the boundary - @param weight_calculator function object to calculate weights, default to Cotangent weights and can be omitted @param density_control_factor factor for density where larger values cause denser refinements @param continuity tangential continuity, default to `FAIRING_C_1` and can be omitted @param use_delaunay_triangulation if `true`, use the Delaunay triangulation face search space @@ -138,8 +136,50 @@ namespace Polygon_mesh_processing { - @a vertex_out \todo handle islands - \todo WeightCalculator should be a property map */ + template + boost::tuple + triangulate_refine_and_fair_hole(PolygonMesh& pmesh, + typename boost::graph_traits::halfedge_descriptor border_halfedge, + FaceOutputIterator face_out, + VertexOutputIterator vertex_out, + SparseLinearSolver +#ifdef DOXYGEN_RUNNING + solver, +#else + /* solver */, +#endif + double density_control_factor = std::sqrt(2.0), + Fairing_continuity continuity = FAIRING_C_1, + bool use_delaunay_triangulation = true) + { + bool use_dt3 = +#ifdef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 + false; +#else + use_delaunay_triangulation; +#endif + std::vector::vertex_descriptor> patch; + + face_out = triangulate_and_refine_hole + (pmesh, border_halfedge, face_out, std::back_inserter(patch), + density_control_factor, use_dt3).first; + + typedef internal::Fair_default_sparse_linear_solver::Solver Default_solver; + typedef typename Default::Get::type Solver; + + bool fair_success = fair(pmesh, patch.begin(), patch.end(), continuity); + + vertex_out = std::copy(patch.begin(), patch.end(), vertex_out); + return boost::make_tuple(fair_success, face_out, vertex_out); + } + + // use non-default weight calculator + // WeightCalculator a model of `FairWeightCalculator` + // weight_calculator function object to calculate weights, default to Cotangent weights and can be omitted template wc(pmesh); return triangulate_refine_and_fair_hole - (pmesh, border_halfedge, face_out, vertex_out, wc, Default(), + (pmesh, border_halfedge, face_out, vertex_out, Default(), density_control_factor, continuity, use_dt3); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_fairing_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_fairing_plugin.cpp index 9ef59fc770b..19ca2a4ae85 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_fairing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_fairing_plugin.cpp @@ -84,7 +84,7 @@ public slots: CGAL::Polygon_mesh_processing::fair(*selection_item->polyhedron(), selection_item->selected_vertices.begin(), selection_item->selected_vertices.end(), - CGAL::internal::Cotangent_weight_with_voronoi_area_fairing(*selection_item->polyhedron()), +// CGAL::internal::Cotangent_weight_with_voronoi_area_fairing(*selection_item->polyhedron()), continuity); selection_item->changed_with_poly_item(); QApplication::restoreOverrideCursor();