mirror of https://github.com/CGAL/cgal
Cleanup
This commit is contained in:
parent
1e199cb2fc
commit
6b8bd7ddb6
|
|
@ -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 <CGAL/Cartesian.h>
|
||||
#include <CGAL/MP_Float.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
#include <vector>
|
||||
|
||||
// #include <CGAL/IO/cgal_window.h>
|
||||
|
||||
// #include <CGAL/IO/Pm_Window_stream.h>
|
||||
// #include <CGAL/IO/Arr_polyline_traits_Window_stream.h>
|
||||
|
||||
|
|
@ -30,8 +29,7 @@ typedef CGAL::Pm_file_writer<PM> 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// examples/Sweep_line/example3.C
|
||||
// ------------------------------
|
||||
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/MP_Float.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
|
|
@ -19,10 +20,8 @@ typedef Traits::Curve Curve;
|
|||
int main()
|
||||
{
|
||||
// Read input
|
||||
|
||||
int num_segments;
|
||||
std::list<Curve> 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<Curve>::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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// examples/Sweep_line/example4.C
|
||||
// ------------------------------
|
||||
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/MP_Float.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
|
|
@ -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<<cv.size()<<std::endl;
|
||||
for (Points_iterator points_iter = cv.begin();
|
||||
|
|
@ -33,22 +33,16 @@ 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;
|
||||
|
||||
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 <class Container>
|
||||
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<<std::endl;
|
||||
|
||||
while (num_polylines--) {
|
||||
Curve polyline;
|
||||
|
||||
Curve polyline;
|
||||
std::cin>>polyline;
|
||||
|
||||
curves.push_back(polyline);
|
||||
|
||||
polyline.clear();
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// Read input
|
||||
|
||||
std::list<Curve> polylines;
|
||||
|
||||
read_polylines(polylines);
|
||||
|
||||
// Use a sweep to create the sub curves
|
||||
|
||||
Traits traits;
|
||||
std::list<Curve> subcurves;
|
||||
CGAL::sweep_to_produce_subcurves_2(polylines.begin(),polylines.end(),
|
||||
traits, std::back_inserter(subcurves));
|
||||
|
||||
// Write output
|
||||
|
||||
for (std::list<Curve>::iterator scv_iter = subcurves.begin();
|
||||
scv_iter != subcurves.end(); scv_iter++)
|
||||
std::cout<<*scv_iter<<std::endl;
|
||||
std::cout << *scv_iter << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// examples/Sweep_line/example5.C
|
||||
// ------------------------------
|
||||
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/MP_Float.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
|
|
@ -11,22 +12,19 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include <CGAL/IO/Segment_circle_Window_stream.h>
|
||||
#include <CGAL/IO/Pm_Window_stream.h>
|
||||
#include <CGAL/IO/cgal_window.h> //used for visualization.
|
||||
#include <CGAL/IO/cgal_window.h>
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT;
|
||||
typedef CGAL::Cartesian<NT> Kernel;
|
||||
typedef CGAL::Arr_segment_exact_traits<Kernel> Traits;
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT;
|
||||
typedef CGAL::Cartesian<NT> Kernel;
|
||||
typedef CGAL::Arr_segment_exact_traits<Kernel> Traits;
|
||||
|
||||
typedef Traits::Point Point;
|
||||
typedef Traits::Curve Curve;
|
||||
|
||||
typedef CGAL::Pm_default_dcel<Traits> Dcel;
|
||||
typedef CGAL::Planar_map_2<Dcel, Traits> PM;
|
||||
typedef Traits::Point Point;
|
||||
typedef Traits::Curve Curve;
|
||||
|
||||
typedef CGAL::Pm_default_dcel<Traits> Dcel;
|
||||
typedef CGAL::Planar_map_2<Dcel,Traits> 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<Point> 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue