mirror of https://github.com/CGAL/cgal
Moving all files to teh new package Sweep_line_2.
This commit is contained in:
parent
fafa02cc4d
commit
35dba89284
|
|
@ -1,71 +0,0 @@
|
|||
// examples/Sweep_line/example1.C
|
||||
// ------------------------------
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
|
||||
#include <CGAL/Pm_default_dcel.h>
|
||||
#include <CGAL/Planar_map_2.h>
|
||||
|
||||
#include <CGAL/Arr_segment_exact_traits.h>
|
||||
|
||||
#include <CGAL/sweep_to_construct_planar_map.h>
|
||||
|
||||
#include <CGAL/IO/Pm_iostream.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
//uncomment if you have LEDA installed.
|
||||
//#include <CGAL/IO/Pm_Window_stream.h>
|
||||
//#include <CGAL/IO/leda_window.h> //used for visualization.
|
||||
|
||||
typedef CGAL::Quotient<int> NT;
|
||||
typedef CGAL::Cartesian<NT> R;
|
||||
|
||||
typedef CGAL::Arr_segment_exact_traits<R> Traits;
|
||||
|
||||
typedef Traits::Point Point;
|
||||
typedef Traits::X_curve X_curve;
|
||||
typedef Traits::Curve Curve;
|
||||
|
||||
typedef CGAL::Pm_default_dcel<Traits> Dcel;
|
||||
typedef CGAL::Planar_map_2<Dcel, Traits> PM;
|
||||
typedef CGAL::Pm_file_writer<PM> Pm_writer;
|
||||
|
||||
using std::cout;
|
||||
using std::cin;
|
||||
using std::endl;
|
||||
using std::vector;
|
||||
|
||||
int main()
|
||||
{
|
||||
PM pm;
|
||||
int num_segments;
|
||||
vector<Curve> segments;
|
||||
|
||||
cout << " * * * Demonstrating a trivial use of the sweep line algorithm" << endl <<endl;
|
||||
|
||||
cin >> num_segments;
|
||||
|
||||
NT x1, y1, x2, y2;
|
||||
|
||||
while (num_segments--) {
|
||||
cin >> x1 >> y1 >> x2 >> y2;
|
||||
|
||||
segments.push_back(Curve(Point(x1,y1), Point(x2,y2)));
|
||||
}
|
||||
|
||||
CGAL::sweep_to_construct_planar_map(segments.begin(),segments.end(), pm);
|
||||
|
||||
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);
|
||||
//W.set_mode(leda_src_mode);
|
||||
//W.set_node_width(3);
|
||||
//W.display();
|
||||
//W << pm;
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
4
|
||||
0 0 1 1
|
||||
0 1 1 0
|
||||
0 0 1 0
|
||||
0 1 1 1
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
* * * Demonstrating a trivial use of the sweep line algorithm
|
||||
|
||||
* * * Printing list of all halfedges of the resulting Planar map
|
||||
-1/-2 -1/-2
|
||||
0/1 1/1 -1/-2 -1/-2
|
||||
0/1 1/1
|
||||
0/1 1/1 -1/-2 -1/-2
|
||||
-1/-2 -1/-2
|
||||
0/1 0/1 -1/-2 -1/-2
|
||||
0/1 0/1
|
||||
0/1 0/1 -1/-2 -1/-2
|
||||
-1/-2 -1/-2
|
||||
-1/-2 -1/-2 1/1 0/1
|
||||
1/1 0/1
|
||||
-1/-2 -1/-2 1/1 0/1
|
||||
0/1 0/1
|
||||
0/1 0/1 1/1 0/1
|
||||
1/1 0/1
|
||||
0/1 0/1 1/1 0/1
|
||||
0/1 1/1
|
||||
0/1 1/1 1/1 1/1
|
||||
1/1 1/1
|
||||
0/1 1/1 1/1 1/1
|
||||
-1/-2 -1/-2
|
||||
-1/-2 -1/-2 1/1 1/1
|
||||
1/1 1/1
|
||||
-1/-2 -1/-2 1/1 1/1
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
// examples/Sweep_line/example2.C
|
||||
// ------------------------------
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
|
||||
#include <CGAL/Pm_default_dcel.h>
|
||||
#include <CGAL/Planar_map_2.h>
|
||||
|
||||
#include <CGAL/sweep_to_construct_planar_map.h>
|
||||
|
||||
#include <CGAL/Arr_polyline_traits.h>
|
||||
|
||||
#include <CGAL/IO/Pm_iostream.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
//uncomment if you have LEDA installed.
|
||||
//#ifndef CGAL_IO_PM_WINDOW_STREAM_H
|
||||
//#include <CGAL/IO/Pm_Window_stream.h>
|
||||
//#endif
|
||||
//#ifndef CGAL_ARR_POLYLINE_TRAITS_WINDOW_STREAM_H
|
||||
//#include <CGAL/IO/Arr_polyline_traits_Window_stream.h>
|
||||
//#endif
|
||||
//#include <CGAL/IO/leda_window.h> //used for visualization.
|
||||
|
||||
using namespace CGAL;
|
||||
|
||||
|
||||
typedef CGAL::Quotient<int> NT;
|
||||
typedef CGAL::Cartesian<NT> R;
|
||||
typedef CGAL::Arr_polyline_traits<R> Traits;
|
||||
|
||||
typedef Traits::Point Point;
|
||||
typedef Traits::X_curve X_curve;
|
||||
typedef Traits::Curve Curve;
|
||||
|
||||
typedef CGAL::Pm_default_dcel<Traits> Dcel;
|
||||
typedef CGAL::Planar_map_2<Dcel, Traits> PM;
|
||||
typedef CGAL::Pm_file_writer<PM> Pm_writer;
|
||||
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
const Curve& cv)
|
||||
{
|
||||
typedef Curve::const_iterator Points_iterator;
|
||||
|
||||
os<<cv.size()<<std::endl;
|
||||
for (Points_iterator points_iter = cv.begin();
|
||||
points_iter != cv.end(); points_iter++)
|
||||
os<<" "<<*points_iter;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
template <class Container>
|
||||
void read_polylines(Container& curves)
|
||||
{
|
||||
int num_polylines = 0;
|
||||
|
||||
std::cin >> num_polylines;
|
||||
std::cout << "number of polylines is : " << num_polylines << std::endl;
|
||||
|
||||
while (num_polylines--) {
|
||||
Curve polyline;
|
||||
|
||||
std::cin>>polyline;
|
||||
curves.push_back(polyline);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
PM pm;
|
||||
std::vector<Curve> polylines;
|
||||
|
||||
read_polylines(polylines);
|
||||
|
||||
CGAL::sweep_to_construct_planar_map(polylines.begin(),polylines.end(), pm);
|
||||
|
||||
std::cout << " * * * Printing list of all halfedges of the resulting Planar map" << std::endl;
|
||||
|
||||
Pm_writer verbose_writer(std::cout, pm, true);
|
||||
|
||||
verbose_writer.write_halfedges(pm.halfedges_begin(), pm.halfedges_end());
|
||||
|
||||
|
||||
//CGAL::Window_stream W(700, 700);
|
||||
//W.init(-10, 10, -10);
|
||||
//W.set_mode(leda_src_mode);
|
||||
//W.set_node_width(3);
|
||||
//W.button("finish",2);
|
||||
//W.display();
|
||||
//W << pm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
3
|
||||
4
|
||||
0 100 70 140 140 100 0 100
|
||||
4
|
||||
40 0 40 60 60 60 60 0
|
||||
5
|
||||
20 0 20 100 120 100 120 0 20 0
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
// examples/Sweep_line/example3.C
|
||||
// ------------------------------
|
||||
#include <CGAL/Quotient.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
|
||||
#include <CGAL/Arr_segment_exact_traits.h>
|
||||
#include <CGAL/sweep_to_produce_planar_map_subcurves.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
typedef CGAL::Quotient<int> NT;
|
||||
typedef CGAL::Cartesian<NT> R;
|
||||
|
||||
typedef CGAL::Arr_segment_exact_traits<R> Traits;
|
||||
|
||||
typedef Traits::Point Point;
|
||||
typedef Traits::X_curve X_curve;
|
||||
typedef Traits::Curve Curve;
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
int num_segments;
|
||||
list<Curve> segments;
|
||||
|
||||
cin >> num_segments;
|
||||
|
||||
NT x1, y1, x2, y2;
|
||||
|
||||
while (num_segments--) {
|
||||
cin >> x1 >> y1 >> x2 >> y2;
|
||||
|
||||
segments.push_back(Curve(Point(x1,y1), Point(x2,y2)));
|
||||
}
|
||||
|
||||
Traits traits;
|
||||
list<Curve> subcurves;
|
||||
CGAL::sweep_to_produce_planar_map_subcurves(segments.begin(),
|
||||
segments.end(),
|
||||
traits,
|
||||
subcurves);
|
||||
|
||||
cout<<"The number of disjoint interior sub segments is "<< subcurves.size();
|
||||
cout<<endl;
|
||||
|
||||
for (list<Curve>::iterator scv_iter = subcurves.begin();
|
||||
scv_iter != subcurves.end();
|
||||
scv_iter++)
|
||||
cout<<*scv_iter<<endl;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
4
|
||||
0 0 1 1
|
||||
0 1 1 0
|
||||
0 0 1 0
|
||||
0 1 1 1
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
The number of disjoint interior sub segments is 6
|
||||
0/1 1/1 -1/-2 -1/-2
|
||||
0/1 0/1 -1/-2 -1/-2
|
||||
-1/-2 -1/-2 1/1 0/1
|
||||
0/1 0/1 1/1 0/1
|
||||
0/1 1/1 1/1 1/1
|
||||
-1/-2 -1/-2 1/1 1/1
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
// examples/Sweep_line/example4.C
|
||||
// ------------------------------
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
|
||||
#include <CGAL/Pm_default_dcel.h>
|
||||
#include <CGAL/Planar_map_2.h>
|
||||
|
||||
#include <CGAL/sweep_to_produce_planar_map_subcurves.h>
|
||||
|
||||
#include <CGAL/Arr_polyline_traits.h>
|
||||
//#include <CGAL/IO/Arr_polyline_traits_iostream.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
typedef CGAL::Quotient<int> NT;
|
||||
typedef CGAL::Cartesian<NT> R;
|
||||
typedef CGAL::Arr_polyline_traits<R> Traits;
|
||||
|
||||
typedef Traits::Point Point;
|
||||
typedef Traits::X_curve X_curve;
|
||||
typedef Traits::Curve Curve;
|
||||
|
||||
using namespace CGAL;
|
||||
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
const Curve& cv)
|
||||
{
|
||||
typedef Curve::const_iterator Points_iterator;
|
||||
|
||||
os<<cv.size()<<std::endl;
|
||||
for (Points_iterator points_iter = cv.begin();
|
||||
points_iter != cv.end(); points_iter++)
|
||||
os<<" "<<*points_iter;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
|
||||
template <class Container>
|
||||
void read_polylines(Container& curves)
|
||||
{
|
||||
int num_polylines = 0;
|
||||
|
||||
std::cin >> num_polylines;
|
||||
std::cout<<"number of polylines is : " << num_polylines<<std::endl;
|
||||
|
||||
while (num_polylines--) {
|
||||
Curve polyline;
|
||||
|
||||
std::cin>>polyline;
|
||||
|
||||
curves.push_back(polyline);
|
||||
|
||||
polyline.clear();
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::list<Curve> polylines;
|
||||
|
||||
read_polylines(polylines);
|
||||
|
||||
Traits traits;
|
||||
std::list<Curve> subcurves;
|
||||
CGAL::sweep_to_produce_planar_map_subcurves(polylines.begin(),polylines.end(), traits, subcurves);
|
||||
|
||||
for (std::list<Curve>::iterator scv_iter = subcurves.begin(); scv_iter != subcurves.end(); scv_iter++)
|
||||
std::cout<<*scv_iter<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
3
|
||||
4
|
||||
0 100 70 140 140 100 0 100
|
||||
4
|
||||
40 0 40 60 60 60 60 0
|
||||
5
|
||||
20 0 20 100 120 100 120 0 20 0
|
||||
Loading…
Reference in New Issue