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

This commit is contained in:
Ange Clement 2023-06-22 17:43:07 +02:00
parent 8998f459b1
commit 447eace7d2
5 changed files with 196 additions and 0 deletions

Binary file not shown.

View File

@ -55,6 +55,7 @@ create_single_source_cgal_program( "test_mesh_polyhedral_domain_with_features_de
create_single_source_cgal_program( "test_meshing_with_one_step.cpp" )
create_single_source_cgal_program( "test_mesh_cell_base_3.cpp")
create_single_source_cgal_program( "test_min_edge_length.cpp")
create_single_source_cgal_program( "test_max_edge_distance.cpp")
foreach(target
test_boost_has_xxx
@ -86,6 +87,7 @@ foreach(target
test_mesh_cell_base_3
test_meshing_with_one_step
test_min_edge_length
test_max_edge_distance
test_min_size_criteria
)
if(TARGET ${target})
@ -111,6 +113,7 @@ if(TARGET CGAL::TBB_support)
test_mesh_polyhedral_domain_with_features_deprecated
test_mesh_cell_base_3
test_min_edge_length
test_max_edge_distance
test_min_size_criteria
)
if(TARGET ${target})

View File

@ -0,0 +1,183 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polyhedral_mesh_domain_with_features_3.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/Mesh_3/Detect_features_in_image.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/Sizing_field_with_aabb_tree.h>
#include "test_meshing_utilities.h"
#define CGAL_MESH_3_VERBOSE true
template <typename Concurrency_tag = CGAL::Sequential_tag>
struct Distance_polyhedral_tester : public Tester<K_e_i>
{
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
// Domain
typedef CGAL::Surface_mesh<K::Point_3> Polyhedron;
typedef CGAL::Polyhedral_mesh_domain_with_features_3<K, Polyhedron> Mesh_domain;
// Triangulation
typedef typename CGAL::Mesh_triangulation_3<Mesh_domain, K, Concurrency_tag>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
// Criteria
typedef CGAL::Mesh_criteria_3<Tr> 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<C3t3>(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<C3t3>(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 <typename Concurrency_tag = CGAL::Sequential_tag>
struct Distance_label_image_tester : public Tester<K_e_i>
{
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
// Domain
typedef CGAL::Labeled_mesh_domain_3<K> Image_domain;
typedef CGAL::Mesh_domain_with_polyline_features_3<Image_domain> Mesh_domain;
// Triangulation
typedef typename CGAL::Mesh_triangulation_3<Mesh_domain, K, Concurrency_tag>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
// Criteria
typedef CGAL::Mesh_criteria_3<Tr> 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<C3t3>(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<C3t3>(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<CGAL::Parallel_tag> test_epic_p;
std::cerr << "Parallel mesh generation with edge_distance from polyhedral domain:\n";
test_epic_p(1924, 3034);
Distance_label_image_tester<CGAL::Parallel_tag> 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;
}

View File

@ -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

View File

@ -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,