Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] segmentation fault, 2D Delaunay triangulation, 3.4 and 3.5-beta1
Chronological Thread
- From: Graham Macpherson <>
- To:
- Subject: Re: [cgal-discuss] segmentation fault, 2D Delaunay triangulation, 3.4 and 3.5-beta1
- Date: Wed, 5 Aug 2009 11:34:19 +0100
- Organization: OpenCFD Ltd.
Hi Manuel,
> Could you send a minimal example that produces the error?
Attached and at the bottom of this email is an example. The objective is at
each step to move or remove some points from the triangulation, and then add
some more.
I get an seg fault within 2-3 steps (no DEBUG) or the "is_valid" assertion
fails at the first step (DEBUG) with both exact and inexact kernels.
If I comment out "move", or replace it with the commented out "insert and
remove", then the problem stops happening. If I just "move" the points (no
removal or insertion) then it fails the assertion in DEBUG, but *doesn't* seg
fault with no DEBUG.
Am I using the "move" function inappropriately or incorrectly?
Thanks very much for your help,
Graham
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_hierarchy_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/Random.h>
#include <CGAL/algorithm.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
// typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_2<K> Vbb;
typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vbb> Vb;
typedef CGAL::Triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
typedef CGAL::Delaunay_triangulation_2<K,Tds> Dt;
typedef CGAL::Triangulation_hierarchy_2<Dt> Triangulation;
typedef Triangulation::Point Point;
typedef CGAL::Creator_uniform_2<double,Point> Creator;
int main( )
{
Triangulation t;
CGAL::Random r;
CGAL::Random_points_in_square_2<Point,Creator> g(1.0);
CGAL::copy_n( g, 10000, std::back_inserter(t));
for (int s = 0; s < 100; s++)
{
std::cout << "\nstep " << s << std::endl;
for
(
Triangulation::Finite_vertices_iterator vit =
t.finite_vertices_begin();
vit != t.finite_vertices_end();
++vit
)
{
if (r.get_double() > 0.9)
{
t.remove(vit);
}
else
{
t.move
(
vit,
vit->point()
+ K::Vector_2(r.get_double(0, 0.1), r.get_double(0, 0.1))
);
// t.insert
// (
// vit->point()
// + K::Vector_2(r.get_double(0, 0.1), r.get_double(0, 0.1))
// );
// t.remove(vit);
}
}
assert(t.is_valid());
std::cout << "Insert more vertices" << std::endl;
for (int i = 0; i < 1000; i++)
{
t.insert
(
Point(r.get_double(0, 1.0) - 0.5, r.get_double(0, 1.0) - 0.5)
);
}
std::cout << t.number_of_vertices() << std::endl;
}
return 0;
}
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_exact_constructions_kernel.h> #include <CGAL/Delaunay_triangulation_2.h> #include <CGAL/Triangulation_hierarchy_2.h> #include <CGAL/point_generators_2.h> #include <CGAL/Random.h> #include <CGAL/algorithm.h> typedef CGAL::Exact_predicates_exact_constructions_kernel K; // typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Triangulation_vertex_base_2<K> Vbb; typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vbb> Vb; typedef CGAL::Triangulation_face_base_2<K> Fb; typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds; typedef CGAL::Delaunay_triangulation_2<K,Tds> Dt; typedef CGAL::Triangulation_hierarchy_2<Dt> Triangulation; typedef Triangulation::Point Point; typedef CGAL::Creator_uniform_2<double,Point> Creator; int main( ) { Triangulation t; CGAL::Random r; CGAL::Random_points_in_square_2<Point,Creator> g(1.0); CGAL::copy_n( g, 10000, std::back_inserter(t)); for (int s = 0; s < 100; s++) { std::cout << "\nstep " << s << std::endl; for ( Triangulation::Finite_vertices_iterator vit = t.finite_vertices_begin(); vit != t.finite_vertices_end(); ++vit ) { if (r.get_double() > 0.9) { t.remove(vit); } else { t.move ( vit, vit->point() + K::Vector_2(r.get_double(0, 0.1), r.get_double(0, 0.1)) ); // t.insert // ( // vit->point() // + K::Vector_2(r.get_double(0, 0.1), r.get_double(0, 0.1)) // ); // t.remove(vit); } } assert(t.is_valid()); std::cout << "Insert more vertices" << std::endl; for (int i = 0; i < 1000; i++) { t.insert ( Point(r.get_double(0, 1.0) - 0.5, r.get_double(0, 1.0) - 0.5) ); } std::cout << t.number_of_vertices() << std::endl; } return 0; }
- Re: [cgal-discuss] segmentation fault, 2D Delaunay triangulation, 3.4 and 3.5-beta1, Manuel Caroli, 08/05/2009
- Re: [cgal-discuss] segmentation fault, 2D Delaunay triangulation, 3.4 and 3.5-beta1, Graham Macpherson, 08/05/2009
- Re: [cgal-discuss] segmentation fault, 2D Delaunay triangulation, 3.4 and 3.5-beta1, Manuel Caroli, 08/05/2009
- Re: [cgal-discuss] segmentation fault, 2D Delaunay triangulation, 3.4 and 3.5-beta1, Graham Macpherson, 08/06/2009
- Re: [cgal-discuss] segmentation fault, 2D Delaunay triangulation, 3.4 and 3.5-beta1, Manuel Caroli, 08/05/2009
- Re: [cgal-discuss] segmentation fault, 2D Delaunay triangulation, 3.4 and 3.5-beta1, Graham Macpherson, 08/05/2009
Archive powered by MHonArc 2.6.16.