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 285b099e599..944ab73e339 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 @@ -8,6 +8,7 @@ #include #include #include +#include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; @@ -137,7 +138,7 @@ struct Noborder { */ // todo: add this in Dual.h -template +template struct Dual_vpm { typedef typename boost::graph_traits::face_descriptor key_type; @@ -145,18 +146,30 @@ struct Dual_vpm typedef Point value_type; typedef boost::readable_property_map_tag category; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + + Dual_vpm(const Pmap& vpmap) : vpmap_(vpmap) {} + friend Point get(Dual_vpm& mesh, key_type& f) { std::vector face_points; + BOOST_FOREACH(vertex_descriptor v, vertices_around_face(halfedge(f), mesh)) + { + Point p = get(vpmap_, v); + face_points.push_back(p); + } - + // temp extra copy Point centroid = CGAL::centroid(face_points.begin(), face_points.end(), CGAL::Dimension_tag<0>()); return centroid; } + + const Pmap& vpmap_; + }; template @@ -175,27 +188,23 @@ test_dual_with_various_faces() return false; } - // todo this - //boost::property_map::const_type PMap; - //Pmap = get_property_map() + // get mesh's vpmap + typedef typename boost::property_map::type Pmap; + Pmap vpmap = get_property_map(boost::vertex_point, mesh); + + // mesh's dual + CGAL::Dual dual(mesh); - typedef CGAL::Dual Dual; //typedef boost::filtered_graph > FiniteDual; - - Dual dual(mesh); //FiniteDual finite_dual(dual, Noborder(mesh)); crap - - + // copy dual to a sm Surface_mesh sm_dual; CGAL::copy_face_graph(dual, sm_dual, CGAL::Emptyset_iterator(), CGAL::Emptyset_iterator(), CGAL::Emptyset_iterator(), - Dual_vpm()); - - - //sm_dual.add_face(vertices(dual)); + Dual_vpm(vpmap)); std::ofstream out("data/dual_sm_elephant.off");