This commit is contained in:
konstantinos katrioplas 2018-02-28 21:47:37 +01:00
parent 18ec0740c4
commit b400f39f1a
1 changed files with 23 additions and 14 deletions

View File

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