From 23bd6189328423d952ecbc74666d901b6a1465f1 Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Tue, 2 Oct 2001 16:37:02 +0000 Subject: [PATCH] - Access functions of objects (like .x() ) now return const references. --- Packages/Cartesian_kernel/changes.txt | 3 + .../include/CGAL/Cartesian/Circle_2.h | 6 +- .../include/CGAL/Cartesian/Direction_2.h | 8 +- .../include/CGAL/Cartesian/Direction_3.h | 16 +- .../include/CGAL/Cartesian/Iso_cuboid_3.h | 42 +-- .../include/CGAL/Cartesian/Iso_rectangle_2.h | 28 +- .../include/CGAL/Cartesian/Line_2.h | 6 +- .../include/CGAL/Cartesian/Line_3.h | 4 +- .../include/CGAL/Cartesian/Plane_3.h | 8 +- .../include/CGAL/Cartesian/Point_2.h | 14 +- .../include/CGAL/Cartesian/Point_3.h | 20 +- .../include/CGAL/Cartesian/Ray_2.h | 8 +- .../include/CGAL/Cartesian/Ray_3.h | 8 +- .../include/CGAL/Cartesian/Segment_2.h | 32 +- .../include/CGAL/Cartesian/Segment_3.h | 32 +- .../include/CGAL/Cartesian/Sphere_3.h | 4 +- .../include/CGAL/Cartesian/Tetrahedron_3.h | 8 +- .../include/CGAL/Cartesian/Triangle_2.h | 8 +- .../include/CGAL/Cartesian/Triangle_3.h | 8 +- .../include/CGAL/Cartesian/Vector_2.h | 16 +- .../include/CGAL/Cartesian/Vector_3.h | 20 +- Packages/H2/changes.txt | 3 + .../H2/include/CGAL/Aff_transformationH2.h | 6 +- Packages/H2/include/CGAL/CircleH2.h | 8 +- Packages/H2/include/CGAL/Iso_rectangleH2.h | 11 +- Packages/H2/include/CGAL/LineH2.h | 28 +- Packages/H2/include/CGAL/PVDH2.h | 41 +- Packages/H2/include/CGAL/RayH2.h | 31 +- Packages/H2/include/CGAL/SegmentH2.h | 64 ++-- Packages/H2/include/CGAL/TriangleH2.h | 8 +- .../include/CGAL/predicates_on_directionsH2.h | 12 +- .../H2/include/CGAL/predicates_on_pointsH2.h | 354 +++++++++--------- Packages/H3/changes.txt | 3 + Packages/H3/include/CGAL/Iso_cuboidH3.h | 11 +- Packages/H3/include/CGAL/LineH3.h | 13 +- Packages/H3/include/CGAL/PVDH3.h | 112 ++---- Packages/H3/include/CGAL/PlaneH3.h | 20 +- Packages/H3/include/CGAL/RayH3.h | 14 +- Packages/H3/include/CGAL/RepH3.h | 16 +- Packages/H3/include/CGAL/SegmentH3.h | 53 ++- Packages/H3/include/CGAL/SphereH3.h | 29 +- Packages/H3/include/CGAL/TetrahedronH3.h | 18 +- Packages/H3/include/CGAL/TriangleH3.h | 8 +- Packages/H3/include/CGAL/VectorH3.h | 2 - .../H3/include/CGAL/predicates_on_pointsH3.h | 40 +- 45 files changed, 563 insertions(+), 641 deletions(-) diff --git a/Packages/Cartesian_kernel/changes.txt b/Packages/Cartesian_kernel/changes.txt index bdb8f7fffd5..3bc54f670ee 100644 --- a/Packages/Cartesian_kernel/changes.txt +++ b/Packages/Cartesian_kernel/changes.txt @@ -1,3 +1,6 @@ +Version 6.29 (2 October 2001) +- Access functions of objects (like .x() ) now return const references. + Version 6.28 (13 September 2001) - More missing typenames. diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Circle_2.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Circle_2.h index 0efccc42ecc..6782c14810d 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Circle_2.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Circle_2.h @@ -111,17 +111,17 @@ public: bool operator==(const Self &s) const; bool operator!=(const Self &s) const; - Point_2 center() const + const Point_2 & center() const { return Ptr()->center; } - FT squared_radius() const + const FT & squared_radius() const { return Ptr()->squared_radius; } - Orientation orientation() const + Orientation orientation() const { return Ptr()->orient; } diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h index a4b41050e0d..f21fe0fb84f 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h @@ -98,12 +98,12 @@ public: Self operator-() const; - FT delta(int i) const; - FT dx() const + const FT & delta(int i) const; + const FT & dx() const { return Ptr()->e0; } - FT dy() const + const FT & dy() const { return Ptr()->e1; } @@ -211,7 +211,7 @@ DirectionC2::operator-() const template < class R > CGAL_KERNEL_INLINE -typename DirectionC2::FT +const typename DirectionC2::FT & DirectionC2::delta(int i) const { CGAL_kernel_precondition( ( i == 0 ) || ( i == 1 ) ); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h index 9d47c1ce849..e6f61cdbd74 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h @@ -83,29 +83,29 @@ public: Self operator-() const; - FT delta(int i) const; - FT dx() const + const FT & delta(int i) const; + const FT & dx() const { return Ptr()->e0; } - FT dy() const + const FT & dy() const { return Ptr()->e1; } - FT dz() const + const FT & dz() const { return Ptr()->e2; } - FT hdx() const + const FT & hdx() const { return dx(); } - FT hdy() const + const FT & hdy() const { return dy(); } - FT hdz() const + const FT & hdz() const { return dz(); } @@ -154,7 +154,7 @@ DirectionC3::operator-() const } template < class R > -typename DirectionC3::FT +const typename DirectionC3::FT & DirectionC3::delta(int i) const { CGAL_kernel_precondition( i >= 0 && i <= 2 ); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h index e86b310c0c7..9ba0d65e49e 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h @@ -88,11 +88,11 @@ public: bool operator==(const Self& s) const; bool operator!=(const Self& s) const; - Point_3 min() const + const Point_3 & min() const { return Ptr()->e0; } - Point_3 max() const + const Point_3 & max() const { return Ptr()->e1; } @@ -111,14 +111,14 @@ public: bool has_on_unbounded_side(const Point_3& p) const; bool is_degenerate() const; Bbox_3 bbox() const; - FT xmin() const; - FT ymin() const; - FT zmin() const; - FT xmax() const; - FT ymax() const; - FT zmax() const; - FT min_coord(int i) const; - FT max_coord(int i) const; + const FT & xmin() const; + const FT & ymin() const; + const FT & zmin() const; + const FT & xmax() const; + const FT & ymax() const; + const FT & zmax() const; + const FT & min_coord(int i) const; + const FT & max_coord(int i) const; FT volume() const; }; @@ -147,7 +147,7 @@ Iso_cuboidC3::operator!=(const Iso_cuboidC3& r) const template < class R > inline -typename Iso_cuboidC3::FT +const typename Iso_cuboidC3::FT & Iso_cuboidC3::xmin() const { return min().x(); @@ -155,7 +155,7 @@ Iso_cuboidC3::xmin() const template < class R > inline -typename Iso_cuboidC3::FT +const typename Iso_cuboidC3::FT & Iso_cuboidC3::ymin() const { return min().y(); @@ -163,7 +163,7 @@ Iso_cuboidC3::ymin() const template < class R > inline -typename Iso_cuboidC3::FT +const typename Iso_cuboidC3::FT & Iso_cuboidC3::zmin() const { return min().z(); @@ -171,7 +171,7 @@ Iso_cuboidC3::zmin() const template < class R > inline -typename Iso_cuboidC3::FT +const typename Iso_cuboidC3::FT & Iso_cuboidC3::xmax() const { return max().x(); @@ -179,7 +179,7 @@ Iso_cuboidC3::xmax() const template < class R > inline -typename Iso_cuboidC3::FT +const typename Iso_cuboidC3::FT & Iso_cuboidC3::ymax() const { return max().y(); @@ -187,7 +187,7 @@ Iso_cuboidC3::ymax() const template < class R > inline -typename Iso_cuboidC3::FT +const typename Iso_cuboidC3::FT & Iso_cuboidC3::zmax() const { return max().z(); @@ -195,7 +195,7 @@ Iso_cuboidC3::zmax() const template < class R > inline -typename Iso_cuboidC3::FT +const typename Iso_cuboidC3::FT & Iso_cuboidC3::min_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 || i == 2 ); @@ -209,7 +209,7 @@ Iso_cuboidC3::min_coord(int i) const template < class R > inline -typename Iso_cuboidC3::FT +const typename Iso_cuboidC3::FT & Iso_cuboidC3::max_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 || i == 2 ); @@ -225,7 +225,7 @@ template < class R > CGAL_KERNEL_LARGE_INLINE typename Iso_cuboidC3::Point_3 Iso_cuboidC3::vertex(int i) const -{ // FIXME : construction +{ switch (i%8) { case 0: return min(); @@ -235,9 +235,9 @@ Iso_cuboidC3::vertex(int i) const case 4: return Point_3(min().hx(), max().hy(), max().hz()); case 5: return Point_3(min().hx(), min().hy(), max().hz()); case 6: return Point_3(max().hx(), min().hy(), max().hz()); - case 7: return max(); + default: // case 7: + return max(); } - return Point_3(); // FIXME : why ? } template < class R > diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h index 51a320b993d..83c481bbf3f 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h @@ -97,11 +97,11 @@ public: bool operator==(const Self &s) const; bool operator!=(const Self &s) const; - Point_2 min() const + const Point_2 & min() const { return Ptr()->e0; } - Point_2 max() const + const Point_2 & max() const { return Ptr()->e1; } @@ -124,12 +124,12 @@ public: Bbox_2 bbox() const; - FT xmin() const; - FT ymin() const; - FT xmax() const; - FT ymax() const; - FT min_coord(int i) const; - FT max_coord(int i) const; + const FT & xmin() const; + const FT & ymin() const; + const FT & xmax() const; + const FT & ymax() const; + const FT & min_coord(int i) const; + const FT & max_coord(int i) const; FT area() const; }; @@ -160,7 +160,7 @@ operator!=(const Iso_rectangleC2 &r) const template < class R > inline -typename Iso_rectangleC2::FT +const typename Iso_rectangleC2::FT & Iso_rectangleC2::xmin() const { return min().x(); @@ -168,7 +168,7 @@ Iso_rectangleC2::xmin() const template < class R > inline -typename Iso_rectangleC2::FT +const typename Iso_rectangleC2::FT & Iso_rectangleC2::ymin() const { return min().y(); @@ -176,7 +176,7 @@ Iso_rectangleC2::ymin() const template < class R > inline -typename Iso_rectangleC2::FT +const typename Iso_rectangleC2::FT & Iso_rectangleC2::xmax() const { return max().x(); @@ -184,7 +184,7 @@ Iso_rectangleC2::xmax() const template < class R > inline -typename Iso_rectangleC2::FT +const typename Iso_rectangleC2::FT & Iso_rectangleC2::ymax() const { return max().y(); @@ -192,7 +192,7 @@ Iso_rectangleC2::ymax() const template < class R > inline -typename Iso_rectangleC2::FT +const typename Iso_rectangleC2::FT & Iso_rectangleC2::min_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 ); @@ -204,7 +204,7 @@ Iso_rectangleC2::min_coord(int i) const template < class R > inline -typename Iso_rectangleC2::FT +const typename Iso_rectangleC2::FT & Iso_rectangleC2::max_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 ); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h index a154ef271dd..9bb07527752 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h @@ -84,15 +84,15 @@ public: bool operator==(const Self &l) const; bool operator!=(const Self &l) const; - FT a() const + const FT & a() const { return Ptr()->e0; } - FT b() const + const FT & b() const { return Ptr()->e1; } - FT c() const + const FT & c() const { return Ptr()->e2; } diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Line_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Line_3.h index e1431089192..a7f98d9cf56 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Line_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Line_3.h @@ -83,11 +83,11 @@ public: Plane_3 perpendicular_plane(const Point_3 &p) const; Self opposite() const; - Point_3 point() const + const Point_3 & point() const { return Ptr()->basepoint; } - Direction_3 direction() const + const Direction_3 & direction() const { return Ptr()->direction; } diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h index c2ad4cc105d..59b6438e81f 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h @@ -90,19 +90,19 @@ public: bool operator==(const Self &p) const; bool operator!=(const Self &p) const; - FT a() const + const FT & a() const { return Ptr()->e0; } - FT b() const + const FT & b() const { return Ptr()->e1; } - FT c() const + const FT & c() const { return Ptr()->e2; } - FT d() const + const FT & d() const { return Ptr()->e3; } diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h index 87e5f15f70e..7f81f704c42 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h @@ -85,20 +85,20 @@ public: PointC2(const Vector_2 &v) : Point_handle_2_(v) {} - FT x() const + const FT& x() const { return Ptr()->e0; } - FT y() const + const FT& y() const { return Ptr()->e1; } - FT hx() const + const FT& hx() const { return x(); } - FT hy() const + const FT& hy() const { return y(); } @@ -107,9 +107,9 @@ public: return FT(1); } - FT cartesian(int i) const; + const FT& cartesian(int i) const; FT homogeneous(int i) const; - FT operator[](int i) const + const FT& operator[](int i) const { return cartesian(i); } @@ -144,7 +144,7 @@ public: template < class R > CGAL_KERNEL_INLINE -typename PointC2::FT +const typename PointC2::FT & PointC2::cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) ); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h index 7dc23dc4279..30031c033ee 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h @@ -81,28 +81,28 @@ public: return !(*this == p); } - FT x() const + const FT & x() const { return Ptr()->e0; } - FT y() const + const FT & y() const { return Ptr()->e1; } - FT z() const + const FT & z() const { return Ptr()->e2; } - FT hx() const + const FT & hx() const { return x(); } - FT hy() const + const FT & hy() const { return y(); } - FT hz() const + const FT & hz() const { return z(); } @@ -111,8 +111,8 @@ public: return FT(1); } - FT cartesian(int i) const; - FT operator[](int i) const; + const FT & cartesian(int i) const; + const FT & operator[](int i) const; FT homogeneous(int i) const; int dimension() const @@ -133,7 +133,7 @@ public: template < class R > inline -typename PointC3::FT +const typename PointC3::FT & PointC3::cartesian(int i) const { CGAL_kernel_precondition( (i>=0) && (i<=2) ); @@ -146,7 +146,7 @@ PointC3::cartesian(int i) const template < class R > inline -typename PointC3::FT +const typename PointC3::FT & PointC3::operator[](int i) const { return cartesian(i); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h index 370a272adc2..0cfb9afdebc 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h @@ -74,13 +74,13 @@ public: bool operator==(const Self &r) const; bool operator!=(const Self &r) const; - Point_2 start() const; - Point_2 source() const + const Point_2 & start() const; + const Point_2 & source() const { return Ptr()->e0; } Point_2 point(int i) const; - Point_2 second_point() const + const Point_2 & second_point() const { return Ptr()->e1; } @@ -125,7 +125,7 @@ RayC2::operator!=(const RayC2 &r) const template < class R > inline -typename RayC2::Point_2 +const typename RayC2::Point_2 & RayC2::start() const { return source(); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h index a20e291029b..15d94412c49 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h @@ -64,12 +64,12 @@ public: bool operator==(const Self &r) const; bool operator!=(const Self &r) const; - Point_3 start() const; - Point_3 source() const + const Point_3 & start() const; + const Point_3 & source() const { return Ptr()->e0; } - Point_3 second_point() const + const Point_3 & second_point() const { return Ptr()->e1; } @@ -113,7 +113,7 @@ RayC3::operator!=(const RayC3 &r) const template < class R > inline -typename RayC3::Point_3 +const typename RayC3::Point_3 & RayC3::start() const { return source(); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h index c1a3037cde3..df4c5728ab7 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h @@ -77,23 +77,23 @@ public: bool operator==(const Self &s) const; bool operator!=(const Self &s) const; - Point_2 source() const + const Point_2 & source() const { return Ptr()->e0; } - Point_2 target() const + const Point_2 & target() const { return Ptr()->e1; } - Point_2 start() const; - Point_2 end() const; + const Point_2 & start() const; + const Point_2 & end() const; - Point_2 min() const; - Point_2 max() const; - Point_2 vertex(int i) const; - Point_2 point(int i) const; - Point_2 operator[](int i) const; + const Point_2 & min() const; + const Point_2 & max() const; + const Point_2 & vertex(int i) const; + const Point_2 & point(int i) const; + const Point_2 & operator[](int i) const; FT squared_length() const; @@ -133,7 +133,7 @@ SegmentC2::operator!=(const SegmentC2 &s) const template < class R > inline -typename SegmentC2::Point_2 +const typename SegmentC2::Point_2 & SegmentC2::start() const { return source(); @@ -141,7 +141,7 @@ SegmentC2::start() const template < class R > inline -typename SegmentC2::Point_2 +const typename SegmentC2::Point_2 & SegmentC2::end() const { return target(); @@ -149,7 +149,7 @@ SegmentC2::end() const template < class R > CGAL_KERNEL_INLINE -typename SegmentC2::Point_2 +const typename SegmentC2::Point_2 & SegmentC2::min() const { return lexicographically_xy_smaller(source(),target()) ? source() : target(); @@ -157,7 +157,7 @@ SegmentC2::min() const template < class R > CGAL_KERNEL_INLINE -typename SegmentC2::Point_2 +const typename SegmentC2::Point_2 & SegmentC2::max() const { return lexicographically_xy_smaller(source(),target()) ? target() : source(); @@ -165,7 +165,7 @@ SegmentC2::max() const template < class R > CGAL_KERNEL_INLINE -typename SegmentC2::Point_2 +const typename SegmentC2::Point_2 & SegmentC2::vertex(int i) const { return (i%2 == 0) ? source() : target(); @@ -173,7 +173,7 @@ SegmentC2::vertex(int i) const template < class R > CGAL_KERNEL_INLINE -typename SegmentC2::Point_2 +const typename SegmentC2::Point_2 & SegmentC2::point(int i) const { return (i%2 == 0) ? source() : target(); @@ -181,7 +181,7 @@ SegmentC2::point(int i) const template < class R > inline -typename SegmentC2::Point_2 +const typename SegmentC2::Point_2 & SegmentC2::operator[](int i) const { return vertex(i); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h index cb851bb124c..1969f3b380f 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h @@ -64,23 +64,23 @@ public: bool operator==(const Self &s) const; bool operator!=(const Self &s) const; - Point_3 source() const + const Point_3 & source() const { return Ptr()->e0; } - Point_3 target() const + const Point_3 & target() const { return Ptr()->e1; } - Point_3 start() const; - Point_3 end() const; + const Point_3 & start() const; + const Point_3 & end() const; - Point_3 min() const; - Point_3 max() const; - Point_3 vertex(int i) const; - Point_3 point(int i) const; - Point_3 operator[](int i) const; + const Point_3 & min() const; + const Point_3 & max() const; + const Point_3 & vertex(int i) const; + const Point_3 & point(int i) const; + const Point_3 & operator[](int i) const; FT squared_length() const; @@ -119,14 +119,14 @@ SegmentC3::operator!=(const SegmentC3 &s) const } template < class R > -typename SegmentC3::Point_3 +const typename SegmentC3::Point_3 & SegmentC3::start() const { return source(); } template < class R > -typename SegmentC3::Point_3 +const typename SegmentC3::Point_3 & SegmentC3::end() const { return target(); @@ -134,7 +134,7 @@ SegmentC3::end() const template < class R > inline -typename SegmentC3::Point_3 +const typename SegmentC3::Point_3 & SegmentC3::min() const { return lexicographically_xyz_smaller(source(),target()) ? source() @@ -143,7 +143,7 @@ SegmentC3::min() const template < class R > inline -typename SegmentC3::Point_3 +const typename SegmentC3::Point_3 & SegmentC3::max() const { return lexicographically_xyz_smaller(source(),target()) ? target() @@ -152,7 +152,7 @@ SegmentC3::max() const template < class R > inline -typename SegmentC3::Point_3 +const typename SegmentC3::Point_3 & SegmentC3::vertex(int i) const { return (i%2 == 0) ? source() : target(); @@ -160,7 +160,7 @@ SegmentC3::vertex(int i) const template < class R > inline -typename SegmentC3::Point_3 +const typename SegmentC3::Point_3 & SegmentC3::point(int i) const { return (i%2 == 0) ? source() : target(); @@ -168,7 +168,7 @@ SegmentC3::point(int i) const template < class R > inline -typename SegmentC3::Point_3 +const typename SegmentC3::Point_3 & SegmentC3::operator[](int i) const { return vertex(i); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h index 275467487f3..d12a803189e 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h @@ -109,11 +109,11 @@ public: bool operator==(const Self &) const; bool operator!=(const Self &) const; - Point_3 center() const + const Point_3 & center() const { return Ptr()->center; } - FT squared_radius() const + const FT & squared_radius() const { // Returns the square of the radius (instead of the radius itself, // which would require square roots) diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h index fd3399c1127..e45deb72530 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h @@ -60,8 +60,8 @@ public: const Point_3 &s) : Tetrahedron_handle_3_(Tetrahedron_ref_3(p, q, r, s)) {} - Point_3 vertex(int i) const; - Point_3 operator[](int i) const; + const Point_3 & vertex(int i) const; + const Point_3 & operator[](int i) const; bool operator==(const Self &t) const; bool operator!=(const Self &t) const; @@ -131,7 +131,7 @@ operator!=(const TetrahedronC3 &t) const } template < class R > -typename TetrahedronC3::Point_3 +const typename TetrahedronC3::Point_3 & TetrahedronC3:: vertex(int i) const { @@ -148,7 +148,7 @@ vertex(int i) const template < class R > inline -typename TetrahedronC3::Point_3 +const typename TetrahedronC3::Point_3 & TetrahedronC3:: operator[](int i) const { diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h index 7374d7f1f0d..ef61f7e56bd 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h @@ -72,8 +72,8 @@ public: bool operator==(const Self &s) const; bool operator!=(const Self &s) const; - Point_2 vertex(int i) const; - Point_2 operator[](int i) const; + const Point_2 & vertex(int i) const; + const Point_2 & operator[](int i) const; Self opposite() const; Self transform(const Aff_transformation_2 &t) const @@ -132,7 +132,7 @@ TriangleC2::operator!=(const TriangleC2 &t) const template < class R > CGAL_KERNEL_MEDIUM_INLINE -typename TriangleC2::Point_2 +const typename TriangleC2::Point_2 & TriangleC2::vertex(int i) const { if (i>2) i = i%3; @@ -144,7 +144,7 @@ TriangleC2::vertex(int i) const template < class R > inline -typename TriangleC2::Point_2 +const typename TriangleC2::Point_2 & TriangleC2::operator[](int i) const { return vertex(i); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h index a7853db55a1..5d5fb0a0113 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h @@ -73,8 +73,8 @@ public: bool has_on(const Point_3 &p) const; bool is_degenerate() const; - Point_3 vertex(int i) const; - Point_3 operator[](int i) const; + const Point_3 & vertex(int i) const; + const Point_3 & operator[](int i) const; Bbox_3 bbox() const; @@ -109,7 +109,7 @@ TriangleC3::operator!=(const TriangleC3 &t) const } template < class R > -typename TriangleC3::Point_3 +const typename TriangleC3::Point_3 & TriangleC3::vertex(int i) const { if (i<0) i=(i%3)+3; @@ -121,7 +121,7 @@ TriangleC3::vertex(int i) const template < class R > inline -typename TriangleC3::Point_3 +const typename TriangleC3::Point_3 & TriangleC3::operator[](int i) const { return vertex(i); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h index 32e10fc32c6..e9bd7615454 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h @@ -93,20 +93,20 @@ public: bool operator==(const Null_vector &) const; bool operator!=(const Null_vector &p) const; - FT x() const + const FT & x() const { return Ptr()->e0; } - FT y() const + const FT & y() const { return Ptr()->e1; } - FT hx() const + const FT & hx() const { return x(); } - FT hy() const + const FT & hy() const { return y(); } @@ -115,8 +115,8 @@ public: return FT(1); } - FT cartesian(int i) const; - FT operator[](int i) const; + const FT & cartesian(int i) const; + const FT & operator[](int i) const; FT homogeneous(int i) const; int dimension() const @@ -179,7 +179,7 @@ VectorC2::operator!=(const Null_vector &v) const template < class R > CGAL_KERNEL_INLINE -typename VectorC2::FT +const typename VectorC2::FT & VectorC2::cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) ); @@ -188,7 +188,7 @@ VectorC2::cartesian(int i) const template < class R > inline -typename VectorC2::FT +const typename VectorC2::FT & VectorC2::operator[](int i) const { return cartesian(i); diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index 46a5e4f1732..4ceeaaa6384 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -82,28 +82,28 @@ public: bool operator==(const Null_vector &) const; bool operator!=(const Null_vector &) const; - FT x() const + const FT & x() const { return Ptr()->e0; } - FT y() const + const FT & y() const { return Ptr()->e1; } - FT z() const + const FT & z() const { return Ptr()->e2; } - FT hx() const + const FT & hx() const { return x(); } - FT hy() const + const FT & hy() const { return y(); } - FT hz() const + const FT & hz() const { return z(); } @@ -112,8 +112,8 @@ public: return FT(1); } - FT cartesian(int i) const; - FT operator[](int i) const; + const FT & cartesian(int i) const; + const FT & operator[](int i) const; FT homogeneous(int i) const; int dimension() const @@ -175,7 +175,7 @@ VectorC3::operator!=(const Null_vector &v) const template < class R > inline -typename VectorC3::FT +const typename VectorC3::FT & VectorC3::cartesian(int i) const { CGAL_kernel_precondition( (i>=0) && (i<3) ); @@ -186,7 +186,7 @@ VectorC3::cartesian(int i) const template < class R > inline -typename VectorC3::FT +const typename VectorC3::FT & VectorC3::operator[](int i) const { return cartesian(i); diff --git a/Packages/H2/changes.txt b/Packages/H2/changes.txt index eb4be9be79a..21b8633021f 100644 --- a/Packages/H2/changes.txt +++ b/Packages/H2/changes.txt @@ -1,3 +1,6 @@ +2.39 (2 October 2001) +- Access functions of objects (like .x() ) now return const references. + 2.38 (15 August 2001) - SunPro patches. diff --git a/Packages/H2/include/CGAL/Aff_transformationH2.h b/Packages/H2/include/CGAL/Aff_transformationH2.h index f03c7c0fcf2..88e58815773 100644 --- a/Packages/H2/include/CGAL/Aff_transformationH2.h +++ b/Packages/H2/include/CGAL/Aff_transformationH2.h @@ -456,9 +456,9 @@ class Reflection_repH2 : public Aff_transformation_rep_baseH2 general_form() const { const RT mRT2 = - RT(2); - const RT& a = l.a_ref(); - const RT& b = l.b_ref(); - const RT& c = l.c_ref(); + const RT& a = l.a(); + const RT& b = l.b(); + const RT& c = l.c(); RT de = a*a + b*b; RT aa = b*b - a*a; RT bb = a*a - b*b; diff --git a/Packages/H2/include/CGAL/CircleH2.h b/Packages/H2/include/CGAL/CircleH2.h index 84ff22c26f7..13f4f1ffa25 100644 --- a/Packages/H2/include/CGAL/CircleH2.h +++ b/Packages/H2/include/CGAL/CircleH2.h @@ -123,13 +123,13 @@ public: CircleH2 orthogonal_transform(const Aff_transformationH2&) const; - PointH2 + const PointH2 & center() const; Orientation orientation() const; - FT + const FT & squared_radius() const; CircleH2 @@ -160,13 +160,13 @@ public: template inline -PointH2 +const PointH2 & CircleH2::center() const { return Ptr()->center; } template inline -typename CircleH2::FT +const typename CircleH2::FT & CircleH2::squared_radius() const { return Ptr()->squared_radius; } diff --git a/Packages/H2/include/CGAL/Iso_rectangleH2.h b/Packages/H2/include/CGAL/Iso_rectangleH2.h index edb134dda99..ea47066bad6 100644 --- a/Packages/H2/include/CGAL/Iso_rectangleH2.h +++ b/Packages/H2/include/CGAL/Iso_rectangleH2.h @@ -55,8 +55,8 @@ public: bool operator==(const Iso_rectangleH2& s) const; bool operator!=(const Iso_rectangleH2& s) const; - PointH2 min() const; - PointH2 max() const; + const PointH2 & min() const; + const PointH2 & max() const; PointH2 vertex(int i) const; PointH2 operator[](int i) const; @@ -150,13 +150,13 @@ Iso_rectangleH2::operator!=(const Iso_rectangleH2& r) const template < class R > inline -PointH2 +const PointH2 & Iso_rectangleH2::min() const { return Ptr()->e0; } template < class R > inline -PointH2 +const PointH2 & Iso_rectangleH2::max() const { return Ptr()->e1; } @@ -229,12 +229,11 @@ Iso_rectangleH2::vertex(int i) const min().hw()*max().hw() ); case 2: return max(); - case 3: + default: // case 3: return PointH2( min().hx()*max().hw(), max().hy()*min().hw(), min().hw()*max().hw() ); } - return PointH2(); } template < class R > diff --git a/Packages/H2/include/CGAL/LineH2.h b/Packages/H2/include/CGAL/LineH2.h index 886df80ec41..383798644eb 100644 --- a/Packages/H2/include/CGAL/LineH2.h +++ b/Packages/H2/include/CGAL/LineH2.h @@ -51,12 +51,9 @@ public: bool operator==(const LineH2& l) const ; bool operator!=(const LineH2& l) const ; - RT a() const; - RT b() const; - RT c() const; - const RT& a_ref() const { return Ptr()->e0; } - const RT& b_ref() const { return Ptr()->e1; } - const RT& c_ref() const { return Ptr()->e2; } + const RT & a() const { return Ptr()->e0; } + const RT & b() const { return Ptr()->e1; } + const RT & c() const { return Ptr()->e2; } FT x_at_y(FT y) const; FT y_at_x(FT x) const; @@ -146,25 +143,6 @@ LineH2::LineH2(const PointH2& p, p.hx()*q.hy() - p.hy()*q.hx() ) ); } -template < class R > -inline -typename LineH2::RT -LineH2::a() const -{ return Ptr()->e0; } - -template < class R > -inline -typename LineH2::RT -LineH2::b() const -{ return Ptr()->e1; } - -template < class R > -inline -typename LineH2::RT -LineH2::c() const -{ return Ptr()->e2; } - - template < class R > CGAL_KERNEL_INLINE typename LineH2::FT diff --git a/Packages/H2/include/CGAL/PVDH2.h b/Packages/H2/include/CGAL/PVDH2.h index 835dab081b2..8e33ae91b8c 100644 --- a/Packages/H2/include/CGAL/PVDH2.h +++ b/Packages/H2/include/CGAL/PVDH2.h @@ -25,10 +25,6 @@ #ifndef CGAL_PVDH2_H #define CGAL_PVDH2_H -#define CGAL_POINTH2_H -#define CGAL_VECTORH2_H -#define CGAL_DIRECTIONH2_H - #include #include #include @@ -57,21 +53,16 @@ public: bool operator==( const PointH2& p) const; bool operator!=( const PointH2& p) const; - RT hx() const { return Ptr()->e0; }; - RT hy() const { return Ptr()->e1; }; - RT hw() const { return Ptr()->e2; }; + const RT & hx() const { return Ptr()->e0; }; + const RT & hy() const { return Ptr()->e1; }; + const RT & hw() const { return Ptr()->e2; }; FT x() const { return FT(hx()) / FT(hw()); }; FT y() const { return FT(hy()) / FT(hw()); }; FT cartesian(int i) const; FT operator[](int i) const; - RT homogeneous(int i) const; - - // and for efficiency in the predicates: - const RT& hx_ref() const { return Ptr()->e0; }; - const RT& hy_ref() const { return Ptr()->e1; }; - const RT& hw_ref() const { return Ptr()->e2; }; + const RT & homogeneous(int i) const; int dimension() const; Bbox_2 bbox() const; @@ -104,15 +95,15 @@ public: bool operator==( const Null_vector&) const; bool operator!=( const Null_vector& v) const; - RT hx() const { return Ptr()->e0; }; - RT hy() const { return Ptr()->e1; }; - RT hw() const { return Ptr()->e2; }; + const RT & hx() const { return Ptr()->e0; }; + const RT & hy() const { return Ptr()->e1; }; + const RT & hw() const { return Ptr()->e2; }; FT x() const { return FT(hx()) / FT(hw()); }; FT y() const { return FT(hy()) / FT(hw()); }; FT cartesian(int i) const; - RT homogeneous(int i) const; + const RT & homogeneous(int i) const; FT operator[](int i) const; int dimension() const; @@ -165,12 +156,12 @@ public: VectorH2 to_vector() const; - RT x() const { return Ptr()->e0; }; - RT y() const { return Ptr()->e1; }; + const RT & x() const { return Ptr()->e0; }; + const RT & y() const { return Ptr()->e1; }; - RT delta(int i) const; - RT dx() const { return Ptr()->e0; }; - RT dy() const { return Ptr()->e1; }; + const RT & delta(int i) const; + const RT & dx() const { return Ptr()->e0; }; + const RT & dy() const { return Ptr()->e1; }; DirectionH2 perpendicular(const Orientation &o) const; DirectionH2 transform(const Aff_transformationH2 &) const; @@ -245,7 +236,7 @@ PointH2::cartesian(int i) const template < class R > CGAL_KERNEL_INLINE -typename PointH2::RT +const typename PointH2::RT & PointH2::homogeneous(int i) const { CGAL_kernel_precondition( (i>=0) && (i<=2) ); @@ -361,7 +352,7 @@ VectorH2::cartesian(int i) const template < class R > CGAL_KERNEL_INLINE -typename VectorH2::RT +const typename VectorH2::RT & VectorH2::homogeneous(int i) const { CGAL_kernel_precondition( (i>=0) && (i<=2) ); @@ -476,7 +467,7 @@ DirectionH2::operator-() const template CGAL_KERNEL_INLINE -typename DirectionH2::RT +const typename DirectionH2::RT & DirectionH2::delta(int i) const { CGAL_kernel_precondition( ( i == 0 ) || ( i == 1 ) ); diff --git a/Packages/H2/include/CGAL/RayH2.h b/Packages/H2/include/CGAL/RayH2.h index 03a78a7dcbd..bb58dce2311 100644 --- a/Packages/H2/include/CGAL/RayH2.h +++ b/Packages/H2/include/CGAL/RayH2.h @@ -35,8 +35,7 @@ public: Ray_repH2(const PointH2& fp, const PointH2& sp) : start(fp), second(sp) {} - PointH2 start; - PointH2 second; + PointH2 start, second; }; template < class R > @@ -47,8 +46,7 @@ public: Simple_Ray_repH2(const PointH2& fp, const PointH2& sp) : start(fp), second(sp) {} - PointH2 start; - PointH2 second; + PointH2 start, second; }; template < class R_ > @@ -73,9 +71,9 @@ public: bool operator==(const RayH2& r) const; bool operator!=(const RayH2& r) const; - PointH2 start() const; - PointH2 source() const; - PointH2 second_point() const; + const PointH2 & start() const; + const PointH2 & source() const; + const PointH2 & second_point() const; PointH2 point(int i) const; DirectionH2 direction() const; LineH2 supporting_line() const; @@ -93,13 +91,13 @@ public: template < class R > inline -PointH2 +const PointH2 & RayH2::source() const { return Ptr()->start; } template < class R > inline -PointH2 +const PointH2 & RayH2::start() const { return Ptr()->start; } @@ -109,11 +107,11 @@ DirectionH2 RayH2::direction() const { CGAL_kernel_precondition( !is_degenerate() ); - return DirectionH2( Ptr()->second - Ptr()->start ); + return DirectionH2( second_point() - start() ); } template < class R > inline -PointH2 +const PointH2 & RayH2::second_point() const { CGAL_kernel_precondition( !is_degenerate() ); @@ -144,7 +142,7 @@ template < class R > inline RayH2 RayH2::opposite() const -{ return RayH2( Ptr()->start, - direction() ); } +{ return RayH2( start(), - direction() ); } template < class R > CGAL_KERNEL_INLINE @@ -152,8 +150,7 @@ RayH2 RayH2:: transform(const Aff_transformationH2 & t) const { - return RayH2(t.transform(Ptr()->start), - t.transform(Ptr()->second) ); + return RayH2(t.transform(start()), t.transform(second_point()) ); } #ifndef CGAL_NO_OSTREAM_INSERT_RAYH2 @@ -206,21 +203,21 @@ CGAL_KERNEL_INLINE bool RayH2::has_on(const PointH2 p) const { - return ( ( p == start() ) - ||(DirectionH2(p - Ptr()->start) == direction() ) ); + return p == start() || DirectionH2(p - start()) == direction(); } template < class R > CGAL_KERNEL_INLINE bool RayH2::is_degenerate() const -{ return ( (Ptr()->start == Ptr()->second) ); } +{ return start() == Ptr()->second; } template < class R > inline bool RayH2::collinear_has_on(const PointH2 p) const { return has_on(p); } + template < class R > CGAL_KERNEL_INLINE bool diff --git a/Packages/H2/include/CGAL/SegmentH2.h b/Packages/H2/include/CGAL/SegmentH2.h index 062af1e2787..9a35487eae1 100644 --- a/Packages/H2/include/CGAL/SegmentH2.h +++ b/Packages/H2/include/CGAL/SegmentH2.h @@ -38,8 +38,7 @@ public: Segment_repH2(const PointH2& sp, const PointH2& ep) : start(sp), end(ep) {} - PointH2 start; - PointH2 end; + PointH2 start, end; }; template < class R > @@ -50,8 +49,7 @@ public: Simple_Segment_repH2(const PointH2& sp, const PointH2& ep) : start(sp), end(ep) {} - PointH2 start; - PointH2 end; + PointH2 start, end; }; template < class R_ > @@ -82,16 +80,16 @@ public: bool operator==(const SegmentH2& s) const; bool operator!=(const SegmentH2& s) const; - PointH2 source() const; - PointH2 target() const; - PointH2 start() const; - PointH2 end() const; - PointH2 vertex(int i) const; - PointH2 point(int i) const; - PointH2 operator[](int i) const; - PointH2 min() const; - PointH2 max() const; - PointH2 other_vertex(const PointH2& p) const; + const PointH2 & source() const; + const PointH2 & target() const; + const PointH2 & start() const; + const PointH2 & end() const; + const PointH2 & vertex(int i) const; + const PointH2 & point(int i) const; + const PointH2 & operator[](int i) const; + const PointH2 & min() const; + const PointH2 & max() const; + const PointH2 & other_vertex(const PointH2& p) const; bool is_horizontal() const; bool is_vertical() const; @@ -115,31 +113,31 @@ public: template < class R > inline -PointH2 +const PointH2 & SegmentH2::source() const { return Ptr()->start; } template < class R > inline -PointH2 +const PointH2 & SegmentH2::start() const { return Ptr()->start; } template < class R > inline -PointH2 +const PointH2 & SegmentH2::target() const { return Ptr()->end; } template < class R > inline -PointH2 +const PointH2 & SegmentH2::end() const { return Ptr()->end; } template < class R > CGAL_KERNEL_INLINE -PointH2 +const PointH2 & SegmentH2::min() const { return @@ -148,7 +146,7 @@ SegmentH2::min() const template < class R > CGAL_KERNEL_INLINE -PointH2 +const PointH2 & SegmentH2::max() const { return @@ -157,7 +155,7 @@ SegmentH2::max() const template < class R > CGAL_KERNEL_INLINE -PointH2 +const PointH2 & SegmentH2::other_vertex(const PointH2& p) const { CGAL_kernel_precondition( (p == end()) || (p == start()) ); @@ -166,26 +164,21 @@ SegmentH2::other_vertex(const PointH2& p) const template < class R > CGAL_KERNEL_INLINE -PointH2 +const PointH2 & SegmentH2::vertex(int i) const { - switch (i%2) - { - case 0: return Ptr()->start; - case 1: return Ptr()->end; - }; - return PointH2(); // otherwise the SGI compiler complains + return (i%2 == 0) ? start() : end(); } template < class R > inline -PointH2 +const PointH2 & SegmentH2::point(int i) const { return vertex(i); } template < class R > inline -PointH2 +const PointH2 & SegmentH2::operator[](int i) const { return vertex(i); } @@ -193,7 +186,7 @@ template < class R > CGAL_KERNEL_INLINE typename SegmentH2::FT SegmentH2::squared_length() const -{ return (Ptr()->end - Ptr()->start) * (Ptr()->end - Ptr()->start); } +{ return (end() - start()) * (end() - start()); } template < class R > CGAL_KERNEL_INLINE @@ -201,7 +194,7 @@ DirectionH2 SegmentH2::direction() const { CGAL_kernel_precondition( !is_degenerate() ); - return DirectionH2( Ptr()->end - Ptr()->start ); + return DirectionH2( end() - start() ); } template < class R > @@ -210,14 +203,14 @@ LineH2 SegmentH2::supporting_line() const { CGAL_kernel_precondition( !is_degenerate() ); - return LineH2(Ptr()->start, Ptr()->end); + return LineH2(start(), end()); } template < class R > CGAL_KERNEL_INLINE SegmentH2 SegmentH2::opposite() const -{ return SegmentH2(Ptr()->end, Ptr()->start); } +{ return SegmentH2(end(), start()); } template < class R > CGAL_KERNEL_INLINE @@ -225,8 +218,7 @@ SegmentH2 SegmentH2:: transform(const Aff_transformationH2& t) const { - return SegmentH2(t.transform(Ptr()->start), - t.transform(Ptr()->end) ); + return SegmentH2(t.transform(start()), t.transform(end()) ); } template < class R > diff --git a/Packages/H2/include/CGAL/TriangleH2.h b/Packages/H2/include/CGAL/TriangleH2.h index d3b3729c23b..0160e7da1b7 100644 --- a/Packages/H2/include/CGAL/TriangleH2.h +++ b/Packages/H2/include/CGAL/TriangleH2.h @@ -118,8 +118,8 @@ public: // bool oriented_equal( const TriangleH2& ) const; // bool unoriented_equal( const TriangleH2& ) const; - PointH2 vertex(int i) const; - PointH2 operator[](int i) const; + const PointH2 & vertex(int i) const; + const PointH2 & operator[](int i) const; FT area() const; }; @@ -130,7 +130,7 @@ public: template CGAL_KERNEL_INLINE -PointH2 +const PointH2 & TriangleH2::vertex(int i) const { if (i>2) i = i%3; @@ -140,7 +140,7 @@ TriangleH2::vertex(int i) const template inline -PointH2 +const PointH2 & TriangleH2::operator[](int i) const { return vertex(i); } diff --git a/Packages/H2/include/CGAL/predicates_on_directionsH2.h b/Packages/H2/include/CGAL/predicates_on_directionsH2.h index 002bd3344b4..4811fa8c8f2 100644 --- a/Packages/H2/include/CGAL/predicates_on_directionsH2.h +++ b/Packages/H2/include/CGAL/predicates_on_directionsH2.h @@ -51,13 +51,13 @@ compare_angle_with_x_axis(const DirectionH2& d1, // PointH2 p1 = ORIGIN + d1.vector(); // Commented out // PointH2 p2 = ORIGIN + d2.vector(); // Commented out - CGAL_kernel_precondition( RT0 < p1.hw_ref() ); - CGAL_kernel_precondition( RT0 < p2.hw_ref() ); + CGAL_kernel_precondition( RT0 < p1.hw() ); + CGAL_kernel_precondition( RT0 < p2.hw() ); - int x_sign1 = static_cast(CGAL_NTS sign( p1.hx_ref() )); - int x_sign2 = static_cast(CGAL_NTS sign( p2.hx_ref() )); - int y_sign1 = static_cast(CGAL_NTS sign( p1.hy_ref() )); - int y_sign2 = static_cast(CGAL_NTS sign( p2.hy_ref() )); + int x_sign1 = static_cast(CGAL_NTS sign( p1.hx() )); + int x_sign2 = static_cast(CGAL_NTS sign( p2.hx() )); + int y_sign1 = static_cast(CGAL_NTS sign( p1.hy() )); + int y_sign2 = static_cast(CGAL_NTS sign( p2.hy() )); if ( y_sign1 * y_sign2 < 0) { diff --git a/Packages/H2/include/CGAL/predicates_on_pointsH2.h b/Packages/H2/include/CGAL/predicates_on_pointsH2.h index a93acc61f29..3e883b01b84 100644 --- a/Packages/H2/include/CGAL/predicates_on_pointsH2.h +++ b/Packages/H2/include/CGAL/predicates_on_pointsH2.h @@ -51,12 +51,12 @@ equal_xy(const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); RT pV = phx*qhw; RT qV = qhx*phw; @@ -75,12 +75,12 @@ compare_xy(const PointH2& p, const PointH2& q) { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); RT pV = phx*qhw; RT qV = qhx*phw; @@ -119,12 +119,12 @@ lexicographically_xy_smaller_or_equal(const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); RT pV = phx * qhw; RT qV = qhx * phw; @@ -150,12 +150,12 @@ lexicographically_xy_smaller(const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); RT pV = phx * qhw; RT qV = qhx * phw; @@ -188,12 +188,12 @@ lexicographically_xy_larger(const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); RT pV = phx * qhw; RT qV = qhx * phw; @@ -217,12 +217,12 @@ compare_yx(const PointH2& p, const PointH2& q) { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); RT pV = phy*qhw; RT qV = qhy*phw; @@ -258,12 +258,12 @@ lexicographically_yx_smaller_or_equal(const PointH2& p, const PointH2& q) { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); RT pV = phy * qhw; RT qV = qhy * phw; @@ -287,12 +287,12 @@ lexicographically_yx_smaller(const PointH2& p, const PointH2& q) { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); RT pV = phy * qhw; RT qV = qhy * phw; @@ -325,12 +325,12 @@ lexicographically_yx_larger(const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); RT pV = phy * qhw; RT qV = qhy * phw; @@ -356,10 +356,10 @@ compare_x(const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhw = q.hw(); const RT RT0 = RT(0); RT com = phx * qhw - qhx * phw; if ( com < RT0 ) @@ -381,10 +381,10 @@ compare_y(const PointH2& p, { typedef typename R::RT RT; - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); const RT RT0 = RT(0); RT com = phy * qhw - qhy * phw; if ( com < RT0 ) @@ -407,15 +407,15 @@ orientation( const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); - const RT& rhx = r.hx_ref(); - const RT& rhy = r.hy_ref(); - const RT& rhw = r.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); + const RT& rhx = r.hx(); + const RT& rhy = r.hy(); + const RT& rhw = r.hw(); const RT RT0 = RT(0); // | A B | @@ -429,9 +429,9 @@ orientation( const PointH2& p, RT det = A*D - B*C; /* - RT det_old = p.hx_ref() * (q.hy_ref()*r.hw_ref() - q.hw_ref()*r.hy_ref() ) - + p.hy_ref() * (q.hw_ref()*r.hx_ref() - q.hx_ref()*r.hw_ref() ) - + p.hw_ref() * (q.hx_ref()*r.hy_ref() - q.hy_ref()*r.hx_ref() ); + RT det_old = p.hx() * (q.hy()*r.hw() - q.hw()*r.hy() ) + + p.hy() * (q.hw()*r.hx() - q.hx()*r.hw() ) + + p.hw() * (q.hx()*r.hy() - q.hy()*r.hx() ); if ( !(CGAL_NTS sign(det) == CGAL_NTS sign(det_old)) ) { @@ -466,15 +466,15 @@ left_turn( const PointH2& p, const PointH2& q, const PointH2& r) { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); - const RT& rhx = r.hx_ref(); - const RT& rhy = r.hy_ref(); - const RT& rhw = r.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); + const RT& rhx = r.hx(); + const RT& rhy = r.hy(); + const RT& rhw = r.hw(); const RT RT0 = RT(0); // | A B | @@ -488,9 +488,9 @@ left_turn( const PointH2& p, const PointH2& q, const PointH2& r) RT det = A*D - B*C; /* - RT det_old = p.hx_ref() * (q.hy_ref()*r.hw_ref() - q.hw_ref()*r.hy_ref() ) - + p.hy_ref() * (q.hw_ref()*r.hx_ref() - q.hx_ref()*r.hw_ref() ) - + p.hw_ref() * (q.hx_ref()*r.hy_ref() - q.hy_ref()*r.hx_ref() ); + RT det_old = p.hx() * (q.hy()*r.hw() - q.hw()*r.hy() ) + + p.hy() * (q.hw()*r.hx() - q.hx()*r.hw() ) + + p.hw() * (q.hx()*r.hy() - q.hy()*r.hx() ); if ( !(CGAL_NTS sign(det) == CGAL_NTS sign(det_old)) ) { @@ -519,15 +519,15 @@ right_turn( const PointH2& p, const PointH2& q, const PointH2& r) { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); - const RT& rhx = r.hx_ref(); - const RT& rhy = r.hy_ref(); - const RT& rhw = r.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); + const RT& rhx = r.hx(); + const RT& rhy = r.hy(); + const RT& rhw = r.hw(); const RT RT0 = RT(0); // | A B | @@ -541,9 +541,9 @@ right_turn( const PointH2& p, const PointH2& q, const PointH2& r) RT det = A*D - B*C; /* - RT det_old = p.hx_ref() * (q.hy_ref()*r.hw_ref() - q.hw_ref()*r.hy_ref() ) - + p.hy_ref() * (q.hw_ref()*r.hx_ref() - q.hx_ref()*r.hw_ref() ) - + p.hw_ref() * (q.hx_ref()*r.hy_ref() - q.hy_ref()*r.hx_ref() ); + RT det_old = p.hx() * (q.hy()*r.hw() - q.hw()*r.hy() ) + + p.hy() * (q.hw()*r.hx() - q.hx()*r.hw() ) + + p.hw() * (q.hx()*r.hy() - q.hy()*r.hx() ); if ( !(CGAL_NTS sign(det) == CGAL_NTS sign(det_old)) ) { @@ -574,15 +574,15 @@ collinear( const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); - const RT& rhx = r.hx_ref(); - const RT& rhy = r.hy_ref(); - const RT& rhw = r.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); + const RT& rhx = r.hx(); + const RT& rhy = r.hy(); + const RT& rhw = r.hw(); const RT RT0 = RT(0); // | A B | @@ -596,9 +596,9 @@ collinear( const PointH2& p, RT det = A*D - B*C; /* - RT det_old = p.hx_ref() * (q.hy_ref()*r.hw_ref() - q.hw_ref()*r.hy_ref() ) - + p.hy_ref() * (q.hw_ref()*r.hx_ref() - q.hx_ref()*r.hw_ref() ) - + p.hw_ref() * (q.hx_ref()*r.hy_ref() - q.hy_ref()*r.hx_ref() ); + RT det_old = p.hx() * (q.hy()*r.hw() - q.hw()*r.hy() ) + + p.hy() * (q.hw()*r.hx() - q.hx()*r.hw() ) + + p.hw() * (q.hx()*r.hy() - q.hy()*r.hx() ); if ( !(CGAL_NTS sign(det) == CGAL_NTS sign(det_old)) ) { @@ -618,15 +618,15 @@ side_of_bounded_circle( const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); - const RT& thx = t.hx_ref(); - const RT& thy = t.hy_ref(); - const RT& thw = t.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); + const RT& thx = t.hx(); + const RT& thy = t.hy(); + const RT& thw = t.hw(); return Bounded_side( CGAL_NTS compare((thx*phw-phx*thw)*(qhx*thw-thx*qhw), (thy*phw-phy*thw)*(thy*qhw-qhy*thw)) ); @@ -642,18 +642,18 @@ side_of_bounded_circle( const PointH2& q, { typedef typename R::RT RT; - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); - const RT& rhx = r.hx_ref(); - const RT& rhy = r.hy_ref(); - const RT& rhw = r.hw_ref(); - const RT& shx = s.hx_ref(); - const RT& shy = s.hy_ref(); - const RT& shw = s.hw_ref(); - const RT& thx = t.hx_ref(); - const RT& thy = t.hy_ref(); - const RT& thw = t.hw_ref(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); + const RT& rhx = r.hx(); + const RT& rhy = r.hy(); + const RT& rhw = r.hw(); + const RT& shx = s.hx(); + const RT& shy = s.hy(); + const RT& shw = s.hw(); + const RT& thx = t.hx(); + const RT& thy = t.hy(); + const RT& thw = t.hw(); const RT RT0 = RT(0); CGAL_kernel_precondition( ! collinear(q,r,s) ); @@ -714,18 +714,18 @@ side_of_oriented_circle( const PointH2& q, { typedef typename R::RT RT; - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); - const RT& rhx = r.hx_ref(); - const RT& rhy = r.hy_ref(); - const RT& rhw = r.hw_ref(); - const RT& shx = s.hx_ref(); - const RT& shy = s.hy_ref(); - const RT& shw = s.hw_ref(); - const RT& thx = t.hx_ref(); - const RT& thy = t.hy_ref(); - const RT& thw = t.hw_ref(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); + const RT& rhx = r.hx(); + const RT& rhy = r.hy(); + const RT& rhw = r.hw(); + const RT& shx = s.hx(); + const RT& shy = s.hy(); + const RT& shw = s.hw(); + const RT& thx = t.hx(); + const RT& thy = t.hy(); + const RT& thw = t.hw(); const RT RT0 = RT(0); CGAL_kernel_precondition( ! collinear(q,r,s) ); @@ -780,15 +780,15 @@ collinear_are_ordered_along_line( const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); - const RT& rhx = r.hx_ref(); - const RT& rhy = r.hy_ref(); - const RT& rhw = r.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); + const RT& rhx = r.hx(); + const RT& rhy = r.hy(); + const RT& rhw = r.hw(); if ( !(phx * rhw == rhx * phw ) ) // non-vertical ? { @@ -835,15 +835,15 @@ collinear_are_strictly_ordered_along_line( const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); - const RT& rhx = r.hx_ref(); - const RT& rhy = r.hy_ref(); - const RT& rhw = r.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); + const RT& rhx = r.hx(); + const RT& rhy = r.hy(); + const RT& rhw = r.hw(); if ( !(phx * rhw == rhx * phw ) ) { @@ -884,14 +884,14 @@ inline bool x_equal( const PointH2& p, const PointH2& q ) -{ return ( p.hx_ref()*q.hw_ref() == q.hx_ref()*p.hw_ref() ); } +{ return ( p.hx()*q.hw() == q.hx()*p.hw() ); } template inline bool y_equal( const PointH2& p, const PointH2& q ) -{ return ( p.hy_ref()*q.hw_ref() == q.hy_ref()*p.hw_ref() ); } +{ return ( p.hy()*q.hw() == q.hy()*p.hw() ); } template CGAL_KERNEL_MEDIUM_INLINE @@ -901,12 +901,12 @@ _where_wrt_L_wedge( const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhw = q.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhw = q.hw(); Sign xs = CGAL_NTS sign( qhx*phw - phx*qhw ); // sign( qx - px ) Sign ys = CGAL_NTS sign( qhy*phw - phy*qhw ); // sign( qy - py ) @@ -932,14 +932,14 @@ compare_deltax_deltay(const PointH2& p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhw = q.hw_ref(); - const RT& rhy = r.hy_ref(); - const RT& rhw = r.hw_ref(); - const RT& shy = s.hy_ref(); - const RT& shw = s.hw_ref(); + const RT& phx = p.hx(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhw = q.hw(); + const RT& rhy = r.hy(); + const RT& rhw = r.hw(); + const RT& shy = s.hy(); + const RT& shw = s.hw(); const RT tbc1 = CGAL_NTS abs(phx*qhw - qhx*phw) * rhw*shw; const RT tbc2 = CGAL_NTS abs(rhy*shw - shy*rhw) * phw*qhw; diff --git a/Packages/H3/changes.txt b/Packages/H3/changes.txt index 1627e6843cc..587a1dea6b6 100644 --- a/Packages/H3/changes.txt +++ b/Packages/H3/changes.txt @@ -1,3 +1,6 @@ +2.36 (2 October 2001) +- Access functions of objects (like .x() ) now return const references. + 2.35 (15 August 2001) - SunPro patches. diff --git a/Packages/H3/include/CGAL/Iso_cuboidH3.h b/Packages/H3/include/CGAL/Iso_cuboidH3.h index c8b140ec6da..2acd48b79a3 100644 --- a/Packages/H3/include/CGAL/Iso_cuboidH3.h +++ b/Packages/H3/include/CGAL/Iso_cuboidH3.h @@ -58,8 +58,8 @@ public: bool operator==(const Iso_cuboidH3& s) const; bool operator!=(const Iso_cuboidH3& s) const; - PointH3 min() const; - PointH3 max() const; + const PointH3 & min() const; + const PointH3 & max() const; PointH3 vertex(int i) const; PointH3 operator[](int i) const; @@ -175,13 +175,13 @@ operator!=(const Iso_cuboidH3& r) const template < class R > inline -PointH3 +const PointH3 & Iso_cuboidH3::min() const { return Ptr()->e0; } template < class R > inline -PointH3 +const PointH3 & Iso_cuboidH3::max() const { return Ptr()->e1; } @@ -273,9 +273,8 @@ Iso_cuboidH3::vertex(int i) const max().hz(), min().hw() ); case 6: return PointH3( max().hx(), min().hy(), max().hz(), min().hw() ); - case 7: return max(); + default: /*case 7:*/ return max(); } - return PointH3(); } template < class R > diff --git a/Packages/H3/include/CGAL/LineH3.h b/Packages/H3/include/CGAL/LineH3.h index 6951cd814ff..13133afc02d 100644 --- a/Packages/H3/include/CGAL/LineH3.h +++ b/Packages/H3/include/CGAL/LineH3.h @@ -92,11 +92,11 @@ public: PlaneH3 perpendicular_plane(const PointH3& p) const; LineH3 opposite() const; - PointH3 point() const; + const PointH3 & point() const; PointH3 point(int i) const; PointH3 projection(const PointH3& p) const; - DirectionH3 + const DirectionH3 & direction() const; bool has_on( const PointH3& p ) const; @@ -126,7 +126,7 @@ CGAL_BEGIN_NAMESPACE template < class R > inline -PointH3 +const PointH3 & LineH3::point() const { return Ptr()->basepoint; } @@ -138,7 +138,7 @@ LineH3::point(int i) const template < class R > inline -DirectionH3 +const DirectionH3 & LineH3::direction() const { return Ptr()->direction; } @@ -153,7 +153,7 @@ template < class R > CGAL_KERNEL_INLINE LineH3 LineH3::opposite() const -{ return LineH3( Ptr()->basepoint, -(Ptr()->direction ) ); } +{ return LineH3( point(), -direction() ); } template < class R > CGAL_KERNEL_LARGE_INLINE @@ -233,8 +233,7 @@ CGAL_KERNEL_INLINE bool LineH3::operator==(const LineH3& l) const { - return ( (l.direction() == Ptr()->direction ) - &&(l.has_on( Ptr()->basepoint ) ) ); + return l.direction() == direction() && l.has_on( point() ); } #ifdef CGAL_CFG_TYPENAME_BUG diff --git a/Packages/H3/include/CGAL/PVDH3.h b/Packages/H3/include/CGAL/PVDH3.h index f32bba407e1..183eb71214a 100644 --- a/Packages/H3/include/CGAL/PVDH3.h +++ b/Packages/H3/include/CGAL/PVDH3.h @@ -63,12 +63,12 @@ class PointH3 FT x() const; FT y() const; FT z() const; - RT hx() const; - RT hy() const; - RT hz() const; - RT hw() const; + const RT & hx() const; + const RT & hy() const; + const RT & hz() const; + const RT & hw() const; + const RT & homogeneous(int i) const; FT cartesian(int i) const; - RT homogeneous(int i) const; FT operator[](int i) const; int dimension() const; @@ -82,11 +82,6 @@ class PointH3 bool operator==( const PointH3& p) const; bool operator!=( const PointH3& p) const; - - const RT& hx_ref() const; - const RT& hy_ref() const; - const RT& hz_ref() const; - const RT& hw_ref() const; }; @@ -127,12 +122,12 @@ class VectorH3 FT x() const; FT y() const; FT z() const; - RT hx() const; - RT hy() const; - RT hz() const; - RT hw() const; + const RT & hx() const; + const RT & hy() const; + const RT & hz() const; + const RT & hw() const; + const RT & homogeneous(int i) const; FT cartesian(int i) const; - RT homogeneous(int i) const; FT operator[](int i) const; int dimension() const; @@ -196,17 +191,17 @@ class DirectionH3 VectorH3 to_vector() const; - RT dx() const; - RT dy() const; - RT dz() const; - RT x() const; - RT y() const; - RT z() const; - RT hx() const; - RT hy() const; - RT hz() const; + const RT & dx() const; + const RT & dy() const; + const RT & dz() const; + const RT & x() const; + const RT & y() const; + const RT & z() const; + const RT & hx() const; + const RT & hy() const; + const RT & hz() const; - RT delta(int i) const; + const RT & delta(int i) const; }; #ifdef CGAL_CFG_TYPENAME_BUG @@ -224,8 +219,7 @@ PointH3::PointH3(const Origin&) template < class R > CGAL_KERNEL_CTOR_INLINE -PointH3::PointH3(const RT& x, const RT& y, const RT& z, - const RT& w) +PointH3::PointH3(const RT& x, const RT& y, const RT& z, const RT& w) { if ( w < RT(0) ) { initialize_with( Point_ref_3(-x,-y,-z,-w)); } @@ -253,52 +247,28 @@ PointH3::z() const template < class R > inline -typename PointH3::RT +const typename PointH3::RT & PointH3::hx() const { return Ptr()->hx() ; } template < class R > inline -typename PointH3::RT +const typename PointH3::RT & PointH3::hy() const { return Ptr()->hy() ; } template < class R > inline -typename PointH3::RT +const typename PointH3::RT & PointH3::hz() const { return Ptr()->hz() ; } template < class R > inline -typename PointH3::RT +const typename PointH3::RT & PointH3::hw() const { return Ptr()->hw(); } -template < class R > -inline -const typename PointH3::RT& -PointH3::hx_ref() const -{ return Ptr()->e0 ; } - -template < class R > -inline -const typename PointH3::RT& -PointH3::hy_ref() const -{ return Ptr()->e1 ; } - -template < class R > -inline -const typename PointH3::RT& -PointH3::hz_ref() const -{ return Ptr()->e2 ; } - -template < class R > -inline -const typename PointH3::RT& -PointH3::hw_ref() const -{ return Ptr()->e3; } - template < class R > inline int @@ -321,7 +291,7 @@ PointH3::cartesian(int i) const template < class R > CGAL_KERNEL_INLINE -typename PointH3::RT +const typename PointH3::RT & PointH3::homogeneous(int i) const { CGAL_kernel_precondition(i == 0 || i == 1 || i == 2 || i == 3); @@ -439,25 +409,25 @@ VectorH3::z() const template < class R > inline -typename VectorH3::RT +const typename VectorH3::RT & VectorH3::hx() const { return Ptr()->hx() ; } template < class R > inline -typename VectorH3::RT +const typename VectorH3::RT & VectorH3::hy() const { return Ptr()->hy() ; } template < class R > inline -typename VectorH3::RT +const typename VectorH3::RT & VectorH3::hz() const { return Ptr()->hz() ; } template < class R > inline -typename VectorH3::RT +const typename VectorH3::RT & VectorH3::hw() const { return Ptr()->hw() ; } @@ -483,7 +453,7 @@ VectorH3::cartesian(int i) const template < class R > CGAL_KERNEL_INLINE -typename VectorH3::RT +const typename VectorH3::RT & VectorH3::homogeneous(int i) const { CGAL_kernel_precondition(i == 0 || i == 1 || i == 2 || i == 3); @@ -543,7 +513,7 @@ DirectionH3::DirectionH3(const RT& x, const RT& y, const RT& z, template CGAL_KERNEL_INLINE -typename DirectionH3::RT +const typename DirectionH3::RT & DirectionH3::delta(int i) const { switch (i) @@ -557,55 +527,55 @@ DirectionH3::delta(int i) const template inline -typename DirectionH3::RT +const typename DirectionH3::RT & DirectionH3::dx() const { return Ptr()->e0; } template inline -typename DirectionH3::RT +const typename DirectionH3::RT & DirectionH3::x() const { return Ptr()->e0; } template inline -typename DirectionH3::RT +const typename DirectionH3::RT & DirectionH3::hx() const { return Ptr()->e0; } template inline -typename DirectionH3::RT +const typename DirectionH3::RT & DirectionH3::dy() const { return Ptr()->e1; } template inline -typename DirectionH3::RT +const typename DirectionH3::RT & DirectionH3::y() const { return Ptr()->e1; } template inline -typename DirectionH3::RT +const typename DirectionH3::RT & DirectionH3::hy() const { return Ptr()->e1; } template inline -typename DirectionH3::RT +const typename DirectionH3::RT & DirectionH3::dz() const { return Ptr()->e2; } template inline -typename DirectionH3::RT +const typename DirectionH3::RT & DirectionH3::z() const { return Ptr()->e2; } template inline -typename DirectionH3::RT +const typename DirectionH3::RT & DirectionH3::hz() const { return Ptr()->e2; } diff --git a/Packages/H3/include/CGAL/PlaneH3.h b/Packages/H3/include/CGAL/PlaneH3.h index 557ab757892..c542caf3095 100644 --- a/Packages/H3/include/CGAL/PlaneH3.h +++ b/Packages/H3/include/CGAL/PlaneH3.h @@ -64,13 +64,13 @@ class PlaneH3 PlaneH3(const PointH3&, const VectorH3& ); PlaneH3(const PointH3&, const DirectionH3&, const DirectionH3& ); - RT a() const; - RT b() const; - RT c() const; - RT d() const; + const RT & a() const; + const RT & b() const; + const RT & c() const; + const RT & d() const; - bool operator==( const PlaneH3& ) const; - bool operator!=( const PlaneH3& ) const; + bool operator==( const PlaneH3& ) const; + bool operator!=( const PlaneH3& ) const; LineH3 perpendicular_line(const PointH3& ) const; PlaneH3 opposite() const; // plane with opposite orientation @@ -261,25 +261,25 @@ PlaneH3::PlaneH3(const PointH3& p, template < class R > inline -typename PlaneH3::RT +const typename PlaneH3::RT & PlaneH3::a() const { return Ptr()->e0; } template < class R > inline -typename PlaneH3::RT +const typename PlaneH3::RT & PlaneH3::b() const { return Ptr()->e1; } template < class R > inline -typename PlaneH3::RT +const typename PlaneH3::RT & PlaneH3::c() const { return Ptr()->e2; } template < class R > inline -typename PlaneH3::RT +const typename PlaneH3::RT & PlaneH3::d() const { return Ptr()->e3; } diff --git a/Packages/H3/include/CGAL/RayH3.h b/Packages/H3/include/CGAL/RayH3.h index ac4355748ac..f8012ad7d62 100644 --- a/Packages/H3/include/CGAL/RayH3.h +++ b/Packages/H3/include/CGAL/RayH3.h @@ -80,11 +80,11 @@ class RayH3 RayH3( const PointH3& sp, const DirectionH3& d) : Ray_handle_3_(Ray_ref_3(sp, d)) {} - PointH3 start() const; - PointH3 source() const; + const PointH3 & start() const; + const PointH3 & source() const; PointH3 second_point() const; PointH3 point(int i) const; - DirectionH3 direction() const; + const DirectionH3 & direction() const; LineH3 supporting_line() const; RayH3 opposite() const; RayH3 transform( const Aff_transformationH3 & t) const; @@ -98,23 +98,23 @@ class RayH3 template < class R > inline -PointH3 +const PointH3 & RayH3::source() const { return Ptr()->startpoint; } template < class R > inline -PointH3 +const PointH3 & RayH3::start() const { return Ptr()->startpoint; } template < class R > inline -DirectionH3 +const DirectionH3 & RayH3::direction() const { CGAL_kernel_precondition( !is_degenerate() ); - return DirectionH3( Ptr()->direction ); + return Ptr()->direction; } diff --git a/Packages/H3/include/CGAL/RepH3.h b/Packages/H3/include/CGAL/RepH3.h index dde0ef1b853..fbb13fe0325 100644 --- a/Packages/H3/include/CGAL/RepH3.h +++ b/Packages/H3/include/CGAL/RepH3.h @@ -37,10 +37,10 @@ public: RepH3(const NT& a0, const NT& a1, const NT& a2, const NT& a3) : e0(a0), e1(a1), e2(a2), e3(a3) {} - NT hx() const { return e0; } - NT hy() const { return e1; } - NT hz() const { return e2; } - NT hw() const { return e3; } // homogenizing component + const NT & hx() const { return e0; } + const NT & hy() const { return e1; } + const NT & hz() const { return e2; } + const NT & hw() const { return e3; } // homogenizing component }; template @@ -53,10 +53,10 @@ public: Simple_RepH3(const NT& a0, const NT& a1, const NT& a2, const NT& a3) : e0(a0), e1(a1), e2(a2), e3(a3) {} - NT hx() const { return e0; } - NT hy() const { return e1; } - NT hz() const { return e2; } - NT hw() const { return e3; } // homogenizing component + const NT & hx() const { return e0; } + const NT & hy() const { return e1; } + const NT & hz() const { return e2; } + const NT & hw() const { return e3; } // homogenizing component }; CGAL_END_NAMESPACE diff --git a/Packages/H3/include/CGAL/SegmentH3.h b/Packages/H3/include/CGAL/SegmentH3.h index 42ddd2a9568..b5ac70fb821 100644 --- a/Packages/H3/include/CGAL/SegmentH3.h +++ b/Packages/H3/include/CGAL/SegmentH3.h @@ -37,12 +37,11 @@ public: Segment_repH3(const PointH3& sp, const PointH3& ep) : startpoint(sp), endpoint(ep) {} - PointH3 start() const { return startpoint; } - PointH3 end() const { return endpoint; } + const PointH3 & start() const { return startpoint; } + const PointH3 & end() const { return endpoint; } private: - PointH3 startpoint; - PointH3 endpoint; + PointH3 startpoint, endpoint; }; template < class R > @@ -53,12 +52,11 @@ public: Simple_Segment_repH3(const PointH3& sp, const PointH3& ep) : startpoint(sp), endpoint(ep) {} - PointH3 start() const { return startpoint; } - PointH3 end() const { return endpoint; } + const PointH3 & start() const { return startpoint; } + const PointH3 & end() const { return endpoint; } private: - PointH3 startpoint; - PointH3 endpoint; + PointH3 startpoint, endpoint; }; template < class R_ > @@ -79,16 +77,16 @@ public: SegmentH3( const PointH3& sp, const PointH3& ep) : Segment_handle_3_(Segment_ref_3(sp, ep)) {} - PointH3 source() const; - PointH3 target() const; + const PointH3 & source() const; + const PointH3 & target() const; - PointH3 start() const; - PointH3 end() const; - PointH3 min() const; - PointH3 max() const; - PointH3 vertex(int i) const; - PointH3 point(int i) const; - PointH3 operator[](int i) const; + const PointH3 & start() const; + const PointH3 & end() const; + const PointH3 & min() const; + const PointH3 & max() const; + const PointH3 & vertex(int i) const; + const PointH3 & point(int i) const; + const PointH3 & operator[](int i) const; FT squared_length() const; DirectionH3 @@ -108,31 +106,31 @@ public: template < class R > inline -PointH3 +const PointH3 & SegmentH3::source() const { return Ptr()->start(); } template < class R > inline -PointH3 +const PointH3 & SegmentH3::target() const { return Ptr()->end(); } template < class R > inline -PointH3 +const PointH3 & SegmentH3::start() const { return Ptr()->start(); } template < class R > inline -PointH3 +const PointH3 & SegmentH3::end() const { return Ptr()->end(); } template < class R > CGAL_KERNEL_INLINE -PointH3 +const PointH3 & SegmentH3::min() const { return @@ -141,29 +139,28 @@ SegmentH3::min() const template < class R > CGAL_KERNEL_INLINE -PointH3 +const PointH3 & SegmentH3::max() const { - return - lexicographically_xyz_smaller_or_equal(source(),target()) ? + return lexicographically_xyz_smaller_or_equal(source(),target()) ? target() : source(); } template < class R > inline -PointH3 +const PointH3 & SegmentH3::vertex(int i) const { return ( i%2 == 0 ) ? start() : end() ; } template < class R > inline -PointH3 +const PointH3 & SegmentH3::point(int i) const { return ( i%2 == 0 ) ? start() : end() ; } template < class R > inline -PointH3 +const PointH3 & SegmentH3::operator[](int i) const { return ( i%2 == 0 ) ? start() : end() ; } diff --git a/Packages/H3/include/CGAL/SphereH3.h b/Packages/H3/include/CGAL/SphereH3.h index 1c9022504e3..915a0c84847 100644 --- a/Packages/H3/include/CGAL/SphereH3.h +++ b/Packages/H3/include/CGAL/SphereH3.h @@ -110,29 +110,21 @@ class SphereH3 operator!=(const SphereH3& s) const { return !(*this == s); } - PointH3 - center() const; + const PointH3 & center() const; - FT - squared_radius() const; + const FT & squared_radius() const; - Orientation - orientation() const; + Orientation orientation() const; - SphereH3 - orthogonal_transform(const Aff_transformationH3& t) const; + SphereH3 orthogonal_transform(const Aff_transformationH3& t) const; - bool - is_degenerate() const; + bool is_degenerate() const; - SphereH3 - opposite() const; + SphereH3 opposite() const; - Bbox_3 - bbox() const; + Bbox_3 bbox() const; - Oriented_side - oriented_side(const PointH3& p) const; + Oriented_side oriented_side(const PointH3& p) const; bool has_on_boundary(const PointH3& p) const @@ -156,7 +148,6 @@ class SphereH3 bool has_on_unbounded_side(const PointH3& p) const { return bounded_side(p)==ON_UNBOUNDED_SIDE; } - }; @@ -231,13 +222,13 @@ SphereH3::operator==(const SphereH3& s) const template inline -PointH3 +const PointH3 & SphereH3::center() const { return Ptr()->center; } template inline -typename SphereH3::FT +const typename SphereH3::FT & SphereH3::squared_radius() const { return Ptr()->squared_radius; } diff --git a/Packages/H3/include/CGAL/TetrahedronH3.h b/Packages/H3/include/CGAL/TetrahedronH3.h index 9a3f54ac8af..144d309a7bf 100644 --- a/Packages/H3/include/CGAL/TetrahedronH3.h +++ b/Packages/H3/include/CGAL/TetrahedronH3.h @@ -93,8 +93,8 @@ public: const PointH3 &s) : Tetrahedron_handle_3_(Tetrahedron_ref_3(p,q,r,s)) {} - PointH3 vertex(int i) const; - PointH3 operator[](int i) const; + const PointH3 & vertex(int i) const; + const PointH3 & operator[](int i) const; bool operator==(const TetrahedronH3 &t) const; bool operator!=(const TetrahedronH3 &t) const; Bbox_3 bbox() const; @@ -119,8 +119,10 @@ CGAL_KERNEL_INLINE bool TetrahedronH3::operator==(const TetrahedronH3 &t) const { - if ( Ptr() == t.Ptr() ) return true; - if ( orientation() != t.orientation() ) return false; + if ( identical(t) ) + return true; + if ( orientation() != t.orientation() ) + return false; std::vector< PointH3 > V1; std::vector< PointH3 > V2; @@ -147,7 +149,7 @@ TetrahedronH3::operator!=(const TetrahedronH3 &t) const template < class R > CGAL_KERNEL_INLINE -PointH3 +const PointH3 & TetrahedronH3::vertex(int i) const { switch (i%4) @@ -155,16 +157,16 @@ TetrahedronH3::vertex(int i) const case 0: return Ptr()->container.e0; case 1: return Ptr()->container.e1; case 2: return Ptr()->container.e2; - case 3: return Ptr()->container.e3; + default: /*case 3:*/ return Ptr()->container.e3; } - return PointH3(); } template < class R > inline -PointH3 +const PointH3 & TetrahedronH3::operator[](int i) const { return vertex(i); } + template < class R > inline bool diff --git a/Packages/H3/include/CGAL/TriangleH3.h b/Packages/H3/include/CGAL/TriangleH3.h index 12efc89e307..ddc783edf5b 100644 --- a/Packages/H3/include/CGAL/TriangleH3.h +++ b/Packages/H3/include/CGAL/TriangleH3.h @@ -61,8 +61,8 @@ public: bool nondegenerate_has_on(const PointH3 &p) const; bool is_degenerate() const; - PointH3 vertex(int i) const; - PointH3 operator[](int i) const; + const PointH3 & vertex(int i) const; + const PointH3 & operator[](int i) const; FT squared_area() const; @@ -91,7 +91,7 @@ TriangleH3::operator!=(const TriangleH3 &t) const template < class R > CGAL_KERNEL_INLINE -PointH3 +const PointH3 & TriangleH3::vertex(int i) const { if (i<0) i=(i%3)+3; @@ -103,7 +103,7 @@ TriangleH3::vertex(int i) const template < class R > inline -PointH3 +const PointH3 & TriangleH3::operator[](int i) const { return vertex(i); } diff --git a/Packages/H3/include/CGAL/VectorH3.h b/Packages/H3/include/CGAL/VectorH3.h index 87175f93b13..2bcb6fc8110 100644 --- a/Packages/H3/include/CGAL/VectorH3.h +++ b/Packages/H3/include/CGAL/VectorH3.h @@ -21,6 +21,4 @@ // coordinator : MPI, Saarbruecken () // ====================================================================== -#ifndef CGAL_PVDH3_H #include -#endif // CGAL_PVDH3_H diff --git a/Packages/H3/include/CGAL/predicates_on_pointsH3.h b/Packages/H3/include/CGAL/predicates_on_pointsH3.h index 425276e47b0..754c5d219c2 100644 --- a/Packages/H3/include/CGAL/predicates_on_pointsH3.h +++ b/Packages/H3/include/CGAL/predicates_on_pointsH3.h @@ -265,8 +265,8 @@ CGAL_KERNEL_INLINE bool equal_xy(const PointH3 &p, const PointH3 &q) { - return (p.hx_ref() * q.hw_ref() == q.hx_ref() * p.hw_ref() ) - && (p.hy_ref() * q.hw_ref() == q.hy_ref() * p.hw_ref() ); + return (p.hx() * q.hw() == q.hx() * p.hw() ) + && (p.hy() * q.hw() == q.hy() * p.hw() ); } template < class R > // ??? -> == @@ -274,29 +274,29 @@ CGAL_KERNEL_INLINE bool equal_xyz(const PointH3 &p, const PointH3 &q) { - return (p.hx_ref() * q.hw_ref() == q.hx_ref() * p.hw_ref() ) - && (p.hy_ref() * q.hw_ref() == q.hy_ref() * p.hw_ref() ) - && (p.hz_ref() * q.hw_ref() == q.hz_ref() * p.hw_ref() ); + return (p.hx() * q.hw() == q.hx() * p.hw() ) + && (p.hy() * q.hw() == q.hy() * p.hw() ) + && (p.hz() * q.hw() == q.hz() * p.hw() ); } template < class R > CGAL_KERNEL_INLINE bool less_x(const PointH3 &p, const PointH3 &q) -{ return (p.hx_ref() * q.hw_ref() < q.hx_ref() * p.hw_ref() ); } +{ return (p.hx() * q.hw() < q.hx() * p.hw() ); } template < class R > CGAL_KERNEL_INLINE bool less_y(const PointH3 &p, const PointH3 &q) -{ return (p.hy_ref() * q.hw_ref() < q.hy_ref() * p.hw_ref() ); } +{ return (p.hy() * q.hw() < q.hy() * p.hw() ); } template < class R > CGAL_KERNEL_INLINE bool less_z(const PointH3 &p, const PointH3 &q) -{ return (p.hz_ref() * q.hw_ref() < q.hz_ref() * p.hw_ref() ); } +{ return (p.hz() * q.hw() < q.hz() * p.hw() ); } CGAL_END_NAMESPACE @@ -502,18 +502,18 @@ side_of_bounded_sphere(const PointH3 &p, { typedef typename R::RT RT; - const RT& phx = p.hx_ref(); - const RT& phy = p.hy_ref(); - const RT& phz = p.hz_ref(); - const RT& phw = p.hw_ref(); - const RT& qhx = q.hx_ref(); - const RT& qhy = q.hy_ref(); - const RT& qhz = q.hz_ref(); - const RT& qhw = q.hw_ref(); - const RT& thx = t.hx_ref(); - const RT& thy = t.hy_ref(); - const RT& thz = t.hz_ref(); - const RT& thw = t.hw_ref(); + const RT& phx = p.hx(); + const RT& phy = p.hy(); + const RT& phz = p.hz(); + const RT& phw = p.hw(); + const RT& qhx = q.hx(); + const RT& qhy = q.hy(); + const RT& qhz = q.hz(); + const RT& qhw = q.hw(); + const RT& thx = t.hx(); + const RT& thy = t.hy(); + const RT& thz = t.hz(); + const RT& thw = t.hw(); return Bounded_side( CGAL_NTS sign((thx*phw-phx*thw)*(qhx*thw-thx*qhw) + (thy*phw-phy*thw)*(qhy*thw-thy*qhw)