Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Bezier curve arrangement error
- Date: Wed, 01 Dec 2010 08:04:50 +0100
Could you try again with the 3.7 version of CGAL?
(I do not have any error on my machine with CGAL 3.7)
S.
Gene wrote:
Greetings,
Here is a program using Bezier curve arrangements that results in an
error that I do not understand.
The error I get is:
--------
terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: p.is_exact() && _pt.is_exact()
File: /usr/include/CGAL/Arr_geometry_traits/Bezier_x_monotone_2.h
Line: 741
Abort
--------
The program listing is shown below. I'm using gcc on Ubuntu 10.04. I
do not get the same error when I run the first option, which places
the curve into a container and calls CGAL::insert using iterators.
The error only occurs when I run the second option, which inserts the
curve directly. The error seems to be saying that some point is not
exact, but all the input points are of type Rat_point_2, which should
be exact. Any insight as to what makes this error arise?
--------
#include <CGAL/basic.h>
#include <CGAL/Cartesian.h>
#include <CGAL/CORE_algebraic_number_traits.h>
#include <CGAL/Arr_Bezier_curve_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/IO/Arr_iostream.h>
#include <vector>
#include "arr_print.h"
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational NT;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef Rat_kernel::Point_2 Rat_point_2;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_Bezier_curve_traits_2
<Rat_kernel, Alg_kernel, Nt_traits> Curve_traits_2;
typedef Curve_traits_2::Curve_2 Curve_2;
typedef CGAL::Arrangement_2<Curve_traits_2> Arrangement_2;
int
main()
{
Arrangement_2 arr;
std::vector<Rat_point_2> points;
points.push_back(Rat_point_2(166, 447));
points.push_back(Rat_point_2(133, 423));
points.push_back(Rat_point_2(72, 377));
points.push_back(Rat_point_2(90, 289));
#if 0
std::vector<Curve_2> curves;
curves.push_back(Curve_2(points.begin(), points.end()));
CGAL::insert(arr, curves.begin(), curves.end());
#else
CGAL::insert(arr, Curve_2(points.begin(), points.end()));
#endif
print_arrangement(arr);
return 0;
}
--------
The output of the first (working) case is as follows:
--------
3 vertices:
(90 289) - degree 1
(~87.132 ~312.542) - degree 2
(166 447) - degree 1
2 edges:
[4 166 447 133 423 72 377 90 289 [2] | ~87.132 ~312.542 --> 90 289]
[4 166 447 133 423 72 377 90 289 [1] | 166 447 --> ~87.132 ~312.542]
1 faces:
Unbounded face. Hole #1: (~87.132 ~312.542) [4 166 447 133 423 72 377 90 289 [2] |
~87.132 ~312.542 --> 90 289] (90 289) [4 166 447 133 423 72 377 90
289 [2] | ~87.132 ~312.542 --> 90 289] (~87.132 ~312.542) [4 166 447 133 423 72 377 90 289 [1] | 166 447 --> ~87.132 ~312.542] (166 447) [4 166 447 133 423 72 377 90 289 [1] | 166 447 --> ~87.132 ~312.542] (~87.132 ~312.542)
--------
Finally, here is the header file "arr_print.h":
--------
#ifndef _PRINT_ARR_H_
#define _PRINT_ARR_H_
// Print all neighboring vertices to a given arrangement vertex.
template<class Arrangement>
void print_neighboring_vertices (typename Arrangement::Vertex_const_handle
v)
{
if (v->is_isolated())
{
std::cout << "The vertex (" << v->point() << ") is isolated" <<
std::endl;
return;
}
typename Arrangement::Halfedge_around_vertex_const_circulator first,
curr;
typename Arrangement::Vertex_const_handle u;
std::cout << "The neighbors of the vertex (" << v->point() << ") are:";
first = curr = v->incident_halfedges();
do
{
// Note that the current halfedge is (u -> v):
u = curr->source();
std::cout << " (" << u->point() << ")";
++curr;
} while (curr != first);
std::cout << std::endl;
return;
}
// Print all vertices (points) and edges (curves) along a connected
component
// boundary.
template<class Arrangement>
void print_ccb (typename Arrangement::Ccb_halfedge_const_circulator circ)
{
typename Arrangement::Ccb_halfedge_const_circulator curr = circ;
typename Arrangement::Halfedge_const_handle he;
std::cout << "(" << curr->source()->point() << ")";
do
{
he = curr;
std::cout << " [" << he->curve() << "] "
<< "(" << he->target()->point() << ")";
++curr;
} while (curr != circ);
std::cout << std::endl;
return;
}
// Print the boundary description of an arrangement face.
template<class Arrangement>
void print_face (typename Arrangement::Face_const_handle f)
{
// Print the outer boundary.
if (f->is_unbounded())
{
std::cout << "Unbounded face. " << std::endl;
}
else
{
std::cout << "Outer boundary: ";
print_ccb<Arrangement> (f->outer_ccb());
}
// Print the boundary of each of the holes.
typename Arrangement::Hole_const_iterator hole;
int index = 1;
for (hole = f->holes_begin(); hole != f->holes_end(); ++hole, ++index)
{
std::cout << " Hole #" << index << ": ";
print_ccb<Arrangement> (*hole);
}
// Print the isolated vertices.
typename Arrangement::Isolated_vertex_const_iterator iv;
for (iv = f->isolated_vertices_begin(), index = 1;
iv != f->isolated_vertices_end(); ++iv, ++index)
{
std::cout << " Isolated vertex #" << index << ": "
<< "(" << iv->point() << ")" << std::endl;
}
return;
}
// Print the given arrangement.
template<class Arrangement>
void print_arrangement (const Arrangement& arr)
{
CGAL_precondition (arr.is_valid());
// Print the arrangement vertices.
typename Arrangement::Vertex_const_iterator vit;
std::cout << arr.number_of_vertices() << " vertices:" << std::endl;
for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit)
{
std::cout << "(" << vit->point() << ")";
if (vit->is_isolated())
std::cout << " - Isolated." << std::endl;
else
std::cout << " - degree " << vit->degree() << std::endl;
}
// Print the arrangement edges.
typename Arrangement::Edge_const_iterator eit;
std::cout << arr.number_of_edges() << " edges:" << std::endl;
for (eit = arr.edges_begin(); eit != arr.edges_end(); ++eit)
std::cout << "[" << eit->curve() << "]" << std::endl;
// Print the arrangement faces.
typename Arrangement::Face_const_iterator fit;
std::cout << arr.number_of_faces() << " faces:" << std::endl;
for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit)
print_face<Arrangement> (fit);
return;
}
#endif
- Re: [cgal-discuss] Bezier curve arrangement error, Sebastien Loriot (GeometryFactory), 12/01/2010
Archive powered by MHonArc 2.6.16.