mirror of https://github.com/CGAL/cgal
add named parameters and an example to remove_degenerate_faces
This commit is contained in:
parent
396d1875ab
commit
6a4e2552db
|
|
@ -74,7 +74,7 @@ create_single_source_cgal_program( "polygon_soup_example.cpp")
|
|||
create_single_source_cgal_program( "triangulate_polyline_example.cpp")
|
||||
create_single_source_cgal_program( "refine_fair_example.cpp")
|
||||
create_single_source_cgal_program( "mesh_slicer_example.cpp")
|
||||
|
||||
create_single_source_cgal_program( "remove_degeneracies_example.cpp")
|
||||
|
||||
|
||||
else(EIGEN3_FOUND)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/repair.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef K::Point_3 Point;
|
||||
typedef K::Vector_3 Vector;
|
||||
|
||||
typedef CGAL::Surface_mesh<Point> Surface_mesh;
|
||||
typedef boost::graph_traits<Surface_mesh>::vertex_descriptor vertex_descriptor;
|
||||
typedef boost::graph_traits<Surface_mesh>::face_descriptor face_descriptor;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* filename = (argc > 1) ? argv[1] : "data/eight.off";
|
||||
std::ifstream input(filename);
|
||||
|
||||
Surface_mesh mesh;
|
||||
if (!input || !(input >> mesh) || mesh.is_empty()) {
|
||||
std::cerr << "Not a valid off file." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::size_t nb
|
||||
= CGAL::Polygon_mesh_processing::remove_degenerate_faces(mesh);
|
||||
|
||||
std::cout << "There were " << nb << " degenerate faces in this mesh" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -26,6 +26,9 @@
|
|||
#include <boost/algorithm/minmax_element.hpp>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/internal/named_function_params.h>
|
||||
#include <CGAL/Polygon_mesh_processing/internal/named_params_helper.h>
|
||||
|
||||
namespace CGAL{
|
||||
namespace Polygon_mesh_processing {
|
||||
|
||||
|
|
@ -230,27 +233,48 @@ namespace internal {
|
|||
} // end of namespace internal
|
||||
|
||||
/// \ingroup PkgPolygonMeshProcessing
|
||||
/// removes the degenerate faces from a triangle mesh.
|
||||
///
|
||||
/// @tparam TriangleMesh a model of `FaceListGraph` and `MutableFaceGraph`
|
||||
/// that has a property map for `boost::vertex_point_t`
|
||||
/// @tparam NamedParameters a sequence of \ref namedparameters
|
||||
///
|
||||
/// @param np optional \ref namedparameters described below
|
||||
///
|
||||
/// \b Named \b parameters
|
||||
/// <ul>
|
||||
/// <li>\b vertex_point_map the property map with the points associated to the vertices of `pmesh`. The type of this mad is model of `ReadWritePropertyMap`.
|
||||
/// <li>\b kernel a geometric traits class instance.
|
||||
/// The traits class must provide the nested types :
|
||||
/// - `Point_3`,
|
||||
/// - `Compare_distance_3` to compute the distance between 2 points
|
||||
/// - `Collinear_are_ordered_along_line_3` to check whether 3 collinear points are ordered
|
||||
/// - `Collinear_3` to check whether 3 points are collinear
|
||||
/// - `Less_xyz_3` to compare lexicographically two points
|
||||
/// - `Equal_3` to check whether 2 points are identical
|
||||
/// - for each functor Foo, a function `Foo foo_object()`
|
||||
/// </ul>
|
||||
|
||||
/// \return number of degenerate faces found
|
||||
/// \tparam Traits must provide the nested types:
|
||||
/// - `Point_3`,
|
||||
/// - `Compare_distance_3` to compute the distance between 2 points
|
||||
/// - `Collinear_are_ordered_along_line_3` to check whether 3 collinear points are ordered
|
||||
/// - `Collinear_3` to check whether 3 points are collinear
|
||||
/// - `Less_xyz_3` to compare lexicographically two points
|
||||
/// - `Equal_3` to check whether 2 points are identical
|
||||
/// - for each functor Foo, a function `Foo foo_object()`
|
||||
/// \tparam VertexPointMap model of `ReadWritePropertyMap` with
|
||||
/// `boost::graph_traits<TriangleMesh>::vertex_descriptor` as key
|
||||
/// and `Traits::Point_3` as value type.
|
||||
template <class Traits, class TriangleMesh, class VertexPointMap>
|
||||
std::size_t remove_degenerate_faces(TriangleMesh& tmesh, const VertexPointMap& vpmap, const Traits& traits)
|
||||
///
|
||||
template <class TriangleMesh, class NamedParameters>
|
||||
std::size_t remove_degenerate_faces(TriangleMesh& tmesh,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef TriangleMesh TM;
|
||||
typedef typename boost::graph_traits<TriangleMesh> GT;
|
||||
typedef typename GT::edge_descriptor edge_descriptor;
|
||||
typedef typename GT::halfedge_descriptor halfedge_descriptor;
|
||||
typedef typename GT::face_descriptor face_descriptor;
|
||||
typedef typename GT::vertex_descriptor vertex_descriptor;
|
||||
|
||||
typedef typename GetVertexPointMap<TM, NamedParameters>::type VertexPointMap;
|
||||
VertexPointMap vpmap = choose_const_pmap(get_param(np, boost::vertex_point),
|
||||
tmesh,
|
||||
boost::vertex_point);
|
||||
typedef typename GetKernel<TM, NamedParameters>::Kernel Traits;
|
||||
Traits traits = choose_param(get_param(np, geom_traits), Traits());
|
||||
|
||||
std::size_t nb_deg_faces = 0;
|
||||
|
||||
// First remove edges of length 0
|
||||
|
|
@ -641,10 +665,11 @@ std::size_t remove_degenerate_faces(TriangleMesh& tmesh, const VertexPointMap& v
|
|||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
template <class Traits, class TriangleMesh>
|
||||
std::size_t remove_degenerate_faces(TriangleMesh& tmesh, const Traits& traits = Traits())
|
||||
template<class TriangleMesh>
|
||||
std::size_t remove_degenerate_faces(TriangleMesh& tmesh)
|
||||
{
|
||||
return remove_degenerate_faces<Traits>(tmesh, get(vertex_point, tmesh), traits);
|
||||
return remove_degenerate_faces(tmesh,
|
||||
CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue