diff --git a/Packages/Arrangement/examples/Sweep_line/example2.C b/Packages/Arrangement/examples/Sweep_line/example2.C index fae3b5171fc..148f1cfa1c3 100644 --- a/Packages/Arrangement/examples/Sweep_line/example2.C +++ b/Packages/Arrangement/examples/Sweep_line/example2.C @@ -16,7 +16,6 @@ #include #include -#include //uncomment if you have LEDA installed. @@ -28,7 +27,7 @@ //#endif //#include //used for visualization. -using namespace std; +//using namespace std; typedef CGAL::Quotient NT; typedef CGAL::Cartesian R; @@ -40,6 +39,46 @@ typedef Traits::Curve Curve; typedef CGAL::Pm_default_dcel Dcel; typedef CGAL::Planar_map_2 PM; +typedef CGAL::Pm_file_writer Pm_writer; + + +CGAL_BEGIN_NAMESPACE + +std::ostream& operator<<(std::ostream& os, + const Curve& cv) +{ + typedef Curve::const_iterator Points_iterator; + + os<>(std::istream& in, + Curve& cv) +{ + typedef Curve::value_type Point; + + std::size_t size; + + in >> size; + + for (unsigned int i = 0; i < size; i++){ + Point p; + + in >> p; + + cv.push_back(p); + } + + return in; +} + +CGAL_END_NAMESPACE template void read_polylines(Container& curves) @@ -52,33 +91,27 @@ void read_polylines(Container& curves) while (num_polylines--) { Curve polyline; - int num_points; - - std::cin >> num_points; - - while (num_points--) { - std::cin >> x >> y; - Point s(x, y); - - polyline.push_back(s); - } + std::cin>>polyline; curves.push_back(polyline); - - polyline.clear(); } } -int main(int argc, char* argv[]) +int main(/*int argc, char* argv[]*/) { PM pm; - vector polylines; + std::vector polylines; read_polylines(polylines); CGAL::sweep_to_construct_planar_map(polylines.begin(),polylines.end(), pm); - std::cout << pm; + std::cout << " * * * Printing list of all halfedges of the resulting Planar map" << endl; + + Pm_writer verbose_writer(cout, pm, true); + + verbose_writer.write_halfedges(pm.halfedges_begin(), pm.halfedges_end()); + //CGAL::Window_stream W(700, 700); //W.init(-10, 10, -10); diff --git a/Packages/Arrangement/examples/Sweep_line/example4.C b/Packages/Arrangement/examples/Sweep_line/example4.C index fb40772e1ee..b3ddc0830ae 100644 --- a/Packages/Arrangement/examples/Sweep_line/example4.C +++ b/Packages/Arrangement/examples/Sweep_line/example4.C @@ -14,11 +14,9 @@ #include #include -#include +//#include -using namespace std; - typedef CGAL::Quotient NT; typedef CGAL::Cartesian R; typedef CGAL::Arr_polyline_traits Traits; @@ -29,6 +27,46 @@ typedef Traits::Curve Curve; using namespace std; + +CGAL_BEGIN_NAMESPACE + +std::ostream& operator<<(std::ostream& os, + const Curve& cv) +{ + typedef Curve::const_iterator Points_iterator; + + os<>(std::istream& in, + Curve& cv) +{ + typedef Curve::value_type Point; + + std::size_t size; + + in >> size; + + for (unsigned int i = 0; i < size; i++){ + Point p; + + in >> p; + + cv.push_back(p); + } + + return in; +} + +CGAL_END_NAMESPACE + + template void read_polylines(Container& curves) { @@ -40,16 +78,19 @@ void read_polylines(Container& curves) while (num_polylines--) { Curve polyline; - int num_points; - cin >> num_points; - - while (num_points--) { - cin >> x >> y; - Point s(x, y); - - polyline.push_back(s); - } + /* int num_points; + + cin >> num_points; + + while (num_points--) { + cin >> x >> y; + Point s(x, y); + + polyline.push_back(s); + }*/ + + std::cin>>polyline; curves.push_back(polyline); @@ -57,7 +98,7 @@ void read_polylines(Container& curves) } } -int main(int argc, char* argv[]) +int main(/*int argc, char* argv[]*/) { list polylines; @@ -67,10 +108,9 @@ int main(int argc, char* argv[]) list subcurves; CGAL::sweep_to_produce_planar_map_subcurves(polylines.begin(),polylines.end(), traits, subcurves); - for (list::iterator scv_iter = subcurves.begin(); scv_iter != subcurves.end(); scv_iter++) + for (list::iterator scv_iter = subcurves.begin(); scv_iter != subcurves.end(); scv_iter++) cout<<*scv_iter<