reorder functions

This commit is contained in:
Sébastien Loriot 2015-02-16 12:23:41 +01:00
parent dcf7e049c1
commit 9ded7bd43a
1 changed files with 299 additions and 317 deletions

View File

@ -27,134 +27,20 @@
namespace CGAL{ namespace CGAL{
namespace Polygon_mesh_processing{ namespace Polygon_mesh_processing{
///\cond SKIP_IN_MANUAL
template <typename PolygonMesh, typename VertexNormalMap, typename FaceNormalMap>
void
compute_normals(const PolygonMesh& pmesh,
VertexNormalMap vnm,
FaceNormalMap fnm)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_normals(pmesh, vnm, fnm, get(vertex_point, pmesh), Kernel());
}
template <typename PolygonMesh, typename VertexNormalMap, typename FaceNormalMap, typename VertexPointMap>
void
compute_normals(const PolygonMesh& pmesh,
VertexNormalMap vnm,
FaceNormalMap fnm,
VertexPointMap vpmap)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_normals(pmesh, vnm, fnm, vpmap, Kernel());
}
///\endcond
/** /**
* \ingroup PkgPolygonMeshProcessing * \ingroup PkgPolygonMeshProcessing
* computes the outward unit vector normal for all vertices and faces of the polygon mesh. * computes the outward unit vector normal to face `f`.
* @tparam Kernel Geometric traits class. It can be omitted and deduced automatically from the point type of `PolygonMesh`. * @tparam Kernel Geometric traits class. It can be omitted and deduced automatically from the point type of `PolygonMesh`.
* @tparam PolygonMesh a model of `FaceGraph` * @tparam PolygonMesh a model of `FaceGraph`
* @tparam VertexNormalMap the property map in which the vertex normals are written.
* @tparam FaceNormalMap the property map in which the face normals are written.
* @tparam VertexPointMap the property map with the points associated to the vertices.
*
* @param pmesh the polygon mesh
*/
template <typename PolygonMesh
, typename VertexNormalMap
, typename FaceNormalMap
, typename VertexPointMap
#ifdef DOXYGEN_RUNNING
= typename boost::property_map<PolygonMesh, vertex_point_t>::type
#endif
, typename Kernel
#ifdef DOXYGEN_RUNNING
= typename Kernel_traits<
typename boost::property_traits<VertexPointMap>::value_type>::Kernel
#endif
>
void
compute_normals(const PolygonMesh& pmesh
, VertexNormalMap vnm
, FaceNormalMap fnm
, VertexPointMap vpmap
#ifdef DOXYGEN_RUNNING
= get(vertex_point, pmesh)
#endif
,const Kernel& k
#ifdef DOXYGEN_RUNNING
= Kernel()
#endif
)
{
typename boost::graph_traits<PolygonMesh>::vertex_descriptor v;
BOOST_FOREACH(v, vertices(pmesh)){
typename Kernel::Vector_3 vec = compute_vertex_normal(v,pmesh, vpmap, k);
put(vnm, v, vec);
}
typename boost::graph_traits<PolygonMesh>::face_descriptor f;
BOOST_FOREACH(f, faces(pmesh)){
typename Kernel::Vector_3 vec = compute_face_normal(f,pmesh, vpmap, k);
put(fnm, f, vec);
}
}
///\cond SKIP_IN_MANUAL
template <typename PolygonMesh, typename VertexNormalMap>
void
compute_vertex_normals(const PolygonMesh& pmesh,
VertexNormalMap vnm)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_vertex_normals(pmesh, vnm, get(vertex_point, pmesh), Kernel());
}
template <typename PolygonMesh, typename VertexNormalMap, typename VertexPointMap>
void
compute_vertex_normals(const PolygonMesh& pmesh,
VertexNormalMap vnm,
VertexPointMap vpmap)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_vertex_normals(pmesh, vnm, vpmap, Kernel());
}
///\endcond
/**
* \ingroup PkgPolygonMeshProcessing
* computes the outward unit vector normal for all vertices of the polygon mesh.
* @tparam Kernel Geometric traits class. It can be omitted and deduced automatically from the point type of `PolygonMesh`.
* @tparam PolygonMesh a model of `FaceGraph`
* @tparam VertexNormalMap the property map in which the normals are written.
* @tparam VertexPointMap the property map with the points associated to the vertices.
* *
* @param f the face on which the normal is computed * @param f the face on which the normal is computed
* @param pmesh the polygon mesh * @param pmesh the polygon mesh to which `f` belongs
*/ */
template <typename PolygonMesh template <typename PolygonMesh
, typename VertexNormalMap
, typename VertexPointMap , typename VertexPointMap
#ifdef DOXYGEN_RUNNING #ifdef DOXYGEN_RUNNING
= typename boost::property_map<PolygonMesh, vertex_point_t>::type = typename boost::property_map<PolygonMesh, CGAL::vertex_point_t>::type
#endif #endif
, typename Kernel , typename Kernel
#ifdef DOXYGEN_RUNNING #ifdef DOXYGEN_RUNNING
@ -162,56 +48,40 @@ template <typename PolygonMesh
typename boost::property_traits<VertexPointMap>::value_type>::Kernel typename boost::property_traits<VertexPointMap>::value_type>::Kernel
#endif #endif
> >
void typename Kernel::Vector_3
compute_vertex_normals(const PolygonMesh& pmesh compute_face_normal(typename boost::graph_traits<PolygonMesh>::face_descriptor f,
, VertexNormalMap vnm const PolygonMesh& pmesh
, VertexPointMap vpmap , VertexPointMap vpmap
#ifdef DOXYGEN_RUNNING #ifdef DOXYGEN_RUNNING
= get(vertex_point, pmesh) = get(vertex_point_t, pmesh)
#endif #endif
,const Kernel& k , const Kernel&
#ifdef DOXYGEN_RUNNING #ifdef DOXYGEN_RUNNING
= Kernel() k = Kernel()
#endif #endif
) )
{ {
typename boost::graph_traits<PolygonMesh>::vertex_descriptor v; typedef typename Kernel::Point_3 Point;
BOOST_FOREACH(v, vertices(pmesh)){ typedef typename Kernel::Vector_3 Vector;
typename Kernel::Vector_3 vec = compute_vertex_normal(v,pmesh, vpmap, k);
put(vnm, v, vec); Vector normal = CGAL::NULL_VECTOR;
} typedef typename boost::graph_traits<PolygonMesh>::halfedge_descriptor halfedge_descriptor;
halfedge_descriptor he = halfedge(f, pmesh);
halfedge_descriptor end = he;
do
{
const Point& prv = vpmap[target(prev(he, pmesh), pmesh)];
const Point& curr = vpmap[target(he, pmesh)];
const Point& nxt = vpmap[target(next(he, pmesh), pmesh)];
Vector n = CGAL::cross_product(nxt - curr, prv - curr);
normal = normal + n;
he = next(he, pmesh);
} while (he != end);
return normal / std::sqrt(normal * normal);
} }
///\cond SKIP_IN_MANUAL
template <typename PolygonMesh, typename FaceNormalMap>
void
compute_face_normals(const PolygonMesh& pmesh,
FaceNormalMap fnm)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_face_normals(pmesh, fnm, get(vertex_point, pmesh), Kernel());
}
template <typename PolygonMesh, typename FaceNormalMap, typename VertexPointMap>
void
compute_face_normals(const PolygonMesh& pmesh,
FaceNormalMap fnm,
VertexPointMap vpmap)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_face_normals(pmesh, fnm, vpmap, Kernel());
}
///\endcond
/** /**
* \ingroup PkgPolygonMeshProcessing * \ingroup PkgPolygonMeshProcessing
* computes the outward unit vector normal for all faces of the polygon mesh. * computes the outward unit vector normal for all faces of the polygon mesh.
@ -255,135 +125,6 @@ compute_face_normals(const PolygonMesh& pmesh
} }
} }
///\cond SKIP_IN_MANUAL
template <typename PolygonMesh>
typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel::Vector_3
compute_face_normal(
typename boost::graph_traits<PolygonMesh>::face_descriptor f,
const PolygonMesh& pmesh)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
return compute_face_normal(f, pmesh, get(vertex_point, pmesh), Kernel());
}
template <typename PolygonMesh, typename VertexPointMap>
typename Kernel_traits<
typename boost::property_traits<VertexPointMap>::value_type>::Kernel::Vector_3
compute_face_normal(
typename boost::graph_traits<PolygonMesh>::face_descriptor f,
const PolygonMesh& pmesh,
VertexPointMap vpmap)
{
typedef typename Kernel_traits<
typename boost::property_traits<VertexPointMap>::value_type>::Kernel Kernel;
return compute_face_normal(f, pmesh, vpmap, Kernel());
}
/// \endcond
/**
* \ingroup PkgPolygonMeshProcessing
* computes the outward unit vector normal to face `f`.
* @tparam Kernel Geometric traits class. It can be omitted and deduced automatically from the point type of `PolygonMesh`.
* @tparam PolygonMesh a model of `FaceGraph`
*
* @param f the face on which the normal is computed
* @param pmesh the polygon mesh to which `f` belongs
*/
template <typename PolygonMesh
, typename VertexPointMap
#ifdef DOXYGEN_RUNNING
= typename boost::property_map<PolygonMesh, CGAL::vertex_point_t>::type
#endif
, typename Kernel
#ifdef DOXYGEN_RUNNING
= typename Kernel_traits<
typename boost::property_traits<VertexPointMap>::value_type>::Kernel
#endif
>
typename Kernel::Vector_3
compute_face_normal(typename boost::graph_traits<PolygonMesh>::face_descriptor f,
const PolygonMesh& pmesh
, VertexPointMap vpmap
#ifdef DOXYGEN_RUNNING
= get(vertex_point_t, pmesh)
#endif
, const Kernel& k
#ifdef DOXYGEN_RUNNING
= Kernel()
#endif
)
{
typedef typename Kernel::Point_3 Point;
typedef typename Kernel::Vector_3 Vector;
Vector normal = CGAL::NULL_VECTOR;
typedef typename boost::graph_traits<PolygonMesh>::halfedge_descriptor halfedge_descriptor;
halfedge_descriptor he = halfedge(f, pmesh);
halfedge_descriptor end = he;
do
{
const Point& prv = vpmap[target(prev(he, pmesh), pmesh)];
const Point& curr = vpmap[target(he, pmesh)];
const Point& nxt = vpmap[target(next(he, pmesh), pmesh)];
Vector n = CGAL::cross_product(nxt - curr, prv - curr);
normal = normal + n;
he = next(he, pmesh);
} while (he != end);
return normal / std::sqrt(normal * normal);
}
///\cond SKIP_IN_MANUAL
template <typename PolygonMesh>
typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel::Vector_3
compute_vertex_normal(
typename boost::graph_traits<PolygonMesh>::vertex_descriptor v,
const PolygonMesh& pmesh)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
return compute_vertex_normal(v, pmesh, get(vertex_point, pmesh), Kernel());
}
template <typename PolygonMesh, typename VertexPointMap>
typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel::Vector_3
compute_vertex_normal(
typename boost::graph_traits<PolygonMesh>::vertex_descriptor v,
const PolygonMesh& pmesh,
VertexPointMap vpmap)
{ typedef typename Kernel_traits<
typename boost::property_traits<VertexPointMap>::value_type>::Kernel Kernel;
return compute_vertex_normal(v, pmesh, vpmap, Kernel);
}
/// \endcond
/** /**
* \ingroup PkgPolygonMeshProcessing * \ingroup PkgPolygonMeshProcessing
* computes the unit normal at vertex `v` as the average of the normals of incident faces. * computes the unit normal at vertex `v` as the average of the normals of incident faces.
@ -436,6 +177,247 @@ compute_vertex_normal(typename boost::graph_traits<PolygonMesh>::vertex_descript
return normal / std::sqrt(normal * normal); return normal / std::sqrt(normal * normal);
} }
/**
* \ingroup PkgPolygonMeshProcessing
* computes the outward unit vector normal for all vertices of the polygon mesh.
* @tparam Kernel Geometric traits class. It can be omitted and deduced automatically from the point type of `PolygonMesh`.
* @tparam PolygonMesh a model of `FaceGraph`
* @tparam VertexNormalMap the property map in which the normals are written.
* @tparam VertexPointMap the property map with the points associated to the vertices.
*
* @param f the face on which the normal is computed
* @param pmesh the polygon mesh
*/
template <typename PolygonMesh
, typename VertexNormalMap
, typename VertexPointMap
#ifdef DOXYGEN_RUNNING
= typename boost::property_map<PolygonMesh, vertex_point_t>::type
#endif
, typename Kernel
#ifdef DOXYGEN_RUNNING
= typename Kernel_traits<
typename boost::property_traits<VertexPointMap>::value_type>::Kernel
#endif
>
void
compute_vertex_normals(const PolygonMesh& pmesh
, VertexNormalMap vnm
, VertexPointMap vpmap
#ifdef DOXYGEN_RUNNING
= get(vertex_point, pmesh)
#endif
,const Kernel& k
#ifdef DOXYGEN_RUNNING
= Kernel()
#endif
)
{
typename boost::graph_traits<PolygonMesh>::vertex_descriptor v;
BOOST_FOREACH(v, vertices(pmesh)){
typename Kernel::Vector_3 vec = compute_vertex_normal(v,pmesh, vpmap, k);
put(vnm, v, vec);
}
}
/**
* \ingroup PkgPolygonMeshProcessing
* computes the outward unit vector normal for all vertices and faces of the polygon mesh.
* @tparam Kernel Geometric traits class. It can be omitted and deduced automatically from the point type of `PolygonMesh`.
* @tparam PolygonMesh a model of `FaceGraph`
* @tparam VertexNormalMap the property map in which the vertex normals are written.
* @tparam FaceNormalMap the property map in which the face normals are written.
* @tparam VertexPointMap the property map with the points associated to the vertices.
*
* @param pmesh the polygon mesh
*/
template <typename PolygonMesh
, typename VertexNormalMap
, typename FaceNormalMap
, typename VertexPointMap
#ifdef DOXYGEN_RUNNING
= typename boost::property_map<PolygonMesh, vertex_point_t>::type
#endif
, typename Kernel
#ifdef DOXYGEN_RUNNING
= typename Kernel_traits<
typename boost::property_traits<VertexPointMap>::value_type>::Kernel
#endif
>
void
compute_normals(const PolygonMesh& pmesh
, VertexNormalMap vnm
, FaceNormalMap fnm
, VertexPointMap vpmap
#ifdef DOXYGEN_RUNNING
= get(vertex_point, pmesh)
#endif
,const Kernel& k
#ifdef DOXYGEN_RUNNING
= Kernel()
#endif
)
{
typename boost::graph_traits<PolygonMesh>::vertex_descriptor v;
BOOST_FOREACH(v, vertices(pmesh)){
typename Kernel::Vector_3 vec = compute_vertex_normal(v,pmesh, vpmap, k);
put(vnm, v, vec);
}
typename boost::graph_traits<PolygonMesh>::face_descriptor f;
BOOST_FOREACH(f, faces(pmesh)){
typename Kernel::Vector_3 vec = compute_face_normal(f,pmesh, vpmap, k);
put(fnm, f, vec);
}
}
///\cond SKIP_IN_MANUAL
// compute_vertex_normal overloads
template <typename PolygonMesh>
typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel::Vector_3
compute_vertex_normal(
typename boost::graph_traits<PolygonMesh>::vertex_descriptor v,
const PolygonMesh& pmesh)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
return compute_vertex_normal(v, pmesh, get(vertex_point, pmesh), Kernel());
}
// compute_vertex_normals overloads
template <typename PolygonMesh, typename VertexNormalMap>
void
compute_vertex_normals(const PolygonMesh& pmesh,
VertexNormalMap vnm)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_vertex_normals(pmesh, vnm, get(vertex_point, pmesh), Kernel());
}
template <typename PolygonMesh, typename VertexNormalMap, typename VertexPointMap>
void
compute_vertex_normals(const PolygonMesh& pmesh,
VertexNormalMap vnm,
VertexPointMap vpmap)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_vertex_normals(pmesh, vnm, vpmap, Kernel());
}
template <typename PolygonMesh, typename VertexPointMap>
typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel::Vector_3
compute_vertex_normal(
typename boost::graph_traits<PolygonMesh>::vertex_descriptor v,
const PolygonMesh& pmesh,
VertexPointMap vpmap)
{ typedef typename Kernel_traits<
typename boost::property_traits<VertexPointMap>::value_type>::Kernel Kernel;
return compute_vertex_normal(v, pmesh, vpmap, Kernel());
}
// compute_face_normal overloads
template <typename PolygonMesh>
typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel::Vector_3
compute_face_normal(
typename boost::graph_traits<PolygonMesh>::face_descriptor f,
const PolygonMesh& pmesh)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
return compute_face_normal(f, pmesh, get(vertex_point, pmesh), Kernel());
}
template <typename PolygonMesh, typename VertexPointMap>
typename Kernel_traits<
typename boost::property_traits<VertexPointMap>::value_type>::Kernel::Vector_3
compute_face_normal(
typename boost::graph_traits<PolygonMesh>::face_descriptor f,
const PolygonMesh& pmesh,
VertexPointMap vpmap)
{
typedef typename Kernel_traits<
typename boost::property_traits<VertexPointMap>::value_type>::Kernel Kernel;
return compute_face_normal(f, pmesh, vpmap, Kernel());
}
// compute_face_normals overloads
template <typename PolygonMesh, typename FaceNormalMap>
void
compute_face_normals(const PolygonMesh& pmesh,
FaceNormalMap fnm)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_face_normals(pmesh, fnm, get(vertex_point, pmesh), Kernel());
}
template <typename PolygonMesh, typename FaceNormalMap, typename VertexPointMap>
void
compute_face_normals(const PolygonMesh& pmesh,
FaceNormalMap fnm,
VertexPointMap vpmap)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_face_normals(pmesh, fnm, vpmap, Kernel());
}
// compute_normals overloads
template <typename PolygonMesh, typename VertexNormalMap, typename FaceNormalMap>
void
compute_normals(const PolygonMesh& pmesh,
VertexNormalMap vnm,
FaceNormalMap fnm)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_normals(pmesh, vnm, fnm, get(vertex_point, pmesh), Kernel());
}
template <typename PolygonMesh, typename VertexNormalMap, typename FaceNormalMap, typename VertexPointMap>
void
compute_normals(const PolygonMesh& pmesh,
VertexNormalMap vnm,
FaceNormalMap fnm,
VertexPointMap vpmap)
{
typedef typename Kernel_traits<
typename boost::property_traits<
typename boost::property_map<
PolygonMesh, CGAL::vertex_point_t>::type>::value_type>::Kernel Kernel;
compute_normals(pmesh, vnm, fnm, vpmap, Kernel());
}
/// \endcond
} }
} // end of namespace CGAL::Polygon_mesh_processing } // end of namespace CGAL::Polygon_mesh_processing