Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] [REPOST] Why do I get precondition violation here

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] [REPOST] Why do I get precondition violation here


Chronological Thread 
  • From: Damian Sheehy <>
  • To:
  • Subject: Re: [cgal-discuss] [REPOST] Why do I get precondition violation here
  • Date: Thu, 14 May 2009 12:59:24 -0400
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=w+4j9L8c3hhvZkd/Myw8bcRKfX3l7JSwC19pj0KEYIAcv2z9yXumm8Z5ozLT5fvkBO 9p1vE7gXLyNzh+zxdQyRfvnzPmvzDDw+6/LhFREeTqDEFbJY8MTaE29pLMJPRmOQWDdy XsrB6gLAC7r/BuOmet008QSwvB3Uo0K/dfkss=

Hi Kim,

The documentation says;

          Returns the orientation of pgn. If the number of vertices
          p.size() < 3 then COLLINEAR is returned.
          Precondition: p.is simple().

The precondition means the code will assert if the polygon is not simple.
Is your polygon simple? Does it self-intersect?

Check the outcome of pgn.is_simple() to see if your polygon passes the test.

Damian

On Thu, May 14, 2009 at 8:13 AM, Kim <> wrote:
Hi Damian , thank for you interest in my problem .

if it easier or more helpfull , I can attach my full project , just
let me know if needed
I had no problem until  I introduced Circle arcs in my X_monotone curves.

typeDefs comes longer down for readability

void ReadPoly(std::istream& is,Polygon_2& pgn, std::string& nextPolyType)
{
 XCurve curve;
 std::list<XCurve>  xcvs;
..
..
//some pseudo code begin

do
    data<<new data from file
     readSegment(data,curve);
      xcvs.push_back(curve);

loop until no_more_lines.
//some pseudo code ends

pgn = Polygon_2 (xcvs.begin(), xcvs.end());

if (pgn.orientation()==CGAL::CLOCKWISE )  <<--failes -Precondition violation.

  pgn.reverse_orientation();
}

void readSegment(std::string s, XCurve& curve)
{
 int t;

 readSegment_field(s,t);
 switch (t)
 {
 case 0: { // line curvesegment
        int sx,sy,ex,ey;
        readSegment_line(s,sx,sy,ex,ey);
                Point_2 ps = Point_2(sx,sy);
        Point_2 pe = Point_2(ex,ey);

        curve = XCurve(ps,pe);

               };break;
 case 1: { //arc  curvesegment
        int sx,sy,mx,my,ex,ey;
                readSegment_arc(s,sx,sy,mx,my,ex,ey);
        Point_2 ps = Point_2(sx,sy);  //startpoint
        Point_2 pm = Point_2(mx,my); //midpoint
        Point_2 pe = Point_2(ex,ey);   //endpoint
        Curve c =Curve( ps,pm,pe);
         curve =
XCurve(c.supporting_circle(),c.source(),c.target(),c.orientation(),0);

         //   curve = XCurve(ps,pe); // this did work perfect if used
instead of above line
               };break;
 case 2: {

               };break;

 } //switch
}

my typedefs :

typedef CGAL::Gmpq                                    Base_nt;
typedef CGAL::Lazy_exact_nt<Base_nt>                  Coord_type;

struct Kernel : public CGAL::Cartesian<Coord_type> {};

typedef Kernel::Point_2                               Point_2;
typedef Kernel::Circle_2                              Circle;
typedef CGAL::Gps_circle_segment_traits_2<Kernel>     Traits;
typedef Traits::Curve_2                               Curve;
typedef Traits::X_monotone_curve_2                    XCurve;
typedef Traits::Point_2                               Circular_point_2;
typedef Traits::Polygon_2                             Polygon_2;

best regards
kim

