mirror of https://github.com/CGAL/cgal
Removed some workarounds (still there in comments).
Adapted to namespace CGAL.
This commit is contained in:
parent
40f235872f
commit
2a44af42c1
|
|
@ -7,9 +7,9 @@
|
|||
// 1) define a point, vector and segment type
|
||||
// 2) define a polygon traits class using these types
|
||||
//
|
||||
// In this example the type MyPoint derives from CGAL_Point_2. As a result
|
||||
// most of the work from 1) and 2) isn't necessary. The types CGAL_Segment_2
|
||||
// and CGAL_Vector_2 and an existing traits class can be reused.
|
||||
// In this example the type MyPoint derives from CGAL::Point_2. As a result
|
||||
// most of the work from 1) and 2) isn't necessary. The types CGAL::Segment_2
|
||||
// and CGAL::Vector_2 and an existing traits class can be reused.
|
||||
//-----------------------------------------------------------------------//
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
|
|
@ -19,36 +19,36 @@
|
|||
enum MyColor { Red, Green, Blue };
|
||||
|
||||
template <class R>
|
||||
class MyPoint: public CGAL_Point_2<R>
|
||||
class MyPoint: public CGAL::Point_2<R>
|
||||
{
|
||||
public:
|
||||
MyColor color; // additional attribute for points
|
||||
|
||||
MyPoint(): color(Red) {}
|
||||
MyPoint(const typename R::RT &x, const typename R::RT &y, MyColor c)
|
||||
: CGAL_Point_2<R>(x,y), color(c) {}
|
||||
: CGAL::Point_2<R>(x,y), color(c) {}
|
||||
};
|
||||
// N.B. The class MyPoint derives from CGAL_Point_2. This is not always a
|
||||
// good idea, since the class CGAL_Point_2 doesn't have a virtual destructor.
|
||||
// N.B. The class MyPoint derives from CGAL::Point_2. This is not always a
|
||||
// good idea, since the class CGAL::Point_2 doesn't have a virtual destructor.
|
||||
|
||||
typedef CGAL_Cartesian<double> R;
|
||||
typedef CGAL::Cartesian<double> R;
|
||||
typedef MyPoint<R> Point;
|
||||
|
||||
#ifdef CGAL_CFG_NO_TEMPLATE_FUNCTION_MATCHING
|
||||
//#ifdef CGAL_CFG_NO_TEMPLATE_FUNCTION_MATCHING
|
||||
// This is a workaround for the g++ 2.7.2 compiler.
|
||||
#include "template_function_matching_workaround.h"
|
||||
#endif // CGAL_CFG_NO_TEMPLATE_FUNCTION_MATCHING
|
||||
//#include "template_function_matching_workaround.h"
|
||||
//#endif // CGAL_CFG_NO_TEMPLATE_FUNCTION_MATCHING
|
||||
|
||||
#include <CGAL/Polygon_2.h>
|
||||
#include <list.h>
|
||||
|
||||
typedef CGAL_Polygon_traits_2_aux<R, R::FT, Point> Traits;
|
||||
// The class MyPoint derives from CGAL_Point, so the polygon traits class
|
||||
// CGAL_Polygon_traits_2_aux can be reused.
|
||||
typedef CGAL::Polygon_traits_2_aux<R, R::FT, Point> Traits;
|
||||
// The class MyPoint derives from CGAL::Point, so the polygon traits class
|
||||
// CGAL::Polygon_traits_2_aux can be reused.
|
||||
|
||||
typedef CGAL_Polygon_2<Traits, list<Point> > Polygon;
|
||||
typedef CGAL_Polygon_2<Traits, list<Point> >::Vertex_iterator VI;
|
||||
typedef CGAL_Polygon_2<Traits, list<Point> >::Edge_const_iterator EI;
|
||||
typedef CGAL::Polygon_2<Traits, list<Point> > Polygon;
|
||||
typedef CGAL::Polygon_2<Traits, list<Point> >::Vertex_iterator VI;
|
||||
typedef CGAL::Polygon_2<Traits, list<Point> >::Edge_const_iterator EI;
|
||||
|
||||
//-----------------------------------------------------------------------//
|
||||
// main
|
||||
|
|
@ -64,7 +64,7 @@ int main()
|
|||
p.push_back(Point(2,2,Red));
|
||||
p.push_back(Point(0,4,Red));
|
||||
|
||||
CGAL_set_pretty_mode(cout);
|
||||
CGAL::set_pretty_mode(cout);
|
||||
cout << "created the polygon p:" << endl;
|
||||
cout << p << endl;
|
||||
cout << endl;
|
||||
|
|
@ -72,7 +72,7 @@ int main()
|
|||
// determine some properties of the polygon
|
||||
bool IsSimple = p.is_simple();
|
||||
bool IsConvex = p.is_convex();
|
||||
bool IsClockwise = (p.orientation() == CGAL_CLOCKWISE);
|
||||
bool IsClockwise = (p.orientation() == CGAL::CLOCKWISE);
|
||||
double Area = p.area();
|
||||
|
||||
cout << "polygon p is";
|
||||
|
|
@ -95,7 +95,7 @@ int main()
|
|||
cout << "created point q = " << q << endl;
|
||||
cout << endl;
|
||||
|
||||
bool IsInside = (p.bounded_side(q) == CGAL_ON_BOUNDED_SIDE);
|
||||
bool IsInside = (p.bounded_side(q) == CGAL::ON_BOUNDED_SIDE);
|
||||
cout << "point q is";
|
||||
if (!IsInside) cout << " not";
|
||||
cout << " inside polygon p." << endl;
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Polygon_2.h>
|
||||
|
||||
#ifdef CGAL_CFG_NO_LAZY_INSTANTIATION
|
||||
#include <CGAL/Bbox_2.h>
|
||||
#endif // CGAL_CFG_NO_LAZY_INSTANTIATION
|
||||
//#ifdef CGAL_CFG_NO_LAZY_INSTANTIATION
|
||||
//#include <CGAL/Bbox_2.h>
|
||||
//#endif // CGAL_CFG_NO_LAZY_INSTANTIATION
|
||||
|
||||
//-----------------------------------------------------------------------//
|
||||
// MyPoint
|
||||
|
|
@ -33,10 +33,10 @@ class MyPoint
|
|||
double x() const { return d_x; }
|
||||
double y() const { return d_y; }
|
||||
|
||||
#ifdef CGAL_CFG_NO_LAZY_INSTANTIATION
|
||||
CGAL_Bbox_2 bbox() const
|
||||
{ return CGAL_Bbox_2(d_x, d_y, d_x, d_y); }
|
||||
#endif // CGAL_CFG_NO_LAZY_INSTANTIATION
|
||||
//#ifdef CGAL_CFG_NO_LAZY_INSTANTIATION
|
||||
// CGAL::Bbox_2 bbox() const
|
||||
// { return CGAL::Bbox_2(d_x, d_y, d_x, d_y); }
|
||||
//#endif // CGAL_CFG_NO_LAZY_INSTANTIATION
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream& to, const MyPoint& p)
|
||||
|
|
@ -122,32 +122,32 @@ class MyTraits
|
|||
return (x < FT(0)) ? -1: (FT(0) < x) ? 1 : 0;
|
||||
}
|
||||
|
||||
CGAL_Orientation orientation(const Point_2& p,
|
||||
CGAL::Orientation orientation(const Point_2& p,
|
||||
const Point_2& q,
|
||||
const Point_2& r) const
|
||||
{
|
||||
int i = sign(determinant_2(p,q,r));
|
||||
switch (i) {
|
||||
case -1: return CGAL_COUNTERCLOCKWISE;
|
||||
case 0: return CGAL_COLLINEAR;
|
||||
case 1: return CGAL_CLOCKWISE;
|
||||
case -1: return CGAL::COUNTERCLOCKWISE;
|
||||
case 0: return CGAL::COLLINEAR;
|
||||
case 1: return CGAL::CLOCKWISE;
|
||||
}
|
||||
|
||||
return CGAL_COLLINEAR; // to prevent compiler warnings
|
||||
return CGAL::COLLINEAR; // to prevent compiler warnings
|
||||
}
|
||||
|
||||
CGAL_Comparison_result compare_x(const Point_2 &p, const Point_2 &q) const
|
||||
CGAL::Comparison_result compare_x(const Point_2 &p, const Point_2 &q) const
|
||||
{
|
||||
if (p.x() == q.x())
|
||||
return CGAL_EQUAL;
|
||||
return (p.x() < q.x()) ? CGAL_SMALLER : CGAL_LARGER;
|
||||
return CGAL::EQUAL;
|
||||
return (p.x() < q.x()) ? CGAL::SMALLER : CGAL::LARGER;
|
||||
}
|
||||
|
||||
CGAL_Comparison_result compare_y(const Point_2 &p, const Point_2 &q) const
|
||||
CGAL::Comparison_result compare_y(const Point_2 &p, const Point_2 &q) const
|
||||
{
|
||||
if (p.y() == q.y())
|
||||
return CGAL_EQUAL;
|
||||
return (p.y() < q.y()) ? CGAL_SMALLER : CGAL_LARGER;
|
||||
return CGAL::EQUAL;
|
||||
return (p.y() < q.y()) ? CGAL::SMALLER : CGAL::LARGER;
|
||||
}
|
||||
|
||||
bool have_equal_direction(const Vector_2&,
|
||||
|
|
@ -176,7 +176,7 @@ class MyTraits
|
|||
|
||||
#include <list.h>
|
||||
|
||||
typedef CGAL_Polygon_2<MyTraits, list<MyPoint> > Polygon;
|
||||
typedef CGAL::Polygon_2<MyTraits, list<MyPoint> > Polygon;
|
||||
typedef Polygon::Vertex_iterator VI;
|
||||
typedef Polygon::Edge_const_iterator EI;
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ int main()
|
|||
// determine some properties of the polygon
|
||||
bool IsSimple = p.is_simple();
|
||||
bool IsConvex = p.is_convex();
|
||||
bool IsClockwise = (p.orientation() == CGAL_CLOCKWISE);
|
||||
bool IsClockwise = (p.orientation() == CGAL::CLOCKWISE);
|
||||
double Area = p.area();
|
||||
|
||||
cout << "polygon p is";
|
||||
|
|
@ -219,7 +219,7 @@ int main()
|
|||
MyPoint q(1,1);
|
||||
cout << endl;
|
||||
|
||||
bool IsInside = (p.bounded_side(q) == CGAL_ON_BOUNDED_SIDE);
|
||||
bool IsInside = (p.bounded_side(q) == CGAL::ON_BOUNDED_SIDE);
|
||||
cout << "point q is";
|
||||
if (!IsInside) cout << " not";
|
||||
cout << " inside polygon p." << endl;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//-----------------------------------------------------------------------//
|
||||
// This is just a simple example that demonstrates how to use the
|
||||
// class CGAL_Polygon_2.
|
||||
// class CGAL::Polygon_2.
|
||||
//-----------------------------------------------------------------------//
|
||||
|
||||
#include <CGAL/Cartesian.h>
|
||||
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
#include <list.h>
|
||||
|
||||
typedef CGAL_Cartesian<double> R;
|
||||
typedef CGAL_Polygon_traits_2<R> Traits;
|
||||
typedef CGAL_Point_2<R> Point;
|
||||
typedef CGAL_Polygon_2<Traits, list<Point> > Polygon;
|
||||
typedef CGAL_Polygon_2<Traits, list<Point> >::Vertex_iterator VertexIterator;
|
||||
typedef CGAL_Polygon_2<Traits, list<Point> >::Edge_const_iterator EdgeIterator;
|
||||
typedef CGAL::Cartesian<double> R;
|
||||
typedef CGAL::Polygon_traits_2<R> Traits;
|
||||
typedef CGAL::Point_2<R> Point;
|
||||
typedef CGAL::Polygon_2<Traits, list<Point> > Polygon;
|
||||
typedef CGAL::Polygon_2<Traits, list<Point> >::Vertex_iterator VertexIterator;
|
||||
typedef CGAL::Polygon_2<Traits, list<Point> >::Edge_const_iterator EdgeIterator;
|
||||
|
||||
//-----------------------------------------------------------------------//
|
||||
// main
|
||||
|
|
@ -29,7 +29,7 @@ int main()
|
|||
p.push_back(Point(2,2));
|
||||
p.push_back(Point(0,4));
|
||||
|
||||
CGAL_set_pretty_mode(cout);
|
||||
CGAL::set_pretty_mode(cout);
|
||||
cout << "created the polygon p:" << endl;
|
||||
cout << p << endl;
|
||||
cout << endl;
|
||||
|
|
@ -37,7 +37,7 @@ int main()
|
|||
// determine some properties of the polygon
|
||||
bool IsSimple = p.is_simple();
|
||||
bool IsConvex = p.is_convex();
|
||||
bool IsClockwise = (p.orientation() == CGAL_CLOCKWISE);
|
||||
bool IsClockwise = (p.orientation() == CGAL::CLOCKWISE);
|
||||
double Area = p.area();
|
||||
|
||||
cout << "polygon p is";
|
||||
|
|
@ -60,7 +60,7 @@ int main()
|
|||
cout << "created point q = " << q << endl;
|
||||
cout << endl;
|
||||
|
||||
bool IsInside = (p.bounded_side(q) == CGAL_ON_BOUNDED_SIDE);
|
||||
bool IsInside = (p.bounded_side(q) == CGAL::ON_BOUNDED_SIDE);
|
||||
cout << "point q is";
|
||||
if (!IsInside) cout << " not";
|
||||
cout << " inside polygon p." << endl;
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@
|
|||
#include <CGAL/Polygon_2.h>
|
||||
#include <list.h>
|
||||
|
||||
typedef CGAL_Cartesian<double> R;
|
||||
typedef CGAL_Polygon_traits_2<R> Traits;
|
||||
typedef CGAL::Cartesian<double> R;
|
||||
typedef CGAL::Polygon_traits_2<R> Traits;
|
||||
typedef Traits::Point_2 Point;
|
||||
typedef list<Point> Container;
|
||||
typedef CGAL_Polygon_2<Traits,Container> Polygon;
|
||||
typedef CGAL::Polygon_2<Traits,Container> Polygon;
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,61 +3,61 @@
|
|||
|
||||
template <class R>
|
||||
inline
|
||||
bool CGAL_lexicographically_xy_smaller(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
bool CGAL::lexicographically_xy_smaller(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
{
|
||||
return CGAL_lexicographically_xy_smaller((const CGAL_Point_2<R>&) p,
|
||||
(const CGAL_Point_2<R>&) q );
|
||||
return CGAL::lexicographically_xy_smaller((const CGAL::Point_2<R>&) p,
|
||||
(const CGAL::Point_2<R>&) q );
|
||||
}
|
||||
|
||||
template <class R>
|
||||
inline
|
||||
bool CGAL_lexicographically_yx_smaller(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
bool CGAL::lexicographically_yx_smaller(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
{
|
||||
return CGAL_lexicographically_yx_smaller((const CGAL_Point_2<R>&) p,
|
||||
(const CGAL_Point_2<R>&) q );
|
||||
return CGAL::lexicographically_yx_smaller((const CGAL::Point_2<R>&) p,
|
||||
(const CGAL::Point_2<R>&) q );
|
||||
}
|
||||
|
||||
template <class R>
|
||||
inline
|
||||
bool CGAL_lexicographically_yx_smaller_or_equal(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
bool CGAL::lexicographically_yx_smaller_or_equal(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
{
|
||||
return CGAL_lexicographically_yx_smaller_or_equal((const CGAL_Point_2<R>&) p,
|
||||
(const CGAL_Point_2<R>&) q );
|
||||
return CGAL::lexicographically_yx_smaller_or_equal((const CGAL::Point_2<R>&) p,
|
||||
(const CGAL::Point_2<R>&) q );
|
||||
}
|
||||
|
||||
template <class R>
|
||||
CGAL_Comparison_result CGAL_compare_x(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
CGAL::Comparison_result CGAL::compare_x(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
{
|
||||
return CGAL_compare_x((const CGAL_Point_2<R>&) p,
|
||||
(const CGAL_Point_2<R>&) q );
|
||||
return CGAL::compare_x((const CGAL::Point_2<R>&) p,
|
||||
(const CGAL::Point_2<R>&) q );
|
||||
}
|
||||
|
||||
template <class R>
|
||||
CGAL_Comparison_result CGAL_compare_y(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
CGAL::Comparison_result CGAL::compare_y(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
{
|
||||
return CGAL_compare_y((const CGAL_Point_2<R>&) p,
|
||||
(const CGAL_Point_2<R>&) q );
|
||||
return CGAL::compare_y((const CGAL::Point_2<R>&) p,
|
||||
(const CGAL::Point_2<R>&) q );
|
||||
}
|
||||
|
||||
template <class R>
|
||||
ostream& operator<<(ostream& to, const MyPoint<R>& p)
|
||||
{
|
||||
return to << (const CGAL_Point_2<R>&) p;
|
||||
return to << (const CGAL::Point_2<R>&) p;
|
||||
}
|
||||
|
||||
template <class R>
|
||||
CGAL_Vector_2<R> operator-(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
CGAL::Vector_2<R> operator-(const MyPoint<R>& p, const MyPoint<R>& q)
|
||||
{
|
||||
return ((const CGAL_Point_2<R>&) p) - ((const CGAL_Point_2<R>&) q );
|
||||
return ((const CGAL::Point_2<R>&) p) - ((const CGAL::Point_2<R>&) q );
|
||||
}
|
||||
|
||||
template < class R >
|
||||
CGAL_Orientation CGAL_orientation(const MyPoint<R>& p,
|
||||
CGAL::Orientation CGAL::orientation(const MyPoint<R>& p,
|
||||
const MyPoint<R>& q,
|
||||
const MyPoint<R>& r)
|
||||
{
|
||||
return CGAL_orientation((const CGAL_Point_2<R>&) p,
|
||||
(const CGAL_Point_2<R>&) q,
|
||||
(const CGAL_Point_2<R>&) r );
|
||||
return CGAL::orientation((const CGAL::Point_2<R>&) p,
|
||||
(const CGAL::Point_2<R>&) q,
|
||||
(const CGAL::Point_2<R>&) r );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue