From 447eace7d276f8e9b0d5f0fd998540197e73b323 Mon Sep 17 00:00:00 2001 From: Ange Clement Date: Thu, 22 Jun 2023 17:43:07 +0200 Subject: [PATCH] Added testing for edge_distance : - Modified test_mesh_criteria_creation.cpp to test the creation with or without a SizingField - Modified test_meshing_determinism.cpp to test determinism of mesh creation - Added test_max_edge_distance.cpp that estimate number of vertices and facets and test that it is greater than without the parameter --- Data/data/images/quadDomainCube.inr | Bin 0 -> 131328 bytes Mesh_3/test/Mesh_3/CMakeLists.txt | 3 + Mesh_3/test/Mesh_3/test_max_edge_distance.cpp | 183 ++++++++++++++++++ .../Mesh_3/test_mesh_criteria_creation.cpp | 9 + .../test/Mesh_3/test_meshing_determinism.cpp | 1 + 5 files changed, 196 insertions(+) create mode 100644 Data/data/images/quadDomainCube.inr create mode 100644 Mesh_3/test/Mesh_3/test_max_edge_distance.cpp diff --git a/Data/data/images/quadDomainCube.inr b/Data/data/images/quadDomainCube.inr new file mode 100644 index 0000000000000000000000000000000000000000..b5ea02a5adfd18bba4a0670fdc90d693913c1fcc GIT binary patch literal 131328 zcmeH~L2F%A6h^Ifbbm$RjTKv+zCoyu@&>6PjUmZU6D0#Xse(}Y-+j9j+Vh?Hx>xtw z5ZV(cA8(ztU%#_EzP>!3pS?PK`{VBYa`V&ieE-9X<@VE`cc1>eu0NkISGO03{oilj zJ^u0b;r`k0kN-T}FBiv~H^;lf>0dqj_3^KF%gc*j_V*9J{kdG8a z-RHmWULAfuKU`hj?q8l=ULD>X&t5Ow>~-InS%b#>0zu(C0%E~cc z|49e7=3n>z>F4+TOFEGIPi9wEj`{jeI*|T(?oEK~UiSalHTnDgAst8q$!zyO>9g+3 ze|!AN?&teszJK}q{vsVn1IcXnKk2jXZ;}5@#NTuxVE<=3c)BHj`I8Rl-$;ODUs*Zk z_uhZ|Kik1`|Ku-!(gFP&36Sh7E2n#Y^6=b?fc>*~|MdR7f6{^cb|tebE605OCml%t zy7x~%zwd9-0rzhtK(eo_9P`)R|GW>+y$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#include +#include +#include +#include + +#include + +#include "test_meshing_utilities.h" + +#define CGAL_MESH_3_VERBOSE true + +template +struct Distance_polyhedral_tester : public Tester +{ + typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + + // Domain + typedef CGAL::Surface_mesh Polyhedron; + typedef CGAL::Polyhedral_mesh_domain_with_features_3 Mesh_domain; + + // Triangulation + typedef typename CGAL::Mesh_triangulation_3::type Tr; + + typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; + + // Criteria + typedef CGAL::Mesh_criteria_3 Mesh_criteria; + +public: + void operator()(std::size_t expected_nb_vertices, std::size_t expected_nb_triangles) + { + const std::string fname = CGAL::data_file_path("meshes/dragknob.off"); + + std::ifstream input(fname); + using namespace CGAL::parameters; + + Polyhedron polyhedron; + input >> polyhedron; + if (input.fail()) { + std::cerr << "Error: Cannot read file " << fname << std::endl; + return; + } + + if (!CGAL::is_triangle_mesh(polyhedron)) { + std::cerr << "Input geometry is not triangulated." << std::endl; + return; + } + + // Create domain + Mesh_domain domain(polyhedron); + + domain.detect_features(40); + + // Mesh criteria + Mesh_criteria criteria(edge_size = 0.074, + edge_distance = 0.00074, + facet_distance = 0.0074, + facet_angle = 25, + facet_size = 0.074, + cell_radius_edge_ratio = 3, + cell_size = 0.074); + + // Mesh generation + C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, no_perturb(), no_exude()); + + std::size_t nb_vertices = c3t3.triangulation().number_of_vertices(); + std::size_t nb_triangles = c3t3.number_of_facets_in_complex(); + + this->verify_c3t3(c3t3, domain, Polyhedral_tag(), expected_nb_vertices * 0.95, expected_nb_vertices * 1.05, expected_nb_triangles * 0.95, expected_nb_triangles * 1.05); + + // verify that there are more vertices than without criteria + + Mesh_criteria criteria_without(edge_size = 0.074, + facet_distance = 0.0074, + facet_angle = 25, + facet_size = 0.074, + cell_radius_edge_ratio = 3, + cell_size = 0.074); + + // Mesh generation + c3t3 = CGAL::make_mesh_3(domain, criteria_without, no_perturb(), no_exude()); + assert(nb_vertices > c3t3.triangulation().number_of_vertices()); + assert(nb_triangles > c3t3.number_of_facets_in_complex()); + } +}; + +template +struct Distance_label_image_tester : public Tester +{ + typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + + // Domain + typedef CGAL::Labeled_mesh_domain_3 Image_domain; + typedef CGAL::Mesh_domain_with_polyline_features_3 Mesh_domain; + + // Triangulation + typedef typename CGAL::Mesh_triangulation_3::type Tr; + + typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; + + // Criteria + typedef CGAL::Mesh_criteria_3 Mesh_criteria; + +public: + + void operator()(std::size_t expected_nb_vertices, std::size_t expected_nb_triangles) + { + const std::string fname = CGAL::data_file_path("images/quadDomainCube.inr"); + + using namespace CGAL::parameters; + + CGAL::Image_3 image; + if(!image.read(fname)){ + std::cerr << "Error: Cannot read file " << fname << std::endl; + return; + } + + // Create domain + Mesh_domain domain + = Mesh_domain::create_labeled_image_mesh_domain(image, + features_detector = CGAL::Mesh_3::Detect_features_in_image()); + + // Mesh criteria + Mesh_criteria criteria(edge_size = 5., + edge_distance = 0.3, + facet_distance = 0.3, + facet_angle = 25, + facet_size = 5., + cell_radius_edge_ratio = 3, + cell_size = 5.); + + // Mesh generation + C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, no_perturb(), no_exude()); + + std::size_t nb_vertices = c3t3.triangulation().number_of_vertices(); + std::size_t nb_triangles = c3t3.number_of_facets_in_complex(); + + this->verify_c3t3(c3t3, domain, Polyhedral_tag(), expected_nb_vertices * 0.95, expected_nb_vertices * 1.05, expected_nb_triangles * 0.95, expected_nb_triangles * 1.05); + + // verify that there are more vertices than without criteria + Mesh_criteria criteria_without(edge_size = 5., + facet_distance = 0.3, + facet_angle = 25, + facet_size = 5., + cell_radius_edge_ratio = 3, + cell_size = 5.); + + // Mesh generation + c3t3 = CGAL::make_mesh_3(domain, criteria_without, no_perturb(), no_exude()); + assert(nb_vertices > c3t3.triangulation().number_of_vertices()); + assert(nb_triangles > c3t3.number_of_facets_in_complex()); + } +}; + + +int main(int argc, char* argv[]) +{ + Distance_polyhedral_tester<> test_epic_poly; + std::cerr << "Mesh generation with edge_distance from polyhedral domain:\n"; + test_epic_poly(1820, 3012); + + Distance_label_image_tester<> test_epic_image; + std::cerr << "Mesh generation with edge_distance from label image domain:\n"; + test_epic_image(776, 1525); + +#ifdef CGAL_LINKED_WITH_TBB + Distance_polyhedral_tester test_epic_p; + std::cerr << "Parallel mesh generation with edge_distance from polyhedral domain:\n"; + test_epic_p(1924, 3034); + + Distance_label_image_tester test_epic_image_p; + std::cerr << "Parallel mesh generation with edge_distance from label image domain:\n"; + test_epic_image_p(847, 1509); +#endif + return EXIT_SUCCESS; +} diff --git a/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp b/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp index b81befd7a56..b4aa8d5c1ae 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp @@ -96,6 +96,15 @@ int main() edge_size = 8.); assert( ec7.edge_criteria_object().sizing_field(bp1,1,index) == 8. ); + Mc ec8(edge_distance = 8.); + assert( ec8.edge_criteria_object().distance_bound_field(bp1, 1, index) == 8. ); + + Mc ec9(edge_distance_sizing_field = 9.); + assert( ec9.edge_criteria_object().distance_bound_field(bp1, 1, index) == 9.); + + Mc ec10(edge_distance_sizing_field = Esf(10.)); + assert( ec10.edge_criteria_object().distance_bound_field(bp1, 1, index) == 10.); + // ----------------------------------- // Test facet criteria diff --git a/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp b/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp index ade0505bca7..fcb314f6ea6 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp @@ -59,6 +59,7 @@ void test() // Mesh criteria Mesh_criteria criteria(edge_size = 0.2, + edge_distance = 0.002, facet_angle = 25, facet_size = 0.2, facet_distance = 0.002,