mirror of https://github.com/CGAL/cgal
Add example
This commit is contained in:
parent
f6302a9479
commit
4ee9875556
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<typename Edge_profile::Point> operator()(const Edge_profile& profile) const;
|
||||
boost::optional<typename Edge_profile::Point> operator()(const Edge_profile& profile,
|
||||
boost::optional<typename Profile::Point> op) const;
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,5 +46,6 @@
|
|||
- `CGAL::Surface_mesh_simplification::GarlandHeckbert_policies<TriangleMesh, GeomTraits>`
|
||||
- `CGAL::Surface_mesh_simplification::Bounded_normal_change_placement<Placement>`
|
||||
- `CGAL::Surface_mesh_simplification::Bounded_normal_change_filter<Filter>`
|
||||
- `CGAL::Surface_mesh_simplification::Envelope_filter<Filter>`
|
||||
- `CGAL::Surface_mesh_simplification::Constrained_placement<Placement, TriangleMesh>`
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -7,3 +7,4 @@ Stream_support
|
|||
Polyhedron
|
||||
Surface_mesh
|
||||
BGL
|
||||
Polygon_mesh_processing
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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" )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
#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/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>
|
||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Envelope_filter.h>
|
||||
|
||||
//bbox
|
||||
#include <CGAL/Polygon_mesh_processing/bbox.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
namespace SMS = CGAL::Surface_mesh_simplification;
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
typedef CGAL::Surface_mesh<Point_3> Surface;
|
||||
|
||||
typedef SMS::LindstromTurk_cost<Surface> Cost;
|
||||
typedef SMS::LindstromTurk_placement<Surface> Placement;
|
||||
typedef SMS::Envelope_filter<Kernel,SMS::Bounded_normal_change_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<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));
|
||||
|
||||
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;
|
||||
}
|
||||
Loading…
Reference in New Issue