Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Please help with a CGAL ERROR: precondition violation!

Subject: CGAL users discussion list

List archive

[cgal-discuss] Please help with a CGAL ERROR: precondition violation!


Chronological Thread 
  • From: Alejandro Aguilar Sierra <>
  • To:
  • Subject: [cgal-discuss] Please help with a CGAL ERROR: precondition violation!
  • Date: Sun, 27 Sep 2009 13:22:35 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=O+m6RmFodlX7civcMkMYgnderRGh+yCBi8rsg/hAXhPEa9Ni3Pi5zVHEvaDOn4vScz CEWq++FtAmapKgWPLabuLTMC1tlxWbzWerF/9+E7phay1s5BpiEDAoWG3WcDDpZFq7q8 lWWN94b08AF3lVrOE4Wzt+Muf5VN3nZWnJPpc=

Hello:

I modified the greene_approx_convex_partition_2.cpp example to work
with a shape file I have. The only significant change is that instead
of giving a list of integer pairs in the function make_polygon I feed
the polygon with the result of a polygon from the shapefile. They are
all floats. It compiles perfectly and runs fine with the original
polygon, but when I my polygon, I got this error:


terminate called after throwing an instance of 'CGAL::Precondition_exception'
what(): CGAL ERROR: precondition violation!
Expr: is_simple_2(first, last, traits)
File: /usr/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h
Line: 420
Aborted

The piece of code I modified is this, a Vectorvertex is a C++ generic
vector of this struct:

typedef struct {
double x, y;
} vertex;

void make_polygon2(Polygon_2& polygon, Vectorvertex plate)
{
for (unsigned int i=0; i < plate.size(); i++) {
Point_2 p = Point_2(plate[i].x, plate[i].y);
polygon.push_back(p);
cout << p << endl;
}
}

In the original main part of the example I just add a couple of lines
to loads the shapes and create a polygon from one of them:


int main(int argc, char** argv)
{
Polygon_2 polygon;
Polygon_list partition_polys;
Traits partition_traits;

// Load the tectonic plates shapefile
plates.load_shapes("today");
Vectorvertex plate = plates.getPlate(201);
make_polygon2(polygon, plate);

CGAL::greene_approx_convex_partition_2(polygon.vertices_begin(),
polygon.vertices_end(),
std::back_inserter(partition_polys),
partition_traits);

assert(CGAL::convex_partition_is_valid_2(polygon.vertices_begin(),
polygon.vertices_end(),
partition_polys.begin(),
partition_polys.end(),
partition_traits));
return 0;
}

The header is the same as in the example.

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Partition_traits_2<K> Traits;
typedef Traits::Point_2 Point_2;
typedef Traits::Polygon_2 Polygon_2;
typedef Polygon_2::Vertex_iterator Vertex_iterator;
typedef std::list<Polygon_2> Polygon_list;
typedef CGAL::Creator_uniform_2<int, Point_2> Creator;
typedef CGAL::Random_points_in_square_2< Point_2, Creator > Point_generator;

I will appreciate any hint.

Au revoir.

-- A.


  • [cgal-discuss] Please help with a CGAL ERROR: precondition violation!, Alejandro Aguilar Sierra, 09/27/2009

Archive powered by MHonArc 2.6.16.

Top of Page