diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml index b15b2658b6c..3d2f2941c95 100644 --- a/.github/workflows/build_doc.yml +++ b/.github/workflows/build_doc.yml @@ -47,15 +47,7 @@ jobs: //get pullrequest url const pr_number = context.payload.issue.number return pr_number - - uses: actions/checkout@v3 - name: "checkout branch" - if: steps.get_round.outputs.result != 'stop' - with: - repository: ${{ github.repository }} - ref: refs/pull/${{ steps.get_pr_number.outputs.result }}/merge - token: ${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }} - fetch-depth: 2 - + - name: Emoji-comment uses: actions/github-script@v6 if: steps.get_round.outputs.result != 'stop' @@ -67,6 +59,16 @@ jobs: repo: context.repo.repo, content: 'rocket' }) + + - uses: actions/checkout@v3 + name: "checkout branch" + if: steps.get_round.outputs.result != 'stop' + with: + repository: ${{ github.repository }} + ref: refs/pull/${{ steps.get_pr_number.outputs.result }}/merge + token: ${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }} + fetch-depth: 2 + - name: install dependencies if: steps.get_round.outputs.result != 'stop' run: | @@ -151,11 +153,13 @@ jobs: }); - name: Post error + env: + ERRORMSG: ${{steps.build_and_run.outputs.DoxygenError}} uses: actions/github-script@v6 if: ${{ failure() && steps.get_round.outputs.result != 'stop' }} with: script: | - const error = "${{steps.build_and_run.outputs.DoxygenError}}" + const error = process.env.ERRORMSG const msg = "There was an error while building the doc: \n"+error github.rest.issues.createComment({ owner: "CGAL", diff --git a/Combinatorial_map/doc/Combinatorial_map/Combinatorial_map.txt b/Combinatorial_map/doc/Combinatorial_map/Combinatorial_map.txt index 37ce36209f0..dc0736fc74b 100644 --- a/Combinatorial_map/doc/Combinatorial_map/Combinatorial_map.txt +++ b/Combinatorial_map/doc/Combinatorial_map/Combinatorial_map.txt @@ -542,7 +542,7 @@ Let d0\f$ \in \f$ D be a dart. Given i, 1 \f$ \leq \f$ i \section Combinatorial_mapDesign Design and Implementation History -The code of this package is inspired by Moka, a 3D topological modeler mainly developed by Frédéric Vidil and Guillaume Damiand (http://moka-modeller.sourceforge.net/). However, Moka was based on Generalized maps (and not Combinatorial maps), and the design was not \cgal "compatible". Thus, Guillaume Damiand started to develop a totally new package by mixing ideas taken from Moka with the design of the Halfedge data structure package of \cgal. Andreas Fabri and Sébastien Loriot contributed to the design, the coding, and to the documentation of the package, and Laurent Rineau helped for the design. Emma Michel contributed to the manual. Monique Teillaud and Bernd Gärtner contributed to the manual by giving useful remarks, really numerous and detailed for Monique. Ken Arroyo Ohori contributed to the two reverse orientation functions. +The code of this package is inspired by Moka, a 3D topological modeler mainly developed by Frédéric Vidil and Guillaume Damiand (https://moka-modeller.sourceforge.net/). However, Moka was based on Generalized maps (and not Combinatorial maps), and the design was not \cgal "compatible". Thus, Guillaume Damiand started to develop a totally new package by mixing ideas taken from Moka with the design of the Halfedge data structure package of \cgal. Andreas Fabri and Sébastien Loriot contributed to the design, the coding, and to the documentation of the package, and Laurent Rineau helped for the design. Emma Michel contributed to the manual. Monique Teillaud and Bernd Gärtner contributed to the manual by giving useful remarks, really numerous and detailed for Monique. Ken Arroyo Ohori contributed to the two reverse orientation functions. */ } /* namespace CGAL */ diff --git a/Documentation/doc/Documentation/Third_party.txt b/Documentation/doc/Documentation/Third_party.txt index f24bb9e24a3..bc1b5475d2f 100644 --- a/Documentation/doc/Documentation/Third_party.txt +++ b/Documentation/doc/Documentation/Third_party.txt @@ -213,7 +213,7 @@ the handling of \pdb data. In \cgal, the \esbtl is used in an example of the \ref PkgSkinSurface3 package. -It can be downloaded from `http://esbtl.sourceforge.net/`. +It can be downloaded from `https://esbtl.sourceforge.net/`. \subsection thirdpartyTBB Intel TBB diff --git a/Generalized_map/doc/Generalized_map/Generalized_map.txt b/Generalized_map/doc/Generalized_map/Generalized_map.txt index 2d6ad5b52ba..b842e148205 100644 --- a/Generalized_map/doc/Generalized_map/Generalized_map.txt +++ b/Generalized_map/doc/Generalized_map/Generalized_map.txt @@ -551,7 +551,7 @@ Let d0 \f$ \in \f$ D be a dart. Given i, 0 \f$ \leq \f$ \section Generalized_mapDesign Design and Implementation History -The code of this package followed the code of Combinatorial maps and was inspired by Moka, a 3D topological modeler that uses 3D generalized maps (http://moka-modeller.sourceforge.net/). +The code of this package followed the code of Combinatorial maps and was inspired by Moka, a 3D topological modeler that uses 3D generalized maps (https://moka-modeller.sourceforge.net/). */ } /* namespace CGAL */ diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 8b1050a721a..d8864b2f58d 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -59,6 +59,10 @@ CGAL tetrahedral Delaunay refinement algorithm. described by the concept `TriangulationDataStructure_2::Face`. The model `CGAL::Hyperbolic_triangulation_face_base_2` has been adapted correspondingly. +### [Surface Mesh Simplification](https://doc.cgal.org/5.6/Manual/packages.html#PkgSurfaceMeshSimplification) +- The stop predicates `Count_stop_predicate` and `Count_ratio_stop_predicate` are renamed to `Edge_count_stop_predicate` and `Edge_count_ratio_stop_predicate`. Older versions have been deprecated. +- Introduce `Face_count_stop_predicate` and `Face_count_ratio_stop_predicate` that can be used to stop the simplification algorithm based on a desired number of faces in the output, or a ratio between input and output face numbers. + [Release 5.5](https://github.com/CGAL/cgal/releases/tag/v5.5) ----------- diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_simplification_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_simplification_plugin.cpp index c8913412da2..31f46ffc2fb 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_simplification_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_simplification_plugin.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -25,7 +25,7 @@ typedef Scene_facegraph_item::Face_graph FaceGraph; class Custom_stop_predicate { bool m_and; - CGAL::Surface_mesh_simplification::Count_stop_predicate m_count_stop; + CGAL::Surface_mesh_simplification::Edge_count_stop_predicate m_count_stop; CGAL::Surface_mesh_simplification::Edge_length_stop_predicate m_length_stop; public: diff --git a/STL_Extension/doc/STL_Extension/CGAL/algorithm.h b/STL_Extension/doc/STL_Extension/CGAL/algorithm.h index 13fa64df19b..2250a4a3e93 100644 --- a/STL_Extension/doc/STL_Extension/CGAL/algorithm.h +++ b/STL_Extension/doc/STL_Extension/CGAL/algorithm.h @@ -42,7 +42,7 @@ Computes the minimal and the maximal element of a range. It is modeled after the \stl functions `std::min_element` and `std::max_element`. +href="https://en.cppreference.com/w/cpp/algorithm/max_element">`std::max_element`. The advantage of `min_max_element()` compared to calling both \stl functions is that one only iterates once over the sequence. This is more efficient especially for large and/or complex sequences. diff --git a/Snap_rounding_2/doc/Snap_rounding_2/Concepts/SnapRoundingTraits_2.h b/Snap_rounding_2/doc/Snap_rounding_2/Concepts/SnapRoundingTraits_2.h index 04d7d3c0359..5f908c59c86 100644 --- a/Snap_rounding_2/doc/Snap_rounding_2/Concepts/SnapRoundingTraits_2.h +++ b/Snap_rounding_2/doc/Snap_rounding_2/Concepts/SnapRoundingTraits_2.h @@ -189,7 +189,7 @@ class ConstructVertex_2 public: /*! returns the source or target of `seg`. If `i` modulo 2 is 0, - the source is returned, otherwise the target is returned.} + the source is returned, otherwise the target is returned. */ Point_2 operator()(Segment_2 seg, int i); }; @@ -223,7 +223,7 @@ class ConstructIsoRectangle_2 public: /*! - introduces an iso-oriented rectangle for whose minimal `x` coordinate + introduces an iso-oriented rectangle whose minimal `x` coordinate is the one of `left`, the maximal `x` coordinate is the one of `right`, the minimal `y` coordinate is the one of `bottom`, the maximal `y` coordinate is the one of `top`.} diff --git a/Snap_rounding_2/doc/Snap_rounding_2/Snap_rounding_2.txt b/Snap_rounding_2/doc/Snap_rounding_2/Snap_rounding_2.txt index bffd43ef1dd..41d9f6872e4 100644 --- a/Snap_rounding_2/doc/Snap_rounding_2/Snap_rounding_2.txt +++ b/Snap_rounding_2/doc/Snap_rounding_2/Snap_rounding_2.txt @@ -128,8 +128,7 @@ Polyline number 4: The package is supplied with a graphical demo program that opens a window, allows the user to edit segments dynamically, applies a selected snap-rounding procedures, and displays the result onto the same window -(see `/demo/Snap_rounding_2/demo.cpp`). +(see `/demo/Snap_rounding_2/Snap_rounding_2.cpp`). */ } /* namespace CGAL */ - diff --git a/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h b/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h index ae424f2bc1c..add923b15e2 100644 --- a/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h +++ b/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h @@ -19,7 +19,6 @@ #include #include -#include #include #include #include diff --git a/Surface_mesh/benchmark/polyhedron_performance.h b/Surface_mesh/benchmark/polyhedron_performance.h index 6229adb0007..b4de8bd6b6d 100644 --- a/Surface_mesh/benchmark/polyhedron_performance.h +++ b/Surface_mesh/benchmark/polyhedron_performance.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -461,7 +461,7 @@ private: ) vb->id() = index++; - SMS::Count_ratio_stop_predicate stop(0.1); + SMS::Edge_count_ratio_stop_predicate stop(0.1); int r = SMS::edge_collapse(P, stop); #endif } diff --git a/Surface_mesh/benchmark/surface_mesh_performance.h b/Surface_mesh/benchmark/surface_mesh_performance.h index 9ab57e28c9a..e310a6f4400 100644 --- a/Surface_mesh/benchmark/surface_mesh_performance.h +++ b/Surface_mesh/benchmark/surface_mesh_performance.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include typedef CGAL::Simple_cartesian K; @@ -284,7 +284,7 @@ private: mesh.clear(); bool b = CGAL::IO::read_OFF(_filename, mesh); - SMS::Count_ratio_stop_predicate stop(0.1); + SMS::Edge_count_ratio_stop_predicate stop(0.1); int r = SMS::edge_collapse(mesh, stop); } diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h index 8ffe08d081a..f4a5378489b 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h @@ -5,6 +5,8 @@ namespace Surface_mesh_simplification { /*! \ingroup PkgSurfaceMeshSimplificationRef +\deprecated This class is deprecated since \cgal 5.6, the class `Edge_count_ratio_stop_predicate` should be used instead. + The class `Count_ratio_stop_predicate` is a model for the `StopPredicate` concept which returns `true` when the relation between the initial and current number of edges drops below a certain ratio. @@ -12,8 +14,8 @@ which returns `true` when the relation between the initial and current number of \cgalModels `StopPredicate` -\sa `CGAL::Surface_mesh_simplification::Count_stop_predicate` - +\sa `CGAL::Surface_mesh_simplification::Edge_count_ratio_stop_predicate` +\sa `CGAL::Surface_mesh_simplification::Face_count_ratio_stop_predicate` */ template< typename TriangleMesh> class Count_ratio_stop_predicate @@ -34,7 +36,7 @@ public: /// @{ /*! - Returns `((double)current_edge_count / (double)initial_edge_count) < ratio`. + Returns `(double(current_edge_count) / double(initial_edge_count)) < ratio`. All other parameters are ignored (but exist since this is a generic policy). */ bool operator()(const Edge_profile::FT current_cost, diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h index 7e6deb0254a..bef9e2fdba9 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h @@ -4,6 +4,8 @@ namespace Surface_mesh_simplification { /*! \ingroup PkgSurfaceMeshSimplificationRef +\deprecated This class is deprecated since \cgal 5.6, the class `Edge_count_stop_predicate` should be used instead. + The class `Count_stop_predicate` is a model for the `StopPredicate` concept, which returns `true` when the number of current edges drops below a certain threshold. @@ -11,8 +13,8 @@ which returns `true` when the number of current edges drops below a certain thre \cgalModels `StopPredicate` -\sa `CGAL::Surface_mesh_simplification::Count_ratio_stop_predicate` - +\sa `CGAL::Surface_mesh_simplification::Edge_count_stop_predicate` +\sa `CGAL::Surface_mesh_simplification::Face_count_stop_predicate` */ template class Count_stop_predicate diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h new file mode 100644 index 00000000000..fed8537304f --- /dev/null +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h @@ -0,0 +1,50 @@ + +namespace CGAL { +namespace Surface_mesh_simplification { + +/*! +\ingroup PkgSurfaceMeshSimplificationRef + +\cgalModels `StopPredicate` + +The class `Edge_count_ratio_stop_predicate` is a model for the `StopPredicate` concept +which returns `true` when the relation between the initial and current number of edges drops below a certain ratio. + +\tparam TriangleMesh is the type of surface mesh being simplified, and must be a model of the `MutableFaceGraph` and `HalfedgeListGraph` concepts. + +\sa `CGAL::Surface_mesh_simplification::Edge_count_stop_predicate` +\sa `CGAL::Surface_mesh_simplification::Face_count_ratio_stop_predicate` +*/ +template< typename TriangleMesh> +class Edge_count_ratio_stop_predicate +{ +public: + + /// \name Creation + /// @{ + + /*! + Initializes the predicate establishing the `ratio`. + */ + Edge_count_ratio_stop_predicate(const double ratio); + + /// @} + + /// \name Operations + /// @{ + + /*! + Returns `(double(current_edge_count) / double(initial_edge_count)) < ratio`. + All other parameters are ignored (but exist since this is a generic policy). + */ + bool operator()(const Edge_profile::FT current_cost, + const Edge_profile& edge_profile, + const Edge_profile::edges_size_type initial_edge_count, + const Edge_profile::edges_size_type current_edge_count) const; + + /// @} + +}; + +} // namespace Surface_mesh_simplification +} // namespace CGAL diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h new file mode 100644 index 00000000000..6e3920dd421 --- /dev/null +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h @@ -0,0 +1,48 @@ +namespace CGAL { +namespace Surface_mesh_simplification { + +/*! +\ingroup PkgSurfaceMeshSimplificationRef + +\cgalModels `StopPredicate` + +The class `Edge_count_stop_predicate` is a model for the `StopPredicate` concept, +which returns `true` when the number of current edges drops below a certain threshold. + +\tparam TriangleMesh is the type of surface mesh being simplified, and must be a model of the `MutableFaceGraph` and `HalfedgeListGraph` concepts. + +\sa `CGAL::Surface_mesh_simplification::Face_count_stop_predicate` +\sa `CGAL::Surface_mesh_simplification::Edge_ratio_count_stop_predicate` +*/ +template +class Edge_count_stop_predicate +{ +public: + + /// \name Creation + /// @{ + + /*! + Initializes the predicate establishing the `threshold` value. + */ + Edge_count_stop_predicate(const Edge_profile::edges_size_type threshold); + + /// @} + + /// \name Operations + /// @{ + + /*! + Returns `(current_edge_count < threshold)`. All other parameters are ignored (but exist since this is a generic policy). + */ + bool operator()(const Edge_profile::FT& current_cost, + const Edge_profile& edge_profile, + const Edge_profile::edges_size_type initial_edge_count, + const Edge_profile::edges_size_type current_edge_count) const; + + /// @} + +}; + +} // namespace Surface_mesh_simplification +} // namespace CGAL diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_ratio_stop_predicate.h b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_ratio_stop_predicate.h new file mode 100644 index 00000000000..f5154aeb0d8 --- /dev/null +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_ratio_stop_predicate.h @@ -0,0 +1,51 @@ + +namespace CGAL { +namespace Surface_mesh_simplification { + +/*! +\ingroup PkgSurfaceMeshSimplificationRef + +\cgalModels `StopPredicate` + +The class `Face_count_ratio_stop_predicate` is a model for the `StopPredicate` concept +which returns `true` when the relation between the initial and current number of faces drops below a certain ratio. + +\tparam TriangleMesh is the type of surface mesh being simplified, and must be a model of the `MutableFaceGraph` and `HalfedgeListGraph` concepts. + +\sa `CGAL::Surface_mesh_simplification::Edge_count_ratio_stop_predicate` +\sa `CGAL::Surface_mesh_simplification::Face_count_stop_predicate` +*/ +template< typename TriangleMesh> +class Face_count_ratio_stop_predicate +{ +public: + + /// \name Creation + /// @{ + + /*! + Initializes the predicate establishing the `ratio`. + */ + Face_count_ratio_stop_predicate(const double ratio, const TriangleMesh& tmesh); + + /// @} + + /// \name Operations + /// @{ + + /*! + Returns `true` if the ratio of current face count over initial face count is strictly smaller than `ratio`, + and `false` otherwise. + All other parameters are ignored (but exist since this is a generic policy). + */ + bool operator()(const Edge_profile::FT current_cost, + const Edge_profile& edge_profile, + const Edge_profile::edges_size_type initial_edge_count, + const Edge_profile::edges_size_type current_edge_count) const; + + /// @} + +}; + +} // namespace Surface_mesh_simplification +} // namespace CGAL diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_stop_predicate.h b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_stop_predicate.h new file mode 100644 index 00000000000..8c35a5c35e7 --- /dev/null +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_stop_predicate.h @@ -0,0 +1,49 @@ +namespace CGAL { +namespace Surface_mesh_simplification { + +/*! +\ingroup PkgSurfaceMeshSimplificationRef + +\cgalModels `StopPredicate` + +The class `Face_count_stop_predicate` is a model for the `StopPredicate` concept, +which returns `true` when the number of current faces drops below a certain threshold. + +\tparam TriangleMesh is the type of surface mesh being simplified, and must be a model of the `MutableFaceGraph` and `HalfedgeListGraph` concepts. + +\sa `CGAL::Surface_mesh_simplification::Edge_count_stop_predicate` +\sa `CGAL::Surface_mesh_simplification::Face_count_ratio_stop_predicate` +*/ +template +class Face_count_stop_predicate +{ +public: + + /// \name Creation + /// @{ + + /*! + Initializes the predicate establishing the `threshold` value. + */ + Face_count_stop_predicate(const Edge_profile::edges_size_type threshold); + + /// @} + + /// \name Operations + /// @{ + + /*! + Returns `true` if the current face count is strictly smaller than `threshold`, and `false` otherwise. + All other parameters are ignored (but exist since this is a generic policy). + */ + bool operator()(const Edge_profile::FT& current_cost, + const Edge_profile& edge_profile, + const Edge_profile::edges_size_type initial_edge_count, + const Edge_profile::edges_size_type current_edge_count) const; + + /// @} + +}; + +} // namespace Surface_mesh_simplification +} // namespace CGAL diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/Concepts/StopPredicate.h b/Surface_mesh_simplification/doc/Surface_mesh_simplification/Concepts/StopPredicate.h index b24bc09c99e..ad5f22d4ccb 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/Concepts/StopPredicate.h +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/Concepts/StopPredicate.h @@ -4,8 +4,10 @@ The concept `StopPredicate` describes the requirements for the predicate which indicates if the simplification process must finish. -\cgalHasModel `CGAL::Surface_mesh_simplification::Count_stop_predicate` -\cgalHasModel `CGAL::Surface_mesh_simplification::Count_ratio_stop_predicate` +\cgalHasModel `CGAL::Surface_mesh_simplification::Edge_count_stop_predicate` +\cgalHasModel `CGAL::Surface_mesh_simplification::Face_count_stop_predicate` +\cgalHasModel `CGAL::Surface_mesh_simplification::Edge_count_ratio_stop_predicate` +\cgalHasModel `CGAL::Surface_mesh_simplification::Face_count_ratio_stop_predicate` \cgalHasModel `CGAL::Surface_mesh_simplification::Edge_length_stop_predicate` */ diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/PackageDescription.txt b/Surface_mesh_simplification/doc/Surface_mesh_simplification/PackageDescription.txt index f29f913fc0a..1d97e670f9d 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/PackageDescription.txt +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/PackageDescription.txt @@ -34,8 +34,12 @@ - `CGAL::Surface_mesh_simplification::edge_collapse()` \cgalCRPSection{Policies} -- `CGAL::Surface_mesh_simplification::Count_stop_predicate` -- `CGAL::Surface_mesh_simplification::Count_ratio_stop_predicate` +- `CGAL::Surface_mesh_simplification::Count_stop_predicate` (deprecated) +- `CGAL::Surface_mesh_simplification::Count_ratio_stop_predicate` (deprecated) +- `CGAL::Surface_mesh_simplification::Edge_count_stop_predicate` +- `CGAL::Surface_mesh_simplification::Face_count_stop_predicate` +- `CGAL::Surface_mesh_simplification::Edge_count_ratio_stop_predicate` +- `CGAL::Surface_mesh_simplification::Face_count_ratio_stop_predicate` - `CGAL::Surface_mesh_simplification::Edge_length_stop_predicate` - `CGAL::Surface_mesh_simplification::Edge_length_cost` - `CGAL::Surface_mesh_simplification::Midpoint_placement` diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_OpenMesh.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_OpenMesh.cpp index a90d0f46d95..ec95cbce18b 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_OpenMesh.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_OpenMesh.cpp @@ -5,7 +5,7 @@ // Simplification function #include -#include +#include #include #include @@ -70,7 +70,7 @@ int main(int argc, char** argv) // In this example, the simplification stops when the number of undirected edges // left in the surface mesh drops below the specified number (1000) const std::size_t stop_n = (argc > 2) ? std::stoi(argv[2]) : 1000; - SMS::Count_stop_predicate stop(stop_n); + SMS::Edge_count_stop_predicate stop(stop_n); // This the actual call to the simplification algorithm. // The surface mesh and stop conditions are mandatory arguments. diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_bounded_normal_change.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_bounded_normal_change.cpp index e8d0ba8ba1b..88eb9b986e7 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_bounded_normal_change.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_bounded_normal_change.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include @@ -53,7 +53,7 @@ int main(int argc, char** argv) // In this example, the simplification stops when the number of undirected edges // left in the surface mesh drops below the specified number const std::size_t stop_n = (argc > 2) ? std::stoi(argv[2]) : num_halfedges(surface_mesh)/2 - 1; - SMS::Count_stop_predicate stop(stop_n); + SMS::Edge_count_stop_predicate stop(stop_n); typedef SMS::LindstromTurk_placement Placement; diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp index 678087c38b2..f40a35faeae 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -121,7 +121,7 @@ int main(int argc, char** argv) std::cerr << "# sharp edges = " << nb_sharp_edges << std::endl; // Contract the surface mesh as much as possible - SMS::Count_stop_predicate stop(0); + SMS::Edge_count_stop_predicate stop(0); std::cout << "Collapsing as many non-sharp edges of mesh: " << filename << " as possible..." << std::endl; int r = SMS::edge_collapse(surface_mesh, stop, diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_polyhedron.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_polyhedron.cpp index 9c50a593725..1fcb9ce4e05 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_polyhedron.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_polyhedron.cpp @@ -11,7 +11,7 @@ #include // Stop-condition policy -#include +#include #include #include @@ -78,7 +78,7 @@ int main(int argc, char** argv) } // Contract the surface mesh as much as possible - SMS::Count_stop_predicate stop(0); + SMS::Edge_count_stop_predicate stop(0); Border_is_constrained_edge_map bem(surface_mesh); // This the actual call to the simplification algorithm. diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_surface_mesh.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_surface_mesh.cpp index b60753cddfc..4d3418e9abe 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_surface_mesh.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_surface_mesh.cpp @@ -11,7 +11,7 @@ #include // Stop-condition policy -#include +#include #include #include @@ -77,7 +77,7 @@ int main(int argc, char** argv) } // Contract the surface mesh as much as possible - SMS::Count_stop_predicate stop(0); + SMS::Edge_count_stop_predicate stop(0); Border_is_constrained_edge_map bem(surface_mesh); // This the actual call to the simplification algorithm. diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_enriched_polyhedron.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_enriched_polyhedron.cpp index b239ca291c8..16677d12fd3 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_enriched_polyhedron.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_enriched_polyhedron.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -53,7 +53,7 @@ int main(int argc, char** argv) // In this example, the simplification stops when the number of undirected edges // drops below xx% of the initial count const double ratio = (argc > 2) ? std::stod(argv[2]) : 0.1; - SMS::Count_ratio_stop_predicate stop(ratio); + SMS::Edge_count_ratio_stop_predicate stop(ratio); // The index maps are not explicitelty passed as in the previous // example because the surface mesh items have a proper id() field. diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_envelope.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_envelope.cpp index 6b8ee4e8902..7fc05ffc8b8 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_envelope.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_envelope.cpp @@ -3,7 +3,7 @@ #include -#include +#include #include #include #include @@ -33,7 +33,7 @@ int main(int argc, char** argv) std::ifstream is(argc > 1 ? argv[1] : CGAL::data_file_path("meshes/helmet.off")); is >> mesh; - SMS::Count_stop_predicate stop(0); // go as far as you can while in the envelope + SMS::Edge_count_stop_predicate stop(0); // go as far as you can while in the envelope CGAL::Iso_cuboid_3 bbox(CGAL::Polygon_mesh_processing::bbox(mesh)); diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_garland_heckbert.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_garland_heckbert.cpp index afd3957287d..365fc39d267 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_garland_heckbert.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_garland_heckbert.cpp @@ -1,11 +1,13 @@ #include #include -#include +#include #include #include #include +#include + #include #include #include @@ -29,13 +31,13 @@ void collapse_gh(Surface_mesh& mesh, { std::chrono::steady_clock::time_point start_time = std::chrono::steady_clock::now(); - SMS::Count_ratio_stop_predicate stop(ratio); + SMS::Edge_count_ratio_stop_predicate stop(ratio); // Garland&Heckbert simplification policies typedef typename GHPolicies::Get_cost GH_cost; typedef typename GHPolicies::Get_placement GH_placement; - typedef SMS::Bounded_normal_change_placement Bounded_GH_placement; + typedef SMS::Bounded_normal_change_placement Bounded_GH_placement; GHPolicies gh_policies(mesh); const GH_cost& gh_cost = gh_policies.get_cost(); diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp index 3528fb06646..4bedf34619a 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp @@ -4,7 +4,7 @@ #include // Stop-condition policy -#include +#include #include #include @@ -42,7 +42,7 @@ int main(int argc, char** argv) // In this example, the simplification stops when the number of undirected edges // left in the surface mesh drops below the specified number (1000 by default) const std::size_t edge_count_treshold = (argc > 2) ? std::stoi(argv[2]) : 1000; - SMS::Count_stop_predicate stop(edge_count_treshold); + SMS::Edge_count_stop_predicate stop(edge_count_treshold); // This the actual call to the simplification algorithm. // The surface mesh and stop conditions are mandatory arguments. diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_polyhedron.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_polyhedron.cpp index a46b5ab76db..712afa46742 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_polyhedron.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_polyhedron.cpp @@ -5,7 +5,7 @@ #include // Stop-condition policy -#include +#include #include #include @@ -36,7 +36,7 @@ int main(int argc, char** argv) // In this example, the simplification stops when the number of undirected edges // left in the surface mesh drops below the specified number (1000) const std::size_t edge_count_treshold = (argc > 2) ? std::stoi(argv[2]) : 1000; - SMS::Count_stop_predicate stop(edge_count_treshold); + SMS::Edge_count_stop_predicate stop(edge_count_treshold); // This the actual call to the simplification algorithm. // The surface mesh and stop conditions are mandatory arguments. diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_surface_mesh.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_surface_mesh.cpp index d0bce9ca051..d21417d9829 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_surface_mesh.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_surface_mesh.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -36,7 +36,7 @@ int main(int argc, char** argv) // In this example, the simplification stops when the number of undirected edges // drops below 10% of the initial count double stop_ratio = (argc > 2) ? std::stod(argv[2]) : 0.1; - SMS::Count_ratio_stop_predicate stop(stop_ratio); + SMS::Edge_count_ratio_stop_predicate stop(stop_ratio); int r = SMS::edge_collapse(surface_mesh, stop); diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_visitor_surface_mesh.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_visitor_surface_mesh.cpp index b711df9683d..16427c55226 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_visitor_surface_mesh.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_visitor_surface_mesh.cpp @@ -8,7 +8,7 @@ #include // Stop-condition policy -#include +#include #include #include @@ -112,7 +112,7 @@ int main(int argc, char** argv) // In this example, the simplification stops when the number of undirected edges // drops below xx% of the initial count const double ratio = (argc > 2) ? std::stod(argv[2]) : 0.1; - SMS::Count_ratio_stop_predicate stop(ratio); + SMS::Edge_count_ratio_stop_predicate stop(ratio); Stats stats; My_visitor vis(&stats); diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h index eaa2849e61b..36b784e4dbf 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h @@ -13,48 +13,24 @@ #include -#include -#include +#define CGAL_DEPRECATED_HEADER "" +#define CGAL_REPLACEMENT_HEADER "" +#include + +#include + +#ifndef CGAL_NO_DEPRECATED_CODE namespace CGAL { namespace Surface_mesh_simplification { -//******************************************************************************************************************* -// -= stopping condition predicate =- -// -// Determines whether the simplification has finished. -// The arguments are (current_cost,vertex,vertex,is_edge,initial_pair_count,current_pair_count,surface) and the result is bool -// -//******************************************************************************************************************* - -// Stops when the ratio of initial to current vertex pairs is below some value. +// Stops when the ratio of initial to current number of edges is below some value. template -class Count_ratio_stop_predicate -{ -public: - typedef TM_ TM; - typedef typename boost::graph_traits::edges_size_type size_type; - - Count_ratio_stop_predicate(const double ratio) - : m_ratio(ratio) - { - CGAL_warning(0. < ratio && ratio <= 1.); - } - - template - bool operator()(const F& /*current_cost*/, - const Profile& /*profile*/, - size_type initial_edge_count, - size_type current_edge_count) const - { - return (static_cast(current_edge_count) / static_cast(initial_edge_count)) < m_ratio; - } - -private: - double m_ratio; -}; +using Count_ratio_stop_predicate CGAL_DEPRECATED = Edge_count_ratio_stop_predicate; } // namespace Surface_mesh_simplification } // namespace CGAL +#endif // CGAL_NO_DEPRECATED_CODE + #endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PREDICATE_H diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h index ddc7e7a4843..66b0f5fb8c9 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h @@ -13,46 +13,24 @@ #include -#include -#include +#define CGAL_DEPRECATED_HEADER "" +#define CGAL_REPLACEMENT_HEADER "" +#include + +#include + +#ifndef CGAL_NO_DEPRECATED_CODE namespace CGAL { namespace Surface_mesh_simplification { -//******************************************************************************************************************* -// -= stopping condition predicate =- -// -// Determines whether the simplification has finished. -// The arguments are (current_cost,vertex,vertex,is_edge,initial_pair_count,current_pair_count,surface) and the result is bool -// -//******************************************************************************************************************* - // Stops when the number of edges left falls below a given number. template -class Count_stop_predicate -{ -public: - typedef TM_ TM; - typedef typename boost::graph_traits::edges_size_type size_type; - - Count_stop_predicate(const std::size_t edge_count_threshold) - : m_edge_count_threshold(edge_count_threshold) - { } - - template - bool operator()(const F& /*current_cost*/, - const Profile& /*profile*/, - std::size_t /*initial_edge_count*/, - std::size_t current_edge_count) const - { - return current_edge_count < m_edge_count_threshold; - } - -private: - std::size_t m_edge_count_threshold; -}; +using Count_stop_predicate CGAL_DEPRECATED = Edge_count_stop_predicate; } // namespace Surface_mesh_simplification } // namespace CGAL +#endif // CGAL_NO_DEPRECATED_CODE + #endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_STOP_PREDICATE_H diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h new file mode 100644 index 00000000000..13123440d86 --- /dev/null +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h @@ -0,0 +1,52 @@ +// Copyright (c) 2006 GeometryFactory (France). All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Fernando Cacciola +// +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_COUNT_RATIO_STOP_PREDICATE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_COUNT_RATIO_STOP_PREDICATE_H + +#include + +#include +#include + +namespace CGAL { +namespace Surface_mesh_simplification { + +// Stops when the ratio of initial to current number of edges is below some value. +template +class Edge_count_ratio_stop_predicate +{ +public: + typedef TM_ TM; + typedef typename boost::graph_traits::edges_size_type size_type; + + Edge_count_ratio_stop_predicate(const double ratio) + : m_ratio(ratio) + { + CGAL_warning(0. < ratio && ratio <= 1.); + } + + template + bool operator()(const F& /*current_cost*/, + const Profile& /*profile*/, + size_type initial_edge_count, + size_type current_edge_count) const + { + return (static_cast(current_edge_count) / static_cast(initial_edge_count)) < m_ratio; + } + +private: + double m_ratio; +}; + +} // namespace Surface_mesh_simplification +} // namespace CGAL + +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_COUNT_RATIO_STOP_PREDICATE_H diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h new file mode 100644 index 00000000000..aa3de2159a9 --- /dev/null +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h @@ -0,0 +1,50 @@ +// Copyright (c) 2006 GeometryFactory (France). All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Fernando Cacciola +// +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_COUNT_STOP_PREDICATE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_COUNT_STOP_PREDICATE_H + +#include + +#include +#include + +namespace CGAL { +namespace Surface_mesh_simplification { + +// Stops when the number of edges falls below a given number. +template +class Edge_count_stop_predicate +{ +public: + typedef TM_ TM; + typedef typename boost::graph_traits::edges_size_type size_type; + + Edge_count_stop_predicate(const std::size_t edge_count_threshold) + : m_edge_count_threshold(edge_count_threshold) + { } + + template + bool operator()(const F& /*current_cost*/, + const Profile& /*profile*/, + std::size_t /*initial_edge_count*/, + std::size_t current_edge_count) const + { + return current_edge_count < m_edge_count_threshold; + } + +private: + std::size_t m_edge_count_threshold; +}; + +} // namespace Surface_mesh_simplification +} // namespace CGAL + +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_EDGE_COUNT_STOP_PREDICATE_H diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_ratio_stop_predicate.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_ratio_stop_predicate.h new file mode 100644 index 00000000000..d349c948181 --- /dev/null +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_ratio_stop_predicate.h @@ -0,0 +1,56 @@ +// Copyright (c) 2006 GeometryFactory (France). All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Fernando Cacciola +// +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_FACE_COUNT_RATIO_STOP_PREDICATE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_FACE_COUNT_RATIO_STOP_PREDICATE_H + +#include + +#include +#include +#include + +namespace CGAL { +namespace Surface_mesh_simplification { + +// Stops when the ratio of initial to current number of faces is below some value. +template +class Face_count_ratio_stop_predicate +{ +public: + typedef TM_ TM; + typedef typename boost::graph_traits::edges_size_type size_type; + + Face_count_ratio_stop_predicate(const double ratio, + const TM& tmesh) + : m_ratio(ratio), m_initial_face_count(CGAL::internal::exact_num_faces(tmesh)) + { + CGAL_warning(0. < ratio && ratio <= 1.); + } + + template + bool operator()(const F& /*current_cost*/, + const Profile& profile, + size_type /*initial_edge_count*/, + size_type /*current_edge_count*/) const + { + const std::size_t current_face_count = CGAL::internal::exact_num_faces(profile.surface_mesh()); + return (static_cast(current_face_count) / static_cast(m_initial_face_count)) < m_ratio; + } + +private: + const double m_ratio; + const std::size_t m_initial_face_count; +}; + +} // namespace Surface_mesh_simplification +} // namespace CGAL + +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_FACE_COUNT_RATIO_STOP_PREDICATE_H diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_stop_predicate.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_stop_predicate.h new file mode 100644 index 00000000000..873cac7c320 --- /dev/null +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_stop_predicate.h @@ -0,0 +1,52 @@ +// Copyright (c) 2006 GeometryFactory (France). All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Fernando Cacciola +// +#ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_FACE_COUNT_STOP_PREDICATE_H +#define CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_FACE_COUNT_STOP_PREDICATE_H + +#include + +#include +#include +#include + +namespace CGAL { +namespace Surface_mesh_simplification { + +// Stops when the number of faces falls below a given number. +template +class Face_count_stop_predicate +{ +public: + typedef TM_ TM; + typedef typename boost::graph_traits::faces_size_type size_type; + + Face_count_stop_predicate(const std::size_t face_count_threshold) + : m_face_count_threshold(face_count_threshold) + { } + + template + bool operator()(const F& /*current_cost*/, + const Profile& profile, + std::size_t /*initial_edge_count*/, + std::size_t /*current_edge_count*/) const + { + const std::size_t current_face_count = CGAL::internal::exact_num_faces(profile.surface_mesh()); + return (current_face_count < m_face_count_threshold); + } + +private: + std::size_t m_face_count_threshold; +}; + +} // namespace Surface_mesh_simplification +} // namespace CGAL + +#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_FACE_COUNT_STOP_PREDICATE_H diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/CMakeLists.txt b/Surface_mesh_simplification/test/Surface_mesh_simplification/CMakeLists.txt index 86599afd28e..2f55474593a 100644 --- a/Surface_mesh_simplification/test/Surface_mesh_simplification/CMakeLists.txt +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/CMakeLists.txt @@ -11,6 +11,7 @@ create_single_source_cgal_program("test_edge_collapse_bounded_distance.cpp") create_single_source_cgal_program("test_edge_collapse_Envelope.cpp") create_single_source_cgal_program("test_edge_collapse_Polyhedron_3.cpp") create_single_source_cgal_program("test_edge_profile_link.cpp") +create_single_source_cgal_program("test_edge_deprecated_stop_predicates.cpp") find_package(Eigen3 3.1.0 QUIET) #(3.1.0 or greater) include(CGAL_Eigen3_support) diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/basics.h b/Surface_mesh_simplification/test/Surface_mesh_simplification/basics.h index 703a7f4c194..e1363e7fed6 100644 --- a/Surface_mesh_simplification/test/Surface_mesh_simplification/basics.h +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/basics.h @@ -32,7 +32,8 @@ void Surface_simplification_external_trace(std::string s) #include #include #include -#include +#include +#include #include #include diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/edge_collapse_garland_heckbert_variations.cpp b/Surface_mesh_simplification/test/Surface_mesh_simplification/edge_collapse_garland_heckbert_variations.cpp index 9b7bd975503..32505153d06 100644 --- a/Surface_mesh_simplification/test/Surface_mesh_simplification/edge_collapse_garland_heckbert_variations.cpp +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/edge_collapse_garland_heckbert_variations.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -102,7 +102,7 @@ Surface_mesh edge_collapse(Surface_mesh& mesh, const Cost& cost = p.get_cost(); const Placement& unbounded_placement = p.get_placement(); Bounded_placement bounded_placement(unbounded_placement); - SMS::Count_ratio_stop_predicate stop(ratio); + SMS::Edge_count_ratio_stop_predicate stop(ratio); std::chrono::time_point start_time = std::chrono::steady_clock::now(); diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/edge_collapse_topology.cpp b/Surface_mesh_simplification/test/Surface_mesh_simplification/edge_collapse_topology.cpp index 5e0ab17d1d6..479a7687dda 100644 --- a/Surface_mesh_simplification/test/Surface_mesh_simplification/edge_collapse_topology.cpp +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/edge_collapse_topology.cpp @@ -8,7 +8,7 @@ #include // Stop-condition policy -#include +#include typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Surface; @@ -36,7 +36,7 @@ int main(int argc, char** argv) std::cout << "Initial count " << initial_count << " edges.\n"; // Contract the surface as much as possible - SMS::Count_stop_predicate stop(0); + SMS::Edge_count_stop_predicate stop(0); int r = SMS::edge_collapse (surface diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_Envelope.cpp b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_Envelope.cpp index 19f988bb697..0f5c8e99109 100644 --- a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_Envelope.cpp +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_Envelope.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include @@ -96,7 +96,7 @@ int main(int argc, char** argv) std::ifstream is(argc > 1 ? argv[1] : "data/helmet.off"); is >> input_mesh; - SMS::Count_stop_predicate stop(0); // go as far as you can while in the envelope + SMS::Edge_count_stop_predicate stop(0); // go as far as you can while in the envelope Stats stats; My_visitor vis(&stats); diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_Polyhedron_3.cpp b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_Polyhedron_3.cpp index b315643245b..6218df2e8e6 100644 --- a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_Polyhedron_3.cpp +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_Polyhedron_3.cpp @@ -378,7 +378,7 @@ bool Test (string aName) set_halfedgeds_items_id(lSurface); - SMS::Count_stop_predicate stop(sStop); + SMS::Edge_count_stop_predicate stop(sStop); Real_timer t; t.start(); diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp index 0764b881fe1..f6cd535bf50 100644 --- a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp @@ -4,7 +4,7 @@ // Simplification function #include #include -#include +#include #include #include @@ -42,7 +42,7 @@ int main(int argc, char** argv) std::ifstream is(argc > 1 ? argv[1] : "data/helmet.off"); is >> ref_mesh; - SMS::Count_stop_predicate stop(num_halfedges(ref_mesh)/10); + SMS::Edge_count_stop_predicate stop(num_halfedges(ref_mesh)/10); std::cout << "input has " << num_vertices(ref_mesh) << " vertices." << std::endl; CGAL::Iso_cuboid_3 bbox(CGAL::Polygon_mesh_processing::bbox(ref_mesh)); diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_deprecated_stop_predicates.cpp b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_deprecated_stop_predicates.cpp new file mode 100644 index 00000000000..238a796eb03 --- /dev/null +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_deprecated_stop_predicates.cpp @@ -0,0 +1,170 @@ +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +// deprecated +#include +#include + +#include +#include + +#include + +typedef CGAL::Simple_cartesian K; +typedef CGAL::Surface_mesh Mesh; + +namespace SMS = CGAL::Surface_mesh_simplification; + +typedef SMS::Edge_count_stop_predicate Edge_count_stop; +typedef SMS::Face_count_stop_predicate Face_count_stop; +typedef SMS::Edge_count_ratio_stop_predicate Edge_count_ratio_stop; +typedef SMS::Face_count_ratio_stop_predicate Face_count_ratio_stop; + +typedef SMS::Count_stop_predicate Count_stop; +typedef SMS::Count_ratio_stop_predicate Count_ratio_stop; + +typedef SMS::Count_ratio_stop_predicate Count_ratio_stop; + +typedef SMS::Edge_length_cost Cost; +typedef SMS::Midpoint_placement Placement; + +int main(int argc, char** argv) +{ + const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cube-meshed.off"); + + Mesh mesh; + if(!CGAL::IO::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Failed to read input mesh: " << filename << std::endl; + return EXIT_FAILURE; + } + + if(!CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Input geometry is not triangulated." << std::endl; + return EXIT_FAILURE; + } + + std::cout << "Input mesh has " << num_vertices(mesh) << " nv " + << num_edges(mesh) << " ne " + << num_faces(mesh) << " nf" << std::endl; + + Cost cost; + Placement placement; + + // Edge_count_stop + { + Mesh mesh_cpy = mesh; + const std::size_t expected_ne = num_edges(mesh_cpy) / 2; + Edge_count_stop stop(expected_ne); + SMS::edge_collapse(mesh_cpy, stop, + CGAL::parameters::get_cost(cost) + .get_placement(placement)); + + std::cout << "Output mesh has " << CGAL::internal::exact_num_vertices(mesh_cpy) << " nv " + << CGAL::internal::exact_num_edges(mesh_cpy) << " ne " + << CGAL::internal::exact_num_faces(mesh_cpy) << " nf" << std::endl; + + assert(CGAL::internal::exact_num_edges(mesh_cpy) < expected_ne); + } + + // Count_stop + { + Mesh mesh_cpy = mesh; + const std::size_t expected_ne = num_edges(mesh_cpy) + 1; + Count_stop stop(expected_ne); + SMS::edge_collapse(mesh_cpy, stop, + CGAL::parameters::get_cost(cost) + .get_placement(placement)); + + std::cout << "Output mesh has " << CGAL::internal::exact_num_vertices(mesh_cpy) << " nv " + << CGAL::internal::exact_num_edges(mesh_cpy) << " ne " + << CGAL::internal::exact_num_faces(mesh_cpy) << " nf" << std::endl; + + assert(CGAL::internal::exact_num_edges(mesh_cpy) < expected_ne); + } + + // Face_count_stop + { + Mesh mesh_cpy = mesh; + const std::size_t expected_nf = num_faces(mesh_cpy) / 4; + Face_count_stop stop(expected_nf); + SMS::edge_collapse(mesh_cpy, stop, + CGAL::parameters::get_cost(cost) + .get_placement(placement)); + + std::cout << "Output mesh has " << CGAL::internal::exact_num_vertices(mesh_cpy) << " nv " + << CGAL::internal::exact_num_edges(mesh_cpy) << " ne " + << CGAL::internal::exact_num_faces(mesh_cpy) << " nf" << std::endl; + + assert(CGAL::internal::exact_num_faces(mesh_cpy) < expected_nf); + } + + /// RATIO + + // Edge_count_ratio_stop + { + Mesh mesh_cpy = mesh; + const double ratio = 0.5; + const std::size_t initial_ne = num_edges(mesh_cpy); + Edge_count_ratio_stop stop(ratio); + SMS::edge_collapse(mesh_cpy, stop, + CGAL::parameters::get_cost(cost) + .get_placement(placement)); + + std::cout << "Output mesh has " << CGAL::internal::exact_num_vertices(mesh_cpy) << " nv " + << CGAL::internal::exact_num_edges(mesh_cpy) << " ne " + << CGAL::internal::exact_num_faces(mesh_cpy) << " nf" << std::endl; + + assert(CGAL::internal::exact_num_edges(mesh_cpy) / initial_ne < ratio); + } + + // Count_ratio_stop + { + Mesh mesh_cpy = mesh; + const double ratio = 1.; + const std::size_t initial_ne = num_edges(mesh_cpy); + Count_ratio_stop stop(ratio); + SMS::edge_collapse(mesh_cpy, stop, + CGAL::parameters::get_cost(cost) + .get_placement(placement)); + + std::cout << "Output mesh has " << CGAL::internal::exact_num_vertices(mesh_cpy) << " nv " + << CGAL::internal::exact_num_edges(mesh_cpy) << " ne " + << CGAL::internal::exact_num_faces(mesh_cpy) << " nf" << std::endl; + + assert(CGAL::internal::exact_num_edges(mesh_cpy) / initial_ne < ratio); + } + + // Face_count_ratio_stop + { + Mesh mesh_cpy = mesh; + const double ratio = 0.7; + const std::size_t initial_nf = num_faces(mesh_cpy); + Face_count_ratio_stop stop(ratio, mesh_cpy); + SMS::edge_collapse(mesh_cpy, stop, + CGAL::parameters::get_cost(cost) + .get_placement(placement)); + + std::cout << "Output mesh has " << CGAL::internal::exact_num_vertices(mesh_cpy) << " nv " + << CGAL::internal::exact_num_edges(mesh_cpy) << " ne " + << CGAL::internal::exact_num_faces(mesh_cpy) << " nf" << std::endl; + + assert(CGAL::internal::exact_num_faces(mesh_cpy) / initial_nf < ratio); + } + + return 0; +} +