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 23:28:30 -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=LSJRr1XjaH+HSoI4PtMt9zfEMaql7qmji0+vxe5cAPQ5l2pacVPDqZ0DAYJGMCoWpG pYBSAxfKGrAeKwc8vf74ZRSN5Plp1UncF2IitrpKg/WA8UxSp333DqJjgPdOt3tTMkCQ 1p1Wur1R3bHcOpMvG5p4CGynrYxq4i78AxcEo=

OK. I thought you were using CGAL::Polygon_2.
 
Damian
On Thu, May 14, 2009 at 10:59 PM, Kim <> wrote:
Hi Damian

Sorry to say , I don't have that function . here is my typedef's ,,,

typedef CGAL::Gmpq                                    Base_nt;
typedef CGAL::Lazy_exact_nt<Base_nt>                  Coord_type;
struct Kernel : public CGAL::Cartesian<Coord_type> {};
typedef CGAL::Gps_circle_segment_traits_2<Kernel>     Traits;
typedef Traits::Polygon_2                             Polygon_2;


regarding the graphic , I have routines to show the polygons before I
input it and after output  (using 3points arcs), but since I have to
make an interpretation of the polygondata , it could lead to wrong
result so it  just would be nice if someone had a viewer to the cgal
format already :) .



Best regards
kim

On Fri, May 15, 2009 at 12:56 AM, Damian Sheehy <> wrote:
> Hi Kim,
>
> According to the code you posted
>>> void ReadPoly(std::istream& is,Polygon_2& pgn, std::string& nextPolyType)
>
> pgn is of type Polygon_2 which has a is_simple() function.
> If you cannot view your polygon, then you are working in the dark.
> I think you should get some basic plotting capability in place to visually
> inspect your polygon, and then work from there.
>
>
> Good luck!
>
>
> Damian
>
> On Thu, May 14, 2009 at 5:12 PM, Kim <> wrote:
>>
>> Hi Damian ..
>>
>> Ones again , thanks for your time .
>>
>> Unfortunately "is_simple" is not member pgn
>>
>> Error   1       error C2039: 'is_simple' : is not a member of
>> 'CGAL::General_polygon_2<Arr_traits>'
>> c:\cgal\projects\likedemo\likedemo\likedemo\likedemo.cpp        117
>>  likedemo
>>
>>
>> 7 (1.74193e+006 44602.1 1.61312e+006 1) [1.74193e+006 43332 -->
>> 1.7432e+006 44602]
>>  (1.73489e+006 44595.5 6.90773e+007 1) [1.7432e+006 44602 -->
>> 1.73847e+006 52099]
>>  (1.73792e+006 50955.1 1.60508e+006 1) [1.73847e+006 52099 -->
>> 1.73792e+006 52222]
>>  (1.73792e+006 50951.9 1.61312e+006 1) [1.73792e+006 52222 -->
>> 1.73665e+006 50952]
>>  (1.73792e+006 50952 1.61415e+006 1) [1.73665e+006 50952 --> 1.73737e+006
>> 49805]
>>  (1.73491e+006 44606.1 3.31029e+007 -1) [1.73737e+006 49805 -->
>> 1.74066e+006 44602]
>>  (1.74193e+006 44602.1 1.61312e+006 1) [1.74066e+006 44602 -->
>> 1.74193e+006 43332]
>>
>>
>> as you see, it consist of 7 segments , both start and end are the same
>>  and the 7 arc as I sent into
>> as a 3 points arcs they  are not intersecting .
>>
>>
>> Do anyone have maded a graphic reader for this format which could
>> check the view.
>> (Did not get the QT to work ) .
>>
>> I will try to make a more simple polygon with only one arc and see how
>> that goes.
>>
>> Best regards
>> Kim
>>
>> On Thu, May 14, 2009 at 6:59 PM, Damian Sheehy <>
>> wrote:
>> > 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
>> >
>> >
>> --
>> 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