mirror of https://github.com/CGAL/cgal
Merge branch 'Polygon_mesh_processing-GF' of ssh://scm.cgal.org/var/git/cgal into Polygon_mesh_processing-GF
This commit is contained in:
commit
a2c45b78f0
|
|
@ -57,6 +57,6 @@ include_directories( BEFORE ../../include )
|
|||
|
||||
include( CGAL_CreateSingleSourceCGALProgram )
|
||||
|
||||
create_single_source_cgal_program( "polygon_mesh_slicer_test.cpp" )
|
||||
create_single_source_cgal_program( "polygon_mesh_slicer.cpp" )
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
std::ifstream input(argv[1]);
|
||||
Mesh m;
|
||||
int N = 10;
|
||||
int N = 100;
|
||||
if (!input || !(input >> m)){
|
||||
std::cerr << "Error: can not read file.\n";
|
||||
return 1;
|
||||
|
|
@ -116,6 +116,7 @@ int main(int argc, char* argv[])
|
|||
CGAL::Polygon_mesh_slicer_3<Mesh, K> slicer(m);
|
||||
|
||||
|
||||
std::ofstream out("out.off");
|
||||
int polycount = 0;
|
||||
int vertex_count = 0;
|
||||
for(int i=0; i < N; i++){
|
||||
|
|
@ -125,11 +126,11 @@ int main(int argc, char* argv[])
|
|||
polycount += polylines.size();
|
||||
BOOST_FOREACH(Polyline pl, polylines){
|
||||
vertex_count += pl.size();
|
||||
std::cout << pl.size();
|
||||
out << pl.size();
|
||||
BOOST_FOREACH(Point_3 p, pl){
|
||||
std::cout << " " << p;
|
||||
out << " " << p;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
out << std::endl;
|
||||
}
|
||||
t.start();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,23 @@ namespace CGAL{
|
|||
|
||||
namespace Polygon_mesh_processing{
|
||||
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
template <class PolygonMesh>
|
||||
typename Kernel_traits<typename boost::property_traits<typename boost::property_map<PolygonMesh,CGAL::vertex_point_t>::type>::value_type>::Kernel::Vector_3
|
||||
compute_facet_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_facet_normal(f, pmesh, Kernel());
|
||||
}
|
||||
#endif
|
||||
|
||||
// %CGAL `Kernel` with `FT` a model of `FieldWithSqrt`. This
|
||||
/**
|
||||
* \ingroup PkgPolygonMeshProcessing
|
||||
* computes the outward unit vector normal to facet `f`.
|
||||
* @tparam Kernel a %CGAL `Kernel` with `FT` a model of `FieldWithSqrt`
|
||||
* @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 facet on which the normal is computed
|
||||
|
|
@ -41,13 +54,14 @@ template <class Kernel, class PolygonMesh>
|
|||
typename Kernel::Vector_3
|
||||
compute_facet_normal(
|
||||
typename boost::graph_traits<PolygonMesh>::face_descriptor f,
|
||||
const PolygonMesh& pmesh)
|
||||
const PolygonMesh& pmesh,
|
||||
const Kernel& )
|
||||
{
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
typedef typename Kernel::Vector_3 Vector;
|
||||
|
||||
typename boost::property_map<PolygonMesh, boost::vertex_point_t>::const_type
|
||||
ppmap = get(boost::vertex_point, pmesh);
|
||||
typename boost::property_map<PolygonMesh, CGAL::vertex_point_t>::const_type
|
||||
ppmap = get(CGAL::vertex_point, pmesh);
|
||||
|
||||
Vector normal = CGAL::NULL_VECTOR;
|
||||
typedef typename boost::graph_traits<PolygonMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
|
|
@ -67,6 +81,19 @@ compute_facet_normal(
|
|||
return normal / std::sqrt(normal * normal);
|
||||
}
|
||||
|
||||
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
template <class 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, Kernel());
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \ingroup PkgPolygonMeshProcessing
|
||||
* computes the unit normal at vertex `v` as the average of the normals of incident facets.
|
||||
|
|
@ -80,7 +107,8 @@ template<typename Kernel, typename PolygonMesh>
|
|||
typename Kernel::Vector_3
|
||||
compute_vertex_normal(
|
||||
typename boost::graph_traits<PolygonMesh>::vertex_descriptor v,
|
||||
const PolygonMesh& pmesh)
|
||||
const PolygonMesh& pmesh,
|
||||
const Kernel& k)
|
||||
{
|
||||
typedef typename Kernel::Vector_3 Vector;
|
||||
typedef typename boost::graph_traits<PolygonMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
|
|
@ -92,7 +120,7 @@ compute_vertex_normal(
|
|||
{
|
||||
if (!is_border(he, pmesh))
|
||||
{
|
||||
Vector n = compute_facet_normal<Kernel>(face(he, pmesh), pmesh);
|
||||
Vector n = compute_facet_normal(face(he, pmesh), pmesh, k);
|
||||
normal = normal + (n / std::sqrt(n*n));
|
||||
}
|
||||
he = opposite(next(he, pmesh), pmesh);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,16 @@ namespace internal{
|
|||
|
||||
};
|
||||
} // end of namespace internal
|
||||
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
template <class PolygonMesh>
|
||||
bool
|
||||
is_outward_oriented(
|
||||
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 is_outward_oriented(pmesh, Kernel());
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* \ingroup PkgPolygonMeshProcessing
|
||||
* Tests whether a closed surface polygon mesh has a positive orientation.
|
||||
|
|
@ -76,10 +85,9 @@ namespace internal{
|
|||
* }
|
||||
* @endcode
|
||||
*/
|
||||
template< class PolygonMesh >
|
||||
bool is_outward_oriented(const PolygonMesh& pmesh)
|
||||
template<class Kernel, class PolygonMesh >
|
||||
bool is_outward_oriented(const PolygonMesh& pmesh, const Kernel&k)
|
||||
{
|
||||
typedef typename CGAL::Kernel_traits<typename PolygonMesh::Point>::Kernel Kernel;
|
||||
CGAL_warning(CGAL::is_closed(pmesh));
|
||||
CGAL_precondition(CGAL::is_valid(pmesh));
|
||||
|
||||
|
|
@ -94,7 +102,7 @@ bool is_outward_oriented(const PolygonMesh& pmesh)
|
|||
= std::min_element(vbegin, vend, less_xyz);
|
||||
|
||||
const typename Kernel::Vector_3&
|
||||
normal_v_min = compute_vertex_normal<Kernel>(*v_min, pmesh);
|
||||
normal_v_min = compute_vertex_normal(*v_min, pmesh, k);
|
||||
|
||||
return normal_v_min[0] < 0 || (
|
||||
normal_v_min[0] == 0 && (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/boost/graph/properties_Polyhedron_3.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/properties_Surface_mesh.h>
|
||||
#include <CGAL/Polygon_mesh_processing/is_oriented.h>
|
||||
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
|
|
|
|||
Loading…
Reference in New Issue