diff --git a/Data/data/meshes/halfcube.off b/Data/data/meshes/halfcube.off new file mode 100644 index 00000000000..4c9a166bc42 --- /dev/null +++ b/Data/data/meshes/halfcube.off @@ -0,0 +1,13 @@ +OFF +5 4 0 + +-1 -1 1 +-1 1 1 +1 -1 -1 +-1 1 -1 +-1 -1 -1 +3 0 4 2 +3 2 4 3 +3 4 0 1 +3 1 3 4 + diff --git a/Mesh_3/test/Mesh_3/CMakeLists.txt b/Mesh_3/test/Mesh_3/CMakeLists.txt index 2a8e19e1c38..37e41ec079a 100644 --- a/Mesh_3/test/Mesh_3/CMakeLists.txt +++ b/Mesh_3/test/Mesh_3/CMakeLists.txt @@ -53,6 +53,7 @@ create_single_source_cgal_program( "test_meshing_without_features_determinism.cp create_single_source_cgal_program( "test_mesh_3_issue_1554.cpp" ) create_single_source_cgal_program( "test_mesh_polyhedral_domain_with_features_deprecated.cpp" ) create_single_source_cgal_program( "test_meshing_with_one_step.cpp" ) +create_single_source_cgal_program( "test_meshing_with_one_step_with_features.cpp" ) create_single_source_cgal_program( "test_mesh_cell_base_3.cpp") create_single_source_cgal_program( "test_min_edge_length.cpp") @@ -85,6 +86,7 @@ foreach(target test_mesh_polyhedral_domain_with_features_deprecated test_mesh_cell_base_3 test_meshing_with_one_step + test_meshing_with_one_step_with_features test_min_edge_length test_min_size_criteria ) diff --git a/Mesh_3/test/Mesh_3/test_meshing_with_one_step_with_features.cpp b/Mesh_3/test/Mesh_3/test_meshing_with_one_step_with_features.cpp new file mode 100644 index 00000000000..7a0935c474e --- /dev/null +++ b/Mesh_3/test/Mesh_3/test_meshing_with_one_step_with_features.cpp @@ -0,0 +1,86 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// Domain +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Surface_mesh Polyhedron; +typedef CGAL::Polyhedral_mesh_domain_with_features_3 Mesh_domain; + +typedef CGAL::Sequential_tag Concurrency_tag; + +// Triangulation +typedef CGAL::Mesh_triangulation_3::type Tr; + +typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; + +// Criteria +typedef CGAL::Mesh_criteria_3 Mesh_criteria; + +typedef CGAL::Mesh_3::Mesher_3 Mesher; + +// To avoid verbose function and named parameters call +using namespace CGAL::parameters; + +int main(int argc, char*argv[]) +{ + const std::string fname = CGAL::data_file_path("meshes/halfcube.off"); + // Create input polyhedron + Polyhedron polyhedron; + std::ifstream input(fname); + input >> polyhedron; + if(input.fail()){ + std::cerr << "Error: Cannot read file " << fname << std::endl; + return EXIT_FAILURE; + } + input.close(); + + if (!CGAL::is_triangle_mesh(polyhedron)){ + std::cerr << "Input geometry is not triangulated." << std::endl; + return EXIT_FAILURE; + } + + // Create domain + + std::vector polyhedra; + polyhedra.push_back(&polyhedron); + + Mesh_domain domain(polyhedra.begin(), polyhedra.end()); + domain.detect_features(); + + // Mesh criteria (no cell_size set) + Mesh_criteria criteria(facet_angle = 25, + facet_size = 0.17, + facet_distance = 0.017, + edge_size = 0.17); + + // Mesh generation + namespace p = CGAL::parameters; + C3t3 c3t3; + CGAL::Mesh_3::internal::C3t3_initializer()(c3t3, domain, criteria, true); + + Mesher mesher(c3t3, domain, criteria, CGAL::FACET_VERTICES_ON_SURFACE); + mesher.initialize(); + mesher.display_number_of_bad_elements(); + while ( ! mesher.is_algorithm_done() ) mesher.one_step(); + assert(c3t3.triangulation().number_of_vertices() > 200); + + // Output + mesher.display_number_of_bad_elements(); + + return EXIT_SUCCESS; +}