diff --git a/Packages/Sweep_line_2/examples/Sweep_line_2/example1.C b/Packages/Sweep_line_2/examples/Sweep_line_2/example1.C index 30be93ec212..1eec3808d9e 100644 --- a/Packages/Sweep_line_2/examples/Sweep_line_2/example1.C +++ b/Packages/Sweep_line_2/examples/Sweep_line_2/example1.C @@ -1,5 +1,28 @@ // examples/Sweep_line/example1.C // ------------------------------ + +#if defined(CGAL_CFG_NO_LONGNAME_PROBLEM) || defined(_MSC_VER) +// Define shorter names to please linker (g++/egcs) +#define Arrangement_2 _Ar +#define Cartesian _Cr +#define Quotient _Qt +#define Planar_map_2 _PM +#define Point_2 _Pt +#define allocator _All +#define Pm_default_dcel _PDD +#define Arr_segment_exact_traits _AST +#define Segment_2 _Sg +#define Pm_change_notification _PCN +#define Sweep_curves_base_2 _SCB +#define _Rb_tree _RT +#define Sweep_curves_to_planar_map_utils _SCPMU +#define X_curve_plus_id _XCPI +#define sweep_to_construct_planar_map_2 _SCPM +#define vector_iterator _VI +#define Point_plus_handle _PPH +#define Intersection_point_node _IPN +#endif + #include #include #include @@ -35,7 +58,6 @@ int main() std::cout << " * * * Demonstrating a trivial use of the sweep line algorithm" << std::endl << std::endl; - // Read input std::cin >> num_segments; @@ -44,10 +66,8 @@ int main() while (num_segments--) { std::cin >> x1 >> y1 >> x2 >> y2; - segments.push_back(Curve(Point(x1, y1), Point(x2, y2))); } - // Construct the planar map Traits traits; CGAL::sweep_to_construct_planar_map_2(segments.begin(), segments.end(), @@ -59,7 +79,7 @@ int main() Pm_writer verbose_writer(std::cout, pm, true); verbose_writer.write_halfedges(pm.halfedges_begin(), pm.halfedges_end()); - + // Use a window visualization // CGAL::Window_stream W(700, 700, "CGAL Sweep Line Example"); // W.init(-10, 10, -10); @@ -67,4 +87,6 @@ int main() // W.display(); // W << pm; // W.read_mouse(); + + return 0; } diff --git a/Packages/Sweep_line_2/examples/Sweep_line_2/example2.C b/Packages/Sweep_line_2/examples/Sweep_line_2/example2.C index 90ce5db966d..343ec737c73 100644 --- a/Packages/Sweep_line_2/examples/Sweep_line_2/example2.C +++ b/Packages/Sweep_line_2/examples/Sweep_line_2/example2.C @@ -12,7 +12,6 @@ #include // #include - // #include // #include @@ -30,8 +29,7 @@ typedef CGAL::Pm_file_writer Pm_writer; CGAL_BEGIN_NAMESPACE -std::ostream& operator<<(std::ostream& os, - const Curve& cv) +std::ostream & operator<<(std::ostream & os, const Curve & cv) { typedef Curve::const_iterator Points_iterator; @@ -43,19 +41,14 @@ std::ostream& operator<<(std::ostream& os, return os; } - -std::istream& operator>>(std::istream& in, - Curve& cv) +std::istream & operator>>(std::istream & in, Curve & cv) { - std::size_t size; - + std::size_t size; in >> size; for (unsigned int i = 0; i < size; i++){ - Point p; - + Point p; in >> p; - cv.push_back(p); } @@ -93,7 +86,7 @@ int main() // Construct the planar map Traits traits; CGAL::sweep_to_construct_planar_map_2(polylines.begin(),polylines.end(), - traits, pm); + traits, pm); // Write output std::cout << " * * * Printing list of all halfedges of the resulting "; @@ -110,9 +103,6 @@ int main() // W.button("Finish",2); // W.display(); // W << pm; + + return 0; } - - - - - diff --git a/Packages/Sweep_line_2/examples/Sweep_line_2/example3.C b/Packages/Sweep_line_2/examples/Sweep_line_2/example3.C index 8f18dcc7a45..3fb68188748 100644 --- a/Packages/Sweep_line_2/examples/Sweep_line_2/example3.C +++ b/Packages/Sweep_line_2/examples/Sweep_line_2/example3.C @@ -1,5 +1,6 @@ // examples/Sweep_line/example3.C // ------------------------------ + #include #include #include @@ -19,10 +20,8 @@ typedef Traits::Curve Curve; int main() { // Read input - int num_segments; std::list segments; - std::cin >> num_segments; NT x1, y1, x2, y2; @@ -30,8 +29,7 @@ int main() while (num_segments--) { std::cin >> x1 >> y1 >> x2 >> y2; - - segments.push_back(Curve(Point(x1,y1), Point(x2,y2))); + segments.push_back(Curve(Point(x1, y1), Point(x2, y2))); } // Use a sweep to create the sub curves @@ -44,11 +42,13 @@ int main() // Write output - std::cout<<"The number of disjoint interior sub segments is "<< subcurves.size(); - std::cout<< std::endl; + std::cout <<"The number of disjoint interior sub segments is " + << subcurves.size(); + std::cout << std::endl; for (std::list::iterator scv_iter = subcurves.begin(); - scv_iter != subcurves.end(); - scv_iter++) + scv_iter != subcurves.end(); scv_iter++) std::cout<< *scv_iter<< std::endl; + + return 0; } diff --git a/Packages/Sweep_line_2/examples/Sweep_line_2/example4.C b/Packages/Sweep_line_2/examples/Sweep_line_2/example4.C index 953f44d7797..bf082cafbd7 100644 --- a/Packages/Sweep_line_2/examples/Sweep_line_2/example4.C +++ b/Packages/Sweep_line_2/examples/Sweep_line_2/example4.C @@ -1,5 +1,6 @@ // examples/Sweep_line/example4.C // ------------------------------ + #include #include #include @@ -20,10 +21,9 @@ typedef Traits::Curve Curve; CGAL_BEGIN_NAMESPACE -std::ostream& operator<<(std::ostream& os, - const Curve& cv) +std::ostream & operator<<(std::ostream & os, const Curve & cv) { - typedef Curve::const_iterator Points_iterator; + typedef Curve::const_iterator Points_iterator; os<>(std::istream& in, - Curve& cv) +std::istream & operator>>(std::istream & in, Curve & cv) { std::size_t size; - in >> size; for (unsigned int i = 0; i < size; i++){ Point p; - in >> p; - cv.push_back(p); } - return in; } @@ -57,7 +51,7 @@ CGAL_END_NAMESPACE // Read polylines from the input template -void read_polylines(Container& curves) +void read_polylines(Container & curves) { int num_polylines = 0; @@ -65,38 +59,28 @@ void read_polylines(Container& curves) std::cout<<"number of polylines is : " << num_polylines<>polyline; - curves.push_back(polyline); - polyline.clear(); } } - int main() { // Read input - std::list polylines; - read_polylines(polylines); // Use a sweep to create the sub curves - Traits traits; std::list subcurves; CGAL::sweep_to_produce_subcurves_2(polylines.begin(),polylines.end(), traits, std::back_inserter(subcurves)); // Write output - for (std::list::iterator scv_iter = subcurves.begin(); scv_iter != subcurves.end(); scv_iter++) - std::cout<<*scv_iter< #include #include @@ -11,22 +12,19 @@ #include #include - #include #include -#include //used for visualization. +#include +typedef CGAL::Quotient NT; +typedef CGAL::Cartesian Kernel; +typedef CGAL::Arr_segment_exact_traits Traits; -typedef CGAL::Quotient NT; -typedef CGAL::Cartesian Kernel; -typedef CGAL::Arr_segment_exact_traits Traits; - -typedef Traits::Point Point; -typedef Traits::Curve Curve; - -typedef CGAL::Pm_default_dcel Dcel; -typedef CGAL::Planar_map_2 PM; +typedef Traits::Point Point; +typedef Traits::Curve Curve; +typedef CGAL::Pm_default_dcel Dcel; +typedef CGAL::Planar_map_2 PM; int main() { @@ -38,20 +36,16 @@ int main() std::cout << "algorithm" << std::endl << std::endl; // Read input - std::cin >> num_segments; while (num_segments--) { Curve cv; - std::cin >> cv; - segments.push_back(cv); } // Use a sweep to find the points induced in the arrangement - std::vector points; Traits traits; CGAL::sweep_to_produce_points_2(segments.begin(), @@ -60,7 +54,6 @@ int main() std::back_inserter(points)); // Write output - std::cout << " * * * Printing list of all points in the arrangement "; std::cout << "induced by the input segments" << std::endl; @@ -68,9 +61,5 @@ int main() p_iter != points.end(); ++p_iter) std::cout<< *p_iter << std::endl; + return 0; } - - - - -