Changing Point, Curve and X_curve to their _2 versions.

This commit is contained in:
Shai Hirsch 2002-05-03 10:09:59 +00:00
parent 07d2c61af7
commit f1398a80df
5 changed files with 49 additions and 57 deletions

View File

@ -41,9 +41,9 @@ 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::X_curve X_curve;
typedef Traits::Curve Curve;
typedef Traits::Point_2 Point_2;
typedef Traits::X_curve_2 X_curve_2;
typedef Traits::Curve_2 Curve_2;
typedef CGAL::Pm_default_dcel<Traits> Dcel;
typedef CGAL::Planar_map_2<Dcel, Traits> PM;
@ -51,9 +51,9 @@ typedef CGAL::Pm_file_writer<PM> Pm_writer;
int main()
{
PM pm;
int num_segments;
std::vector<Curve> segments;
PM pm;
int num_segments;
std::vector<Curve_2> segments;
std::cout << " * * * Demonstrating a trivial use of the sweep line algorithm"
<< std::endl << std::endl;
@ -66,7 +66,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_2(Point_2(x1, y1), Point_2(x2, y2)));
}
// Construct the planar map
Traits traits;

View File

@ -19,35 +19,33 @@ typedef CGAL::Quotient<CGAL::MP_Float> NT;
typedef CGAL::Cartesian<NT> Kernel;
typedef CGAL::Arr_polyline_traits<Kernel> Traits;
typedef Traits::Point Point;
typedef Traits::Curve Curve;
typedef Traits::Point_2 Point_2;
typedef Traits::Curve_2 Curve_2;
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)
std::ostream & operator<<(std::ostream & os, const Curve_2 & cv)
{
typedef Curve::const_iterator Points_iterator;
typedef Curve_2::const_iterator Points_iterator;
os<<cv.size()<<std::endl;
os << cv.size() << std::endl;
for (Points_iterator points_iter = cv.begin();
points_iter != cv.end(); points_iter++)
os<<" "<<*points_iter;
os << " " << *points_iter;
return os;
}
std::istream & operator>>(std::istream & in, Curve & cv)
std::istream & operator>>(std::istream & in, Curve_2 & cv)
{
std::size_t size;
in >> size;
for (unsigned int i = 0; i < size; i++){
Point p;
Point_2 p;
in >> p;
cv.push_back(p);
}
@ -55,30 +53,28 @@ std::istream & operator>>(std::istream & in, Curve & cv)
return in;
}
CGAL_END_NAMESPACE
// Read polylines from the input
template <class Container>
void read_polylines(Container& curves)
{
int num_polylines = 0;
int num_polylines = 0;
std::cin >> num_polylines;
std::cout << "number of polylines is : " << num_polylines << std::endl;
while (num_polylines--) {
Curve polyline;
Curve_2 polyline;
std::cin>>polyline;
std::cin >> polyline;
curves.push_back(polyline);
}
}
int main()
{
PM pm;
std::vector<Curve> polylines;
PM pm;
std::vector<Curve_2> polylines;
// Read input
read_polylines(polylines);

View File

@ -13,15 +13,15 @@ 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 Traits::Point_2 Point_2;
typedef Traits::Curve_2 Curve_2;
int main()
{
// Read input
int num_segments;
std::list<Curve> segments;
int num_segments;
std::list<Curve_2> segments;
std::cin >> num_segments;
NT x1, y1, x2, y2;
@ -29,12 +29,12 @@ 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_2(Point_2(x1, y1), Point_2(x2, y2)));
}
// Use a sweep to create the sub curves
Traits traits;
std::list<Curve> subcurves;
std::list<Curve_2> subcurves;
CGAL::sweep_to_produce_subcurves_2(segments.begin(),
segments.end(),
traits,
@ -46,7 +46,7 @@ int main()
<< subcurves.size();
std::cout << std::endl;
for (std::list<Curve>::iterator scv_iter = subcurves.begin();
for (std::list<Curve_2>::iterator scv_iter = subcurves.begin();
scv_iter != subcurves.end(); scv_iter++)
std::cout<< *scv_iter<< std::endl;

View File

@ -16,38 +16,34 @@ typedef CGAL::Cartesian<NT> Kernel;
typedef CGAL::Arr_polyline_traits<Kernel> Traits;
typedef Traits::Point Point;
typedef Traits::Curve Curve;
typedef Traits::Point_2 Point_2;
typedef Traits::Curve_2 Curve_2;
CGAL_BEGIN_NAMESPACE
std::ostream & operator<<(std::ostream & os, const Curve & cv)
std::ostream & operator<<(std::ostream & os, const Curve_2 & cv)
{
typedef Curve::const_iterator Points_iterator;
typedef Curve_2::const_iterator Points_iterator;
os<<cv.size()<<std::endl;
os << cv.size() << std::endl;
for (Points_iterator points_iter = cv.begin();
points_iter != cv.end(); points_iter++)
os<<" "<<*points_iter;
os << " " << *points_iter;
return os;
}
std::istream & operator>>(std::istream & in, Curve & cv)
std::istream & operator>>(std::istream & in, Curve_2 & cv)
{
std::size_t size;
std::size_t size;
in >> size;
for (unsigned int i = 0; i < size; i++){
Point p;
Point_2 p;
in >> p;
cv.push_back(p);
}
return in;
}
CGAL_END_NAMESPACE
// Read polylines from the input
template <class Container>
@ -56,10 +52,10 @@ void read_polylines(Container & curves)
int num_polylines = 0;
std::cin >> num_polylines;
std::cout<<"number of polylines is : " << num_polylines<<std::endl;
std::cout << "number of polylines is : " << num_polylines << std::endl;
while (num_polylines--) {
Curve polyline;
Curve_2 polyline;
std::cin>>polyline;
curves.push_back(polyline);
polyline.clear();
@ -68,17 +64,17 @@ void read_polylines(Container & curves)
int main()
{
// Read input
std::list<Curve> polylines;
std::list<Curve_2> polylines;
read_polylines(polylines);
// Use a sweep to create the sub curves
Traits traits;
std::list<Curve> subcurves;
std::list<Curve_2> 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();
for (std::list<Curve_2>::iterator scv_iter = subcurves.begin();
scv_iter != subcurves.end(); scv_iter++)
std::cout << *scv_iter << std::endl;

View File

@ -28,17 +28,17 @@ 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 Traits::Point_2 Point_2;
typedef Traits::Curve_2 Curve_2;
typedef CGAL::Pm_default_dcel<Traits> Dcel;
typedef CGAL::Planar_map_2<Dcel,Traits> PM;
int main()
{
PM pm;
int num_segments;
std::vector<Curve> segments;
PM pm;
int num_segments;
std::vector<Curve_2> segments;
std::cout << " * * * Demonstrating a trivial usage of the sweep line ";
std::cout << "algorithm" << std::endl << std::endl;
@ -48,13 +48,13 @@ int main()
while (num_segments--)
{
Curve cv;
Curve_2 cv;
std::cin >> cv;
segments.push_back(cv);
}
// Use a sweep to find the points induced in the arrangement
std::vector<Point> points;
std::vector<Point_2> points;
Traits traits;
CGAL::sweep_to_produce_points_2(segments.begin(),
segments.end(),
@ -65,7 +65,7 @@ int main()
std::cout << " * * * Printing list of all points in the arrangement ";
std::cout << "induced by the input segments" << std::endl;
for (std::vector<Point>::iterator p_iter = points.begin();
for (std::vector<Point_2>::iterator p_iter = points.begin();
p_iter != points.end(); ++p_iter)
std::cout<< *p_iter << std::endl;