Subject: CGAL users discussion list
List archive
- From: Pedro Machado Manhães de Castro <>
- To:
- Subject: Re: [cgal-discuss] Error with intersection in boolean set operations
- Date: Mon, 22 Jun 2009 12:37:20 +0200
- 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=TLESVCubxkyrvS8v4F/atLWk+C9U5rQHsK6aQL/KhyMN+GfKicEwR49/uVvg9nfqOA jbA1p4G52WTXqeoBOVhAOmaxTz0TqayAFV0n0yVuWpZ7L4pPmKjeg+ahUebtpAvg1/ew vKCPA8BSPKK5zrFTmxCULvFKszVCIokc6XSes=
I think you are probably choosing the wrong number type.
Read http://www.cgal.org/FAQ.html#inexact_NT .
CGAL::Simple_cartesian<double> // Inexact Number Type
Cheers,
Pedro Machado Manhaes de Castro
Hi All,I have the following error in the intersection boolean set operation:CGAL error: precondition violation!
Expr: cv1.point_position (p) == EQUAL && cv2.point_position (p) == EQUAL
File: C:\Archivos de programa\CGAL-3.3.1\include\CGAL/Arr_circle_segment_traits_
2.h
Line: 247
I have used a test program than compute a simple intersection as show in the figurewith this the program code:#include "bso_rational_nt.h"
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Gps_circle_segment_traits_2.h>
#include <CGAL/General_polygon_set_2.h>
#include <CGAL/General_polygon_with_holes_2.h>
#include <CGAL/Lazy_exact_nt.h>
#include <CGAL/squared_distance_2.h>
#include <CGAL/Object.h>
#include <CGAL/intersections.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <CGAL/enum.h>
enum Sign { NEGATIVE, ZERO, POSITIVE};
typedef Sign Orientation;
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Circle_2 Circle_2;
typedef Kernel::Line_2 Line_2;
typedef Kernel::Segment_2 Segment_2;
typedef CGAL::Gps_circle_segment_traits_2<Kernel> Traits_2;
typedef CGAL::General_polygon_set_2<Traits_2> Polygon_set_2;
typedef Traits_2::Polygon_with_holes_2 Polygon_with_holes_2;
typedef Traits_2::Curve_2 Curve_2;
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
typedef Traits_2::Point_2 TPoint_2;
typedef Polygon_with_holes_2::General_polygon_2 Polygon_2;
int main (int argc, char * argv[])
{
std::list<Polygon_2> polygons;
Polygon_2 pgn;
X_monotone_curve_2 s1(Point_2(449.268,624.272),Point_2(128.151,1180.46));
pgn.push_back(s1);
X_monotone_curve_2 s2(Point_2(128.151,1180.46),Point_2(-514.084,1180.46));
pgn.push_back(s2);
X_monotone_curve_2 s3(Point_2(-514.084,1180.46),Point_2(-835.202,624.272));
pgn.push_back(s3);
X_monotone_curve_2 s4(Point_2(-835.202,624.272),Point_2(-514.084,68.0801));
pgn.push_back(s4);
X_monotone_curve_2 s5(Point_2(-514.084,68.0801),Point_2(128.151,68.0801));
pgn.push_back(s5);
X_monotone_curve_2 s6(Point_2(128.151,68.0801),Point_2(449.268,624.272));
pgn.push_back(s6);
polygons.push_back (pgn);
Polygon_2 pgn2;
X_monotone_curve_2 r1(Point_2(101,2),Point_2(1,102));
pgn2.push_back(r1);
X_monotone_curve_2 r2(Point_2(1,102),Point_2(-99,2));
pgn2.push_back(r2);
X_monotone_curve_2 r3(Point_2(-99,2),Point_2(1,-98));
pgn2.push_back(r3);
X_monotone_curve_2 r4(Point_2(1,-98),Point_2(101,2));
pgn2.push_back(r4);
polygons.push_back (pgn2);
std::list<Polygon_with_holes_2> res;
// HERE IS THE ERROR
CGAL::intersection (polygons.begin(), polygons.end(), std::back_inserter (res));
std::copy (res.begin(), res.end(),
std::ostream_iterator<Polygon_with_holes_2>(std::cout, "\n"));
std::cout << std::endl;
system("pause");
return 0;
}
Otherwise I really want compute the intersection of polygons that support both circle and line segments. An test example is the next:with this the program code:#include "bso_rational_nt.h"
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Gps_circle_segment_traits_2.h>
#include <CGAL/General_polygon_set_2.h>
#include <CGAL/General_polygon_with_holes_2.h>
#include <CGAL/Lazy_exact_nt.h>
#include <CGAL/squared_distance_2.h>
#include <CGAL/Object.h>
#include <CGAL/intersections.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <CGAL/enum.h>
enum Sign { NEGATIVE, ZERO, POSITIVE};
typedef Sign Orientation;
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Circle_2 Circle_2;
typedef Kernel::Line_2 Line_2;
typedef Kernel::Segment_2 Segment_2;
typedef CGAL::Gps_circle_segment_traits_2<Kernel> Traits_2;
typedef CGAL::General_polygon_set_2<Traits_2> Polygon_set_2;
typedef Traits_2::Polygon_with_holes_2 Polygon_with_holes_2;
typedef Traits_2::Curve_2 Curve_2;
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
typedef Traits_2::Point_2 TPoint_2;
typedef Polygon_with_holes_2::General_polygon_2 Polygon_2;
Polygon_2 construct_polygon (const Circle_2& circle)
{
// Subdivide the circle into two x-monotone arcs.
Traits_2 traits;
Curve_2 curve (circle);
std::list<CGAL::Object> objects;
traits.make_x_monotone_2_object() (curve, std::back_inserter(objects));
CGAL_assertion (objects.size() == 2);
// Construct the polygon.
Polygon_2 pgn;
X_monotone_curve_2 arc;
std::list<CGAL::Object>::iterator iter;
for (iter = objects.begin(); iter != objects.end(); ++iter) {
CGAL::assign (arc, *iter);
pgn.push_back (arc);
}
return pgn;
}
int main (int argc, char * argv[])
{
std::list<Polygon_2> circles;
Polygon_2 pgn;
X_monotone_curve_2 s1(Point_2(88,49),Point_2(53,87));
pgn.push_back(s1);
X_monotone_curve_2 s2(Point_2(53,87),Point_2(3,101));
pgn.push_back(s2);
X_monotone_curve_2 s3(Point_2(3,101),Point_2(-46,89));
pgn.push_back(s3);
X_monotone_curve_2 s4(Point_2(-46,89),Point_2(-84,54));
pgn.push_back(s4);
X_monotone_curve_2 s5(Point_2(-84,54),Point_2(-98,4));
pgn.push_back(s5);
X_monotone_curve_2 s6(Point_2(-98,4),Point_2(-86,-45));
pgn.push_back(s6);
X_monotone_curve_2 s7(Point_2(-86,-45),Point_2(-51,-83));
pgn.push_back(s7);
X_monotone_curve_2 s8(Point_2(-51,-83),Point_2(-1,-97));
pgn.push_back(s8);
X_monotone_curve_2 s9(Point_2(-1,-97),Point_2(48,-85));
pgn.push_back(s9);
X_monotone_curve_2 s10(Point_2(48,-85),Point_2(86,-50));
pgn.push_back(s10);
X_monotone_curve_2 s11(Point_2(86,-50),Point_2(100,0));
pgn.push_back(s11);
X_monotone_curve_2 s12(Point_2(100,0),Point_2(88,49));
pgn.push_back(s12);
circles.push_back (pgn);
circles.push_back (construct_polygon (Circle_2(Point_2(-192.967,624.272), 412465.795225)));
std::list<Polygon_with_holes_2> res;
// HERE IS THE ERROR
CGAL::intersection (circles.begin(), circles.end(), std::back_inserter (res));
std::copy (res.begin(), res.end(),
std::ostream_iterator<Polygon_with_holes_2>(std::cout, "\n"));
std::cout << std::endl;
system("pause");
return 0;
}
With the same errorCan anybody help me ? I already don´t know where it is the problem.ThanksFrancisco
- [cgal-discuss] Error with intersection in boolean set operations, Francisco Miguel Romero Medina, 06/22/2009
- Re: [cgal-discuss] Error with intersection in boolean set operations, Pedro Machado Manhães de Castro, 06/22/2009
Archive powered by MHonArc 2.6.16.