Return boolean when run or run_until + function to count isolated vertices

This commit is contained in:
Simon Giraudot 2016-07-18 09:52:39 +02:00
parent 6e01c51f72
commit 18f859193c
1 changed files with 38 additions and 2 deletions

View File

@ -1355,6 +1355,7 @@ public:
std::cerr << "STATS" << std::endl; std::cerr << "STATS" << std::endl;
std::cerr << "# vertices : " << m_dt.number_of_vertices()-4 << std::endl; std::cerr << "# vertices : " << m_dt.number_of_vertices()-4 << std::endl;
std::cerr << "# isolated vertices : " << number_of_isolated_vertices() << std::endl;
std::cerr << "# triangles: " << m_dt.number_of_faces() << std::endl; std::cerr << "# triangles: " << m_dt.number_of_faces() << std::endl;
std::cerr << "# edges: " << m_dt.tds().number_of_edges() << std::endl; std::cerr << "# edges: " << m_dt.tds().number_of_edges() << std::endl;
std::cerr << "# solid: " << nb_solid << std::endl; std::cerr << "# solid: " << nb_solid << std::endl;
@ -1370,6 +1371,32 @@ public:
} }
/*!
Returns the number of isolated vertices present in the reconstructed triangulation.
*/
int number_of_isolated_vertices () const
{
int nb_isolated = 0;
for (Vertex_iterator vi = m_dt.vertices_begin();
vi != m_dt.vertices_end(); ++vi)
{
if (!((*vi).has_sample_assigned()))
continue;
typename Triangulation::Edge_circulator start = m_dt.incident_edges(vi);
typename Triangulation::Edge_circulator cur = start;
do {
if (!m_dt.is_ghost(*cur)) {
++nb_isolated;
break;
}
++cur;
} while (cur != start);
}
return nb_isolated;
}
/*! /*!
Returns the number of (solid) edges present in the reconstructed triangulation. Returns the number of (solid) edges present in the reconstructed triangulation.
*/ */
@ -1415,8 +1442,11 @@ public:
Computes a shape consisting of `np` points, reconstructing the input Computes a shape consisting of `np` points, reconstructing the input
points. points.
\param np The number of points which will be present in the output. \param np The number of points which will be present in the output.
\return `true` if the number of points `np` was reached, `false`
if the algorithm was prematurely ended because no more edge
collapse was possible.
*/ */
void run_until(std::size_t np) { bool run_until(std::size_t np) {
CGAL::Real_timer timer; CGAL::Real_timer timer;
if (m_verbose > 0) if (m_verbose > 0)
std::cerr << "reconstruct until " << np << " V"; std::cerr << "reconstruct until " << np << " V";
@ -1436,14 +1466,19 @@ public:
<< " iters, " << m_dt.number_of_vertices() - 4 << " V " << " iters, " << m_dt.number_of_vertices() - 4 << " V "
<< timer.time() << " s)" << timer.time() << " s)"
<< std::endl; << std::endl;
return (m_dt.number_of_vertices() <= N);
} }
/*! /*!
Computes a shape, reconstructing the input, by performing `steps` Computes a shape, reconstructing the input, by performing `steps`
edge collapse operators on the output simplex. edge collapse operators on the output simplex.
\param steps The number of edge collapse operators to be performed. \param steps The number of edge collapse operators to be performed.
\return `true` if the required number of steps was performed,
`false` if the algorithm was prematurely ended because no more
edge collapse was possible.
*/ */
void run(const unsigned steps) { bool run(const unsigned steps) {
CGAL::Real_timer timer; CGAL::Real_timer timer;
if (m_verbose > 0) if (m_verbose > 0)
std::cerr << "reconstruct " << steps; std::cerr << "reconstruct " << steps;
@ -1462,6 +1497,7 @@ public:
<< steps << " iters, " << m_dt.number_of_vertices() - 4 << steps << " iters, " << m_dt.number_of_vertices() - 4
<< " V, " << timer.time() << " s)" << " V, " << timer.time() << " s)"
<< std::endl; << std::endl;
return (performed == steps);
} }