Subject: CGAL users discussion list
List archive
- From: Sterpa <>
- To:
- Subject: [cgal-discuss] CGAL ERROR: precondition violation! Expr: is_line()
- Date: Thu, 15 Oct 2009 19:18:56 +0200 (CEST)
This is my code:
int getLevel(Halfedge e, vector<Line_2> lines) {
int level = 0;
NT x;
bool source_finite, target_finite;
if(e.direction() == CGAL::ARR_RIGHT_TO_LEFT) e = *e.twin();
source_finite = !e.source()->is_at_open_boundary();
target_finite = !e.target()->is_at_open_boundary();
if(source_finite) {
if(target_finite) x = CGAL::midpoint(e.source()->point(),
e.target()->point()).x(); // segmento
else x = e.source()->point().x() + 1;
// semiretta finita a sinistra
}
else if(target_finite) x = e.target()->point().x() - 1;
// semiretta finita a destra
else x = 0;
// retta
Line_2 l = Line_2(-1, 0, x);
Point_2 p = intersection(e.curve().line(), l);
for(unsigned i = 0; i < lines.size(); i++) {
Point_2 tmp = intersection(l, lines[i]);
if(p.y() > tmp.y()) level++;
}
return level;
}
and this is the error I got:
terminate called after throwing an instance of 'CGAL::Precondition_exception'
what(): CGAL ERROR: precondition violation!
Expr: is_line()
File: /usr/local/include/CGAL/Arr_linear_traits_2.h
Line: 1700
The problem seems to be in the line:
Point_2 p = intersection(e.curve().line(), l);
and looking at the header file the problem should be here:
bool is_line () const
{
return (! this->is_degen && ! this->has_source && ! this->has_target);
}
this function is called by an assert(this->is_line()), I tried to do cout <<
line.is_degenerate(); but I still got the same error without any output to
read. Does someone know how can I fix this issue?
- [cgal-discuss] CGAL ERROR: precondition violation! Expr: is_line(), Sterpa, 10/15/2009
Archive powered by MHonArc 2.6.16.