- Insert a random sample of the polyhedron points, instead of the first

points, to avoid having a triangulation of dimension < 3
- Set the error_behavior to ABORT, so that the try/catch of the Qt4 main
  loop does not intercept our CGAL assertions (that prevents efficient
  debugging).
This commit is contained in:
Laurent Rineau 2009-11-19 14:18:33 +00:00
parent 4c37f9d69c
commit 3baee3ce4c
1 changed files with 26 additions and 6 deletions

View File

@ -14,10 +14,15 @@
#include <CGAL/Timer.h>
#include <CGAL/assertions_behaviour.h>
#include <algorithm>
Polyhedron* cgal_code_remesh(const Polyhedron* pMesh,
const double angle,
const double sizing,
const double approx) {
CGAL::set_error_behaviour(CGAL::ABORT);
if(!pMesh) return 0;
// remesh
@ -46,14 +51,29 @@ Polyhedron* cgal_code_remesh(const Polyhedron* pMesh,
timer.reset();
std::cerr << "Insert initial point set...";
unsigned int nb_initial_points = 10;
Polyhedron::Point_const_iterator it;
typedef CGAL::Cartesian_converter<Kernel,GT> Converter;
Converter convert;
unsigned int i = 0;
for(it = pMesh->points_begin();
it != pMesh->points_end(), i < nb_initial_points;
it++, i++)
triangulation.insert(convert(*it));
{ // new scope for the initialization, so that the vector
// polyhedron_points is destroyed as soon as the initialization is
// finished
std::vector<Point> polyhedron_points;
polyhedron_points.reserve(pMesh->size_of_vertices());
std::copy(pMesh->points_begin(), pMesh->points_end(),
std::back_inserter(polyhedron_points));
for(int n = 0;
n < nb_initial_points || (n < 10 * nb_initial_points &&
triangulation.dimension() < 3 );
n = triangulation.number_of_vertices())
{
const int pos = CGAL::default_random.get_int(0, polyhedron_points.size());
triangulation.insert(convert(polyhedron_points[pos]));
}
}
if(triangulation.dimension() < 3)
return 0;
std::cerr << "done (" << timer.time() << " ms)" << std::endl;
// remesh