Merge pull request #2071 from janetournois/Polyhedron_demo-improve_surf_reader-GF
Polyhedron demo : improve .surf reader
This commit is contained in:
+20
-1
@@ -29,6 +29,7 @@
|
||||
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>
|
||||
#include <CGAL/algorithm.h>
|
||||
#include <set>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
#include <boost/range/size.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
@@ -67,13 +68,29 @@ public:
|
||||
_polygons(polygons)
|
||||
{ }
|
||||
|
||||
void operator()(PM& pmesh)
|
||||
void operator()(PM& pmesh, const bool insert_isolated_vertices = true)
|
||||
{
|
||||
Vpmap vpmap = get(CGAL::vertex_point, pmesh);
|
||||
|
||||
boost::dynamic_bitset<> not_isolated;
|
||||
if (!insert_isolated_vertices)
|
||||
{
|
||||
not_isolated.resize(_points.size());
|
||||
for (std::size_t i = 0, end = _polygons.size(); i < end; ++i)
|
||||
{
|
||||
const Polygon& polygon = _polygons[i];
|
||||
const std::size_t size = polygon.size();
|
||||
for (std::size_t j = 0; j < size; ++j)
|
||||
not_isolated.set(polygon[j], true);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<vertex_descriptor> vertices(_points.size());
|
||||
for (std::size_t i = 0, end = _points.size(); i < end; ++i)
|
||||
{
|
||||
if (!insert_isolated_vertices && !not_isolated.test(i))
|
||||
continue;
|
||||
|
||||
Point_3 pi(_points[i][0], _points[i][1], _points[i][2]);
|
||||
vertices[i] = add_vertex(pmesh);
|
||||
put(vpmap, vertices[i], pi);
|
||||
@@ -162,6 +179,8 @@ public:
|
||||
typename Orienter::Marked_edges marked_edges;
|
||||
Orienter::fill_edge_map(edges, marked_edges, polygons);
|
||||
//returns false if duplication is necessary
|
||||
if (!marked_edges.empty())
|
||||
return false;
|
||||
return Orienter::has_singular_vertices(static_cast<std::size_t>(max_id+1),polygons,edges,marked_edges);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user