added the option to pass a flat container of indices (without the -1 at the end of each facet)

This commit is contained in:
Efi Fogel 2013-06-04 18:17:14 +03:00
parent ab37ee592e
commit d7ca4432c4
1 changed files with 103 additions and 67 deletions

View File

@ -200,6 +200,9 @@ private:
/*! The number of facest */ /*! The number of facest */
size_type m_num_facets; size_type m_num_facets;
/*! The type of the facets. */
size_type m_num_vertices_per_facet;
/*! The index of the marked vertex */ /*! The index of the marked vertex */
unsigned int m_marked_vertex_index; unsigned int m_marked_vertex_index;
@ -216,11 +219,13 @@ private:
unsigned int num_points, unsigned int num_points,
const Coord_index_iter& indices_begin, const Coord_index_iter& indices_begin,
const Coord_index_iter& indices_end, const Coord_index_iter& indices_end,
unsigned int num_facets) : size_type num_facets,
size_type num_vertices_per_facet = 0) :
m_points_begin(points_begin), m_points_end(points_end), m_points_begin(points_begin), m_points_end(points_end),
m_num_points(num_points), m_num_points(num_points),
m_indices_begin(indices_begin), m_indices_end(indices_end), m_indices_begin(indices_begin), m_indices_end(indices_end),
m_num_facets(num_facets), m_num_facets(num_facets),
m_num_vertices_per_facet(num_vertices_per_facet),
m_marked_vertex_index(0), m_marked_vertex_index(0),
m_marked_edge_index(0), m_marked_edge_index(0),
m_marked_facet_index(0) m_marked_facet_index(0)
@ -254,25 +259,53 @@ private:
} }
// Add the facets: // Add the facets:
bool facet_ended = true;
counter = 0; counter = 0;
for (Coord_index_iter ii = m_indices_begin; ii != m_indices_end; ++ii) { switch (m_num_vertices_per_facet) {
int index = *ii; case 0: // '0' indicates variant number of vertices per facet
if (facet_ended) { {
Coord_index_iter ii = m_indices_begin;
while (ii != m_indices_end) {
Polyhedron_facet_handle fh = B.begin_facet(); Polyhedron_facet_handle fh = B.begin_facet();
if (counter == m_marked_facet_index) fh->set_marked(true); if (counter == m_marked_facet_index) fh->set_marked(true);
int index = *ii++;
while (index != -1) {
B.add_vertex_to_facet(index); B.add_vertex_to_facet(index);
facet_ended = false; index = *ii++;
continue;
}
if (index != -1) {
B.add_vertex_to_facet(index);
continue;
} }
B.end_facet(); B.end_facet();
facet_ended = true;
++counter; ++counter;
} }
}
break;
case 3:
// Unfold for to improve preformance:
for (Coord_index_iter ii = m_indices_begin; ii != m_indices_end;
ii += m_num_vertices_per_facet)
{
Polyhedron_facet_handle fh = B.begin_facet();
if (counter == m_marked_facet_index) fh->set_marked(true);
B.add_vertex_to_facet(*ii);
B.add_vertex_to_facet(*(ii+1));
B.add_vertex_to_facet(*(ii+2));
B.end_facet();
++counter;
}
break;
default:
for (Coord_index_iter ii = m_indices_begin; ii != m_indices_end;
ii += m_num_vertices_per_facet)
{
Polyhedron_facet_handle fh = B.begin_facet();
if (counter == m_marked_facet_index) fh->set_marked(true);
for (size_type i = 0; i < m_num_vertices_per_facet; ++i)
B.add_vertex_to_facet(*(ii + i));
B.end_facet();
++counter;
}
break;
}
B.end_surface(); B.end_surface();
} }
}; };
@ -330,12 +363,13 @@ private:
unsigned int num_points, unsigned int num_points,
const Coord_index_iter indices_begin, const Coord_index_iter indices_begin,
Coord_index_iter indices_end, Coord_index_iter indices_end,
unsigned int num_facets) unsigned int num_facets,
unsigned int num_vertices_per_facet = 0)
{ {
/*! The builder */ /*! The builder */
Build_surface<PointIterator_3> Build_surface<PointIterator_3>
surface(points_begin, points_end, num_points, surface(points_begin, points_end, num_points,
indices_begin, indices_end, num_facets); indices_begin, indices_end, num_facets, num_vertices_per_facet);
surface.set_marked_vertex_index(m_marked_vertex_index); surface.set_marked_vertex_index(m_marked_vertex_index);
surface.set_marked_edge_index(m_marked_edge_index); surface.set_marked_edge_index(m_marked_edge_index);
surface.set_marked_facet_index(m_marked_facet_index); surface.set_marked_facet_index(m_marked_facet_index);
@ -567,13 +601,15 @@ public:
const Coord_index_iter indices_begin, const Coord_index_iter indices_begin,
Coord_index_iter indices_end, Coord_index_iter indices_end,
unsigned int num_facets, unsigned int num_facets,
unsigned int num_vertices_per_facet = 0,
Visitor* visitor = NULL) Visitor* visitor = NULL)
{ {
m_visitor = visitor; m_visitor = visitor;
Polyhedron polyhedron; Polyhedron polyhedron;
update_polyhedron(polyhedron, points_begin, points_end, num_points, update_polyhedron(polyhedron, points_begin, points_end, num_points,
indices_begin, indices_end, num_facets); indices_begin, indices_end, num_facets,
num_vertices_per_facet);
#if 0 #if 0
std::copy(polyhedron.points_begin(), polyhedron.points_end(), std::copy(polyhedron.points_begin(), polyhedron.points_end(),