#include <fstream>
#include <boost/graph/graph_traits.hpp>
#include <CGAL/property_map.h>
#include <CGAL/basic.h>
#include <CGAL/Kernel/global_functions.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
typename PointMap,
typename NormalMap>
PointMap pm,
NormalMap nm)
{
typedef boost::graph_traits<HalfedgeGraph> GraphTraits;
typedef typename GraphTraits::face_iterator face_iterator;
typedef typename GraphTraits::halfedge_descriptor halfedge_descriptor;
typedef typename boost::property_traits<PointMap>::value_type point;
typedef typename boost::property_traits<NormalMap>::value_type
normal;
face_iterator fb, fe;
for(boost::tie(fb, fe) = faces(g); fb != fe; ++fb)
{
halfedge_descriptor edg = halfedge(*fb, g);
halfedge_descriptor edgb = edg;
point p0 = pm[target(edg, g)];
point p1 = pm[target(edg, g)];
point p2 = pm[target(edg, g)];
if(edg == edgb) {
} else {
do {
p0 = p1;
p1 = p2;
p2 = pm[target(edg, g)];
} while(edg != edgb);
}
}
}
int main(int, char** argv)
{
typedef boost::property_map<
Polyhedron,
>::const_type Face_index_map;
std::ifstream in(argv[1]);
Polyhedron P;
in >> P ;
std::size_t i = 0;
for(Polyhedron::Facet_iterator it = P.facets_begin(); it != P.facets_end(); ++it, ++i)
{
it->id() = i;
}
boost::vector_property_map<Vector, Face_index_map>
normals(get(CGAL::face_index, P));
calculate_face_normals(
P
, get(CGAL::vertex_point, P)
, normals
);
std::cout << "Normals" << std::endl;
for(Polyhedron::Facet_iterator it = P.facets_begin(); it != P.facets_end(); ++it) {
std::cout << normals[it] << std::endl;
}
return 0;
}