From b392643a98e5f2ae8615c6fe70b23ed277a6e48e Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 5 Apr 2019 14:50:30 +0200 Subject: [PATCH] This branch now targets 4.13.2. --- Installation/include/CGAL/version.h | 4 +- Maintenance/release_building/BUGFIX_NUMBER | 2 +- .../release_building/public_release_name | 2 +- .../Mesh_3/remesh_polyhedral_surface.cpp | 110 +++++++++++++++--- 4 files changed, 98 insertions(+), 20 deletions(-) diff --git a/Installation/include/CGAL/version.h b/Installation/include/CGAL/version.h index b3392f4a8cf..0a470094547 100644 --- a/Installation/include/CGAL/version.h +++ b/Installation/include/CGAL/version.h @@ -25,8 +25,8 @@ #ifndef CGAL_VERSION_H #define CGAL_VERSION_H -#define CGAL_VERSION 4.13 -#define CGAL_VERSION_NR 1041301000 +#define CGAL_VERSION 4.13.2 +#define CGAL_VERSION_NR 1041321000 #define CGAL_SVN_REVISION 99999 #define CGAL_GIT_HASH abcdef #define CGAL_RELEASE_DATE 20181001 diff --git a/Maintenance/release_building/BUGFIX_NUMBER b/Maintenance/release_building/BUGFIX_NUMBER index d00491fd7e5..0cfbf08886f 100644 --- a/Maintenance/release_building/BUGFIX_NUMBER +++ b/Maintenance/release_building/BUGFIX_NUMBER @@ -1 +1 @@ -1 +2 diff --git a/Maintenance/release_building/public_release_name b/Maintenance/release_building/public_release_name index 6c1ca18f09d..84f3800ce0a 100644 --- a/Maintenance/release_building/public_release_name +++ b/Maintenance/release_building/public_release_name @@ -1 +1 @@ -CGAL-4.13.1 +CGAL-4.13.2 diff --git a/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface.cpp b/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface.cpp index 7d87aedbb94..2ee50fe8f9b 100644 --- a/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface.cpp +++ b/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface.cpp @@ -1,23 +1,70 @@ #include +#include #include #include #include #include #include +#include +#include + +#include +#include +#include +#include +#include + +// BGL bug-fix +namespace CGAL{ +namespace Polygon_mesh_processing{ +template +bool is_degenerate_triangle_face(typename boost::graph_traits::face_descriptor f, + const TriangleMesh& tm, + const NamedParameters& np) +{ + CGAL_precondition(CGAL::is_triangle(halfedge(f, tm), tm)); + + using boost::get_param; + using boost::choose_param; + + typedef typename GetVertexPointMap::const_type VertexPointMap; + VertexPointMap vpmap = choose_param(get_param(np, internal_np::vertex_point), + get_const_property_map(vertex_point, tm)); + + typedef typename GetGeomTraits::type Traits; + Traits traits = choose_param(get_param(np, internal_np::geom_traits), Traits()); + + typename boost::graph_traits::halfedge_descriptor h = halfedge(f, tm); + + return traits.collinear_3_object()(get(vpmap, source(h, tm)), + get(vpmap, target(h, tm)), + get(vpmap, target(next(h, tm), tm))); +} + +template +bool is_degenerate_triangle_face(typename boost::graph_traits::face_descriptor f, + const TriangleMesh& tm) +{ + return CGAL::Polygon_mesh_processing::is_degenerate_triangle_face(f, tm, parameters::all_default()); +} +} + +} + +#include -// Domain typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Polyhedral_mesh_domain_with_features_3 Mesh_domain; - // Polyhedron type -typedef CGAL::Mesh_polyhedron_3::type Polyhedron; +typedef CGAL::Surface_mesh Polyhedron; +// Domain +typedef CGAL::Polyhedral_mesh_domain_3 Mesh_domain; + // Triangulation -typedef CGAL::Mesh_triangulation_3::type Tr; -typedef CGAL::Mesh_complex_3_in_triangulation_3< - Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; +typedef CGAL::Mesh_triangulation_3::type Tr; +typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria typedef CGAL::Mesh_criteria_3 Mesh_criteria; @@ -25,18 +72,42 @@ typedef CGAL::Mesh_criteria_3 Mesh_criteria; // To avoid verbose function and named parameters call using namespace CGAL::parameters; -int main() +int main(int, char** argv) { - // Load a polyhedron + // Load OBJ + std::vector points; + std::vector > faces; + + std::ifstream in(argv[1]); + if(!in || !CGAL::read_OBJ(in,points,faces)) + { + return 1; + } + Polyhedron poly; - std::ifstream input("data/lion-head.off"); - input >> poly; + namespace PMP = CGAL::Polygon_mesh_processing; + PMP::orient_polygon_soup(points,faces); + PMP::polygon_soup_to_polygon_mesh(points, faces, poly); + if (!CGAL::is_triangle_mesh(poly)) + { + std::cerr << "Input geometry is not triangulated." << std::endl; + return EXIT_FAILURE; + } if (!CGAL::is_triangle_mesh(poly)){ std::cerr << "Input geometry is not triangulated." << std::endl; return EXIT_FAILURE; } + // remove degenerate faces + std::vector faces_to_remove; + for (Polyhedron::Face_index f : poly.faces()) + if( PMP::is_degenerate_triangle_face(f, poly)) + faces_to_remove.push_back(f); + for (Polyhedron::Face_index f : faces_to_remove) + CGAL::Euler::remove_face(halfedge(f,poly), poly); + faces_to_remove.clear(); + // Create a vector with only one element: the pointer to the polyhedron. std::vector poly_ptrs_vector(1, &poly); @@ -46,21 +117,28 @@ int main() Mesh_domain domain(poly_ptrs_vector.begin(), poly_ptrs_vector.end()); // Get sharp features - domain.detect_features(); //includes detection of borders + // domain.detect_features(); //includes detection of borders // Mesh criteria - Mesh_criteria criteria(edge_size = 0.025, + Mesh_criteria criteria(edge_size = 1, facet_angle = 25, - facet_size = 0.1, - facet_distance = 0.001); - + facet_size = 0.2, + facet_distance = 0.02); + CGAL::Real_timer timer; + timer.start(); // Mesh generation C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, no_perturb(), no_exude()); + timer.stop(); + std::cerr << "Remeshing: " << timer.time() << '\n'; + timer.reset(); + timer.start(); // Output the facets of the c3t3 to an OFF file. The facets will not be // oriented. std::ofstream off_file("out.off"); c3t3.output_boundary_to_off(off_file); + timer.stop(); + std::cerr << "Export surface: " << timer.time() << '\n'; return off_file.fail() ? EXIT_FAILURE : EXIT_SUCCESS; }