void test_coords_and_neighbors(const Tr& T, const typename Tr::Geom_traits::Point_3& p, const typename Tr::Geom_traits::Vector_3& n, const typename Tr::Geom_traits::FT& tolerance, const int& version) { CGAL::Set_ieee_double_precision pfr; typedef std::pair<typename Tr::Geom_traits::Point_3, typename Tr::Geom_traits::FT > Point_coord_pair; std::vector<Point_coord_pair> coords; typename Tr::Geom_traits::FT norm; norm = test_coords(T, p, n,version, std::back_inserter(coords)).second; assert(test_norm( coords.begin(), coords.end(), norm)); assert(test_barycenter(coords.begin(), coords.end(), norm, p, tolerance)); //All function testing surface neighbors are // grouped together: std::vector< typename Tr::Geom_traits::Point_3 > neighbors; test_neighbors(T, p, n,version, std::back_inserter(neighbors)); assert(compare_neighbors(coords.begin(), coords.end(),neighbors.begin(), neighbors.end(), T.geom_traits())); //done }
int main() { Tr::Point p1(0,0,0); Tr::Point p2(1,0,0); Tr::Point p3(0,1,0); Tr::Point p4(0,0,1); Tr tr; tr.insert(p1); tr.insert(p2); tr.insert(p3); tr.insert(p4); Tr::Cell_handle ch = tr.finite_cells_begin(); int k = 0; Tr::Facet f = std::make_pair(ch,k); Tr::Cell::Subdomain_index sub_index = 1; Tr::Cell::Surface_patch_index surf_index = 2; Tr::Cell::Surface_patch_index surf_index_bis = 21; Tr::Vertex::Index index (surf_index); Tr::Vertex::Index index_bis(surf_index_bis); // Init cell tr.dual(ch); ch->set_subdomain_index(sub_index); // Init facet Tr::Bare_point facet_circum = tr.geom_traits().construct_weighted_circumcenter_3_object()( tr.point(ch, k+1), tr.point(ch, k+2), tr.point(ch, k+3)); ch->set_surface_patch_index(k,surf_index); ch->set_facet_surface_center(k,facet_circum); ch->set_facet_surface_center_index(k,index); // Init vertices ch->vertex(0)->set_dimension(2); ch->vertex(1)->set_dimension(2); ch->vertex(2)->set_dimension(2); ch->vertex(3)->set_dimension(2); ch->vertex(0)->set_index(index); ch->vertex(1)->set_index(index); ch->vertex(2)->set_index(index_bis); ch->vertex(3)->set_index(index_bis); // ----------------------------------- // Test edge criteria // ----------------------------------- Tr::Bare_point bp1 = tr.geom_traits().construct_point_3_object()(p1); Mc ec1(edge_size = 1); assert( ec1.edge_criteria_object().sizing_field(bp1,1,index) == 1 ); Mc ec2(edge_sizing_field = Esf(2)); assert( ec2.edge_criteria_object().sizing_field(bp1,1,index) == 2 ); Mc ec3(edge_sizing_field = 3.); assert( ec3.edge_criteria_object().sizing_field(bp1,1,index) == 3 ); Mc ec4(edge_size = 4.1, edge_sizing_field = Esf(4.2)); assert( ec4.edge_criteria_object().sizing_field(bp1,1,index) == 4.1 ); Mc ec5(sizing_field = 5.); assert( ec5.edge_criteria_object().sizing_field(bp1,1,index) == 5 ); Mc ec6(sizing_field = 6.1, edge_sizing_field = 6.2); assert( ec6.edge_criteria_object().sizing_field(bp1,1,index) == 6.2 ); Mc ec7(sizing_field = 7.1, edge_size = 7.2); assert( ec7.edge_criteria_object().sizing_field(bp1,1,index) == 7.2 ); // ----------------------------------- // Test facet criteria // ----------------------------------- typedef Tr::Geom_traits::FT FT; Tr::Geom_traits::Compute_squared_radius_3 squared_radius = tr.geom_traits().compute_squared_radius_3_object(); Tr::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); FT radius_facet = CGAL::sqrt(squared_radius(cp(tr.point(ch, k+1)), cp(tr.point(ch, k+2)), cp(tr.point(ch, k+3)))); FT facet_size_ok = radius_facet*FT(10); FT facet_size_nok = radius_facet/FT(10); Mc fc1(facet_size = facet_size_ok); assert( ! fc1.facet_criteria_object()(tr, f) ); Mc fc2(facet_sizing_field = facet_size_ok); assert( ! fc2.facet_criteria_object()(tr, f) ); Mc fc3(facet_sizing_field = Fsf(facet_size_ok)); assert( ! fc3.facet_criteria_object()(tr, f) ); Mc fc4(facet_sizing_field = facet_size_nok, facet_size = facet_size_ok); assert( ! fc4.facet_criteria_object()(tr, f) ); Mc fc5(sizing_field = facet_size_ok); assert( ! fc5.facet_criteria_object()(tr, f) ); Mc fc6(facet_size = facet_size_ok, facet_sizing_field = facet_size_nok, sizing_field = facet_size_nok); assert( ! fc6.facet_criteria_object()(tr, f) ); Mc fc7(facet_sizing_field = Fsf(facet_size_ok), sizing_field = facet_size_nok); assert( ! fc7.facet_criteria_object()(tr, f) ); Mc fc8(facet_distance = 8.); Mc fc9(facet_angle = 9.); Mc fc10(facet_angle = 10.1, facet_distance = 10.2, facet_size = 10.3, facet_sizing_field = Fsf(10.4), sizing_field = 10.5); // Test construction from int Mc fc11(facet_size = 11); Mc fc12(facet_sizing_field = 12); Mc fc13(sizing_field = 13); // Test topological criterion creation Mc fc14(facet_topology = CGAL::FACET_VERTICES_ON_SURFACE); assert( ! fc14.facet_criteria_object()(tr, f) ); Mc fc15(facet_topology = CGAL::FACET_VERTICES_ON_SAME_SURFACE_PATCH); assert( fc15.facet_criteria_object()(tr, f) ); // ----------------------------------- // Test cell criteria // ----------------------------------- FT radius_cell = CGAL::sqrt(squared_radius(cp(tr.point(ch, 0)), cp(tr.point(ch, 1)), cp(tr.point(ch, 2)), cp(tr.point(ch, 3)))); FT cell_size_ok = radius_cell*FT(10); FT cell_size_nok = radius_cell/FT(10); Mc cc1(cell_size = cell_size_ok); assert( ! cc1.cell_criteria_object()(tr, ch) ); Mc cc2(cell_sizing_field = cell_size_ok); assert( ! cc2.cell_criteria_object()(tr, ch) ); Mc cc3(cell_sizing_field = Fsf(cell_size_ok)); assert( ! cc3.cell_criteria_object()(tr, ch) ); Mc cc4(cell_sizing_field = cell_size_nok, cell_size = cell_size_ok); assert( ! cc4.cell_criteria_object()(tr, ch) ); Mc cc5(sizing_field = cell_size_ok); assert( ! cc5.cell_criteria_object()(tr, ch) ); Mc cc6(cell_size = cell_size_ok, cell_sizing_field = cell_size_nok, sizing_field = cell_size_nok); assert( ! cc6.cell_criteria_object()(tr, ch) ); Mc cc7(cell_sizing_field = Csf(cell_size_ok), sizing_field = cell_size_nok); assert( ! cc7.cell_criteria_object()(tr, ch) ); Mc cc8(cell_radius_edge_ratio = 8.); Mc cc9(cell_radius_edge_ratio = 9.1, sizing_field = Csf(9.2) ); Mc cc10(cell_radius_edge_ratio = 10.1, cell_size = 10.2, cell_sizing_field = Csf(10.3), sizing_field = 10.4); // Test construction from int Mc cc11(cell_size = 11); Mc cc12(cell_sizing_field = 12); Mc cc13(sizing_field = 13); }
std::pair< OutputIterator, typename Tr::Geom_traits::FT> test_coords(const Tr& T, const typename Tr::Geom_traits::Point_3& p, const typename Tr::Geom_traits::Vector_3& n, const int& version, OutputIterator out) { typedef CGAL::Voronoi_intersection_2_traits_3<typename Tr::Geom_traits> I_traits; //coordinate computation result types typedef CGAL::Triple< OutputIterator, typename Tr::Geom_traits::FT, bool > Result_triple; //the result type of the certified version: typedef CGAL::Quadruple< OutputIterator, typename Tr::Geom_traits::FT, bool, bool > Result_quadruple; typename Tr::Cell_handle start; typename Tr::Geom_traits::FT norm = 1; // 1 for that default doesn't trigger an assert //test different function calls switch(version){ case 0:{ Result_triple result = CGAL::surface_neighbor_coordinates_3(T, p,n,out); assert(result.third); norm = result.second; break;} case 1: { Result_triple result = CGAL::surface_neighbor_coordinates_3(T, p,out,I_traits(p,n)); assert(result.third); norm = result.second; break;} //both versions with locate: case 2:{ start = T.locate(p); Result_triple result = CGAL::surface_neighbor_coordinates_3(T, p, n, out, start); assert(result.third); norm = result.second; break;} case 3: { start = T.locate(p); Result_triple result = CGAL::surface_neighbor_coordinates_3(T, p, out, I_traits(p,n), start); assert(result.third); norm = result.second; break;} //taking all points: case 4: { Result_triple result = CGAL::surface_neighbor_coordinates_3(T.points_begin(), T.points_end(), p, n, out, T.geom_traits()); assert(result.third); norm = result.second; break;} case 5: { Result_triple result = CGAL::surface_neighbor_coordinates_3(T.points_begin(), T.points_end(), p, out ,I_traits(p,n)); assert(result.third); norm = result.second; break;} //the last two with certification: case 6: { Result_quadruple result = CGAL::surface_neighbor_coordinates_certified_3 (T.points_begin(), T.points_end(),p,n, out, T.geom_traits()); assert(result.third && result.fourth); norm = result.second; break; } case 7: { Result_quadruple result = CGAL::surface_neighbor_coordinates_certified_3 (T.points_begin(), T.points_end(),p, out ,I_traits(p,n)); assert(result.third && result.fourth); norm = result.second; break; } default: std::cout << "Switch function calls: Nothing is tested. " << std::endl; } assert(norm > 0); return std::make_pair(out, norm); }
OutputIterator test_neighbors(const Tr& T, const typename Tr::Geom_traits::Point_3& p, const typename Tr::Geom_traits::Vector_3& n, const int& version, OutputIterator out) { typedef CGAL::Voronoi_intersection_2_traits_3<typename Tr::Geom_traits> I_traits; //the result type of the certified version: typedef std::pair< OutputIterator, bool > NeighborIt_bool_pair; typename Tr::Cell_handle start; //test different function calls switch(version) { case 0:{ //certified call with Kernel: NeighborIt_bool_pair result_pair = CGAL::surface_neighbors_certified_3(T.points_begin(), T.points_end(), p, n, out, T.geom_traits()); assert(result_pair.second); out = result_pair.first; break;} case 1: { //certified call with instantiated traits:: NeighborIt_bool_pair result_pair = CGAL::surface_neighbors_certified_3(T.points_begin(), T.points_end(), p, out, I_traits(p,n)); assert(result_pair.second); out =result_pair.first; break;} //both versions with locate: case 2:{ start = T.locate(p); //certified call with Kernel and locate: out =CGAL::surface_neighbors_3(T, p,n,out, start); break;} case 3: { start = T.locate(p); //with instantiated traits and locate: out =CGAL::surface_neighbors_3(T,p,out, I_traits(p,n),start); break;} //taking all points: case 4: { //with instantiated traits and locate: out = CGAL::surface_neighbors_3(T,p,out,I_traits(p,n)); break;} case 5: { //certified call with Kernel and locate: out = CGAL::surface_neighbors_3(T, p,n,out); break;} //the last two with certification: case 6: { out = CGAL::surface_neighbors_3(T.points_begin(), T.points_end(), p, out,I_traits(p,n)); break; } case 7: { out = CGAL::surface_neighbors_3(T.points_begin(), T.points_end(), p,n,out,T.geom_traits()); break; } default: std::cout << "Switch function calls: Nothing is tested. " << std::endl; } return out; }