#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Triangulation_vertex_base_2 Vb; typedef CGAL::Delaunay_mesh_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; typedef CGAL::Polygon_2 Polygon_2; using namespace CGAL; int test_triangles_2() { typedef K::Point_2 Point; // Generated points are in that vector std::vector points; // Create input triangles std::vector triangles; triangles.push_back(K::Triangle_2(Point(0,0), Point(0.5,0), Point(0,0.5))); triangles.push_back(K::Triangle_2(Point(0,0.5), Point(0.5,0), Point(0.5,0.5))); // Create the generator, input is the vector of Triangle_2 Random_points_in_triangles_2 g(triangles); // Get 100 random points in triangle range CGAL::cpp11::copy_n(g, 100, std::back_inserter(points)); // Check that we have really created 100 points. assert( points.size() == 100); BOOST_FOREACH(Point p, points) { bool on_quad = p.x() > -0.01 && p.x() < 0.51 && p.y() > -0.01 && p.y() < 0.51; if(!on_quad) { std::cerr< points; // Create input triangles std::vector triangles; triangles.push_back(K::Triangle_3(Point(0,0,0), Point(0.5,0,0), Point(0,0.5,0))); triangles.push_back(K::Triangle_3(Point(0,0.5,0), Point(0.5,0,0), Point(0.5,0.5,0))); triangles.push_back(K::Triangle_3(Point(0.5,0,0), Point(0.5,0,0.5), Point(0.5,0.5,0))); triangles.push_back(K::Triangle_3(Point(0.5,0.5,0), Point(0.5,0.5,0.5), Point(0.5,0.,0.5))); // Create the generator, input is the vector of Triangle_3 Random_points_in_triangles_3 g(triangles); // Get 100 random points in triangle range CGAL::cpp11::copy_n(g, 100, std::back_inserter(points)); // Check that we have really created 100 points. assert( points.size() == 100); BOOST_FOREACH(Point p, points) { bool on_front = p.z() < 0.01 && p.z()> -0.01 && p.x() > -0.01 && p.x() < 0.51 && p.y() > -0.01 && p.y() < 0.51; bool on_right = p.x() < 0.51 && p.x()> 0.49 && p.z() > -0.01 && p.z() < 0.51 && p.y() > -0.01 && p.y() < 0.51; if(!on_front && !on_right) { std::cerr< points; //construct two non-intersecting nested polygons ::Polygon_2 polygon1; polygon1.push_back(Point_2(0,0)); polygon1.push_back(Point_2(2,0)); polygon1.push_back(Point_2(2,2)); polygon1.push_back(Point_2(0,2)); //Insert the polygons into a constrained triangulation CDT cdt; cdt.insert_constraint(polygon1.vertices_begin(), polygon1.vertices_end(), true); Random_points_in_triangle_mesh_2 g(cdt); cpp11::copy_n( g, 300, std::back_inserter(points)); for(std::size_t i = 0; i2.05 || coords[j]<-0.05) { std::cerr<<"ERROR : Generated point is not on the cube."< Polyhedron; typedef K::Point_3 Point; typedef K::FT FT; bool on_face(int face, double coord[3]) { if(CGAL::abs(CGAL::abs(coord[face]) - 0.5) < 0.05 && CGAL::abs(coord[(face+1)%3]) - 0.5 < 0.05 && CGAL::abs(coord[(face+2)%3]) - 0.5 < 0.05) return true; return false; } int test_volume_mesh(Polyhedron& polyhedron) { std::vector points; Random_points_in_triangle_mesh_3 g(polyhedron); CGAL::cpp11::copy_n( g, 300, std::back_inserter(points)); for (std::size_t i = 0; i Mesh_domain; #ifdef CGAL_CONCURRENT_MESH_3 typedef CGAL::Parallel_tag Concurrency_tag; #else typedef CGAL::Sequential_tag Concurrency_tag; #endif // 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 C3t3::Point Point_c3t3; int test_on_c3t3(const Polyhedron& polyhedron) { std::vector points; points.clear(); // Create domain Mesh_domain domain(polyhedron); using namespace CGAL::parameters; // Mesh criteria (no cell_size set) Mesh_criteria criteria(facet_angle=25, facet_size=0.15, facet_distance=0.008, cell_radius_edge_ratio=3); // Mesh generation C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, no_perturb(), no_exude()); Random_points_in_tetrahedral_mesh_boundary_3 g(c3t3); CGAL::cpp11::copy_n( g, 300, std::back_inserter(points)); for (std::size_t i = 0; i points; points.clear(); // Create domain Mesh_domain domain(polyhedron); using namespace CGAL::parameters; // Mesh criteria (no cell_size set) Mesh_criteria criteria(facet_angle=25, facet_size=0.15, facet_distance=0.008, cell_radius_edge_ratio=3); // Mesh generation C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, no_perturb(), no_exude()); Random_points_in_tetrahedral_mesh_3 g(c3t3); CGAL::cpp11::copy_n( g, 300, std::back_inserter(points)); for (std::size_t i = 0; i 0.501) { std::cerr<<"ERROR : Generated point is not in the cube."<::halfedge_descriptor facets[6]; int i = 0; BOOST_FOREACH(boost::graph_traits::face_descriptor fd, faces(polyhedron)) facets[i++] = halfedge(fd, polyhedron); for(int i=0; i<6; ++i) CGAL::Euler::split_face(facets[i],next(next(facets[i], polyhedron), polyhedron), polyhedron); int validity = test_triangles_2() *test_triangles_3() *test_volume_mesh(polyhedron) *test_T2() *test_on_c3t3(polyhedron) *test_in_c3t3(polyhedron) ; assert(validity == 1); return 0; }