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 */
size_type m_num_facets;
/*! The type of the facets. */
size_type m_num_vertices_per_facet;
/*! The index of the marked vertex */
unsigned int m_marked_vertex_index;
@ -216,11 +219,13 @@ private:
unsigned int num_points,
const Coord_index_iter& indices_begin,
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_num_points(num_points),
m_indices_begin(indices_begin), m_indices_end(indices_end),
m_num_facets(num_facets),
m_num_vertices_per_facet(num_vertices_per_facet),
m_marked_vertex_index(0),
m_marked_edge_index(0),
m_marked_facet_index(0)
@ -254,25 +259,53 @@ private:
}
// Add the facets:
bool facet_ended = true;
counter = 0;
for (Coord_index_iter ii = m_indices_begin; ii != m_indices_end; ++ii) {
int index = *ii;
if (facet_ended) {
switch (m_num_vertices_per_facet) {
case 0: // '0' indicates variant number of vertices per facet
{
Coord_index_iter ii = m_indices_begin;
while (ii != m_indices_end) {
Polyhedron_facet_handle fh = B.begin_facet();
if (counter == m_marked_facet_index) fh->set_marked(true);
int index = *ii++;
while (index != -1) {
B.add_vertex_to_facet(index);
facet_ended = false;
continue;
}
if (index != -1) {
B.add_vertex_to_facet(index);
continue;
index = *ii++;
}
B.end_facet();
facet_ended = true;
++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();
}
};
@ -330,12 +363,13 @@ private:
unsigned int num_points,
const Coord_index_iter indices_begin,
Coord_index_iter indices_end,
unsigned int num_facets)
unsigned int num_facets,
unsigned int num_vertices_per_facet = 0)
{
/*! The builder */
Build_surface<PointIterator_3>
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_edge_index(m_marked_edge_index);
surface.set_marked_facet_index(m_marked_facet_index);
@ -567,13 +601,15 @@ public:
const Coord_index_iter indices_begin,
Coord_index_iter indices_end,
unsigned int num_facets,
unsigned int num_vertices_per_facet = 0,
Visitor* visitor = NULL)
{
m_visitor = visitor;
Polyhedron polyhedron;
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
std::copy(polyhedron.points_begin(), polyhedron.points_end(),