mirror of https://github.com/CGAL/cgal
Merge pull request #7001 from MaelRL/SMS-Add_EF_stop_predicates-GF
This commit is contained in:
commit
24cc17e152
|
|
@ -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)
|
||||
-----------
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Constrained_placement.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_placement.h>
|
||||
|
|
@ -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<FaceGraph> m_count_stop;
|
||||
CGAL::Surface_mesh_simplification::Edge_count_stop_predicate<FaceGraph> m_count_stop;
|
||||
CGAL::Surface_mesh_simplification::Edge_length_stop_predicate<double> m_length_stop;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include <CGAL/HalfedgeDS_face_base.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Memory_sizer.h>
|
||||
|
||||
#include <iostream>
|
||||
|
|
@ -461,7 +461,7 @@ private:
|
|||
)
|
||||
vb->id() = index++;
|
||||
|
||||
SMS::Count_ratio_stop_predicate<Polyhedron> stop(0.1);
|
||||
SMS::Edge_count_ratio_stop_predicate<Polyhedron> stop(0.1);
|
||||
int r = SMS::edge_collapse(P, stop);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <CGAL/boost/graph/IO/OFF.h>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Memory_sizer.h>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
|
|
@ -284,7 +284,7 @@ private:
|
|||
|
||||
mesh.clear();
|
||||
bool b = CGAL::IO::read_OFF(_filename, mesh);
|
||||
SMS::Count_ratio_stop_predicate<Surface_mesh> stop(0.1);
|
||||
SMS::Edge_count_ratio_stop_predicate<Surface_mesh> stop(0.1);
|
||||
int r = SMS::edge_collapse(mesh, stop);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<TriangleMesh>`
|
||||
|
||||
\sa `CGAL::Surface_mesh_simplification::Edge_count_ratio_stop_predicate<TriangleMesh>`
|
||||
\sa `CGAL::Surface_mesh_simplification::Face_count_ratio_stop_predicate<TriangleMesh>`
|
||||
*/
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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<TriangleMesh>`
|
||||
|
||||
\sa `CGAL::Surface_mesh_simplification::Edge_count_stop_predicate<TriangleMesh>`
|
||||
\sa `CGAL::Surface_mesh_simplification::Face_count_stop_predicate<TriangleMesh>`
|
||||
*/
|
||||
template <typename TriangleMesh>
|
||||
class Count_stop_predicate
|
||||
|
|
|
|||
|
|
@ -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<TriangleMesh>`
|
||||
\sa `CGAL::Surface_mesh_simplification::Face_count_ratio_stop_predicate<TriangleMesh>`
|
||||
*/
|
||||
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
|
||||
|
|
@ -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<TriangleMesh>`
|
||||
\sa `CGAL::Surface_mesh_simplification::Edge_ratio_count_stop_predicate<TriangleMesh>`
|
||||
*/
|
||||
template <typename TriangleMesh>
|
||||
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
|
||||
|
|
@ -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<TriangleMesh>`
|
||||
\sa `CGAL::Surface_mesh_simplification::Face_count_stop_predicate<TriangleMesh>`
|
||||
*/
|
||||
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
|
||||
|
|
@ -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<TriangleMesh>`
|
||||
\sa `CGAL::Surface_mesh_simplification::Face_count_ratio_stop_predicate<TriangleMesh>`
|
||||
*/
|
||||
template <typename TriangleMesh>
|
||||
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
|
||||
|
|
@ -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<TriangleMesh>`
|
||||
\cgalHasModel `CGAL::Surface_mesh_simplification::Count_ratio_stop_predicate<TriangleMesh>`
|
||||
\cgalHasModel `CGAL::Surface_mesh_simplification::Edge_count_stop_predicate<TriangleMesh>`
|
||||
\cgalHasModel `CGAL::Surface_mesh_simplification::Face_count_stop_predicate<TriangleMesh>`
|
||||
\cgalHasModel `CGAL::Surface_mesh_simplification::Edge_count_ratio_stop_predicate<TriangleMesh>`
|
||||
\cgalHasModel `CGAL::Surface_mesh_simplification::Face_count_ratio_stop_predicate<TriangleMesh>`
|
||||
\cgalHasModel `CGAL::Surface_mesh_simplification::Edge_length_stop_predicate<FT>`
|
||||
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -34,8 +34,12 @@
|
|||
- `CGAL::Surface_mesh_simplification::edge_collapse()`
|
||||
|
||||
\cgalCRPSection{Policies}
|
||||
- `CGAL::Surface_mesh_simplification::Count_stop_predicate<TriangleMesh>`
|
||||
- `CGAL::Surface_mesh_simplification::Count_ratio_stop_predicate<TriangleMesh>`
|
||||
- `CGAL::Surface_mesh_simplification::Count_stop_predicate<TriangleMesh>` (deprecated)
|
||||
- `CGAL::Surface_mesh_simplification::Count_ratio_stop_predicate<TriangleMesh>` (deprecated)
|
||||
- `CGAL::Surface_mesh_simplification::Edge_count_stop_predicate<TriangleMesh>`
|
||||
- `CGAL::Surface_mesh_simplification::Face_count_stop_predicate<TriangleMesh>`
|
||||
- `CGAL::Surface_mesh_simplification::Edge_count_ratio_stop_predicate<TriangleMesh>`
|
||||
- `CGAL::Surface_mesh_simplification::Face_count_ratio_stop_predicate<TriangleMesh>`
|
||||
- `CGAL::Surface_mesh_simplification::Edge_length_stop_predicate<FT>`
|
||||
- `CGAL::Surface_mesh_simplification::Edge_length_cost<TriangleMesh>`
|
||||
- `CGAL::Surface_mesh_simplification::Midpoint_placement<TriangleMesh>`
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
// Simplification function
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_cost.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h>
|
||||
|
||||
|
|
@ -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<Surface_mesh> stop(stop_n);
|
||||
SMS::Edge_count_stop_predicate<Surface_mesh> stop(stop_n);
|
||||
|
||||
// This the actual call to the simplification algorithm.
|
||||
// The surface mesh and stop conditions are mandatory arguments.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <CGAL/Timer.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_cost.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_placement.h>
|
||||
|
||||
|
|
@ -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<Surface_mesh> stop(stop_n);
|
||||
SMS::Edge_count_stop_predicate<Surface_mesh> stop(stop_n);
|
||||
|
||||
typedef SMS::LindstromTurk_placement<Surface_mesh> Placement;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Constrained_placement.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
#include <CGAL/Unique_hash_map.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
|
|
@ -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<Surface_mesh> stop(0);
|
||||
SMS::Edge_count_stop_predicate<Surface_mesh> 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,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Constrained_placement.h>
|
||||
|
||||
// Stop-condition policy
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
|
@ -78,7 +78,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
// Contract the surface mesh as much as possible
|
||||
SMS::Count_stop_predicate<Surface_mesh> stop(0);
|
||||
SMS::Edge_count_stop_predicate<Surface_mesh> stop(0);
|
||||
Border_is_constrained_edge_map bem(surface_mesh);
|
||||
|
||||
// This the actual call to the simplification algorithm.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Constrained_placement.h>
|
||||
|
||||
// Stop-condition policy
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
|
@ -77,7 +77,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
// Contract the surface mesh as much as possible
|
||||
SMS::Count_stop_predicate<Surface_mesh> stop(0);
|
||||
SMS::Edge_count_stop_predicate<Surface_mesh> stop(0);
|
||||
Border_is_constrained_edge_map bem(surface_mesh);
|
||||
|
||||
// This the actual call to the simplification algorithm.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <CGAL/Polyhedron_items_with_id_3.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
|
@ -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<Surface_mesh> stop(ratio);
|
||||
SMS::Edge_count_ratio_stop_predicate<Surface_mesh> stop(ratio);
|
||||
|
||||
// The index maps are not explicitelty passed as in the previous
|
||||
// example because the surface mesh items have a proper id() field.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_cost.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_placement.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_normal_change_filter.h>
|
||||
|
|
@ -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<Surface> stop(0); // go as far as you can while in the envelope
|
||||
SMS::Edge_count_stop_predicate<Surface> stop(0); // go as far as you can while in the envelope
|
||||
|
||||
|
||||
CGAL::Iso_cuboid_3<Kernel> bbox(CGAL::Polygon_mesh_processing::bbox(mesh));
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_normal_change_placement.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/GarlandHeckbert_policies.h>
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
|
@ -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<Surface_mesh> stop(ratio);
|
||||
SMS::Edge_count_ratio_stop_predicate<Surface_mesh> 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<GH_placement> Bounded_GH_placement;
|
||||
typedef SMS::Bounded_normal_change_placement<GH_placement> Bounded_GH_placement;
|
||||
|
||||
GHPolicies gh_policies(mesh);
|
||||
const GH_cost& gh_cost = gh_policies.get_cost();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
|
||||
// Stop-condition policy
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_cost.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h>
|
||||
|
||||
|
|
@ -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<LCC> stop(edge_count_treshold);
|
||||
SMS::Edge_count_stop_predicate<LCC> stop(edge_count_treshold);
|
||||
|
||||
// This the actual call to the simplification algorithm.
|
||||
// The surface mesh and stop conditions are mandatory arguments.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
|
||||
// Stop-condition policy
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
|
@ -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<Surface_mesh> stop(edge_count_treshold);
|
||||
SMS::Edge_count_stop_predicate<Surface_mesh> stop(edge_count_treshold);
|
||||
|
||||
// This the actual call to the simplification algorithm.
|
||||
// The surface mesh and stop conditions are mandatory arguments.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
|
|
@ -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<Surface_mesh> stop(stop_ratio);
|
||||
SMS::Edge_count_ratio_stop_predicate<Surface_mesh> stop(stop_ratio);
|
||||
|
||||
int r = SMS::edge_collapse(surface_mesh, stop);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <CGAL/Surface_mesh_simplification/Edge_collapse_visitor_base.h>
|
||||
|
||||
// Stop-condition policy
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
|
@ -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<Surface_mesh> stop(ratio);
|
||||
SMS::Edge_count_ratio_stop_predicate<Surface_mesh> stop(ratio);
|
||||
|
||||
Stats stats;
|
||||
My_visitor vis(&stats);
|
||||
|
|
|
|||
|
|
@ -13,48 +13,24 @@
|
|||
|
||||
#include <CGAL/license/Surface_mesh_simplification.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/internal/Common.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h>
|
||||
#define CGAL_DEPRECATED_HEADER "<CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>"
|
||||
#define CGAL_REPLACEMENT_HEADER "<CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h>"
|
||||
#include <CGAL/Installation/internal/deprecation_warning.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h>
|
||||
|
||||
#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 TM_>
|
||||
class Count_ratio_stop_predicate
|
||||
{
|
||||
public:
|
||||
typedef TM_ TM;
|
||||
typedef typename boost::graph_traits<TM>::edges_size_type size_type;
|
||||
|
||||
Count_ratio_stop_predicate(const double ratio)
|
||||
: m_ratio(ratio)
|
||||
{
|
||||
CGAL_warning(0. < ratio && ratio <= 1.);
|
||||
}
|
||||
|
||||
template <typename F, typename Profile>
|
||||
bool operator()(const F& /*current_cost*/,
|
||||
const Profile& /*profile*/,
|
||||
size_type initial_edge_count,
|
||||
size_type current_edge_count) const
|
||||
{
|
||||
return (static_cast<double>(current_edge_count) / static_cast<double>(initial_edge_count)) < m_ratio;
|
||||
}
|
||||
|
||||
private:
|
||||
double m_ratio;
|
||||
};
|
||||
using Count_ratio_stop_predicate CGAL_DEPRECATED = Edge_count_ratio_stop_predicate<TM_>;
|
||||
|
||||
} // namespace Surface_mesh_simplification
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_COUNT_RATIO_STOP_PREDICATE_H
|
||||
|
|
|
|||
|
|
@ -13,46 +13,24 @@
|
|||
|
||||
#include <CGAL/license/Surface_mesh_simplification.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/internal/Common.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h>
|
||||
#define CGAL_DEPRECATED_HEADER "<CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>"
|
||||
#define CGAL_REPLACEMENT_HEADER "<CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>"
|
||||
#include <CGAL/Installation/internal/deprecation_warning.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
|
||||
#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 TM_>
|
||||
class Count_stop_predicate
|
||||
{
|
||||
public:
|
||||
typedef TM_ TM;
|
||||
typedef typename boost::graph_traits<TM>::edges_size_type size_type;
|
||||
|
||||
Count_stop_predicate(const std::size_t edge_count_threshold)
|
||||
: m_edge_count_threshold(edge_count_threshold)
|
||||
{ }
|
||||
|
||||
template <typename F, typename Profile>
|
||||
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<TM_>;
|
||||
|
||||
} // namespace Surface_mesh_simplification
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
#endif // CGAL_SURFACE_MESH_SIMPLIFICATION_POLICIES_EDGE_COLLAPSE_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 <fernando.cacciola@geometryfactory.com>
|
||||
//
|
||||
#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 <CGAL/license/Surface_mesh_simplification.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/internal/Common.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Surface_mesh_simplification {
|
||||
|
||||
// Stops when the ratio of initial to current number of edges is below some value.
|
||||
template<class TM_>
|
||||
class Edge_count_ratio_stop_predicate
|
||||
{
|
||||
public:
|
||||
typedef TM_ TM;
|
||||
typedef typename boost::graph_traits<TM>::edges_size_type size_type;
|
||||
|
||||
Edge_count_ratio_stop_predicate(const double ratio)
|
||||
: m_ratio(ratio)
|
||||
{
|
||||
CGAL_warning(0. < ratio && ratio <= 1.);
|
||||
}
|
||||
|
||||
template <typename F, typename Profile>
|
||||
bool operator()(const F& /*current_cost*/,
|
||||
const Profile& /*profile*/,
|
||||
size_type initial_edge_count,
|
||||
size_type current_edge_count) const
|
||||
{
|
||||
return (static_cast<double>(current_edge_count) / static_cast<double>(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
|
||||
|
|
@ -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 <fernando.cacciola@geometryfactory.com>
|
||||
//
|
||||
#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 <CGAL/license/Surface_mesh_simplification.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/internal/Common.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Surface_mesh_simplification {
|
||||
|
||||
// Stops when the number of edges falls below a given number.
|
||||
template<class TM_>
|
||||
class Edge_count_stop_predicate
|
||||
{
|
||||
public:
|
||||
typedef TM_ TM;
|
||||
typedef typename boost::graph_traits<TM>::edges_size_type size_type;
|
||||
|
||||
Edge_count_stop_predicate(const std::size_t edge_count_threshold)
|
||||
: m_edge_count_threshold(edge_count_threshold)
|
||||
{ }
|
||||
|
||||
template <typename F, typename Profile>
|
||||
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
|
||||
|
|
@ -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 <fernando.cacciola@geometryfactory.com>
|
||||
//
|
||||
#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 <CGAL/license/Surface_mesh_simplification.h>
|
||||
|
||||
#include <CGAL/boost/graph/internal/helpers.h>
|
||||
#include <CGAL/Surface_mesh_simplification/internal/Common.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Surface_mesh_simplification {
|
||||
|
||||
// Stops when the ratio of initial to current number of faces is below some value.
|
||||
template<class TM_>
|
||||
class Face_count_ratio_stop_predicate
|
||||
{
|
||||
public:
|
||||
typedef TM_ TM;
|
||||
typedef typename boost::graph_traits<TM>::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 <typename F, typename Profile>
|
||||
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<double>(current_face_count) / static_cast<double>(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
|
||||
|
|
@ -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 <fernando.cacciola@geometryfactory.com>
|
||||
//
|
||||
#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 <CGAL/license/Surface_mesh_simplification.h>
|
||||
|
||||
#include <CGAL/boost/graph/internal/helpers.h>
|
||||
#include <CGAL/Surface_mesh_simplification/internal/Common.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_profile.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Surface_mesh_simplification {
|
||||
|
||||
// Stops when the number of faces falls below a given number.
|
||||
template<class TM_>
|
||||
class Face_count_stop_predicate
|
||||
{
|
||||
public:
|
||||
typedef TM_ TM;
|
||||
typedef typename boost::graph_traits<TM>::faces_size_type size_type;
|
||||
|
||||
Face_count_stop_predicate(const std::size_t face_count_threshold)
|
||||
: m_face_count_threshold(face_count_threshold)
|
||||
{ }
|
||||
|
||||
template <typename F, typename Profile>
|
||||
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
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ void Surface_simplification_external_trace(std::string s)
|
|||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_cost.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_stop_predicate.h>
|
||||
|
||||
#include <CGAL/Polyhedron_items_with_id_3.h>
|
||||
#include <CGAL/Polyhedron_incremental_builder_3.h>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_normal_change_placement.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/GarlandHeckbert_policies.h>
|
||||
|
||||
|
|
@ -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<Surface_mesh> stop(ratio);
|
||||
SMS::Edge_count_ratio_stop_predicate<Surface_mesh> stop(ratio);
|
||||
|
||||
std::chrono::time_point<std::chrono::steady_clock> start_time = std::chrono::steady_clock::now();
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
|
||||
// Stop-condition policy
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef CGAL::Polyhedron_3<Kernel> 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<Surface> stop(0);
|
||||
SMS::Edge_count_stop_predicate<Surface> stop(0);
|
||||
|
||||
int r = SMS::edge_collapse
|
||||
(surface
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <CGAL/Surface_mesh_simplification/Edge_collapse_visitor_base.h>
|
||||
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_cost.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_placement.h>
|
||||
|
||||
|
|
@ -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<Surface> stop(0); // go as far as you can while in the envelope
|
||||
SMS::Edge_count_stop_predicate<Surface> stop(0); // go as far as you can while in the envelope
|
||||
|
||||
Stats stats;
|
||||
My_visitor vis(&stats);
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ bool Test (string aName)
|
|||
|
||||
set_halfedgeds_items_id(lSurface);
|
||||
|
||||
SMS::Count_stop_predicate<Surface> stop(sStop);
|
||||
SMS::Edge_count_stop_predicate<Surface> stop(sStop);
|
||||
|
||||
Real_timer t; t.start();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// Simplification function
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_distance_placement.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_cost.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_placement.h>
|
||||
|
||||
|
|
@ -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<Surface> stop(num_halfedges(ref_mesh)/10);
|
||||
SMS::Edge_count_stop_predicate<Surface> stop(num_halfedges(ref_mesh)/10);
|
||||
|
||||
std::cout << "input has " << num_vertices(ref_mesh) << " vertices." << std::endl;
|
||||
CGAL::Iso_cuboid_3<Kernel> bbox(CGAL::Polygon_mesh_processing::bbox(ref_mesh));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,170 @@
|
|||
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
|
||||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_ratio_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Face_count_ratio_stop_predicate.h>
|
||||
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Midpoint_placement.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_length_cost.h>
|
||||
|
||||
// deprecated
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_stop_predicate.h>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
|
||||
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
#include <CGAL/boost/graph/internal/helpers.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
|
||||
|
||||
namespace SMS = CGAL::Surface_mesh_simplification;
|
||||
|
||||
typedef SMS::Edge_count_stop_predicate<Mesh> Edge_count_stop;
|
||||
typedef SMS::Face_count_stop_predicate<Mesh> Face_count_stop;
|
||||
typedef SMS::Edge_count_ratio_stop_predicate<Mesh> Edge_count_ratio_stop;
|
||||
typedef SMS::Face_count_ratio_stop_predicate<Mesh> Face_count_ratio_stop;
|
||||
|
||||
typedef SMS::Count_stop_predicate<Mesh> Count_stop;
|
||||
typedef SMS::Count_ratio_stop_predicate<Mesh> Count_ratio_stop;
|
||||
|
||||
typedef SMS::Count_ratio_stop_predicate<Mesh> Count_ratio_stop;
|
||||
|
||||
typedef SMS::Edge_length_cost<Mesh> Cost;
|
||||
typedef SMS::Midpoint_placement<Mesh> 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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue