From ed35455ecedc930a8d6a92476d8609cf07f6b51d Mon Sep 17 00:00:00 2001 From: Ester Ezra Date: Wed, 7 Aug 2002 14:17:40 +0000 Subject: [PATCH] Creating a boolean operations object from map overlay. It gives the user the possibility to create the boolean oepration object with the walk along aline point-location, which is more efficient when using sweep-line. --- .../examples/Boolean_operations_2/example2.C | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 Packages/Map_overlay_2/examples/Boolean_operations_2/example2.C diff --git a/Packages/Map_overlay_2/examples/Boolean_operations_2/example2.C b/Packages/Map_overlay_2/examples/Boolean_operations_2/example2.C new file mode 100644 index 00000000000..70197f90735 --- /dev/null +++ b/Packages/Map_overlay_2/examples/Boolean_operations_2/example2.C @@ -0,0 +1,112 @@ +#include //CGAL definitions that need to be before anything else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// uncomment if LEDA is installed. +//#include //used for visualization - +//#include + +typedef CGAL::Quotient NT; +typedef CGAL::Cartesian R; +typedef CGAL::Arr_segment_exact_traits Traits; +typedef Traits::Point Point; +typedef Traits::X_curve X_curve; +typedef Traits::Curve Curve; + +typedef CGAL::Bop_default_dcel Dcel; +typedef CGAL::Planar_map_2 Planar_map; +typedef CGAL::Map_overlay_2 MapOverlay; +typedef CGAL::Boolean_operations_2 Bops; +typedef CGAL::Pm_walk_along_line_point_location PmWalkPL; + +typedef Bops::Faces_container Faces_container; +typedef Bops::Halfedges_container Halfedges_container; +typedef Bops::Vertices_container Vertices_container; + + +using std::cin; +using std::cout; +using std::endl; + +int main() +{ + Planar_map pm1, pm2; + int num_curves1, num_curves2; + + NT x1, y1, x2, y2; + + cin >> num_curves1; + std::vector curves; + + while (num_curves1--) { + cin >> x1 >> y1 >> x2 >> y2; + + Point p1(x1,y2), p2(x2,y2); + curves.push_back(X_curve(p1, p2)); + } + + Traits traits; + CGAL::sweep_to_construct_planar_map_2(curves.begin(), + curves.end(), traits, pm1); + + curves.clear(); + + cin >> num_curves2; + while (num_curves2--) { + cin >> x1 >> y1 >> x2 >> y2; + + Point p1(x1,y2), p2(x2,y2); + curves.push_back(X_curve(p1, p2)); + } + + CGAL::sweep_to_construct_planar_map_2(curves.begin(), + curves.end(), traits, pm2); + + // ignoring unbounded face in boolean operations. + pm1.unbounded_face()->set_ignore_bop(false); + pm2.unbounded_face()->set_ignore_bop(false); + + PmWalkPL ovl_walk; + MapOverlay map1(pm1), map2(pm2); + MapOverlay map_overlay(map1, map2, &ovl_walk); + cout<<"Creating a boolean-operation object efficiently"<curve() << endl; + + // uncomment if LEDA is installed. + //CGAL::Window_stream W(700, 700); + //W.init(-10,10,-10); + //W.set_node_width(3); + //W.display(); + + //W<curve(); + //} + + return 0; +} +