From 702149cd938ff54bca3d90de82baa242cfede12e Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 27 May 2016 15:37:48 +0200 Subject: [PATCH] Also test EPEC in the testsuite --- .../CGAL/Polygon_mesh_processing/Weights.h | 4 +- .../Polygon_mesh_processing/compute_normal.h | 2 +- .../Hole_filling/Triangulate_hole_polyline.h | 2 +- .../internal/refine_impl.h | 8 +- .../Polygon_mesh_processing/fairing_test.cpp | 23 ++-- .../Polygon_mesh_processing/measures_test.cpp | 31 ++--- .../orient_polygon_mesh_test.cpp | 18 ++- .../orient_polygon_soup_test.cpp | 27 +++-- .../pmp_compute_normals_test.cpp | 32 +++-- .../point_inside_surface_mesh_test.cpp | 22 +++- .../polygon_mesh_slicer_test.cpp | 22 +++- .../remeshing_test.cpp | 40 +++++-- .../self_intersection_polyhedron_test.cpp | 25 ++-- .../test_is_polygon_soup_a_polygon_mesh.cpp | 39 ++++--- .../test_stitching.cpp | 25 ++-- .../triangulate_faces_test.cpp | 23 +++- ...ate_hole_Polyhedron_3_no_delaunay_test.cpp | 109 +++++++++++++----- .../triangulate_hole_polyline_test.cpp | 26 ++++- 18 files changed, 322 insertions(+), 156 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Weights.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Weights.h index 98a1a62875b..8545341ac2a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Weights.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Weights.h @@ -55,7 +55,7 @@ struct Cotangent_value_Meyer_impl //double divider = CGAL::sqrt( dot_aa * dot_bb - dot_ab * dot_ab ); Vector cross_ab = CGAL::cross_product(a, b); - double divider = CGAL::approximate_sqrt(cross_ab*cross_ab); + double divider = to_double(CGAL::approximate_sqrt(cross_ab*cross_ab)); if(divider == 0 /*|| divider != divider*/) { @@ -314,7 +314,7 @@ public: voronoi_area += (1.0 / 8.0) * (term1 + term2); } else { - double area_t = CGAL::approximate_sqrt(squared_area(v0_p, v1_p, v_op_p)); + double area_t = to_double(CGAL::approximate_sqrt(squared_area(v0_p, v1_p, v_op_p))); if(angle0 == CGAL::OBTUSE) { voronoi_area += area_t / 2.0; } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h index 31c9cda2954..7926e0787db 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h @@ -43,7 +43,7 @@ namespace internal { template void normalize(typename GT::Vector_3& v, const GT& traits) { - double norm = CGAL::approximate_sqrt( + typename GT::FT norm = CGAL::approximate_sqrt( traits.compute_squared_length_3_object()(v)); v = traits.construct_divided_vector_3_object()(v, norm); } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h index 9f374557e1b..24ba8208117 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h @@ -260,7 +260,7 @@ private: ang_max = (std::max)(ang_max, angle); } - w = std::make_pair(ang_max, CGAL::approximate_sqrt(CGAL::squared_area(P[i],P[j],P[k]))); + w = std::make_pair(ang_max, to_double(CGAL::approximate_sqrt(CGAL::squared_area(P[i],P[j],P[k])))); } public: diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/refine_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/refine_impl.h index 1f76cdd630f..27ded6db95b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/refine_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/refine_impl.h @@ -113,9 +113,9 @@ private: vertex_descriptor vk = target(prev(halfedge(fd,pmesh),pmesh),pmesh); Point_3 c = CGAL::centroid(vpmap[vi], vpmap[vj], vpmap[vk]); double sac = (scale_attribute[vi] + scale_attribute[vj] + scale_attribute[vk])/3.0; - double dist_c_vi = CGAL::approximate_sqrt(CGAL::squared_distance(c,vpmap[vi])); - double dist_c_vj = CGAL::approximate_sqrt(CGAL::squared_distance(c, vpmap[vj])); - double dist_c_vk = CGAL::approximate_sqrt(CGAL::squared_distance(c, vpmap[vk])); + double dist_c_vi = to_double(CGAL::approximate_sqrt(CGAL::squared_distance(c,vpmap[vi]))); + double dist_c_vj = to_double(CGAL::approximate_sqrt(CGAL::squared_distance(c, vpmap[vj]))); + double dist_c_vk = to_double(CGAL::approximate_sqrt(CGAL::squared_distance(c, vpmap[vk]))); if((alpha * dist_c_vi > sac) && (alpha * dist_c_vj > sac) && (alpha * dist_c_vk > sac) && @@ -218,7 +218,7 @@ private: } const Point_3& vq = vpmap[target(opposite(*circ,pmesh),pmesh)]; - sum += CGAL::approximate_sqrt(CGAL::squared_distance(vp, vq)); + sum += to_double(CGAL::approximate_sqrt(CGAL::squared_distance(vp, vq))); ++deg; } while(++circ != done); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/fairing_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/fairing_test.cpp index 5d5fd2ab400..ddf1c6b343e 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/fairing_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/fairing_test.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -11,16 +12,19 @@ #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Polyhedron_3 Polyhedron; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; -typedef K::Point_3 Point; -typedef K::Vector_3 Vector; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; - -void test(const char* filename) +template +void test(const char* filename, const K&) { + typedef CGAL::Polyhedron_3 Polyhedron; + + typedef K::Point_3 Point; + typedef K::Vector_3 Vector; + typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef boost::graph_traits::face_descriptor face_descriptor; + //run test for a Polyhedron Polyhedron poly; // file should contain oriented polyhedron std::ifstream input(filename); @@ -53,7 +57,8 @@ int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/elephant.off"; - test(filename); + test(filename, Epic()); + test(filename, Epec()); std::cerr << "All done." << std::endl; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp index bc99a9e4b1b..18c2ccb1985 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -20,18 +21,18 @@ #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef K::Point_3 Point; -typedef K::FT FT; - -typedef CGAL::Polyhedron_3 Polyhedron; -typedef CGAL::Surface_mesh Surface_mesh; - namespace PMP = CGAL::Polygon_mesh_processing; -template +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; + + +template void test(const Mesh& pmesh) { + typedef K::Point_3 Point; + typedef K::FT FT; + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; @@ -100,6 +101,7 @@ void test(const Mesh& pmesh) } +template void test_polyhedron(const char* filename) { //run test for a Polyhedron @@ -114,9 +116,10 @@ void test_polyhedron(const char* filename) return; } - test(poly); + test(poly); } +template void test_closed_surface_mesh(const char* filename) { Surface_mesh sm; @@ -130,9 +133,9 @@ void test_closed_surface_mesh(const char* filename) return; } - test(sm); + test(sm); - FT vol = PMP::volume(sm); + typename K::FT vol = PMP::volume(sm); std::cout << "volume = " << vol << std::endl; } @@ -140,11 +143,13 @@ int main(int argc, char* argv[]) { const char* filename_polyhedron = (argc > 1) ? argv[1] : "data/mech-holes-shark.off"; - test_polyhedron(filename_polyhedron); + test_polyhedron,Epic>(filename_polyhedron); + test_polyhedron,Epec>(filename_polyhedron); const char* filename_surface_mesh = (argc > 1) ? argv[1] : "data/elephant.off"; - test_closed_surface_mesh(filename_surface_mesh); + test_closed_surface_mesh,Epic>(filename_surface_mesh); + test_closed_surface_mesh,Epec>(filename_surface_mesh); std::cerr << "All done." << std::endl; return 0; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_mesh_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_mesh_test.cpp index f9bf5c04037..81a01e54680 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_mesh_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_mesh_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -11,14 +12,17 @@ #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Polyhedron_3 Polyhedron; - -typedef K::Point_3 Point; -typedef CGAL::Surface_mesh Surface_mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; +template void test(const char* file_name) { + typedef CGAL::Polyhedron_3 Polyhedron; + + typedef K::Point_3 Point; + typedef CGAL::Surface_mesh Surface_mesh; + //run test for a Polyhedron std::ifstream input(file_name); Polyhedron poly; // file should contain oriented polyhedron @@ -58,7 +62,9 @@ void test(const char* file_name) int main() { - test("data/elephant.off"); + + test("data/elephant.off"); + test("data/elephant.off"); std::cerr << "All done." << std::endl; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_soup_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_soup_test.cpp index fb00ce38ace..948616d84bb 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_soup_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_soup_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -14,16 +15,16 @@ #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef K::Point_3 Point_3; -typedef CGAL::Polyhedron_3 Polyhedron; -typedef CGAL::Surface_mesh Surface_mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; +template std::istream& read_soup( std::istream& stream, - std::vector& points, + std::vector& points, std::vector< std::vector >& polygons) { + typedef typename K::Point_3 Point_3; CGAL::File_scanner_OFF scanner(stream); points.resize(scanner.size_of_vertices()); polygons.resize(scanner.size_of_facets()); @@ -94,13 +95,18 @@ void shuffle_off(const char* fname_in, const char* fname_out) } } -int main(int,char** ) { +template +int test() { + typedef K::Point_3 Point_3; + typedef CGAL::Polyhedron_3 Polyhedron; + typedef CGAL::Surface_mesh Surface_mesh; + std::vector points; std::vector< std::vector > polygons; shuffle_off("data/elephant.off", "elephant-shuffled.off"); std::ifstream input("elephant-shuffled.off"); - if ( !input || !read_soup(input, points, polygons)){ + if ( !input || !read_soup(input, points, polygons)){ std::cerr << "Error: can not shuffled file.\n"; return 1; } @@ -124,3 +130,10 @@ int main(int,char** ) { } return 0; } + +int main() +{ + assert(test()); + assert(test()); + return 0; +} diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp index 32d5b2d1db1..347b5921540 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp @@ -1,34 +1,32 @@ #include -#include -#include +#include #include #include -#include #include #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Polyhedron_3 Polyhedron; - -typedef K::Point_3 Point; -typedef K::Vector_3 Vector; -typedef CGAL::Surface_mesh Surface_mesh; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; +template void test(const char* file_name) { + typedef K::Point_3 Point; + typedef K::Vector_3 Vector; + typedef CGAL::Surface_mesh Surface_mesh; + typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef boost::graph_traits::face_descriptor face_descriptor; + Surface_mesh mesh; std::ifstream input(file_name); - if (!(input >> mesh)) - { + if (!(input >> mesh)){ std::cerr << "Error: cannot read Surface_mesh : " << file_name << "\n"; assert(false); } - + Surface_mesh::Property_map fnormals; bool created; boost::tie(fnormals, created) = mesh.add_property_map("f:normals",Vector(0,0,0)); @@ -53,14 +51,12 @@ void test(const char* file_name) CGAL::Polygon_mesh_processing::compute_normals(mesh, vnormals, fnormals, CGAL::Polygon_mesh_processing::parameters::vertex_point_map(mesh.points()).geom_traits(K())); - BOOST_FOREACH(face_descriptor fd , faces(mesh)){ - std::cout << fnormals[fd] << std::endl; - } } int main() { - test("data/elephant.off"); + test("data/elephant.off"); + test("data/elephant.off"); std::cerr << "All done." << std::endl; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp index 1c42e80d57c..3c2efbf76c6 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -8,13 +9,16 @@ #include "point_inside_helpers.h" -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef K::Point_3 Point; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; -int main(int argc, char** argv) + +template +int test(int argc, char** argv) { - const char* filename = (argc > 1) ? argv[1] : "data/elephant.off"; + typedef K::Point_3 Point; + typedef CGAL::Surface_mesh Mesh; + const char* filename = (argc > 1) ? argv[1] : "data/elephant.off"; std::ifstream input(filename); Mesh mesh; @@ -44,6 +48,12 @@ int main(int argc, char** argv) CGAL::Bounded_side bs = inside_test(CGAL::ORIGIN); std::cout << "Origin is " << bs << std::endl; - + return 0; +} + +int main(int argc, char** argv) +{ + assert(test(argc,argv)); + assert(test(argc,argv)); return 0; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp index 45a8bdfc370..c13264f1372 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp @@ -1,6 +1,7 @@ // #define USE_SURFACE_MESH #include +#include #ifdef USE_SURFACE_MESH #include #include @@ -19,7 +20,12 @@ #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epec; + +template +int test() +{ #ifdef USE_SURFACE_MESH typedef CGAL::Surface_mesh Mesh; #else @@ -32,9 +38,6 @@ typedef CGAL::AABB_tree AABB_tree; typedef std::vector Polyline_type; typedef std::list< Polyline_type > Polylines; - -int main() -{ //API test { std::ifstream input("data/U.off"); @@ -98,3 +101,14 @@ int main() return 0; } + + +int main() +{ + int r = test(); + assert(r==0); + r = test(); + assert(r==0); + + return 0; +} diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp index 5762e8b626d..fbe3e5f3174 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp @@ -6,6 +6,7 @@ //#define CGAL_PMP_REMESHING_EXPENSIVE_DEBUG #include +#include #include #include @@ -21,16 +22,24 @@ #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Surface_mesh Mesh; - -typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; -typedef boost::graph_traits::edge_descriptor edge_descriptor; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; - namespace PMP = CGAL::Polygon_mesh_processing; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epec; + +template +struct Main { + + +typedef CGAL::Surface_mesh Mesh; + +typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef typename boost::graph_traits::edge_descriptor edge_descriptor; +typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef typename boost::graph_traits::face_descriptor face_descriptor; + + + void collect_patch(const char* file, const Mesh& m, std::set& patch) @@ -141,7 +150,9 @@ public: } }; -int main(int argc, char* argv[]) + + +Main(int argc, char* argv[]) { #ifdef CGAL_PMP_REMESHING_DEBUG std::cout.precision(17); @@ -154,7 +165,7 @@ int main(int argc, char* argv[]) Mesh m; if (!input || !(input >> m)){ std::cerr << "Error: can not read file.\n"; - return 1; + return; } double target_edge_length = (argc > 2) ? atof(argv[2]) : 0.079; @@ -173,7 +184,7 @@ int main(int argc, char* argv[]) if(!facets.empty()) { std::cout << "Input is self intersecting. STOP" << std::endl; - return 0; + return; } else std::cout << "OK." << std::endl; @@ -232,6 +243,13 @@ int main(int argc, char* argv[]) //this test should make the precondition fail test_precondition("data/joint_refined.off", "data/joint-patch-toolargeconstraints.selection.txt"); +} +}; + +int main(int argc, char* argv[]) +{ + Main m(argc,argv); + Main m2(argc,argv); return 0; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp index 10ff1e62cea..59e0ec5a4a0 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp @@ -2,6 +2,8 @@ #include #include +#include + #include #include #include @@ -9,14 +11,16 @@ #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Polyhedron_3 Polyhedron; -typedef boost::graph_traits::face_descriptor face_descriptor; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; - -int main(int argc, char** argv) +template +int +test(const char* filename) { - const char* filename = (argc > 1) ? argv[1] : "data/elephant.off"; + typedef CGAL::Polyhedron_3 Polyhedron; + typedef boost::graph_traits::face_descriptor face_descriptor; + std::ifstream input(filename); Polyhedron poly; @@ -50,6 +54,13 @@ int main(int argc, char** argv) std::cerr << (intersecting_2 ? "There is a self-intersection." : "There are no self-intersections.") << std::endl; - return 0; } + +int main(int argc, char** argv) +{ + const char* filename = (argc > 1) ? argv[1] : "data/elephant.off"; + int r = test(filename); + r += test(filename); + return r; +} diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_is_polygon_soup_a_polygon_mesh.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_is_polygon_soup_a_polygon_mesh.cpp index dbaf6db952b..b3b58b99d55 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_is_polygon_soup_a_polygon_mesh.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_is_polygon_soup_a_polygon_mesh.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -10,11 +11,14 @@ #include #include -typedef CGAL::Simple_cartesian K; -typedef CGAL::Polyhedron_3 Polyhedron; +typedef CGAL::Simple_cartesian SC; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; + +template void test(std::string fname, bool expected) { + typedef CGAL::Polyhedron_3 Polyhedron; std::vector points; std::vector< std::vector > polygons; std::ifstream input(fname.c_str()); @@ -61,22 +65,23 @@ void test(std::string fname, bool expected) int main() { - test("data_polygon_soup/bad_cube.off", false); - test("data_polygon_soup/isolated_singular_vertex_one_cc.off", false); + test("data_polygon_soup/bad_cube.off", false); + test("data_polygon_soup/bad_cube.off", false); + test("data_polygon_soup/isolated_singular_vertex_one_cc.off", false); - test("data_polygon_soup/isolated_vertices.off", false); + test("data_polygon_soup/isolated_vertices.off", false); - test("data_polygon_soup/nm_vertex_and_edge.off", false); - test("data_polygon_soup/one_duplicated_edge.off", false); - test("data_polygon_soup/one_duplicated_edge_sharing_vertex.off", false); - test("data_polygon_soup/partial_overlap.off", false); - test("data_polygon_soup/incompatible_orientation.off", false); + test("data_polygon_soup/nm_vertex_and_edge.off", false); + test("data_polygon_soup/one_duplicated_edge.off", false); + test("data_polygon_soup/one_duplicated_edge_sharing_vertex.off", false); + test("data_polygon_soup/partial_overlap.off", false); + test("data_polygon_soup/incompatible_orientation.off", false); - test("data/blobby_3cc.off", true); - test("data/elephant.off", true); - test("data/joint_refined.off", true); - test("data/mech-holes-shark.off", true); - test("data/non_manifold_vertex.off", false); - test("data/two_tris_collinear.off", true); - test("data/U.off", true); + test("data/blobby_3cc.off", true); + test("data/elephant.off", true); + test("data/joint_refined.off", true); + test("data/mech-holes-shark.off", true); + test("data/non_manifold_vertex.off", false); + test("data/two_tris_collinear.off", true); + test("data/U.off", true); } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp index 26e621af0fd..93c9570bb87 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -10,8 +11,10 @@ #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; +template void test_polyhedron(const char* fname) { typedef CGAL::Polyhedron_3 Polyhedron; @@ -33,8 +36,10 @@ void test_polyhedron(const char* fname) std::cout << "OK\n"; } + void test_surface_mesh(const char* fname) { + typedef Epic K; typedef K::Point_3 Point; typedef CGAL::Surface_mesh Mesh; @@ -56,13 +61,15 @@ void test_surface_mesh(const char* fname) int main() { - test_polyhedron("data_stitching/full_border.off"); - test_polyhedron("data_stitching/full_border_quads.off"); - test_polyhedron("data_stitching/half_border.off"); - test_polyhedron("data_stitching/mid_border.off"); - test_polyhedron("data_stitching/multiple_incidence.off"); - test_polyhedron("data_stitching/incidence_3.off"); - test_polyhedron("data_stitching/incoherent_patch_orientation.off"); + test_polyhedron("data_stitching/full_border.off"); + + test_polyhedron("data_stitching/full_border.off"); + test_polyhedron("data_stitching/full_border_quads.off"); + test_polyhedron("data_stitching/half_border.off"); + test_polyhedron("data_stitching/mid_border.off"); + test_polyhedron("data_stitching/multiple_incidence.off"); + test_polyhedron("data_stitching/incidence_3.off"); + test_polyhedron("data_stitching/incoherent_patch_orientation.off"); test_surface_mesh("data_stitching/full_border.off"); test_surface_mesh("data_stitching/full_border_quads.off"); @@ -70,7 +77,7 @@ int main() test_surface_mesh("data_stitching/mid_border.off"); test_surface_mesh("data_stitching/multiple_incidence.off"); test_surface_mesh("data_stitching/incidence_3.off"); - test_polyhedron("data_stitching/incoherent_patch_orientation.off"); + test_polyhedron("data_stitching/incoherent_patch_orientation.off"); return 0; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp index 75d5150c983..30e4eb88099 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -8,12 +9,16 @@ #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point; -typedef CGAL::Surface_mesh Surface_mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; -int main() +template +int +test() { + typedef typename K::Point_3 Point; + typedef CGAL::Surface_mesh Surface_mesh; + Surface_mesh mesh; std::ifstream input("data/elephant.off"); @@ -38,4 +43,14 @@ int main() CGAL::Polygon_mesh_processing::triangulate_face(fit, mesh, CGAL::Polygon_mesh_processing::parameters::all_default()); } + return 0; +} + +int main() +{ + int r = test(); + assert(r==0); + r = test(); + assert(r==0); + return 0; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp index 8607765c413..61bc94dc387 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp @@ -1,6 +1,7 @@ //#define POLY #include +#include #include #ifdef POLY #include @@ -25,19 +26,12 @@ #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -#ifdef POLY -typedef CGAL::Polyhedron_3 Polyhedron; -#else -typedef CGAL::Surface_mesh Polyhedron; -#endif -typedef boost::graph_traits::face_descriptor Facet_handle; -typedef boost::graph_traits::vertex_descriptor Vertex_handle; -typedef boost::graph_traits::halfedge_descriptor Halfedge_handle; -typedef boost::graph_traits::halfedge_iterator Halfedge_iterator; -typedef CGAL::Halfedge_around_face_circulator Halfedge_around_facet_circulator; -typedef boost::property_map::type Point_property_map; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; + + +template void read_poly(const char* file_name, Polyhedron& poly) { poly.clear(); @@ -48,8 +42,10 @@ void read_poly(const char* file_name, Polyhedron& poly) { } } +template void detect_borders(Polyhedron& poly, std::vector& border_reps) { + typedef CGAL::Halfedge_around_face_circulator Halfedge_around_facet_circulator; border_reps.clear(); std::set border_map; BOOST_FOREACH(Halfedge_handle h, halfedges(poly)){ @@ -64,6 +60,7 @@ void detect_borders(Polyhedron& poly, std::vector& border_reps) } } +template void read_poly_with_borders(const char* file_name, Polyhedron& poly, std::vector& border_reps) { read_poly(file_name, poly); @@ -78,7 +75,7 @@ CGAL::internal::Weight_min_max_dihedral_and_area { typedef typename boost::graph_traits::halfedge_descriptor Halfedge_handle; typedef CGAL::internal::Weight_min_max_dihedral_and_area Weight; - + typedef typename boost::property_map::type Point_property_map; Point_property_map ppmap = get(CGAL::vertex_point, poly); Weight res(0,0); for(; begin!=end; ++begin) { @@ -103,14 +100,20 @@ CGAL::internal::Weight_min_max_dihedral_and_area } +template void test_triangulate_hole_weight(const char* file_name, std::size_t nb_remaining_holes) { + + typedef typename boost::graph_traits::face_descriptor Facet_handle; + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_handle; + typedef typename boost::graph_traits::vertex_descriptor Vertex_handle; + std::cout << "test_triangulate_hole_weight"<< std::endl; std::cout << " File: "<< file_name << std::endl; Polyhedron poly; std::vector border_reps; read_poly_with_borders(file_name, poly, border_reps); - for(std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { + for(typename std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { std::vector patch; CGAL::Polygon_mesh_processing::triangulate_hole( poly, *it, back_inserter(patch),CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(true)); @@ -122,15 +125,19 @@ void test_triangulate_hole_weight(const char* file_name, std::size_t nb_remainin std::cout << " Done!" << std::endl; } /******************************************************************/ - +template void test_triangulate_hole(const char* file_name) { + typedef typename boost::graph_traits::face_descriptor Facet_handle; + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_handle; + typedef typename boost::graph_traits::vertex_descriptor Vertex_handle; + std::cout << "test_triangulate_hole:" << std::endl; std::cout << " File: "<< file_name << std::endl; Polyhedron poly; std::vector border_reps; read_poly_with_borders(file_name, poly, border_reps); - for(std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { + for(typename std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { std::vector patch; CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch)); if(patch.empty()) { @@ -146,15 +153,18 @@ void test_triangulate_hole(const char* file_name) { std::cout << " Done!" << std::endl; } - +template void test_triangulate_hole_should_be_no_output(const char* file_name) { + typedef typename boost::graph_traits::face_descriptor Facet_handle; + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_handle; + typedef typename boost::graph_traits::vertex_descriptor Vertex_handle; std::cout << "test_triangulate_hole_should_be_no_output:" << std::endl; std::cout << " File: "<< file_name << std::endl; Polyhedron poly; std::vector border_reps; read_poly_with_borders(file_name, poly, border_reps); - for(std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { + for(typename std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { std::vector patch; CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(false)); @@ -174,7 +184,11 @@ void test_triangulate_hole_should_be_no_output(const char* file_name) { std::cout << " Done!" << std::endl; } +template void test_triangulate_and_refine_hole(const char* file_name) { + typedef typename boost::graph_traits::face_descriptor Facet_handle; + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_handle; + typedef typename boost::graph_traits::vertex_descriptor Vertex_handle; std::cout << "test_triangulate_and_refine_hole:" << std::endl; std::cout << " File: "<< file_name << std::endl; Polyhedron poly; @@ -201,7 +215,11 @@ void test_triangulate_and_refine_hole(const char* file_name) { std::cout << " Done!" << std::endl; } +template void test_triangulate_refine_and_fair_hole(const char* file_name) { + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_handle; + typedef typename boost::graph_traits::face_descriptor Facet_handle; + typedef typename boost::graph_traits::vertex_descriptor Vertex_handle; std::cout << "test_triangulate_refine_and_fair_hole:" << std::endl; std::cout << " File: "<< file_name << std::endl; Polyhedron poly; @@ -228,7 +246,11 @@ void test_triangulate_refine_and_fair_hole(const char* file_name) { std::cout << " Done!" << std::endl; } +template void test_ouput_iterators_triangulate_hole(const char* file_name) { + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_handle; + typedef typename boost::graph_traits::face_descriptor Facet_handle; + typedef typename boost::graph_traits::vertex_descriptor Vertex_handle; std::cout << "test_ouput_iterators_triangulate_hole:" << std::endl; std::cout << " File: "<< file_name << std::endl; @@ -256,7 +278,11 @@ void test_ouput_iterators_triangulate_hole(const char* file_name) { std::cout << " Done!" << std::endl; } +template void test_ouput_iterators_triangulate_and_refine_hole(const char* file_name) { + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_handle; + typedef typename boost::graph_traits::face_descriptor Facet_handle; + typedef typename boost::graph_traits::vertex_descriptor Vertex_handle; std::cout << "test_ouput_iterators_triangulate_and_refine_hole:" << std::endl; std::cout << " File: "<< file_name << std::endl; @@ -296,8 +322,11 @@ void test_ouput_iterators_triangulate_and_refine_hole(const char* file_name) { std::cout << " Done!" << std::endl; } - +template void test_triangulate_refine_and_fair_hole_compile() { + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_handle; + typedef typename boost::graph_traits::face_descriptor Facet_handle; + typedef typename boost::graph_traits::vertex_descriptor Vertex_handle; typedef CGAL::Eigen_solver_traits< Eigen::SparseLU< CGAL::Eigen_sparse_matrix::EigenType, @@ -331,8 +360,12 @@ void test_triangulate_refine_and_fair_hole_compile() { (poly, border_reps[0], back_inserter(patch_facets), back_inserter(patch_vertices)); } +template void generate_elephant_with_hole() { + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_handle; + typedef typename boost::graph_traits::face_descriptor Facet_handle; + typedef typename boost::graph_traits::vertex_descriptor Vertex_handle; Polyhedron poly; read_poly("data/elephant.off", poly); int i=0; @@ -351,8 +384,14 @@ void generate_elephant_with_hole() } } -int main() { - generate_elephant_with_hole(); +template +void test() { +#ifdef POLY +typedef CGAL::Polyhedron_3 Polyhedron; +#else +typedef CGAL::Surface_mesh Polyhedron; +#endif + generate_elephant_with_hole(); std::vector input_files; input_files.push_back("elephant_triangle_hole.off"); @@ -360,18 +399,26 @@ int main() { input_files.push_back("data/mech-holes-shark.off"); // std::cerr.precision(15); for(std::vector::iterator it = input_files.begin(); it != input_files.end(); ++it) { - test_triangulate_hole(it->c_str()); - test_triangulate_and_refine_hole(it->c_str()); - test_triangulate_refine_and_fair_hole(it->c_str()); - test_ouput_iterators_triangulate_and_refine_hole(it->c_str()); - test_ouput_iterators_triangulate_hole(it->c_str()); - test_triangulate_hole_weight(it->c_str(), 0); - std::cout << "------------------------------------------------" << std::endl; + test_triangulate_hole(it->c_str()); + test_triangulate_and_refine_hole(it->c_str()); + test_triangulate_refine_and_fair_hole(it->c_str()); + test_ouput_iterators_triangulate_and_refine_hole(it->c_str()); + test_ouput_iterators_triangulate_hole(it->c_str()); + test_triangulate_hole_weight(it->c_str(), 0); + std::cout << std::endl; } - test_triangulate_hole_should_be_no_output("data/non_manifold_vertex.off"); - test_triangulate_hole_should_be_no_output("data/two_tris_collinear.off"); + test_triangulate_hole_should_be_no_output("data/non_manifold_vertex.off"); + test_triangulate_hole_should_be_no_output("data/two_tris_collinear.off"); - test_triangulate_refine_and_fair_hole_compile(); + test_triangulate_refine_and_fair_hole_compile(); + + +} +int main() +{ + + test(); + test(); std::cout << "All Done!" << std::endl; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp index 5113b310d0b..68874a54c48 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp @@ -1,5 +1,6 @@ #include +#include #include #include @@ -14,13 +15,13 @@ #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point_3; -typedef CGAL::Polyhedron_3 Polyhedron; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; // to debug visually, construct polyhedron from patch -template +template class Polyhedron_builder : public CGAL::Modifier_base { + typedef typename K::Point_3 Point_3; public: Polyhedron_builder(std::vector >* triangles, std::vector* polyline) @@ -54,6 +55,12 @@ private: }; +template +struct Main { + +typedef typename K::Point_3 Point_3; + typedef CGAL::Polyhedron_3 Polyhedron; + // it reads .polylines.txt (there should be one polyline with last point repeated) void read_polyline_one_line(const char* file_name, std::vector& points) { std::ifstream stream(file_name); @@ -119,7 +126,7 @@ void check_constructed_polyhedron(const char* file_name, std::vector* polyline) { Polyhedron poly; - Polyhedron_builder patch_builder(triangles, polyline); + Polyhedron_builder patch_builder(triangles, polyline); poly.delegate(patch_builder); if(!poly.is_valid()) { @@ -185,7 +192,7 @@ void test_should_be_no_output(const char* file_name, bool use_DT) { std::cerr << " Done!" << std::endl; } -int main() { + Main() { std::vector input_files_1; input_files_1.push_back("data/triangle.polylines.txt"); input_files_1.push_back("data/quad.polylines.txt"); @@ -212,6 +219,13 @@ int main() { test_should_be_no_output("data/collinear.polylines.txt", true); test_should_be_no_output("data/collinear.polylines.txt", false); std::cerr << "All Done!" << std::endl; + } +}; + +int main() +{ + Main m; + Main m2; return 0; }