On Thu, May 14, 2009 at 2:06 PM, Kim Pedersen <> wrote:
> Hi Damian , thank for you interest in my problem .
>
> if it easier or more helpfull , I can attach my full project , just
> let me know if needed
> I had no problem until  I introduced Circle arcs in my X_monotone curves.
>
> typeDefs comes longer down for readability
>
> void ReadPoly(std::istream& is,Polygon_2& pgn, std::string& nextPolyType)
> {
>  XCurve curve;
>  std::list<XCurve>  xcvs;
> ..
> ..
> do //some pseudo code
>       data<<new data from file
>       readSegment(data,curve);
>        xcvs.push_back(curve);
>
> loop until no_more_lines.   //some pseudo code ends
>
> pgn = Polygon_2 (xcvs.begin(), xcvs.end());
>
> if (pgn.orientation()==CGAL::CLOCKWISE )  <<--failes here Precondition
> violation. , se below
>    pgn.reverse_orientation();
> }
>
> void readSegment(std::string s, XCurve& curve)
> {
>  int t;
>
>  readSegment_field(s,t);
>  switch (t)
>  {
>   case 0: {
>          int sx,sy,ex,ey;
>          readSegment_line(s,sx,sy,ex,ey);
>                  Point_2 ps = Point_2(sx,sy);
>          Point_2 pe = Point_2(ex,ey);
>
>          curve = XCurve(ps,pe);
>
>                 };break;
>   case 1: {
>          int sx,sy,mx,my,ex,ey;
>                  readSegment_arc(s,sx,sy,mx,my,ex,ey);
>          Point_2 ps = Point_2(sx,sy);  //startpoint
>          Point_2 pm = Point_2(mx,my); //midpoint
>          Point_2 pe = Point_2(ex,ey);   //endpoint
>          Curve c =Curve( ps,pm,pe);
>           curve = XCurve(c.supporting_circle(),c.source(),c.target(),c.orientation(),0);
>
>           //   curve = XCurve(ps,pe); // this did work perfect if used
> instead of above line
>                 };break;
>   case 2: {
>
>                 };break;
>
>   } //switch
> }
>
> my typedefs :
>
> typedef CGAL::Gmpq                                    Base_nt;
> typedef CGAL::Lazy_exact_nt<Base_nt>                  Coord_type;
>
> struct Kernel : public CGAL::Cartesian<Coord_type> {};
>
> typedef Kernel::Point_2                               Point_2;
> typedef Kernel::Circle_2                              Circle;
> typedef CGAL::Gps_circle_segment_traits_2<Kernel>     Traits;
> typedef Traits::Curve_2                               Curve;
> typedef Traits::X_monotone_curve_2                    XCurve;
> typedef Traits::Point_2                               Circular_point_2;
> typedef Traits::Polygon_2                             Polygon_2;
>
> best regards
> kim
>
> On Thu, May 14, 2009 at 3:26 AM, Damian Sheehy <> wrote:
>> Hi Kim,
>>
>> You need to provide more details.  Which orientation test are you using?
>> CGAL::orientation(ForwardIterator,ForwardIterator)? It takes two arguments.
>>
>>>> if (pgn.orientation()==CGAL::CLOCKWISE )
>> What is png - Portable Network Graphics?
>> Damian
>> On Wed, May 13, 2009 at 5:49 PM, Kim <> wrote:
>>>
>>> Hi
>>> sorry ! this is a repost ,,,  but I am really stopped.
>>>
>>> noone has any idear at all ? any clue is appreciated!
>>> I am sure the start and endpoint are the same ,, since if I input the
>>> same , just as linesegment then it works perfect.
>>>
>>> Why is the polygon below failing when
>>> trying to
>>> if (pgn.orientation()==CGAL::CLOCKWISE )   <-- fails with error , see
>>> below
>>> Precondition violation.
>>>
>>> I can not see any thing wrong !!
>>>
>>> Polygon_2(
>>>  (Circle_2(PointC2(1.74193e+006, 44602.1),
>>> 1.61312e+006,counterclockwise)) [1.74193e+006 43332 --> 1.7432e+006
>>> 44602]
>>>  (Circle_2(PointC2(1.73489e+006, 44595.5),
>>> 6.90773e+007,counterclockwise)) [1.7432e+006 44602 --> 1.73847e+006
>>> 52099]
>>>  (Circle_2(PointC2(1.73792e+006, 50955.1),
>>> 1.60508e+006,counterclockwise)) [1.73847e+006 52099 --> 1.73792e+006
>>> 52222]
>>>  (Circle_2(PointC2(1.73792e+006, 50951.9),
>>> 1.61312e+006,counterclockwise)) [1.73792e+006 52222 --> 1.73665e+006
>>> 50952]
>>>  (Circle_2(PointC2(1.73792e+006, 50952),
>>> 1.61415e+006,counterclockwise)) [1.73665e+006 50952 --> 1.73737e+006
>>> 49805]
>>>  (Circle_2(PointC2(1.73491e+006, 44606.1), 3.31029e+007,
>>> clockwise))[1.73737e+006 49805 --> 1.74066e+006 44602]
>>>  (Circle_2(PointC2(1.74193e+006, 44602.1),
>>> 1.61312e+006,counterclockwise)) [1.74066e+006 44602 --> 1.74193e+006
>>> 43332]
>>> )
>>> CGAL error: precondition violation!
>>> _expression_ : cv1.point_position (p) == EQUAL && cv2.point_position (p) ==
>>> EQUAL
>>> File       : c:\cgal\cgal-3.4\include\cgal\arr_circle_segment_traits_2.h
>>> Line       : 249
>>> Explanation:
>>> Refer to the bug-reporting instructions at
>>> http://www.cgal.org/bug_report.html
>>>
>>> I did use this way to calc the  the curves:
>>>
>>> Point_2 ps = Point_2(sx,sy);  //start
>>> Point_2 pm = Point_2(mx,my);  //midpoint
>>> Point_2 pe = Point_2(ex,ey);  //endpoint
>>> Curve c =Curve( ps,pm,pe);
>>> curve =
>>> XCurve(c.supporting_circle(),c.source(),c.target(),c.orientation(),0);
>>>
>>> TIA
>>> Kim
>>> --
>>> You are currently subscribed to cgal-discuss.
>>> To unsubscribe or access the archives, go to
>>> https://lists-sop.inria.fr/wws/info/cgal-discuss
>>
>>
>
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss




Archive powered by MHonArc 2.6.16.

Top of Page