diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index a21e801fffd..0eea8a6e3f2 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -520,7 +520,7 @@ the envelope is not the Minkowski sum with a sphere, because this would have cyl patches at convex edges and vertices of the input triangle mesh. Instead, the envelope consists of a collection of prisms that are guaranteed to be inside the Minkowski sum envelope, hence the term polyhedral envelope. This containment test is exact for the polyhedral envelope, and -conservative in the sense that if a query is inside the polyhedral envelope, we can be sure +conservative in the sense that, if a query is inside the polyhedral envelope, we can be sure that it is also in the Minkowski sum envelope, but if it is outside we do not know. Such a test is used in the class `Surface_mesh_simplification::Envelope_filter` of the diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_normal_change_filter.h b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_normal_change_filter.h index 84e4a41e646..7f0d229a753 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_normal_change_filter.h +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_normal_change_filter.h @@ -44,7 +44,8 @@ public: Returns the placement, if it does not get filtered by the wrapped filter and if no triangle in the profile has its normal changed by more than 90 degree. */ - boost::optional operator()(const Edge_profile& profile) const; + boost::optional operator()(const Edge_profile& profile, + boost::optional op) const; /// @} diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/PackageDescription.txt b/Surface_mesh_simplification/doc/Surface_mesh_simplification/PackageDescription.txt index 59a2871ceb8..4780d3912e5 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/PackageDescription.txt +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/PackageDescription.txt @@ -46,5 +46,6 @@ - `CGAL::Surface_mesh_simplification::GarlandHeckbert_policies` - `CGAL::Surface_mesh_simplification::Bounded_normal_change_placement` - `CGAL::Surface_mesh_simplification::Bounded_normal_change_filter` +- `CGAL::Surface_mesh_simplification::Envelope_filter` - `CGAL::Surface_mesh_simplification::Constrained_placement` */ diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/Surface_mesh_simplification.txt b/Surface_mesh_simplification/doc/Surface_mesh_simplification/Surface_mesh_simplification.txt index dff0d95714c..baa73cbbb5c 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/Surface_mesh_simplification.txt +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/Surface_mesh_simplification.txt @@ -347,6 +347,20 @@ and not during the update on all edges incident to the vertex that is the result \cgalExample{Surface_mesh_simplification/edge_collapse_bounded_normal_change.cpp} + + +\subsection Surface_mesh_simplificationExamplewithEnvelope Example with Envelope + +The surface mesh simplification can be done in a way that the simplified mesh stays inside an envelope of the input mesh. +This makes use of the class `Envelope` which enables to check whether a query point, segment, or triangle lies within +a polyhedral envelope, which consists of the union of inflated triangles. While the user gives a distance `d`, the check +is conservative, that is there may be triangles which would be inside a surface obtained as the Minkowski sum +with a sphere of radius `d`, but which are outside the polyhedral envelope. + +\cgalExample{Surface_mesh_simplification/edge_collapse_envelope.cpp} + + + \subsection Surface_mesh_simplificationExamplewithVisitor Example with Visitor The last example shows how to use a visitor with callbacks that are called at the different diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/dependencies b/Surface_mesh_simplification/doc/Surface_mesh_simplification/dependencies index d2fa6db6731..9eefc1c34ec 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/dependencies +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/dependencies @@ -7,3 +7,4 @@ Stream_support Polyhedron Surface_mesh BGL +Polygon_mesh_processing diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/examples.txt b/Surface_mesh_simplification/doc/Surface_mesh_simplification/examples.txt index 0cf2e8c5099..245e94654d2 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/examples.txt +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/examples.txt @@ -1,4 +1,5 @@ /*! +\example Surface_mesh_simplification/edge_collapse_envelope.cpp \example Surface_mesh_simplification/edge_collapse_polyhedron.cpp \example Surface_mesh_simplification/edge_collapse_OpenMesh.cpp \example Surface_mesh_simplification/edge_collapse_enriched_polyhedron.cpp diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/CMakeLists.txt b/Surface_mesh_simplification/examples/Surface_mesh_simplification/CMakeLists.txt index bfd216d1e80..4ec5485d52c 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/CMakeLists.txt +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/CMakeLists.txt @@ -31,6 +31,7 @@ endif() # Creating entries for all .cpp/.C files with "main" routine # ########################################################## +create_single_source_cgal_program( "edge_collapse_envelope.cpp" ) create_single_source_cgal_program( "edge_collapse_constrain_sharp_edges.cpp" ) create_single_source_cgal_program( "edge_collapse_constrained_border_polyhedron.cpp" ) create_single_source_cgal_program( "edge_collapse_enriched_polyhedron.cpp" ) 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 new file mode 100644 index 00000000000..c36c90ad205 --- /dev/null +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_envelope.cpp @@ -0,0 +1,56 @@ +#include +#include + +#include + +#include +#include +#include +#include +#include + +//bbox +#include + +#include +#include + +namespace SMS = CGAL::Surface_mesh_simplification; + +typedef CGAL::Simple_cartesian Kernel; + +typedef Kernel::Point_3 Point_3; +typedef CGAL::Surface_mesh Surface; + +typedef SMS::LindstromTurk_cost Cost; +typedef SMS::LindstromTurk_placement Placement; +typedef SMS::Envelope_filter > Filter; + + +int main(int argc, char** argv) +{ + Surface mesh; + std::ifstream is(argc > 1 ? argv[1] : "data/helmet.off"); + is >> mesh; + + SMS::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)); + + Point_3 cmin = (bbox.min)(); + Point_3 cmax = (bbox.max)(); + const double diag = CGAL::approximate_sqrt(CGAL::squared_distance(cmin, cmax)); + + + std::cout << "eps = " << 0.01*diag << std::endl; + Placement placement; + Filter filter(0.01*diag); + SMS::edge_collapse(mesh, stop, CGAL::parameters::get_cost(Cost()).get_filter(filter).get_placement(placement)); + + std::ofstream out("out.off"); + out << big_mesh << std::endl; + out.close(); + + return EXIT_SUCCESS; +}