From 09ffa8665dcddc0be5de37d35de8a19d41e8aac5 Mon Sep 17 00:00:00 2001 From: Mariette Yvinec Date: Tue, 4 Aug 1998 09:38:26 +0000 Subject: [PATCH] Initial revision --- .../CGAL/Constrained_triangulation_demo_2.h | 41 ++++++++ .../include/CGAL/Weighted_point_2.h | 94 +++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 Packages/Triangulation_2/include/CGAL/Constrained_triangulation_demo_2.h create mode 100644 Packages/Triangulation_2/include/CGAL/Weighted_point_2.h diff --git a/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_demo_2.h b/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_demo_2.h new file mode 100644 index 00000000000..9364392d100 --- /dev/null +++ b/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_demo_2.h @@ -0,0 +1,41 @@ +#ifndef CGAL_CONSTRAINED_TRIANGULATION_DEMO_2_H +#define CGAL_CONSTRAINED_TRIANGULATION_DEMO_2_H + +#include +#include +#include + +// template < class Gt,class Tds> +// class CGAL_Constrained_triangulation_sweep_demo_2; + +template < class Gt,class Tds> +class CGAL_Constrained_triangulation_demo_2 + : public CGAL_Constrained_triangulation_2 +{ +public: + typedef CGAL_Constrained_triangulation_2 Constrained_triangulation; + typedef CGAL_Constrained_triangulation_sweep_demo_2 Sweep_demo; + typedef typename Gt::Segment Segment; + typedef CGAL_Window_stream Window_stream; + +CGAL_Constrained_triangulation_demo_2() : + CGAL_Constrained_triangulation_2() {} + +CGAL_Constrained_triangulation_demo_2(const Gt& gt=Gt()) + : CGAL_Constrained_triangulation_2(gt) {} + + +CGAL_Constrained_triangulation_demo_2(Window_stream& W, + list& lc, const Gt& gt=Gt()) + : CGAL_Constrained_triangulation_2(gt) +{ + Sweep_demo sweep(W,lc, gt); + CGAL_Constrained_triangulation_2 Tr( sweep.vertex(), gt); + swap(Tr); + CGAL_triangulation_postcondition( is_valid() ); +} + +}; + + +#endif //CGAL_CONSTRAINED_TRIANGULATION_DEMO_2_H diff --git a/Packages/Triangulation_2/include/CGAL/Weighted_point_2.h b/Packages/Triangulation_2/include/CGAL/Weighted_point_2.h new file mode 100644 index 00000000000..a33e912209a --- /dev/null +++ b/Packages/Triangulation_2/include/CGAL/Weighted_point_2.h @@ -0,0 +1,94 @@ +#ifndef CGAL_WEIGHTED_POINT_2_H +#define CGAL_WEIGHTED_POINT_2_H + +#include +#include + +template < class Pt, class We > +class CGAL_Weighted_point_2 : public Pt +{ +public: + typedef We Weight; + typedef Pt Point; + typedef typename Point::RT RT; +private: + Weight _weight; + +public: //constructors and destructors + CGAL_Weighted_point_2 () + : Point () + { + _weight=Weight ( 0 ) ; + } + + + CGAL_Weighted_point_2 ( const CGAL_Weighted_point_2 &p0) + { + Point::operator=(p0.point() ); + _weight=Weight( p0.weight() ); + } + +#ifndef CGAL_CFG_NO_MEMBER_TEMPLATES + template + CGAL_Weighted_point_2 + ( const CGAL_Weighted_point_2< Point, Weight_0 > &p0) : Point(p0.point()) + { _weight=Weight( p0.weight() ); + } +#endif + + CGAL_Weighted_point_2 ( const Point &p ) + : Point ( p ) + { _weight=Weight ( 0 ) ; + } + + CGAL_Weighted_point_2 ( const RT &x, const RT &y ) + : Point ( x, y ) + { _weight=Weight ( 0 ) ; + } + + CGAL_Weighted_point_2 ( const Point &p, const Weight &_weight_ ) + : Point ( p ) + { _weight=_weight_; + } + + +public: + // conversion from Weighted_point to Weight + operator Weight() const + {return weight();} + + Point point() const + { return (Point)*this; + } + + Weight weight() const + { return _weight; + } + + Weight power(const Point &p) + { return ((p.x()-x())*(p.x()-x())+(p.y()-y())*(p.y()-y())-weight()*weight()); + } + +}; + + +template < class Point, class Weight > +ostream &operator<<(ostream &os, const CGAL_Weighted_point_2 &p) +{ + return os << p.point() << " " << p.weight() ; +} + +template < class Point, class Weight > +istream &operator>>(istream &is, CGAL_Weighted_point_2 &p) +{ + Weight _weight_; + Point _point_; + is >> _point_ >> _weight_ ; + p=CGAL_Weighted_point_2( _point_, _weight_ ); + return is; +} + + + + +#endif