diff --git a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h index 67327004f5f..0f8b57e0ffe 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h +++ b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h @@ -977,12 +977,15 @@ print_stats(const double sliver_bound) const } double min_angle_before = min_angle; - min_angle = (std::min)(minimum_dihedral_angle(tr_.tetrahedron(cit)), min_angle); + min_angle = (std::min)(CGAL::to_double(minimum_dihedral_angle(tr_.tetrahedron(cit))), + min_angle); + if ( min_angle < min_angle_before ) min_cell_handle_angle = cit; double min_ratio_before = min_ratio; - min_ratio = (std::min)(radius_ratio(tr_.tetrahedron(cit)), min_ratio); + min_ratio = (std::min)(CGAL::to_double(radius_ratio(tr_.tetrahedron(cit))), + min_ratio); if ( min_ratio < min_ratio_before ) min_cell_handle = cit; } diff --git a/Mesh_3/include/CGAL/make_mesh_3.h b/Mesh_3/include/CGAL/make_mesh_3.h index fc7ccf2a57c..9a70fbda2e8 100644 --- a/Mesh_3/include/CGAL/make_mesh_3.h +++ b/Mesh_3/include/CGAL/make_mesh_3.h @@ -35,7 +35,8 @@ namespace CGAL { */ template C3T3 make_mesh_3(const MeshDomain& domain, - const MeshCriteria& criteria) + const MeshCriteria& criteria, + bool exude = true) { typedef typename MeshDomain::Point_3 Point_3; typedef typename MeshDomain::Index Index; @@ -59,7 +60,7 @@ C3T3 make_mesh_3(const MeshDomain& domain, } // Build mesher and launch refinement process - refine_mesh_3(c3t3, domain, criteria); + refine_mesh_3(c3t3, domain, criteria, exude); return c3t3; }; diff --git a/Mesh_3/include/CGAL/refine_mesh_3.h b/Mesh_3/include/CGAL/refine_mesh_3.h index e31b798f42c..be2233f2d08 100644 --- a/Mesh_3/include/CGAL/refine_mesh_3.h +++ b/Mesh_3/include/CGAL/refine_mesh_3.h @@ -35,7 +35,8 @@ namespace CGAL { template void refine_mesh_3(C3T3& c3t3, const MeshDomain& domain, - const MeshCriteria& criteria) + const MeshCriteria& criteria, + bool exude = true) { typedef Mesh_3::Mesher_3 Mesher; typedef typename C3T3::Triangulation::Geom_traits Gt; @@ -48,18 +49,21 @@ void refine_mesh_3(C3T3& c3t3, mesher.refine_mesh(); // Exudation - Exuder exuder(c3t3); + if ( exude ) + { + Exuder exuder(c3t3); #ifdef CGAL_MESH_3_VERBOSE - exuder.print_stats(10); + exuder.print_stats(10); #endif // CGAL_MESH_3_VERBOSE - exuder.pump_vertices(); + exuder.pump_vertices(); #ifdef CGAL_MESH_3_VERBOSE - exuder.print_stats(10); + exuder.print_stats(10); #endif // CGAL_MESH_3_VERBOSE - + } + }; } // end namespace CGAL diff --git a/Mesh_3/test/Mesh_3/CMakeLists.txt b/Mesh_3/test/Mesh_3/CMakeLists.txt index 02e6ed9fe18..fea586428ff 100644 --- a/Mesh_3/test/Mesh_3/CMakeLists.txt +++ b/Mesh_3/test/Mesh_3/CMakeLists.txt @@ -23,7 +23,9 @@ if ( CGAL_FOUND ) include( CGAL_CreateSingleSourceCGALProgram ) # Test - create_single_source_cgal_program("test_meshing.cpp") + create_single_source_cgal_program("test_meshing_polyhedron.cpp") + create_single_source_cgal_program("test_meshing_3D_image.cpp") + create_single_source_cgal_program("test_meshing_implicit_function.cpp") create_single_source_cgal_program("test_c3t3.cpp") create_single_source_cgal_program("test_criteria.cpp") create_single_source_cgal_program("test_robust_weighted_circumcenter.cpp") diff --git a/Mesh_3/test/Mesh_3/test_meshing.cpp b/Mesh_3/test/Mesh_3/test_meshing.cpp deleted file mode 100644 index aa7b24aa827..00000000000 --- a/Mesh_3/test/Mesh_3/test_meshing.cpp +++ /dev/null @@ -1,319 +0,0 @@ -// Copyright (c) 2009 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you may redistribute it under -// the terms of the Q Public License version 1.0. -// See the file LICENSE.QPL distributed with CGAL. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// -// Author(s) : Stephane Tayeb -// -//****************************************************************************** -// File Description : Tests meshing. -// -//****************************************************************************** - - -//#define CGAL_MESHER_3_SCAN_VERBOSE -//#define CGAL_MESH_3_DEBUG_CELL_CRITERIA -//#define CGAL_SURFACE_MESHER_DEBUG_CRITERIA -//#define CGAL_MESH_3_VERBOSE -//#define CGAL_MESH_3_DEBUG_FACET_CRITERIA - -#include - -#include - -#include -#include - -#include "test_utilities.h" - -#include - -#include -#include -#include -#include -#include - -#include -#include - -// IO -#include -#include -#include -#include - -#include -#include - - -template -struct Tester -{ - void polyhedron() const - { - typedef CGAL::Polyhedron_3 Polyhedron; - typedef CGAL::Polyhedral_mesh_domain_3 Mesh_domain; - - typedef typename CGAL::Mesh_triangulation_3::type Tr; - typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - - typedef CGAL::Mesh_criteria_3 Mesh_criteria; - typedef typename Mesh_criteria::Facet_criteria Facet_criteria; - typedef typename Mesh_criteria::Cell_criteria Cell_criteria; - - typedef typename Mesh_domain::Surface_index Surface_index; - - //------------------------------------------------------- - // Data generation - //------------------------------------------------------- - Polyhedron polyhedron; - std::ifstream input("data/cube.off"); - input >> polyhedron; - input.close(); - - Mesh_domain domain(polyhedron); - - // Set mesh criteria - Facet_criteria facet_criteria(25, 0.8, 1); - Cell_criteria cell_criteria(5, 1.2); - Mesh_criteria criteria(facet_criteria, cell_criteria); - - // Mesh generation - C3t3 c3t3; - c3t3.insert_surface_points(polyhedron.points_begin(), - polyhedron.points_end(), - domain.index_from_surface_index(Surface_index(0,1))); - - CGAL::refine_mesh_3(c3t3, domain, criteria); - - // Verify - verify(c3t3,domain,criteria,26,26,48,48); - } - - typedef typename K::Point_3 Point; - typedef typename K::FT FT; - static FT sphere_function (const Point& p) - { - const FT x2=p.x()*p.x(), y2=p.y()*p.y(), z2=p.z()*p.z(); - return x2+y2+z2-1; - } - - void implicit() const - { - - typedef FT (Function)(const Point&); - - typedef CGAL::Implicit_mesh_domain_3 Mesh_domain; - - typedef typename CGAL::Mesh_triangulation_3::type Tr; - typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - - typedef CGAL::Mesh_criteria_3 Mesh_criteria; - typedef typename Mesh_criteria::Facet_criteria Facet_criteria; - typedef typename Mesh_criteria::Cell_criteria Cell_criteria; - - typedef typename K::Sphere_3 Sphere_3; - - typedef typename Mesh_domain::Surface_index Surface_index; - - //------------------------------------------------------- - // Data generation - //------------------------------------------------------- - Mesh_domain domain(Tester::sphere_function, Sphere_3(CGAL::ORIGIN,2.)); - - // Set mesh criteria - Facet_criteria facet_criteria(0, 0, 0.3); - Cell_criteria cell_criteria(0, 0.5); - Mesh_criteria criteria(facet_criteria, cell_criteria); - - std::vector initial_points; - initial_points.push_back(Point(1,0,0)); - initial_points.push_back(Point(0,1,0)); - initial_points.push_back(Point(0,0,1)); - initial_points.push_back(Point(-1,0,0)); - initial_points.push_back(Point(0,-1,0)); - initial_points.push_back(Point(0,0,-1)); - - // Mesh generation - C3t3 c3t3; - c3t3.insert_surface_points(initial_points.begin(), - initial_points.end(), - domain.index_from_surface_index(Surface_index(0,1))); - - CGAL::refine_mesh_3(c3t3, domain, criteria); - - // Verify - verify(c3t3,domain,criteria,50,58,80,90); - } - - void image() const - { - typedef CGAL::Image_3 Image; - typedef CGAL::Labeled_image_mesh_domain_3 Mesh_domain; - - typedef typename CGAL::Mesh_triangulation_3::type Tr; - typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - - typedef CGAL::Mesh_criteria_3 Mesh_criteria; - typedef typename Mesh_criteria::Facet_criteria Facet_criteria; - typedef typename Mesh_criteria::Cell_criteria Cell_criteria; - - typedef typename Mesh_domain::Surface_index Surface_index; - - //------------------------------------------------------- - // Data generation - //------------------------------------------------------- - Image image; - image.read("data/liver_kidney_gallbladder.inr"); - Mesh_domain domain(image,1e-9); - - // Set mesh criteria - Facet_criteria facet_criteria(25, 20*image.vx(), 5*image.vx()); - Cell_criteria cell_criteria(4, 25*image.vx()); - Mesh_criteria criteria(facet_criteria, cell_criteria); - - // Mesh generation - C3t3 c3t3 = make_mesh_3(domain,criteria); - - // Verify - verify(c3t3,domain,criteria); - } - - template - void verify(C3t3& c3t3, - const Domain& domain, - const Criteria& criteria, - const unsigned int min_vertices_expected = 0, - const unsigned int max_vertices_expected = -1, - const unsigned int min_facets_expected = 0, - const unsigned int max_facets_expected = -1, - const unsigned int min_cells_expected = 0, - const unsigned int max_cells_expected = -1) const - { - typedef typename C3t3::size_type size_type; - - // Store mesh properties - size_type v = c3t3.triangulation().number_of_vertices(); - size_type f = c3t3.number_of_facets(); - size_type c = c3t3.number_of_cells(); - - // Verify - verify_c3t3(c3t3, - min_vertices_expected, - max_vertices_expected, - min_facets_expected, - max_facets_expected, - min_cells_expected, - max_cells_expected); - - // Refine again and verify nothing changed - std::cerr << "\tRefining again...\n"; - refine_mesh_3(c3t3,domain,criteria); - verify_c3t3(c3t3,v,v,f,f,c,c); - } - - template - void verify_c3t3(const C3t3& c3t3, - const unsigned int min_vertices_expected = 0, - const unsigned int max_vertices_expected = -1, - const unsigned int min_facets_expected = 0, - const unsigned int max_facets_expected = -1, - const unsigned int min_cells_expected = 0, - const unsigned int max_cells_expected = -1) const - { - //------------------------------------------------------- - // Verifications - //------------------------------------------------------- - std::cerr << "\t\tNumber of cells: " << c3t3.number_of_cells() << "\n"; - std::cerr << "\t\tNumber of facets: " << c3t3.number_of_facets() << "\n"; - std::cerr << "\t\tNumber of vertices: " << c3t3.number_of_vertices() << "\n"; - - assert(min_vertices_expected <= c3t3.number_of_vertices()); - assert(max_vertices_expected >= c3t3.number_of_vertices()); - - assert(min_facets_expected <= c3t3.number_of_facets()); - assert(max_facets_expected >= c3t3.number_of_facets()); - - assert(min_cells_expected <= c3t3.number_of_cells()); - assert(max_cells_expected >= c3t3.number_of_cells()); - } -}; - - - - - - -int main() -{ - std::cerr << "TESTING WITH Exact_predicates_inexact_constructions_kernel...\n"; - Tester test_epic; - std::cerr << "Mesh generation from a polyhedron:\n"; - test_epic.polyhedron(); - std::cerr << "Mesh generation from an implicit function:\n"; - test_epic.implicit(); - std::cerr << "Mesh generation from a 3D image:\n"; - test_epic.image(); - -// std::cerr << "Test trilinear interpolation:\n"; -// test_epic.test(); - -// std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; -// Tester > > test_scf; -// std::cerr << "Mesh generation from a polyhedron:\n"; -// test_scf.polyhedron(); -// std::cerr << "Mesh generation from an implicit function:\n"; -// test_scf.implicit(); -// -// std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; -// Tester > > test_cf; -// std::cerr << "Mesh generation from a polyhedron:\n"; -// test_cf.polyhedron(); -// std::cerr << "Mesh generation from an implicit function:\n"; -// test_cf.implicit(); -// -// std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; -// Tester > > test_cd; -// std::cerr << "Mesh generation from a polyhedron:\n"; -// test_cd.polyhedron(); -// std::cerr << "Mesh generation from an implicit function:\n"; -// test_cd.implicit(); - -// std::cerr << "\nTESTING WITH Exact_predicates_exact_constructions_kernel...\n"; -// Tester test_epec; -// std::cerr << "Mesh generation from a polyhedron:\n"; -// test_epec.polyhedron(); -// std::cerr << "Mesh generation from an implicit function:\n"; -// test_epec.implicit(); -// std::cerr << "Mesh generation from a 3D image:\n"; -// test_epec.image(); - -}; - - -// BBox test in AABB_tree... -//FT inv_dir_x(1e9); -//FT inv_dir_y(1e9); -//FT inv_dir_z(1e9); -// -//if ( 0 != direction.x() ) -// inv_dir_x = (FT)1.0/direction.x(); -//if ( 0 != direction.y() ) -// inv_dir_y = (FT)1.0/direction.y(); -//if ( 0 != direction.z() ) -// inv_dir_y = (FT)1.0/direction.z(); -// -//const Vector inv_direction(inv_dir_x, inv_dir_y, inv_dir_z); diff --git a/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp b/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp new file mode 100644 index 00000000000..1befda1ac53 --- /dev/null +++ b/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp @@ -0,0 +1,120 @@ +// Copyright (c) 2009 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you may redistribute it under +// the terms of the Q Public License version 1.0. +// See the file LICENSE.QPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Stephane Tayeb +// +//****************************************************************************** +// File Description : +//****************************************************************************** + +#define CGAL_MESH_3_VERBOSE + + +#include "test_meshing_utilities.h" +#include +#include + +template +struct Image_tester : public Tester +{ +public: + void image() const + { + typedef CGAL::Image_3 Image; + typedef CGAL::Labeled_image_mesh_domain_3 Mesh_domain; + + typedef typename CGAL::Mesh_triangulation_3::type Tr; + typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; + + typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef typename Mesh_criteria::Facet_criteria Facet_criteria; + typedef typename Mesh_criteria::Cell_criteria Cell_criteria; + + typedef typename Mesh_domain::Surface_index Surface_index; + + //------------------------------------------------------- + // Data generation + //------------------------------------------------------- + Image image; + image.read("data/liver_kidney_gallbladder.inr"); + Mesh_domain domain(image,1e-9); + + // Set mesh criteria + Facet_criteria facet_criteria(25, 20*image.vx(), 5*image.vx()); + Cell_criteria cell_criteria(4, 25*image.vx()); + Mesh_criteria criteria(facet_criteria, cell_criteria); + + // Mesh generation + C3t3 c3t3 = make_mesh_3(domain,criteria,false); + + // Verify + verify(c3t3,domain,criteria); + } +}; + + + +int main() +{ + std::cerr << "TESTING WITH Exact_predicates_inexact_constructions_kernel...\n"; + Image_tester test_epic; + std::cerr << "Mesh generation from a 3D image:\n"; + test_epic.image(); + +// std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; +// Tester > > test_cf; +// std::cerr << "Mesh generation from a polyhedron:\n"; +// test_cf.image(); + + return EXIT_SUCCESS; + +// std::cerr << "Mesh generation from an implicit function:\n"; +// test_epic.implicit(); + + + // std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; + // Tester > > test_scf; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_scf.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_scf.implicit(); + // + // std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; + // Tester > > test_cf; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_cf.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_cf.implicit(); + // + // std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; + // Tester > > test_cd; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_cd.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_cd.implicit(); + + // std::cerr << "\nTESTING WITH Exact_predicates_exact_constructions_kernel...\n"; + // Tester test_epec; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_epec.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_epec.implicit(); + // std::cerr << "Mesh generation from a 3D image:\n"; + // test_epec.image(); + +}; + diff --git a/Mesh_3/test/Mesh_3/test_meshing_implicit_function.cpp b/Mesh_3/test/Mesh_3/test_meshing_implicit_function.cpp new file mode 100644 index 00000000000..71941058c6e --- /dev/null +++ b/Mesh_3/test/Mesh_3/test_meshing_implicit_function.cpp @@ -0,0 +1,137 @@ +// Copyright (c) 2009 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you may redistribute it under +// the terms of the Q Public License version 1.0. +// See the file LICENSE.QPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Stephane Tayeb +// +//****************************************************************************** +// File Description : +//****************************************************************************** + +#define CGAL_MESH_3_VERBOSE + +#include "test_meshing_utilities.h" +#include + +template +struct Implicit_tester : public Tester +{ + typedef typename K::Point_3 Point; + typedef typename K::FT FT; + static FT sphere_function (const Point& p) + { + const FT x2=p.x()*p.x(), y2=p.y()*p.y(), z2=p.z()*p.z(); + return x2+y2+z2-1; + } + + void implicit() const + { + + typedef FT (Function)(const Point&); + + typedef CGAL::Implicit_mesh_domain_3 Mesh_domain; + + typedef typename CGAL::Mesh_triangulation_3::type Tr; + typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; + + typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef typename Mesh_criteria::Facet_criteria Facet_criteria; + typedef typename Mesh_criteria::Cell_criteria Cell_criteria; + + typedef typename K::Sphere_3 Sphere_3; + + typedef typename Mesh_domain::Surface_index Surface_index; + + //------------------------------------------------------- + // Data generation + //------------------------------------------------------- + Mesh_domain domain(Implicit_tester::sphere_function, + Sphere_3(CGAL::ORIGIN,2.)); + + // Set mesh criteria + Facet_criteria facet_criteria(0, 0, 0.3); + Cell_criteria cell_criteria(0, 0.5); + Mesh_criteria criteria(facet_criteria, cell_criteria); + + std::vector initial_points; + initial_points.push_back(Point(1,0,0)); + initial_points.push_back(Point(0,1,0)); + initial_points.push_back(Point(0,0,1)); + initial_points.push_back(Point(-1,0,0)); + initial_points.push_back(Point(0,-1,0)); + initial_points.push_back(Point(0,0,-1)); + + // Mesh generation + C3t3 c3t3; + c3t3.insert_surface_points(initial_points.begin(), + initial_points.end(), + domain.index_from_surface_index(Surface_index(0,1))); + + CGAL::refine_mesh_3(c3t3, domain, criteria,false); + + // Verify + verify(c3t3,domain,criteria,50,58,80,90); + } +}; + + +int main() +{ + std::cerr << "TESTING WITH Exact_predicates_inexact_constructions_kernel...\n"; + Implicit_tester test_epic; + std::cerr << "Mesh generation from an implicit function:\n"; + test_epic.implicit(); + +// std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; +// Implicit_tester > > test_cf; +// std::cerr << "Mesh generation from an implicit function:\n"; +// test_cf.implicit(); + + return EXIT_SUCCESS; + + + // std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; + // Tester > > test_scf; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_scf.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_scf.implicit(); + // + // std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; + // Tester > > test_cf; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_cf.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_cf.implicit(); + // + // std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; + // Tester > > test_cd; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_cd.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_cd.implicit(); + + // std::cerr << "\nTESTING WITH Exact_predicates_exact_constructions_kernel...\n"; + // Tester test_epec; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_epec.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_epec.implicit(); + // std::cerr << "Mesh generation from a 3D image:\n"; + // test_epec.image(); + +}; + diff --git a/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp b/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp new file mode 100644 index 00000000000..2672c03fab1 --- /dev/null +++ b/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp @@ -0,0 +1,127 @@ +// Copyright (c) 2009 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you may redistribute it under +// the terms of the Q Public License version 1.0. +// See the file LICENSE.QPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Stephane Tayeb +// +//****************************************************************************** +// File Description : +//****************************************************************************** + +#define CGAL_MESH_3_VERBOSE + +#include +#include "test_meshing_utilities.h" +#include +#include + + +template +struct Polyhedron_tester : public Tester +{ + void polyhedron() const + { + typedef CGAL::Polyhedron_3 Polyhedron; + typedef CGAL::Polyhedral_mesh_domain_3 Mesh_domain; + + typedef typename CGAL::Mesh_triangulation_3::type Tr; + typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; + + typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef typename Mesh_criteria::Facet_criteria Facet_criteria; + typedef typename Mesh_criteria::Cell_criteria Cell_criteria; + + typedef typename Mesh_domain::Surface_index Surface_index; + + //------------------------------------------------------- + // Data generation + //------------------------------------------------------- + Polyhedron polyhedron; + std::ifstream input("data/cube.off"); + input >> polyhedron; + input.close(); + + Mesh_domain domain(polyhedron); + + // Set mesh criteria + Facet_criteria facet_criteria(25, 0.8, 1); + Cell_criteria cell_criteria(5, 1.2); + Mesh_criteria criteria(facet_criteria, cell_criteria); + + // Mesh generation + C3t3 c3t3; + c3t3.insert_surface_points(polyhedron.points_begin(), + polyhedron.points_end(), + domain.index_from_surface_index(Surface_index(0,1))); + + CGAL::refine_mesh_3(c3t3, domain, criteria, false); + + // Verify + verify(c3t3,domain,criteria,26,26,48,48); + } +}; + +int main() +{ + std::cerr << "TESTING WITH Exact_predicates_inexact_constructions_kernel...\n"; + Polyhedron_tester test_epic; + std::cerr << "Mesh generation from a polyhedron:\n"; + test_epic.polyhedron(); + +// std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; +// Polyhedron_tester > > test_scf; +// std::cerr << "Mesh generation from a polyhedron:\n"; +// test_scf.polyhedron(); + + return EXIT_SUCCESS; + +// std::cerr << "Mesh generation from an implicit function:\n"; +// test_epic.implicit(); +// std::cerr << "Mesh generation from a 3D image:\n"; +// test_epic.image(); + + // std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; + // Tester > > test_scf; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_scf.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_scf.implicit(); + // + // std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; + // Tester > > test_cf; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_cf.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_cf.implicit(); + // + // std::cerr << "TESTING WITH Filtered_kernel > kernel...\n"; + // Tester > > test_cd; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_cd.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_cd.implicit(); + + // std::cerr << "\nTESTING WITH Exact_predicates_exact_constructions_kernel...\n"; + // Tester test_epec; + // std::cerr << "Mesh generation from a polyhedron:\n"; + // test_epec.polyhedron(); + // std::cerr << "Mesh generation from an implicit function:\n"; + // test_epec.implicit(); + // std::cerr << "Mesh generation from a 3D image:\n"; + // test_epec.image(); + +}; + diff --git a/Mesh_3/test/Mesh_3/test_meshing_utilities.h b/Mesh_3/test/Mesh_3/test_meshing_utilities.h new file mode 100644 index 00000000000..1a76d5214f7 --- /dev/null +++ b/Mesh_3/test/Mesh_3/test_meshing_utilities.h @@ -0,0 +1,102 @@ +// Copyright (c) 2009 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you may redistribute it under +// the terms of the Q Public License version 1.0. +// See the file LICENSE.QPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Stephane Tayeb +// +//****************************************************************************** +// File Description : Test meshing utilities. +//****************************************************************************** + +#include +#include + +#include "test_utilities.h" + +#include +#include +#include + +#include + +// IO +#include +#include + + +template +struct Tester +{ + template + void verify(C3t3& c3t3, + const Domain& domain, + const Criteria& criteria, + const unsigned int min_vertices_expected = 0, + const unsigned int max_vertices_expected = -1, + const unsigned int min_facets_expected = 0, + const unsigned int max_facets_expected = -1, + const unsigned int min_cells_expected = 0, + const unsigned int max_cells_expected = -1) const + { + typedef typename C3t3::size_type size_type; + + // Store mesh properties + size_type v = c3t3.triangulation().number_of_vertices(); + size_type f = c3t3.number_of_facets(); + size_type c = c3t3.number_of_cells(); + + // Verify + verify_c3t3(c3t3, + min_vertices_expected, + max_vertices_expected, + min_facets_expected, + max_facets_expected, + min_cells_expected, + max_cells_expected); + + // Refine again and verify nothing changed + std::cerr << "\tRefining again...\n"; + refine_mesh_3(c3t3,domain,criteria,false); + verify_c3t3(c3t3,v,v,f,f,c,c); + } + + template + void verify_c3t3(const C3t3& c3t3, + const unsigned int min_vertices_expected = 0, + const unsigned int max_vertices_expected = -1, + const unsigned int min_facets_expected = 0, + const unsigned int max_facets_expected = -1, + const unsigned int min_cells_expected = 0, + const unsigned int max_cells_expected = -1) const + { + //------------------------------------------------------- + // Verifications + //------------------------------------------------------- + std::cerr << "\t\tNumber of cells: " << c3t3.number_of_cells() << "\n"; + std::cerr << "\t\tNumber of facets: " << c3t3.number_of_facets() << "\n"; + std::cerr << "\t\tNumber of vertices: " << c3t3.number_of_vertices() << "\n"; + + assert(min_vertices_expected <= c3t3.number_of_vertices()); + assert(max_vertices_expected >= c3t3.number_of_vertices()); + + assert(min_facets_expected <= c3t3.number_of_facets()); + assert(max_facets_expected >= c3t3.number_of_facets()); + + assert(min_cells_expected <= c3t3.number_of_cells()); + assert(max_cells_expected >= c3t3.number_of_cells()); + } +}; + diff --git a/Mesh_3/test/Mesh_3/test_robust_weighted_circumcenter.cpp b/Mesh_3/test/Mesh_3/test_robust_weighted_circumcenter.cpp index b6acb74c9ac..c3649570b0d 100644 --- a/Mesh_3/test/Mesh_3/test_robust_weighted_circumcenter.cpp +++ b/Mesh_3/test/Mesh_3/test_robust_weighted_circumcenter.cpp @@ -35,7 +35,7 @@ struct Tester typedef CGAL::Polyhedral_mesh_domain_3 Mesh_traits; typedef typename CGAL::Mesh_triangulation_3::type Tr; - + typedef typename Tr::Geom_traits Gt; typedef typename Gt::FT FT; typedef typename Gt::Point_3 Point; @@ -117,6 +117,10 @@ int main() std::cerr << "\nTESTING WITH Exact_predicates_exact_constructions_kernel...\n"; Tester test_epec; test_epec(); + +// std::cerr << "\nTESTING WITH Filtered_kernel > kernel...\n"; +// Tester > > test_scf; +// test_scf(); return EXIT_SUCCESS; }