From ac4dd40d3a82dd713a4cc91e5f0186b3a067a904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20Sch=C3=B6nherr?= Date: Sun, 1 Feb 1998 18:28:42 +0000 Subject: [PATCH] adapted to g++-2.8.0 and g++-egcs-2.90.23 --- .../demo/Min_circle_2/demo_Min_circle_2.C | 1 + Packages/Min_circle_2/web/Min_circle_2.aw | 36 +- Packages/Min_ellipse_2/web/Conic_2.aw | 1801 ++++++------- Packages/Min_ellipse_2/web/Min_ellipse_2.aw | 2311 +++++++++-------- 4 files changed, 2079 insertions(+), 2070 deletions(-) diff --git a/Packages/Min_circle_2/demo/Min_circle_2/demo_Min_circle_2.C b/Packages/Min_circle_2/demo/Min_circle_2/demo_Min_circle_2.C index 463cceb907e..f22bbe6d7bc 100644 --- a/Packages/Min_circle_2/demo/Min_circle_2/demo_Min_circle_2.C +++ b/Packages/Min_circle_2/demo/Min_circle_2/demo_Min_circle_2.C @@ -30,6 +30,7 @@ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // includes +#include #include #include #include diff --git a/Packages/Min_circle_2/web/Min_circle_2.aw b/Packages/Min_circle_2/web/Min_circle_2.aw index 3e960e007af..de17f1241f2 100644 --- a/Packages/Min_circle_2/web/Min_circle_2.aw +++ b/Packages/Min_circle_2/web/Min_circle_2.aw @@ -947,7 +947,7 @@ diameter of the circle. if ( ( ! has_on_boundary( p) ) || ( ! has_on_boundary( q) ) || ( tco.orientation( p, q, - circle().center()) != CGAL_COLLINEAR) ) + circle().center()) != CGAL_COLLINEAR) ) return( CGAL__optimisation_is_valid_fail( verr, "circle does not have its \ two support points as diameter.")); @@ -1587,7 +1587,7 @@ it is declared \ccc{friend}. CGAL_Orientation orientation( Point const& p, Point const& q, Point const& r) const { - typedef _DA::FT FT; + typedef typename _DA::FT FT; FT px; FT py; @@ -1616,7 +1616,7 @@ it is declared \ccc{friend}. typedef _PT PT; typedef _DA DA; - typedef _DA::FT FT; + typedef typename _DA::FT FT; private: // data members @@ -1910,7 +1910,7 @@ it is declared \ccc{friend}. CGAL_Orientation orientation( Point const& p, Point const& q, Point const& r) const { - typedef _DA::RT RT; + typedef typename _DA::RT RT; RT phx; RT phy; @@ -1943,8 +1943,8 @@ it is declared \ccc{friend}. typedef _PT PT; typedef _DA DA; - typedef _DA::RT RT; - typedef CGAL_Quotient FT; + typedef typename _DA::RT RT; + typedef CGAL_Quotient FT; private: // data members @@ -2228,18 +2228,18 @@ homogeneous representation with number type \ccc{CGAL_Gmpz}. #ifdef CGAL_USE_LEDA # include - typedef leda_integer Rt; - typedef CGAL_Quotient< leda_integer > Ft; + typedef leda_integer Rt; + typedef CGAL_Quotient< leda_integer > Ft; #else # include - typedef CGAL_Gmpz Rt; - typedef CGAL_Quotient< CGAL_Gmpz > Ft; + typedef CGAL_Gmpz Rt; + typedef CGAL_Quotient< CGAL_Gmpz > Ft; #endif - typedef CGAL_Cartesian< Ft > RepC; - typedef CGAL_Homogeneous< Rt > RepH; - typedef CGAL_Optimisation_traits_2< RepC > TraitsC; - typedef CGAL_Optimisation_traits_2< RepH > TraitsH; + typedef CGAL_Cartesian< Ft > RepC; + typedef CGAL_Homogeneous< Rt > RepH; + typedef CGAL_Optimisation_traits_2< RepC > TraitsC; + typedef CGAL_Optimisation_traits_2< RepH > TraitsH; @end The command line option \ccc{-verbose} enables verbose output. @@ -2683,8 +2683,8 @@ end of each file. #ifndef CGAL_OPTIMISATION_ASSERTIONS_H # include #endif - #ifndef CGAL_OPTIMISATION_MISC_H - # include + #ifndef CGAL_OPTIMISATION_BASIC_H + # include #endif #ifndef CGAL_PROTECT_LIST_H # include @@ -2933,7 +2933,7 @@ end of each file. "Optimisation/Min_circle_2", "Sven Schönherr ", "Bernd Gärtner", - "ETH Zurich (Bernd Gärtner )", + "ETH Zurich (Bernd Gärtner )", "$Revision$","$Date$") @end @@ -2942,7 +2942,7 @@ end of each file. "Optimisation/Min_circle_2", "Sven Schönherr ", "Bernd Gärtner", - "ETH Zurich (Bernd Gärtner )", + "ETH Zurich (Bernd Gärtner )", "$Revision$","$Date$") @end diff --git a/Packages/Min_ellipse_2/web/Conic_2.aw b/Packages/Min_ellipse_2/web/Conic_2.aw index cbe8485a244..e7d60474e22 100644 --- a/Packages/Min_ellipse_2/web/Conic_2.aw +++ b/Packages/Min_ellipse_2/web/Conic_2.aw @@ -310,36 +310,39 @@ the conic class @prg{R::Conic_2} of the representation type @prg{R}. template < class _R> class CGAL_Conic_2 : public _R::Conic_2 { - friend class CGAL_Optimisation_ellipse_2 <_R>; - friend - CGAL_Window_stream& operator<< ( CGAL_Window_stream&, - CGAL_Optimisation_ellipse_2<_R> const&); + friend class CGAL_Optimisation_ellipse_2<_R>; + + friend CGAL_Window_stream& operator << CGAL_NULL_TMPL_ARGS ( + CGAL_Window_stream&, CGAL_Optimisation_ellipse_2<_R> const&); public: - // types - typedef _R R; + // types + typedef _R R; + typedef typename _R::RT RT; + typedef typename _R::FT FT; + typedef typename _R::Conic_2 Conic_2; - // construction - @ + // construction + @ - // general access - @ + // general access + @ - // type related access - @ + // type related access + @ - // orientation related access - @ + // orientation related access + @ - // comparisons - @ + // comparisons + @ - // set methods - @ + // set methods + @ private: - @ + @ }; @end @@ -355,11 +358,11 @@ The orientation of the conic is determined by $\r$, as described in subsection \ref{orientation_sec}. @macro = @begin - CGAL_Conic_2 () + CGAL_Conic_2 () {} - CGAL_Conic_2 (R::RT r, R::RT s, R::RT t, R::RT u, R::RT v, R::RT w) - : R::Conic_2 (r, s, t, u, v, w) + CGAL_Conic_2 (RT r, RT s, RT t, RT u, RT v, RT w) + : R::Conic_2 (r, s, t, u, v, w) {} @end @@ -377,34 +380,34 @@ decide to divide all of them by their gcd to get smaller numbers. (In this implementation, this does not happen.) @macro += @begin - R::RT r () const + RT r () const { - return R::Conic_2::r(); + return Conic_2::r(); } - R::RT s () const + RT s () const { - return R::Conic_2::s(); + return Conic_2::s(); } - R::RT t () const + RT t () const { - return R::Conic_2::t(); + return Conic_2::t(); } - R::RT u () const + RT u () const { - return R::Conic_2::u(); + return Conic_2::u(); } - R::RT v () const + RT v () const { - return R::Conic_2::v(); + return Conic_2::v(); } - R::RT w () const + RT w () const { - return R::Conic_2::w(); + return Conic_2::w(); } @end @@ -415,7 +418,7 @@ $\C$ is not a parabola. @macro += @begin CGAL_Point_2 center () const { - return R::Conic_2::center(); + return Conic_2::center(); } @end @@ -438,9 +441,9 @@ enumeration type. @macro = @begin enum CGAL_Conic_type { - CGAL_HYPERBOLA = -1, - CGAL_PARABOLA, - CGAL_ELLIPSE + CGAL_HYPERBOLA = -1, + CGAL_PARABOLA, + CGAL_ELLIPSE }; @end @@ -448,22 +451,22 @@ enumeration type. @macro += @begin CGAL_Conic_type conic_type () const { - return R::Conic_2::conic_type(); + return Conic_2::conic_type(); } bool is_hyperbola () const { - return R::Conic_2::is_hyperbola(); + return Conic_2::is_hyperbola(); } bool is_parabola () const { - return R::Conic_2::is_parabola(); + return Conic_2::is_parabola(); } bool is_ellipse () const { - return R::Conic_2::is_ellipse(); + return Conic_2::is_ellipse(); } @end @@ -476,17 +479,17 @@ degenerate. @macro += @begin bool is_empty () const { - return R::Conic_2::is_empty(); + return Conic_2::is_empty(); } bool is_trivial () const { - return R::Conic_2::is_trivial(); + return Conic_2::is_trivial(); } bool is_degenerate () const { - return R::Conic_2::is_degenerate(); + return Conic_2::is_degenerate(); } @end @@ -502,7 +505,7 @@ We can retrieve the orientation of a conic as defined in subsection @macro += @begin CGAL_Orientation orientation () const { - return R::Conic_2::orientation (); + return Conic_2::orientation (); } @end @@ -514,27 +517,27 @@ side directly or ask whether the point lies on some specific side. @macro += @begin CGAL_Oriented_side oriented_side (const CGAL_Point_2 &p) const { - return R::Conic_2::oriented_side (p); + return Conic_2::oriented_side (p); } bool has_on_positive_side (const CGAL_Point_2 &p) const { - return R::Conic_2::has_on_positive_side (p); + return Conic_2::has_on_positive_side (p); } bool has_on_negative_side (const CGAL_Point_2 &p) const { - return R::Conic_2::has_on_negative_side (p); + return Conic_2::has_on_negative_side (p); } bool has_on_boundary (const CGAL_Point_2 &p) const { - return R::Conic_2::has_on_boundary (p); + return Conic_2::has_on_boundary (p); } - + bool has_on (const CGAL_Point_2 &p) const { - return R::Conic_2::has_on (p); + return Conic_2::has_on (p); } @end @@ -553,17 +556,17 @@ to bounded and unbounded side, we `extend' the type @prg{CGAL_Bounded_side}. @macro += @begin CGAL_Convex_side convex_side (const CGAL_Point_2 &p) const { - return R::Conic_2::convex_side (p); + return Conic_2::convex_side (p); } bool has_on_convex_side (const CGAL_Point_2 &p) const { - return R::Conic_2::has_on_convex_side (p); + return Conic_2::has_on_convex_side (p); } bool has_on_nonconvex_side (const CGAL_Point_2 &p) const { - return R::Conic_2::has_on_nonconvex_side (p); + return Conic_2::has_on_nonconvex_side (p); } @end @@ -577,12 +580,12 @@ We provide tests for equality and inequality of two conics. @macro = @begin bool operator == ( CGAL_Conic_2<_R> const& c) const { - return R::Conic_2::operator == ( (R::Conic_2)c); + return Conic_2::operator == ( (Conic_2)c); } bool operator != ( CGAL_Conic_2<_R> const& c) const { - return( ! operator == ( c)); + return( ! operator == ( c)); } @end @@ -599,9 +602,10 @@ conic. But of course, there is also a set function that works on the coordinate level. @macro += @begin - void set (R::RT r, R::RT s, R::RT t, R::RT u, R::RT v, R::RT w) + void set (RT r, RT s, RT t, + RT u, RT v, RT w) { - R::Conic_2::set (r, s, t, u, v, w); + Conic_2::set (r, s, t, u, v, w); } @end @@ -618,7 +622,7 @@ of course). Note that if $\C_{\r}$ has zero orientation, so has $\C_{-\r}$. @macro += @begin void set_opposite () { - R::Conic_2::set_opposite(); + Conic_2::set_opposite(); } @end @@ -627,18 +631,18 @@ of course). Note that if $\C_{\r}$ has zero orientation, so has $\C_{-\r}$. @subsubsection{Pair of lines through four points} @! --------------------------------------------------------------------------- -The method @prg{set_linepair} builds the conic equal to union of the lines -$\overline{p_1p_2}$ and $\overline{p_3p_4}$. This is either a degenerate -hyperbola in case the two lines are not parallel, or a degenerate parabola. -The precondition is that $p_1\neq p_2$ and $p_3\neq p_4$. -The positive side is the region to the left resp. to the right of both oriented -lines $\overline{p_1p_2}, \overline{p_3p_4}$. +The method @prg{set_linepair} builds the conic equal to union of the +lines $\overline{p_1p_2}$ and $\overline{p_3p_4}$. This is either a +degenerate hyperbola in case the two lines are not parallel, or a +degenerate parabola. The precondition is that $p_1\neq p_2$ and +$p_3\neq p_4$. The positive side is the region to the left resp. to +the right of both oriented lines $\overline{p_1p_2}, \overline{p_3p_4}$. @macro += @begin void set_linepair (const CGAL_Point_2 &p1, const CGAL_Point_2 &p2, - const CGAL_Point_2 &p3, const CGAL_Point_2 &p4) + const CGAL_Point_2 &p3, const CGAL_Point_2 &p4) { - R::Conic_2::set_linepair (p1, p2, p3, p4); + Conic_2::set_linepair (p1, p2, p3, p4); } @end @@ -656,9 +660,9 @@ the ellipse is the orientation of the point triple. @macro += @begin void set_ellipse (const CGAL_Point_2 &p1, const CGAL_Point_2 &p2, - const CGAL_Point_2 &p3) + const CGAL_Point_2 &p3) { - R::Conic_2::set_ellipse (p1, p2, p3); + Conic_2::set_ellipse (p1, p2, p3); } @end @@ -676,10 +680,10 @@ orientation of the ellipse can be specified and defaults to positive. @macro += @begin void set_ellipse (const CGAL_Point_2 &p1, const CGAL_Point_2 &p2, - const CGAL_Point_2 &p3, const CGAL_Point_2 &p4, - CGAL_Orientation o = CGAL_POSITIVE) + const CGAL_Point_2 &p3, const CGAL_Point_2 &p4, + CGAL_Orientation o = CGAL_POSITIVE) { - R::Conic_2::set_ellipse (p1, p2, p3, p4, o); + Conic_2::set_ellipse (p1, p2, p3, p4, o); } @end @@ -693,13 +697,13 @@ the points $p_1,p_2,p_3,p_4,p_5$. Precondition is that all points are distinct. The orientation can be specified but is automatically set to zero if the resulting conic has zero orientation. -@macro += @begin +@macro += @begin void set (const CGAL_Point_2 &p1, const CGAL_Point_2 &p2, - const CGAL_Point_2 &p3, const CGAL_Point_2 &p4, - const CGAL_Point_2 &p5, - CGAL_Orientation o = CGAL_POSITIVE) + const CGAL_Point_2 &p3, const CGAL_Point_2 &p4, + const CGAL_Point_2 &p5, + CGAL_Orientation o = CGAL_POSITIVE) { - R::Conic_2::set (p1, p2, p3, p4, p5, o); + Conic_2::set (p1, p2, p3, p4, p5, o); } @end @@ -720,10 +724,11 @@ because the result depends on $\r_1,\r_2$ and not only on $\C_{\r_1}$ and $\C_{\r_2}$. @macro += @begin - void set_linear_combination (const R::RT &a1, const CGAL_Conic_2 &c1, - const R::RT &a2, const CGAL_Conic_2 &c2) + void set_linear_combination ( + const RT &a1, const CGAL_Conic_2 &c1, + const RT &a2, const CGAL_Conic_2 &c2) { - R::Conic_2::set_linear_combination (a1, c1, a2, c2); + Conic_2::set_linear_combination (a1, c1, a2, c2); } @end @@ -746,13 +751,13 @@ which ones. This is a static method. @macro += @begin static void set_two_linepairs (const CGAL_Point_2 &p1, - const CGAL_Point_2 &p2, - const CGAL_Point_2 &p3, - const CGAL_Point_2 &p4, - CGAL_Conic_2 &pair1, - CGAL_Conic_2 &pair2) + const CGAL_Point_2 &p2, + const CGAL_Point_2 &p3, + const CGAL_Point_2 &p4, + CGAL_Conic_2 &pair1, + CGAL_Conic_2 &pair2) { - R::Conic_2::set_two_linepairs (p1, p2, p3, p4, pair1, pair2); + Conic_2::set_two_linepairs (p1, p2, p3, p4, pair1, pair2); } @end @@ -771,9 +776,9 @@ conic is unspecified. @macro += @begin void set_ellipse (const CGAL_Conic_2 &pair1, - const CGAL_Conic_2 &pair2) + const CGAL_Conic_2 &pair2) { - R::Conic_2::set_ellipse (pair1, pair2); + Conic_2::set_ellipse (pair1, pair2); } @end @@ -795,9 +800,9 @@ actual orientation of $\C_{\r}$ is unspecified. @macro += @begin void set (const CGAL_Conic_2 &c1, const CGAL_Conic_2 &c2, - const CGAL_Point_2 &p) + const CGAL_Point_2 &p) { - R::Conic_2::set (c1, c2, p); analyse(); + Conic_2::set( c1, c2, p); analyse(); } @end @@ -821,10 +826,11 @@ i.e. decides how the volume develops when going from $\E(0)$ `in direction' $\d\r$. If $\E$ is not an ellipse, the result is meaningless. @macro += @begin - CGAL_Sign vol_derivative (R::RT dr, R::RT ds, R::RT dt, - R::RT du, R::RT dv, R::RT dw) const + CGAL_Sign vol_derivative (RT dr, RT ds, + RT dt, RT du, + RT dv, RT dw) const { - return R::Conic_2::vol_derivative (dr, ds, dt, du, dv, dw); + return Conic_2::vol_derivative (dr, ds, dt, du, dv, dw); } @end @@ -839,10 +845,11 @@ $\E(\tau^*)$, a @prg{double}-approximation suffices. As before, if $\E$ is not an ellipse, the result is meaningless. @macro += @begin - double vol_minimum (R::RT dr, R::RT ds, R::RT dt, R::RT du, R::RT dv, - R::RT dw) const + double vol_minimum (RT dr, RT ds, + RT dt, RT du, + RT dv, RT dw) const { - return R::Conic_2::vol_minimum (dr, ds, dt, du, dv, dw); + return Conic_2::vol_minimum (dr, ds, dt, du, dv, dw); } @end @@ -856,8 +863,8 @@ As before, if $\E$ is not an ellipse, the result is meaningless. template< class _R> ostream& operator << ( ostream& os, CGAL_Conic_2<_R> const& c) { - return( os << c.r() << ' ' << c.s() << ' ' << c.t() << ' ' - << c.u() << ' ' << c.v() << ' ' << c.w()); + return( os << c.r() << ' ' << c.s() << ' ' << c.t() << ' ' + << c.u() << ' ' << c.v() << ' ' << c.w()); } @end @@ -886,83 +893,83 @@ As before, if $\E$ is not an ellipse, the result is meaningless. @!macro = @begin @! template < class R > @! CGAL_Window_stream& operator<< (CGAL_Window_stream &win, -@! const CGAL_Conic_2 &c) +@! const CGAL_Conic_2 &c) @! { -@! // length of a pixel in win-coordinates -@! double pixel = 1/win.scale(); +@! // length of a pixel in win-coordinates +@! double pixel = 1/win.scale(); @! -@! // pixel dimensions of win -@! int width = (int)((win.xmax() - win.xmin()) * win.scale()) + 1, +@! // pixel dimensions of win +@! int width = (int)((win.xmax() - win.xmin()) * win.scale()) + 1, @! height = (int)((win.ymax() - win.ymin()) * win.scale()) + 1, @! dim = (width > height) ? width : height; @! -@! // pixel coordinates, stored for faster output -@! double *X = new double [2*dim]; -@! double *Y = new double [2*dim]; +@! // pixel coordinates, stored for faster output +@! double *X = new double [2*dim]; +@! double *Y = new double [2*dim]; @! -@! // actual number of pixels to be drawn -@! int pixels; +@! // actual number of pixels to be drawn +@! int pixels; @! @! // conic coordinates -@! double r = CGAL_to_double (c.r()), -@! s = CGAL_to_double (c.s()), -@! t = CGAL_to_double (c.t()), -@! u = CGAL_to_double (c.u()), -@! v = CGAL_to_double (c.v()), -@! w = CGAL_to_double (c.w()); -@! -@! // Phase I: draw in x-direction -@! pixels = 0; -@! // solve conic equation for y -@! if (s != 0.0) -@! for (double x = win.xmin(); x <= win.xmax(); x+=pixel) { -@! double discr = (t*t-4.0*r*s)*(x*x) + (2.0*t*v-4.0*s*u)*x + -@! v*v - 4.0*s*w; -@! if (discr >= 0.0) { -@! double y1 = (-t*x - v - sqrt(discr))/(2.0*s); -@! double y2 = (-t*x - v + sqrt(discr))/(2.0*s); -@! X[pixels] = x; Y[pixels++] = y1; -@! X[pixels] = x; Y[pixels++] = y2; -@! } -@! } -@! else -@! for (double x = win.xmin(); x <= win.xmax(); x+=pixel) { -@! double denom = t*x + v; -@! if (denom != 0.0) { -@! double y = -(r*x*x + u*x + w)/denom; -@! X[pixels] = x; Y[pixels++] = y; -@! } -@! } -@! win.draw_pixels (pixels, X, Y); +@! double r = CGAL_to_double (c.r()), +@! s = CGAL_to_double (c.s()), +@! t = CGAL_to_double (c.t()), +@! u = CGAL_to_double (c.u()), +@! v = CGAL_to_double (c.v()), +@! w = CGAL_to_double (c.w()); +@! +@! // Phase I: draw in x-direction +@! pixels = 0; +@! // solve conic equation for y +@! if (s != 0.0) +@! for (double x = win.xmin(); x <= win.xmax(); x+=pixel) { +@! double discr = (t*t-4.0*r*s)*(x*x) + (2.0*t*v-4.0*s*u)*x + +@! v*v - 4.0*s*w; +@! if (discr >= 0.0) { +@! double y1 = (-t*x - v - sqrt(discr))/(2.0*s); +@! double y2 = (-t*x - v + sqrt(discr))/(2.0*s); +@! X[pixels] = x; Y[pixels++] = y1; +@! X[pixels] = x; Y[pixels++] = y2; +@! } +@! } +@! else +@! for (double x = win.xmin(); x <= win.xmax(); x+=pixel) { +@! double denom = t*x + v; +@! if (denom != 0.0) { +@! double y = -(r*x*x + u*x + w)/denom; +@! X[pixels] = x; Y[pixels++] = y; +@! } +@! } +@! win.draw_pixels (pixels, X, Y); @! -@! // Phase II: draw in y-direction -@! pixels = 0; -@! // solve conic equation for x -@! if (r != 0.0) -@! for (double y = win.ymin(); y <= win.ymax(); y+=pixel) { -@! double discr = (t*t-4.0*r*s)*(y*y) + (2.0*t*u-4.0*r*v)*y + -@! u*u - 4.0*r*w; -@! if (discr >= 0.0) { -@! double x1 = (-t*y - u - sqrt(discr))/(2.0*r); -@! double x2 = (-t*y - u + sqrt(discr))/(2.0*r); -@! X[pixels] = x1; Y[pixels++] = y; -@! X[pixels] = x2; Y[pixels++] = y; -@! } -@! } -@! else -@! for (double y = win.ymin(); y <= win.ymax(); y+=pixel) { -@! double denom = t*y + u; -@! if (denom != 0.0) { -@! double x = -(s*y*y + v*y + w)/denom; -@! X[pixels] = x; Y[pixels++] = y; -@! } -@! } -@! win.draw_pixels (pixels, X, Y); +@! // Phase II: draw in y-direction +@! pixels = 0; +@! // solve conic equation for x +@! if (r != 0.0) +@! for (double y = win.ymin(); y <= win.ymax(); y+=pixel) { +@! double discr = (t*t-4.0*r*s)*(y*y) + (2.0*t*u-4.0*r*v)*y + +@! u*u - 4.0*r*w; +@! if (discr >= 0.0) { +@! double x1 = (-t*y - u - sqrt(discr))/(2.0*r); +@! double x2 = (-t*y - u + sqrt(discr))/(2.0*r); +@! X[pixels] = x1; Y[pixels++] = y; +@! X[pixels] = x2; Y[pixels++] = y; +@! } +@! } +@! else +@! for (double y = win.ymin(); y <= win.ymax(); y+=pixel) { +@! double denom = t*y + u; +@! if (denom != 0.0) { +@! double x = -(s*y*y + v*y + w)/denom; +@! X[pixels] = x; Y[pixels++] = y; +@! } +@! } +@! win.draw_pixels (pixels, X, Y); @! -@! delete [] Y; -@! delete [] X; +@! delete [] Y; +@! delete [] X; @! -@! return win; +@! return win; @! } @! @!@end @@ -1023,11 +1030,11 @@ of a type @prg{DA} for the homogeneous representation would look as follows. @macro zero = @begin class DA { - public: - // ring type - typedef /* some CGAL-conform number type */ RT; - // coordinate access - void get (const PT &p, RT &x, RT &y, RT &h); + public: + // ring type + typedef /* some CGAL-conform number type */ RT; + // coordinate access + void get (const PT &p, RT &x, RT &y, RT &h); }; @end @@ -1042,11 +1049,11 @@ look as follows. @macro zero = @begin class DA { - public: - // field type - typedef /* some CGAL-conform number type */ FT; - // coordinate access - void get (const PT &p, FT &x, FT &y); + public: + // field type + typedef /* some CGAL-conform number type */ FT; + // coordinate access + void get (const PT &p, FT &x, FT &y); }; @end @@ -1081,22 +1088,22 @@ use them. { public: // types - typedef _PT PT; - typedef _DA DA; - typedef typename _DA::RT RT; + typedef _PT PT; + typedef _DA DA; + typedef typename _DA::RT RT; private: - friend class CGAL_Conic_2< CGAL_Homogeneous >; - friend class CGAL__Min_ellipse_2_adapterH2__Ellipse; + friend class CGAL_Conic_2< CGAL_Homogeneous >; + friend class CGAL__Min_ellipse_2_adapterH2__Ellipse; - @ - @ + @ + @ protected: - @ + @ public: - @ + @ }; @end @@ -1111,22 +1118,22 @@ use them. { public: // types - typedef _PT PT; - typedef _DA DA; - typedef typename _DA::FT FT; + typedef _PT PT; + typedef _DA DA; + typedef typename _DA::FT FT; private: - friend class CGAL_Conic_2< CGAL_Cartesian >; - friend class CGAL__Min_ellipse_2_adapterC2__Ellipse; + friend class CGAL_Conic_2< CGAL_Cartesian >; + friend class CGAL__Min_ellipse_2_adapterC2__Ellipse; - @ - @ + @ + @ protected: - @ + @ public: - @ + @ }; @end @@ -1159,20 +1166,20 @@ side tests on the same conic but with different points access these data over and over again. @macro = @begin - DA dao; - RT _r, _s, _t, _u, _v, _w; - CGAL_Conic_type type; + DA dao; + RT _r, _s, _t, _u, _v, _w; + CGAL_Conic_type type; CGAL_Orientation o; - bool empty, trivial, degenerate; + bool empty, trivial, degenerate; @end @macro = @begin - DA dao; - FT _r, _s, _t, _u, _v, _w; - CGAL_Conic_type type; + DA dao; + FT _r, _s, _t, _u, _v, _w; + CGAL_Conic_type type; CGAL_Orientation o; - bool empty, trivial, degenerate; + bool empty, trivial, degenerate; @end @@ -1195,7 +1202,7 @@ computes $\det(\r)=4rs-t^2$, and as mentioned in subsection @macro += @begin RT det () const { - return RT(4)*s()*r() - t()*t(); + return RT(4)*s()*r() - t()*t(); } @end @@ -1203,7 +1210,7 @@ computes $\det(\r)=4rs-t^2$, and as mentioned in subsection @macro += @begin FT det () const { - return FT(4)*s()*r() - t()*t(); + return FT(4)*s()*r() - t()*t(); } @end @@ -1221,24 +1228,24 @@ a @prg{case} statement. @macro += @begin void analyse () { - RT d = det(); - type = (CGAL_Conic_type)(CGAL_sign(d)); - switch (type) { - case CGAL_HYPERBOLA: - { - @ - } - break; - case CGAL_PARABOLA: - { - @ - } - break; - case CGAL_ELLIPSE: - { - @ - } - break; + RT d = det(); + type = (CGAL_Conic_type)(CGAL_sign(d)); + switch (type) { + case CGAL_HYPERBOLA: + { + @ + } + break; + case CGAL_PARABOLA: + { + @ + } + break; + case CGAL_ELLIPSE: + { + @ + } + break; } } @@ -1248,24 +1255,24 @@ a @prg{case} statement. @macro += @begin void analyse () { - FT d = det(); - type = (CGAL_Conic_type)(CGAL_sign(d)); - switch (type) { - case CGAL_HYPERBOLA: - { - @ - } - break; - case CGAL_PARABOLA: - { - @ - } - break; - case CGAL_ELLIPSE: - { - @ - } - break; + FT d = det(); + type = (CGAL_Conic_type)(CGAL_sign(d)); + switch (type) { + case CGAL_HYPERBOLA: + { + @ + } + break; + case CGAL_PARABOLA: + { + @ + } + break; + case CGAL_ELLIPSE: + { + @ + } + break; } } @@ -1353,11 +1360,11 @@ this, we get the equivalent condition $r>0$. trivial = false; RT z_prime = d*w() - u()*u()*s() - v()*v()*r() + u()*v()*t(); if (CGAL_is_positive (r())) { - empty = CGAL_is_positive(CGAL_sign (z_prime)); - empty ? o = CGAL_POSITIVE : o = CGAL_NEGATIVE; + empty = CGAL_is_positive(CGAL_sign (z_prime)); + empty ? o = CGAL_POSITIVE : o = CGAL_NEGATIVE; } else { - empty = CGAL_is_negative(CGAL_sign (z_prime)); - empty ? o = CGAL_NEGATIVE : o = CGAL_POSITIVE; + empty = CGAL_is_negative(CGAL_sign (z_prime)); + empty ? o = CGAL_NEGATIVE : o = CGAL_POSITIVE; } degenerate = empty || CGAL_is_zero (z_prime); @@ -1367,11 +1374,11 @@ this, we get the equivalent condition $r>0$. trivial = false; FT z_prime = d*w() - u()*u()*s() - v()*v()*r() + u()*v()*t(); if (CGAL_is_positive (r())) { - empty = CGAL_is_positive(CGAL_sign (z_prime)); - empty ? o = CGAL_POSITIVE : o = CGAL_NEGATIVE; + empty = CGAL_is_positive(CGAL_sign (z_prime)); + empty ? o = CGAL_POSITIVE : o = CGAL_NEGATIVE; } else { - empty = CGAL_is_negative(CGAL_sign (z_prime)); - empty ? o = CGAL_NEGATIVE : o = CGAL_POSITIVE; + empty = CGAL_is_negative(CGAL_sign (z_prime)); + empty ? o = CGAL_NEGATIVE : o = CGAL_POSITIVE; } degenerate = empty || CGAL_is_zero (z_prime); @@ -1424,131 +1431,131 @@ $$\r(p) = -(\sqrt{-r} x - \sqrt{-s} y)^2 + ux + vy + w.$$ $\r(p)$ is a concave function which implies that if $\r(p_1),\r(p_2)>0$, then also $\r(p)>0$, $p$ a convex combination of $p_1,p_2$. This means that the positive side is a convex set, thus equal to the convex side. - + @macro = @begin if (!CGAL_is_zero (r())) { - trivial = false; - degenerate = (t()*u() == RT(2)*r()*v()); - if (degenerate) { - CGAL_Sign discr = (CGAL_Sign) - CGAL_sign(u()*u()-RT(4)*r()*w()); - switch (discr) { - case CGAL_NEGATIVE: - empty = true; - o = (CGAL_Orientation)(CGAL_sign (w())); - break; - case CGAL_ZERO: - empty = false; - o = (CGAL_Orientation)(CGAL_sign (r())); - break; - case CGAL_POSITIVE: - empty = false; - o = CGAL_ZERO; - break; - } - } else { - empty = false; - o = (CGAL_Orientation)(-CGAL_sign (r())); - } + trivial = false; + degenerate = (t()*u() == RT(2)*r()*v()); + if (degenerate) { + CGAL_Sign discr = (CGAL_Sign) + CGAL_sign(u()*u()-RT(4)*r()*w()); + switch (discr) { + case CGAL_NEGATIVE: + empty = true; + o = (CGAL_Orientation)(CGAL_sign (w())); + break; + case CGAL_ZERO: + empty = false; + o = (CGAL_Orientation)(CGAL_sign (r())); + break; + case CGAL_POSITIVE: + empty = false; + o = CGAL_ZERO; + break; + } + } else { + empty = false; + o = (CGAL_Orientation)(-CGAL_sign (r())); + } } else if (!CGAL_is_zero (s())) { - trivial = false; - degenerate = (t()*v() == RT(2)*s()*u()); - if (degenerate) { - CGAL_Sign discr = (CGAL_Sign) - CGAL_sign(v()*v()-RT(4)*s()*w()); - switch (discr) { - case CGAL_NEGATIVE: - empty = true; - o = (CGAL_Orientation)(CGAL_sign (w())); - break; - case CGAL_ZERO: - empty = false; - o = (CGAL_Orientation)(CGAL_sign (s())); - break; - case CGAL_POSITIVE: - empty = false; - o = CGAL_ZERO; - break; - } - } else { - empty = false; - o = (CGAL_Orientation)(-CGAL_sign (s())); - } + trivial = false; + degenerate = (t()*v() == RT(2)*s()*u()); + if (degenerate) { + CGAL_Sign discr = (CGAL_Sign) + CGAL_sign(v()*v()-RT(4)*s()*w()); + switch (discr) { + case CGAL_NEGATIVE: + empty = true; + o = (CGAL_Orientation)(CGAL_sign (w())); + break; + case CGAL_ZERO: + empty = false; + o = (CGAL_Orientation)(CGAL_sign (s())); + break; + case CGAL_POSITIVE: + empty = false; + o = CGAL_ZERO; + break; + } + } else { + empty = false; + o = (CGAL_Orientation)(-CGAL_sign (s())); + } } else { // r=0, s=0 - degenerate = true; - bool uv_zero = CGAL_is_zero (u()) && CGAL_is_zero (v()); - trivial = uv_zero && CGAL_is_zero (w()); - empty = uv_zero && !trivial; - if (empty) - o = (CGAL_Orientation)(CGAL_sign (w())); - else if (trivial) - o = CGAL_POSITIVE; - else - o = CGAL_ZERO; + degenerate = true; + bool uv_zero = CGAL_is_zero (u()) && CGAL_is_zero (v()); + trivial = uv_zero && CGAL_is_zero (w()); + empty = uv_zero && !trivial; + if (empty) + o = (CGAL_Orientation)(CGAL_sign (w())); + else if (trivial) + o = CGAL_POSITIVE; + else + o = CGAL_ZERO; } @end @macro = @begin if (!CGAL_is_zero (r())) { - trivial = false; - degenerate = (t()*u() == FT(2)*r()*v()); - if (degenerate) { - CGAL_Sign discr = (CGAL_Sign) - CGAL_sign(u()*u()-FT(4)*r()*w()); - switch (discr) { - case CGAL_NEGATIVE: - empty = true; - o = (CGAL_Orientation)(CGAL_sign (w())); - break; - case CGAL_ZERO: - empty = false; - o = (CGAL_Orientation)(CGAL_sign (r())); - break; - case CGAL_POSITIVE: - empty = false; - o = CGAL_ZERO; - break; - } - } else { - empty = false; - o = (CGAL_Orientation)(-CGAL_sign (r())); - } + trivial = false; + degenerate = (t()*u() == FT(2)*r()*v()); + if (degenerate) { + CGAL_Sign discr = (CGAL_Sign) + CGAL_sign(u()*u()-FT(4)*r()*w()); + switch (discr) { + case CGAL_NEGATIVE: + empty = true; + o = (CGAL_Orientation)(CGAL_sign (w())); + break; + case CGAL_ZERO: + empty = false; + o = (CGAL_Orientation)(CGAL_sign (r())); + break; + case CGAL_POSITIVE: + empty = false; + o = CGAL_ZERO; + break; + } + } else { + empty = false; + o = (CGAL_Orientation)(-CGAL_sign (r())); + } } else if (!CGAL_is_zero (s())) { - trivial = false; - degenerate = (t()*v() == FT(2)*s()*u()); - if (degenerate) { - CGAL_Sign discr = (CGAL_Sign) - CGAL_sign(v()*v()-FT(4)*s()*w()); - switch (discr) { - case CGAL_NEGATIVE: - empty = true; - o = (CGAL_Orientation)(CGAL_sign (w())); - break; - case CGAL_ZERO: - empty = false; - o = (CGAL_Orientation)(CGAL_sign (s())); - break; - case CGAL_POSITIVE: - empty = false; - o = CGAL_ZERO; - break; - } - } else { - empty = false; - o = (CGAL_Orientation)(-CGAL_sign (s())); - } + trivial = false; + degenerate = (t()*v() == FT(2)*s()*u()); + if (degenerate) { + CGAL_Sign discr = (CGAL_Sign) + CGAL_sign(v()*v()-FT(4)*s()*w()); + switch (discr) { + case CGAL_NEGATIVE: + empty = true; + o = (CGAL_Orientation)(CGAL_sign (w())); + break; + case CGAL_ZERO: + empty = false; + o = (CGAL_Orientation)(CGAL_sign (s())); + break; + case CGAL_POSITIVE: + empty = false; + o = CGAL_ZERO; + break; + } + } else { + empty = false; + o = (CGAL_Orientation)(-CGAL_sign (s())); + } } else { // r=0, s=0 - degenerate = true; - bool uv_zero = CGAL_is_zero (u()) && CGAL_is_zero (v()); - trivial = uv_zero && CGAL_is_zero (w()); - empty = uv_zero && !trivial; - if (empty) - o = (CGAL_Orientation)(CGAL_sign (w())); - else if (trivial) - o = CGAL_POSITIVE; - else - o = CGAL_ZERO; + degenerate = true; + bool uv_zero = CGAL_is_zero (u()) && CGAL_is_zero (v()); + trivial = uv_zero && CGAL_is_zero (w()); + empty = uv_zero && !trivial; + if (empty) + o = (CGAL_Orientation)(CGAL_sign (w())); + else if (trivial) + o = CGAL_POSITIVE; + else + o = CGAL_ZERO; } @end @@ -1564,9 +1571,9 @@ $\r(p) = rx^2+sy^2+txy+uxh+vyh+wh^2$. @macro += @begin RT evaluate (const PT &p) const { - RT x, y, h; - dao.get (p, x, y, h); - return r()*x*x + s()*y*y + t()*x*y + u()*x*h + v()*y*h + w()*h*h; + RT x, y, h; + dao.get (p, x, y, h); + return r()*x*x + s()*y*y + t()*x*y + u()*x*h + v()*y*h + w()*h*h; } @end @@ -1577,9 +1584,9 @@ $\r(p) = rx^2+sy^2+txy+ux+vy+w$. @macro += @begin FT evaluate (const PT &p) const { - FT x, y; - dao.get (p, x, y); - return r()*x*x + s()*y*y + t()*x*y + u()*x + v()*y + w(); + FT x, y; + dao.get (p, x, y); + return r()*x*x + s()*y*y + t()*x*y + u()*x + v()*y + w(); } @end @@ -1602,9 +1609,9 @@ data. CGAL_ConicHPA2 ( const DA& da = DA()) : dao( da) { } CGAL_ConicHPA2 (RT r, RT s, RT t, RT u, RT v, RT w, const DA& da = DA()) - : dao( da), _r(r), _s(s), _t(t), _u(u), _v(v), _w(w) + : dao( da), _r(r), _s(s), _t(t), _u(u), _v(v), _w(w) { - analyse (); + analyse (); } @end @@ -1613,9 +1620,9 @@ data. CGAL_ConicCPA2 ( const DA& da = DA()) : dao( da) { } CGAL_ConicCPA2 (FT r, FT s, FT t, FT u, FT v, FT w, const DA& da = DA()) - : dao( da), _r(r), _s(s), _t(t), _u(u), _v(v), _w(w) + : dao( da), _r(r), _s(s), _t(t), _u(u), _v(v), _w(w) { - analyse (); + analyse (); } @end @@ -1627,7 +1634,7 @@ data. @macro += @begin DA const& da() const { - return dao; + return dao; } @end @@ -1635,7 +1642,7 @@ data. @macro += @begin DA const& da() const { - return dao; + return dao; } @end @@ -1685,11 +1692,11 @@ by it. @macro += @begin PT center () const { - CGAL_kernel_precondition (type != CGAL_PARABOLA); - PT p; - RT two = RT(2); - dao.set( p, two*s()*u() - t()*v(), two*r()*v() - t()*u(), -det()); - return p; + CGAL_kernel_precondition (type != CGAL_PARABOLA); + PT p; + RT two = RT(2); + dao.set( p, two*s()*u() - t()*v(), two*r()*v() - t()*u(), -det()); + return p; } @end @@ -1697,13 +1704,13 @@ by it. @macro += @begin PT center () const { - CGAL_kernel_precondition (type != CGAL_PARABOLA); - PT p; - FT two = FT(2); - FT div = -det(); - dao.set( p, (two*s()*u() - t()*v()) / div, - (two*r()*v() - t()*u()) / div); - return p; + CGAL_kernel_precondition (type != CGAL_PARABOLA); + PT p; + FT two = FT(2); + FT div = -det(); + dao.set( p, (two*s()*u() - t()*v()) / div, + (two*r()*v() - t()*u()) / div); + return p; } @end @@ -1719,37 +1726,37 @@ straightforward. @macro += @begin CGAL_Conic_type conic_type () const { - return type; + return type; } - + bool is_hyperbola () const { - return (type == CGAL_HYPERBOLA); + return (type == CGAL_HYPERBOLA); } bool is_parabola () const { - return (type == CGAL_PARABOLA); + return (type == CGAL_PARABOLA); } bool is_ellipse () const { - return (type == CGAL_ELLIPSE); + return (type == CGAL_ELLIPSE); } bool is_empty () const { - return empty; + return empty; } bool is_trivial () const { - return trivial; + return trivial; } bool is_degenerate () const { - return degenerate; + return degenerate; } @end @@ -1758,37 +1765,37 @@ straightforward. @macro += @begin CGAL_Conic_type conic_type () const { - return type; + return type; } - + bool is_hyperbola () const { - return (type == CGAL_HYPERBOLA); + return (type == CGAL_HYPERBOLA); } bool is_parabola () const { - return (type == CGAL_PARABOLA); + return (type == CGAL_PARABOLA); } bool is_ellipse () const { - return (type == CGAL_ELLIPSE); + return (type == CGAL_ELLIPSE); } bool is_empty () const { - return empty; + return empty; } bool is_trivial () const { - return trivial; + return trivial; } bool is_degenerate () const { - return degenerate; + return degenerate; } @end @@ -1800,7 +1807,7 @@ straightforward. @macro += @begin CGAL_Orientation orientation () const { - return o; + return o; } @end @@ -1808,7 +1815,7 @@ straightforward. @macro += @begin CGAL_Orientation orientation () const { - return o; + return o; } @end @@ -1821,12 +1828,12 @@ positive resp. negative side iff $\r(p)>0$ resp. $\r(p)<0$. @macro += @begin CGAL_Oriented_side oriented_side (const PT& p) const { - return (CGAL_Oriented_side)(CGAL_sign (evaluate (p))); + return (CGAL_Oriented_side)(CGAL_sign (evaluate (p))); } bool has_on_positive_side (const PT& p) const { - return (CGAL_is_positive (evaluate(p))); + return (CGAL_is_positive (evaluate(p))); } bool has_on_negative_side (const PT& p) const @@ -1849,12 +1856,12 @@ positive resp. negative side iff $\r(p)>0$ resp. $\r(p)<0$. @macro += @begin CGAL_Oriented_side oriented_side (const PT& p) const { - return (CGAL_Oriented_side)(CGAL_sign (evaluate (p))); + return (CGAL_Oriented_side)(CGAL_sign (evaluate (p))); } bool has_on_positive_side (const PT& p) const { - return (CGAL_is_positive (evaluate(p))); + return (CGAL_is_positive (evaluate(p))); } bool has_on_negative_side (const PT& p) const @@ -1883,26 +1890,26 @@ zero, we know that the nonconvex side is empty, see subsection @macro += @begin CGAL_Convex_side convex_side (const PT &p) const { - switch (o) { - case CGAL_POSITIVE: - return (CGAL_Convex_side)(-CGAL_sign (evaluate (p))); - case CGAL_NEGATIVE: - return (CGAL_Convex_side)( CGAL_sign (evaluate (p))); - case CGAL_ZERO: - return (CGAL_Convex_side)(-CGAL_sign (CGAL_abs (evaluate(p)))); + switch (o) { + case CGAL_POSITIVE: + return (CGAL_Convex_side)(-CGAL_sign (evaluate (p))); + case CGAL_NEGATIVE: + return (CGAL_Convex_side)( CGAL_sign (evaluate (p))); + case CGAL_ZERO: + return (CGAL_Convex_side)(-CGAL_sign (CGAL_abs (evaluate(p)))); } - // keeps g++ happy - return( CGAL_Convex_side( 0)); + // keeps g++ happy + return( CGAL_Convex_side( 0)); } bool has_on_convex_side (const PT &p) const { - return (convex_side (p) == CGAL_ON_CONVEX_SIDE); + return (convex_side (p) == CGAL_ON_CONVEX_SIDE); } bool has_on_nonconvex_side (const PT &p) const { - return (convex_side (p) == CGAL_ON_NONCONVEX_SIDE); + return (convex_side (p) == CGAL_ON_NONCONVEX_SIDE); } @end @@ -1910,26 +1917,26 @@ zero, we know that the nonconvex side is empty, see subsection @macro += @begin CGAL_Convex_side convex_side (const PT &p) const { - switch (o) { - case CGAL_POSITIVE: - return (CGAL_Convex_side)(-CGAL_sign (evaluate (p))); - case CGAL_NEGATIVE: - return (CGAL_Convex_side)( CGAL_sign (evaluate (p))); - case CGAL_ZERO: - return (CGAL_Convex_side)(-CGAL_sign (CGAL_abs (evaluate(p)))); + switch (o) { + case CGAL_POSITIVE: + return (CGAL_Convex_side)(-CGAL_sign (evaluate (p))); + case CGAL_NEGATIVE: + return (CGAL_Convex_side)( CGAL_sign (evaluate (p))); + case CGAL_ZERO: + return (CGAL_Convex_side)(-CGAL_sign (CGAL_abs (evaluate(p)))); } - // keeps g++ happy - return( CGAL_Convex_side( 0)); + // keeps g++ happy + return( CGAL_Convex_side( 0)); } bool has_on_convex_side (const PT &p) const { - return (convex_side (p) == CGAL_ON_CONVEX_SIDE); + return (convex_side (p) == CGAL_ON_CONVEX_SIDE); } bool has_on_nonconvex_side (const PT &p) const { - return (convex_side (p) == CGAL_ON_NONCONVEX_SIDE); + return (convex_side (p) == CGAL_ON_NONCONVEX_SIDE); } @end @@ -1943,32 +1950,32 @@ We provide tests for equality and inequality of two conics. @macro += @begin bool operator == ( CGAL_ConicHPA2<_PT,_DA> const& c) const { - // find coefficient != 0 - RT factor1; - if ( ! CGAL_is_zero( r())) factor1 = r(); else - if ( ! CGAL_is_zero( s())) factor1 = s(); else - if ( ! CGAL_is_zero( t())) factor1 = t(); else - if ( ! CGAL_is_zero( u())) factor1 = u(); else - if ( ! CGAL_is_zero( v())) factor1 = v(); else - if ( ! CGAL_is_zero( w())) factor1 = w(); else - CGAL_optimisation_assertion_msg( false, "all coefficients zero"); + // find coefficient != 0 + RT factor1; + if ( ! CGAL_is_zero( r())) factor1 = r(); else + if ( ! CGAL_is_zero( s())) factor1 = s(); else + if ( ! CGAL_is_zero( t())) factor1 = t(); else + if ( ! CGAL_is_zero( u())) factor1 = u(); else + if ( ! CGAL_is_zero( v())) factor1 = v(); else + if ( ! CGAL_is_zero( w())) factor1 = w(); else + CGAL_optimisation_assertion_msg( false, "all coefficients zero"); - // find coefficient != 0 - RT factor2; - if ( ! CGAL_is_zero( c.r())) factor2 = c.r(); else - if ( ! CGAL_is_zero( c.s())) factor2 = c.s(); else - if ( ! CGAL_is_zero( c.t())) factor2 = c.t(); else - if ( ! CGAL_is_zero( c.u())) factor2 = c.u(); else - if ( ! CGAL_is_zero( c.v())) factor2 = c.v(); else - if ( ! CGAL_is_zero( c.w())) factor2 = c.w(); else - CGAL_optimisation_assertion_msg( false, "all coefficients zero"); + // find coefficient != 0 + RT factor2; + if ( ! CGAL_is_zero( c.r())) factor2 = c.r(); else + if ( ! CGAL_is_zero( c.s())) factor2 = c.s(); else + if ( ! CGAL_is_zero( c.t())) factor2 = c.t(); else + if ( ! CGAL_is_zero( c.u())) factor2 = c.u(); else + if ( ! CGAL_is_zero( c.v())) factor2 = c.v(); else + if ( ! CGAL_is_zero( c.w())) factor2 = c.w(); else + CGAL_optimisation_assertion_msg( false, "all coefficients zero"); - return( ( r()*factor2 == c.r()*factor1) - && ( s()*factor2 == c.s()*factor1) - && ( t()*factor2 == c.t()*factor1) - && ( u()*factor2 == c.u()*factor1) - && ( v()*factor2 == c.v()*factor1) - && ( w()*factor2 == c.w()*factor1)); + return( ( r()*factor2 == c.r()*factor1) + && ( s()*factor2 == c.s()*factor1) + && ( t()*factor2 == c.t()*factor1) + && ( u()*factor2 == c.u()*factor1) + && ( v()*factor2 == c.v()*factor1) + && ( w()*factor2 == c.w()*factor1)); } @end @@ -1976,32 +1983,32 @@ We provide tests for equality and inequality of two conics. @macro += @begin bool operator == ( CGAL_ConicCPA2<_PT,_DA> const& c) const { - // find coefficient != 0 - FT factor1; - if ( ! CGAL_is_zero( r())) factor1 = r(); else - if ( ! CGAL_is_zero( s())) factor1 = s(); else - if ( ! CGAL_is_zero( t())) factor1 = t(); else - if ( ! CGAL_is_zero( u())) factor1 = u(); else - if ( ! CGAL_is_zero( v())) factor1 = v(); else - if ( ! CGAL_is_zero( w())) factor1 = w(); else - CGAL_optimisation_assertion_msg( false, "all coefficients zero"); + // find coefficient != 0 + FT factor1; + if ( ! CGAL_is_zero( r())) factor1 = r(); else + if ( ! CGAL_is_zero( s())) factor1 = s(); else + if ( ! CGAL_is_zero( t())) factor1 = t(); else + if ( ! CGAL_is_zero( u())) factor1 = u(); else + if ( ! CGAL_is_zero( v())) factor1 = v(); else + if ( ! CGAL_is_zero( w())) factor1 = w(); else + CGAL_optimisation_assertion_msg( false, "all coefficients zero"); - // find coefficient != 0 - FT factor2; - if ( ! CGAL_is_zero( c.r())) factor2 = c.r(); else - if ( ! CGAL_is_zero( c.s())) factor2 = c.s(); else - if ( ! CGAL_is_zero( c.t())) factor2 = c.t(); else - if ( ! CGAL_is_zero( c.u())) factor2 = c.u(); else - if ( ! CGAL_is_zero( c.v())) factor2 = c.v(); else - if ( ! CGAL_is_zero( c.w())) factor2 = c.w(); else - CGAL_optimisation_assertion_msg( false, "all coefficients zero"); + // find coefficient != 0 + FT factor2; + if ( ! CGAL_is_zero( c.r())) factor2 = c.r(); else + if ( ! CGAL_is_zero( c.s())) factor2 = c.s(); else + if ( ! CGAL_is_zero( c.t())) factor2 = c.t(); else + if ( ! CGAL_is_zero( c.u())) factor2 = c.u(); else + if ( ! CGAL_is_zero( c.v())) factor2 = c.v(); else + if ( ! CGAL_is_zero( c.w())) factor2 = c.w(); else + CGAL_optimisation_assertion_msg( false, "all coefficients zero"); - return( ( r()*factor2 == c.r()*factor1) - && ( s()*factor2 == c.s()*factor1) - && ( t()*factor2 == c.t()*factor1) - && ( u()*factor2 == c.u()*factor1) - && ( v()*factor2 == c.v()*factor1) - && ( w()*factor2 == c.w()*factor1)); + return( ( r()*factor2 == c.r()*factor1) + && ( s()*factor2 == c.s()*factor1) + && ( t()*factor2 == c.t()*factor1) + && ( u()*factor2 == c.u()*factor1) + && ( v()*factor2 == c.v()*factor1) + && ( w()*factor2 == c.w()*factor1)); } @end @@ -2029,14 +2036,14 @@ whenever they call a private set method. @macro += @begin void set_linear_combination (const RT &a1, const CGAL_ConicHPA2 &c1, - const RT &a2, const CGAL_ConicHPA2 &c2) + const RT &a2, const CGAL_ConicHPA2 &c2) { - _r = a1 * c1.r() + a2 * c2.r(); - _s = a1 * c1.s() + a2 * c2.s(); - _t = a1 * c1.t() + a2 * c2.t(); - _u = a1 * c1.u() + a2 * c2.u(); - _v = a1 * c1.v() + a2 * c2.v(); - _w = a1 * c1.w() + a2 * c2.w(); + _r = a1 * c1.r() + a2 * c2.r(); + _s = a1 * c1.s() + a2 * c2.s(); + _t = a1 * c1.t() + a2 * c2.t(); + _u = a1 * c1.u() + a2 * c2.u(); + _v = a1 * c1.v() + a2 * c2.v(); + _w = a1 * c1.w() + a2 * c2.w(); } @end @@ -2044,14 +2051,14 @@ whenever they call a private set method. @macro += @begin void set_linear_combination (const FT &a1, const CGAL_ConicCPA2 &c1, - const FT &a2, const CGAL_ConicCPA2 &c2) + const FT &a2, const CGAL_ConicCPA2 &c2) { - _r = a1 * c1.r() + a2 * c2.r(); - _s = a1 * c1.s() + a2 * c2.s(); - _t = a1 * c1.t() + a2 * c2.t(); - _u = a1 * c1.u() + a2 * c2.u(); - _v = a1 * c1.v() + a2 * c2.v(); - _w = a1 * c1.w() + a2 * c2.w(); + _r = a1 * c1.r() + a2 * c2.r(); + _s = a1 * c1.s() + a2 * c2.s(); + _t = a1 * c1.t() + a2 * c2.t(); + _u = a1 * c1.u() + a2 * c2.u(); + _v = a1 * c1.v() + a2 * c2.v(); + _w = a1 * c1.w() + a2 * c2.w(); } @end @@ -2092,37 +2099,37 @@ obtained by setting $h_i=1,i=1\ldots 3$). @macro += @begin static void set_two_linepairs (const PT &p1, - const PT &p2, - const PT &p3, - const PT &p4, - CGAL_ConicHPA2 &pair1, - CGAL_ConicHPA2 &pair2) + const PT &p2, + const PT &p3, + const PT &p4, + CGAL_ConicHPA2 &pair1, + CGAL_ConicHPA2 &pair2) { - RT x1, y1, h1, x2, y2, h2, x3, y3, h3, x4, y4, h4; - const DA& da = pair1.da(); - da.get (p1, x1, y1, h1); - da.get (p2, x2, y2, h2); - da.get (p3, x3, y3, h3); - da.get (p4, x4, y4, h4); + RT x1, y1, h1, x2, y2, h2, x3, y3, h3, x4, y4, h4; + const DA& da = pair1.da(); + da.get (p1, x1, y1, h1); + da.get (p2, x2, y2, h2); + da.get (p3, x3, y3, h3); + da.get (p4, x4, y4, h4); - CGAL_Orientation side1_24 = @("2", "4", "1"), - side3_24 = @("2", "4", "3"); - if (side1_24 != side3_24) { - // (counter)clockwise order - pair1.set_linepair (p1, p2, p3, p4); - pair2.set_linepair (p2, p3, p4, p1); - } else { - CGAL_Orientation side1_32 = @("3", "2", "1"); - if (side1_32 != side3_24) { - // p1, p2 need to be swapped - pair1.set_linepair (p2, p1, p3, p4); - pair2.set_linepair (p1, p3, p4, p2); - } else { - // p2, p3 need to be swapped - pair1.set_linepair (p1, p3, p2, p4); - pair2.set_linepair (p3, p2, p4, p1); - } - } + CGAL_Orientation side1_24 = @("2", "4", "1"), + side3_24 = @("2", "4", "3"); + if (side1_24 != side3_24) { + // (counter)clockwise order + pair1.set_linepair (p1, p2, p3, p4); + pair2.set_linepair (p2, p3, p4, p1); + } else { + CGAL_Orientation side1_32 = @("3", "2", "1"); + if (side1_32 != side3_24) { + // p1, p2 need to be swapped + pair1.set_linepair (p2, p1, p3, p4); + pair2.set_linepair (p1, p3, p4, p2); + } else { + // p2, p3 need to be swapped + pair1.set_linepair (p1, p3, p2, p4); + pair2.set_linepair (p3, p2, p4, p1); + } + } } @end @@ -2130,37 +2137,37 @@ obtained by setting $h_i=1,i=1\ldots 3$). @macro += @begin static void set_two_linepairs (const PT &p1, - const PT &p2, - const PT &p3, - const PT &p4, - CGAL_ConicCPA2 &pair1, - CGAL_ConicCPA2 &pair2) + const PT &p2, + const PT &p3, + const PT &p4, + CGAL_ConicCPA2 &pair1, + CGAL_ConicCPA2 &pair2) { - FT x1, y1, x2, y2, x3, y3, x4, y4; - const DA& da = pair1.da(); - da.get (p1, x1, y1); - da.get (p2, x2, y2); - da.get (p3, x3, y3); - da.get (p4, x4, y4); + FT x1, y1, x2, y2, x3, y3, x4, y4; + const DA& da = pair1.da(); + da.get (p1, x1, y1); + da.get (p2, x2, y2); + da.get (p3, x3, y3); + da.get (p4, x4, y4); - CGAL_Orientation side1_24 = @("2", "4", "1"), - side3_24 = @("2", "4", "3"); - if (side1_24 != side3_24) { - // (counter)clockwise order - pair1.set_linepair (p1, p2, p3, p4); - pair2.set_linepair (p2, p3, p4, p1); - } else { - CGAL_Orientation side1_32 = @("3", "2", "1"); - if (side1_32 != side3_24) { - // p1, p2 need to be swapped - pair1.set_linepair (p2, p1, p3, p4); - pair2.set_linepair (p1, p3, p4, p2); - } else { - // p2, p3 need to be swapped - pair1.set_linepair (p1, p3, p2, p4); - pair2.set_linepair (p3, p2, p4, p1); - } - } + CGAL_Orientation side1_24 = @("2", "4", "1"), + side3_24 = @("2", "4", "3"); + if (side1_24 != side3_24) { + // (counter)clockwise order + pair1.set_linepair (p1, p2, p3, p4); + pair2.set_linepair (p2, p3, p4, p1); + } else { + CGAL_Orientation side1_32 = @("3", "2", "1"); + if (side1_32 != side3_24) { + // p1, p2 need to be swapped + pair1.set_linepair (p2, p1, p3, p4); + pair2.set_linepair (p1, p3, p4, p2); + } else { + // p2, p3 need to be swapped + pair1.set_linepair (p1, p3, p2, p4); + pair2.set_linepair (p3, p2, p4, p1); + } + } } @end @@ -2181,24 +2188,24 @@ $r_i,\ldots,w_i$ the components of $\r_i,i=1\ldots 2$. @macro += @begin void set_ellipse (const CGAL_ConicHPA2 &pair1, - const CGAL_ConicHPA2 &pair2) + const CGAL_ConicHPA2 &pair2) { - RT b = RT(2) * (pair1.r() * pair2.s() + pair1.s() * pair2.r()) - - pair1.t() * pair2.t(); - set_linear_combination (pair2.det()-b, pair1, - pair1.det()-b, pair2); + RT b = RT(2) * (pair1.r() * pair2.s() + pair1.s() * pair2.r()) - + pair1.t() * pair2.t(); + set_linear_combination (pair2.det()-b, pair1, + pair1.det()-b, pair2); } @end @macro += @begin void set_ellipse (const CGAL_ConicCPA2 &pair1, - const CGAL_ConicCPA2 &pair2) + const CGAL_ConicCPA2 &pair2) { - FT b = FT(2) * (pair1.r() * pair2.s() + pair1.s() * pair2.r()) - - pair1.t() * pair2.t(); - set_linear_combination (pair2.det()-b, pair1, - pair1.det()-b, pair2); + FT b = FT(2) * (pair1.r() * pair2.s() + pair1.s() * pair2.r()) - + pair1.t() * pair2.t(); + set_linear_combination (pair2.det()-b, pair1, + pair1.det()-b, pair2); } @end @@ -2214,20 +2221,20 @@ this conic is contructed here. @macro += @begin void set (const CGAL_ConicHPA2 &c1, - const CGAL_ConicHPA2 &c2, - const PT &p) + const CGAL_ConicHPA2 &c2, + const PT &p) { - set_linear_combination (c2.evaluate(p), c1, -c1.evaluate(p), c2); + set_linear_combination (c2.evaluate(p), c1, -c1.evaluate(p), c2); } @end @macro += @begin void set (const CGAL_ConicCPA2 &c1, - const CGAL_ConicCPA2 &c2, - const PT &p) + const CGAL_ConicCPA2 &c2, + const PT &p) { - set_linear_combination (c2.evaluate(p), c1, -c1.evaluate(p), c2); + set_linear_combination (c2.evaluate(p), c1, -c1.evaluate(p), c2); } @end @@ -2313,38 +2320,38 @@ $a_1,a_0,b_1,b_0$ from above. @macro += @begin CGAL_Sign vol_derivative (RT dr, RT ds, RT dt, - RT du, RT dv, RT dw) const + RT du, RT dv, RT dw) const { - RT a1 = RT(4)*r()*ds+RT(4)*dr*s()-RT(2)*t()*dt, - a0 = RT(4)*r()*s()-t()*t(), - b1 = (RT(4)*r()*s()-t()*t())*dw+(RT(4)*r()*ds+RT(4)*dr*s()- - RT(2)*t()*dt)*w()-u()*u()*ds - - RT(2)*u()*du*s()-v()*v()*dr-RT(2)*v()*dv*r()+u()*v()*dt+ - (u()*dv+du*v())*t(), - b0 = (RT(4)*r()*s()-t()*t())*w() - -u()*u()*s()-v()*v()*r()+u()*v()*t(), - c0 = -RT(2)*a0*b1 + RT(3)*a1*b0; + RT a1 = RT(4)*r()*ds+RT(4)*dr*s()-RT(2)*t()*dt, + a0 = RT(4)*r()*s()-t()*t(), + b1 = (RT(4)*r()*s()-t()*t())*dw+(RT(4)*r()*ds+RT(4)*dr*s()- + RT(2)*t()*dt)*w()-u()*u()*ds - + RT(2)*u()*du*s()-v()*v()*dr-RT(2)*v()*dv*r()+u()*v()*dt+ + (u()*dv+du*v())*t(), + b0 = (RT(4)*r()*s()-t()*t())*w() + -u()*u()*s()-v()*v()*r()+u()*v()*t(), + c0 = -RT(2)*a0*b1 + RT(3)*a1*b0; - return CGAL_Sign (-CGAL_sign (c0)*o); + return CGAL_Sign (-CGAL_sign (c0)*o); } @end @macro += @begin CGAL_Sign vol_derivative (FT dr, FT ds, FT dt, - FT du, FT dv, FT dw) const + FT du, FT dv, FT dw) const { - FT a1 = FT(4)*r()*ds+FT(4)*dr*s()-FT(2)*t()*dt, - a0 = FT(4)*r()*s()-t()*t(), - b1 = (FT(4)*r()*s()-t()*t())*dw+(FT(4)*r()*ds+FT(4)*dr*s()- - FT(2)*t()*dt)*w()-u()*u()*ds - - FT(2)*u()*du*s()-v()*v()*dr-FT(2)*v()*dv*r()+u()*v()*dt+ - (u()*dv+du*v())*t(), - b0 = (FT(4)*r()*s()-t()*t())*w() - -u()*u()*s()-v()*v()*r()+u()*v()*t(), - c0 = -FT(2)*a0*b1 + FT(3)*a1*b0; + FT a1 = FT(4)*r()*ds+FT(4)*dr*s()-FT(2)*t()*dt, + a0 = FT(4)*r()*s()-t()*t(), + b1 = (FT(4)*r()*s()-t()*t())*dw+(FT(4)*r()*ds+FT(4)*dr*s()- + FT(2)*t()*dt)*w()-u()*u()*ds - + FT(2)*u()*du*s()-v()*v()*dr-FT(2)*v()*dv*r()+u()*v()*dt+ + (u()*dv+du*v())*t(), + b0 = (FT(4)*r()*s()-t()*t())*w() + -u()*u()*s()-v()*v()*r()+u()*v()*t(), + c0 = -FT(2)*a0*b1 + FT(3)*a1*b0; - return CGAL_Sign (-CGAL_sign (c0)*o); + return CGAL_Sign (-CGAL_sign (c0)*o); } @end @@ -2395,13 +2402,13 @@ the values $u_R,u_I$ in some other way. For this, we need to solve the equation $$u^3 = C := -b/2 + i\sqrt{-D}$$ for $u$. Expressing $C$ in polar coordinates $(r,\phi)$ we get \begin{eqnarray*} -r &=& \|C\| = \sqrt{b^2/4 -D} = \sqrt{-(a/3)^3}, \\ +r &=& \|C\| = \sqrt{b^2/4 -D} = \sqrt{-(a/3)^3}, \\ \cos \phi &=& -\frac{b/2}{\|C\|}, \end{eqnarray*} where $0\leq \phi < \pi$ because of $\sqrt{-D}>0$. Therefore, a possible choice for $u$ is $u=(r', \phi')$ with \begin{eqnarray*} -r' &=& \sqrt{-a/3}, \\ +r' &=& \sqrt{-a/3}, \\ \phi' &=& \acos \left(-\frac{b/2}{\|C\|}\right)/3. \end{eqnarray*} This gives @@ -2431,75 +2438,75 @@ $p(\tau)$ is not a constant function. @macro zero = @begin int CGAL_solve_cubic (double c3, double c2, double c1, double c0, - double &r1, double &r2, double &r3) + double &r1, double &r2, double &r3) { - if (c3 == 0.0) { - // quadratic equation - if (c2 == 0) { - // linear equation - CGAL_kernel_precondition (c1 != 0); - r1 = -c0/c1; - return 1; - } - double D = c1*c1-4*c2*c0; - if (D < 0.0) - // only complex roots - return 0; - if (D == 0.0) { - // one real root - r1 = -c1/(2.0*c2); - return 1; - } - // two real roots - r1 = (-c1 + sqrt(D))/(2.0*c2); - r2 = (-c1 - sqrt(D))/(2.0*c2); - return 2; - } + if (c3 == 0.0) { + // quadratic equation + if (c2 == 0) { + // linear equation + CGAL_kernel_precondition (c1 != 0); + r1 = -c0/c1; + return 1; + } + double D = c1*c1-4*c2*c0; + if (D < 0.0) + // only complex roots + return 0; + if (D == 0.0) { + // one real root + r1 = -c1/(2.0*c2); + return 1; + } + // two real roots + r1 = (-c1 + sqrt(D))/(2.0*c2); + r2 = (-c1 - sqrt(D))/(2.0*c2); + return 2; + } - // cubic equation + // cubic equation // define the gamma_i - double g2 = c2/c3, - g1 = c1/c3, - g0 = c0/c3; + double g2 = c2/c3, + g1 = c1/c3, + g0 = c0/c3; - // define a, b - double a = g1 - g2*g2/3.0, - b = 2.0*g2*g2*g2/27.0 - g1*g2/3.0 + g0; + // define a, b + double a = g1 - g2*g2/3.0, + b = 2.0*g2*g2*g2/27.0 - g1*g2/3.0 + g0; - if (a == 0) { - // one real root - r1 = cbrt(-b) - g2/3.0; - return 1; - } + if (a == 0) { + // one real root + r1 = cbrt(-b) - g2/3.0; + return 1; + } - // define D - double D = a*a*a/27.0 + b*b/4.0; - if (D >= 0.0) { - // real case - double u = cbrt(-b/2.0 + sqrt(D)), - alpha = 1.0 - a/(3.0*u*u); - if (D == 0) { - // two distinct real roots - r1 = u*alpha - g2/3.0; - r2 = -0.5*alpha*u - g2/3.0; - return 2; - } - // one real root - r1 = u*alpha - g2/3.0; - return 1; - } - // complex case - double r_prime = sqrt(-a/3), - phi_prime = acos (-b/(2.0*r_prime*r_prime*r_prime))/3.0, - u_R = r_prime * cos (phi_prime), - u_I = r_prime * sin (phi_prime); - // three distinct real roots - r1 = 2.0*u_R - g2/3.0; - r2 = -u_R + u_I*sqrt(3.0) - g2/3.0; - r3 = -u_R - u_I*sqrt(3.0) - g2/3.0; - return 3; + // define D + double D = a*a*a/27.0 + b*b/4.0; + if (D >= 0.0) { + // real case + double u = cbrt(-b/2.0 + sqrt(D)), + alpha = 1.0 - a/(3.0*u*u); + if (D == 0) { + // two distinct real roots + r1 = u*alpha - g2/3.0; + r2 = -0.5*alpha*u - g2/3.0; + return 2; + } + // one real root + r1 = u*alpha - g2/3.0; + return 1; + } + // complex case + double r_prime = sqrt(-a/3), + phi_prime = acos (-b/(2.0*r_prime*r_prime*r_prime))/3.0, + u_R = r_prime * cos (phi_prime), + u_I = r_prime * sin (phi_prime); + // three distinct real roots + r1 = 2.0*u_R - g2/3.0; + r2 = -u_R + u_I*sqrt(3.0) - g2/3.0; + r3 = -u_R - u_I*sqrt(3.0) - g2/3.0; + return 3; } - + @end Here comes the actual computation of the volume minimum. To this end, @@ -2515,37 +2522,37 @@ to find the roots, so we can directly evaluate the determinant, using @macro += @begin double vol_minimum (RT dr, RT ds, RT dt, RT du, RT dv, RT dw) const { - RT a2 = RT(4)*dr*ds-dt*dt, - a1 = RT(4)*r()*ds+RT(4)*dr*s()-RT(2)*t()*dt, - a0 = RT(4)*r()*s()-t()*t(), - b3 = (RT(4)*dr*ds-dt*dt)*dw-du*du*ds-dv*dv*dr+du*dv*dt, - b2 = (RT(4)*r()*ds+RT(4)*dr*s()-RT(2)*t()*dt)*dw+ - (RT(4)*dr*ds-dt*dt)*w()-RT(2)*u()*du*ds-du*du*s()- - RT(2)*v()*dv*dr-dv*dv*r()+(u()*dv+du*v())*dt+du*dv*t(), - b1 = (RT(4)*r()*s()-t()*t())*dw+(RT(4)*r()*ds+RT(4)*dr*s()- - RT(2)*t()*dt)*w()-u()*u()*ds - - RT(2)*u()*du*s()-v()*v()*dr-RT(2)*v()*dv*r()+u()*v()*dt+ - (u()*dv+du*v())*t(), - b0 = (RT(4)*r()*s()-t()*t())*w() - -u()*u()*s()-v()*v()*r()+u()*v()*t(), - c3 = -RT(3)*a1*b3 + RT(2)*a2*b2, - c2 = -RT(6)*a0*b3 - a1*b2 + RT(4)*a2*b1, - c1 = -RT(4)*a0*b2 + a1*b1 + RT(6)*a2*b0, - c0 = -RT(2)*a0*b1 + RT(3)*a1*b0; + RT a2 = RT(4)*dr*ds-dt*dt, + a1 = RT(4)*r()*ds+RT(4)*dr*s()-RT(2)*t()*dt, + a0 = RT(4)*r()*s()-t()*t(), + b3 = (RT(4)*dr*ds-dt*dt)*dw-du*du*ds-dv*dv*dr+du*dv*dt, + b2 = (RT(4)*r()*ds+RT(4)*dr*s()-RT(2)*t()*dt)*dw+ + (RT(4)*dr*ds-dt*dt)*w()-RT(2)*u()*du*ds-du*du*s()- + RT(2)*v()*dv*dr-dv*dv*r()+(u()*dv+du*v())*dt+du*dv*t(), + b1 = (RT(4)*r()*s()-t()*t())*dw+(RT(4)*r()*ds+RT(4)*dr*s()- + RT(2)*t()*dt)*w()-u()*u()*ds - + RT(2)*u()*du*s()-v()*v()*dr-RT(2)*v()*dv*r()+u()*v()*dt+ + (u()*dv+du*v())*t(), + b0 = (RT(4)*r()*s()-t()*t())*w() + -u()*u()*s()-v()*v()*r()+u()*v()*t(), + c3 = -RT(3)*a1*b3 + RT(2)*a2*b2, + c2 = -RT(6)*a0*b3 - a1*b2 + RT(4)*a2*b1, + c1 = -RT(4)*a0*b2 + a1*b1 + RT(6)*a2*b0, + c0 = -RT(2)*a0*b1 + RT(3)*a1*b0; - if (c0 == 0) return 0; // E(0) is the smallest ellipse + if (c0 == 0) return 0; // E(0) is the smallest ellipse - double roots[3]; - int nr_roots = CGAL_solve_cubic - (CGAL_to_double(c3), CGAL_to_double(c2), - CGAL_to_double(c1), CGAL_to_double(c0), - roots[0], roots[1], roots[2]); - CGAL_kernel_precondition (nr_roots > 0); // minimum exists - return CGAL_best_value (roots, nr_roots, - CGAL_to_double(a2), CGAL_to_double(a1), - CGAL_to_double(a0), CGAL_to_double(b3), - CGAL_to_double(b2), CGAL_to_double(b1), - CGAL_to_double(b0)); + double roots[3]; + int nr_roots = CGAL_solve_cubic + (CGAL_to_double(c3), CGAL_to_double(c2), + CGAL_to_double(c1), CGAL_to_double(c0), + roots[0], roots[1], roots[2]); + CGAL_kernel_precondition (nr_roots > 0); // minimum exists + return CGAL_best_value (roots, nr_roots, + CGAL_to_double(a2), CGAL_to_double(a1), + CGAL_to_double(a0), CGAL_to_double(b3), + CGAL_to_double(b2), CGAL_to_double(b1), + CGAL_to_double(b0)); } @end @@ -2554,37 +2561,37 @@ to find the roots, so we can directly evaluate the determinant, using @macro += @begin double vol_minimum (FT dr, FT ds, FT dt, FT du, FT dv, FT dw) const { - FT a2 = FT(4)*dr*ds-dt*dt, - a1 = FT(4)*r()*ds+FT(4)*dr*s()-FT(2)*t()*dt, - a0 = FT(4)*r()*s()-t()*t(), - b3 = (FT(4)*dr*ds-dt*dt)*dw-du*du*ds-dv*dv*dr+du*dv*dt, - b2 = (FT(4)*r()*ds+FT(4)*dr*s()-FT(2)*t()*dt)*dw+ - (FT(4)*dr*ds-dt*dt)*w()-FT(2)*u()*du*ds-du*du*s()- - FT(2)*v()*dv*dr-dv*dv*r()+(u()*dv+du*v())*dt+du*dv*t(), - b1 = (FT(4)*r()*s()-t()*t())*dw+(FT(4)*r()*ds+FT(4)*dr*s()- - FT(2)*t()*dt)*w()-u()*u()*ds - - FT(2)*u()*du*s()-v()*v()*dr-FT(2)*v()*dv*r()+u()*v()*dt+ - (u()*dv+du*v())*t(), - b0 = (FT(4)*r()*s()-t()*t())*w() + FT a2 = FT(4)*dr*ds-dt*dt, + a1 = FT(4)*r()*ds+FT(4)*dr*s()-FT(2)*t()*dt, + a0 = FT(4)*r()*s()-t()*t(), + b3 = (FT(4)*dr*ds-dt*dt)*dw-du*du*ds-dv*dv*dr+du*dv*dt, + b2 = (FT(4)*r()*ds+FT(4)*dr*s()-FT(2)*t()*dt)*dw+ + (FT(4)*dr*ds-dt*dt)*w()-FT(2)*u()*du*ds-du*du*s()- + FT(2)*v()*dv*dr-dv*dv*r()+(u()*dv+du*v())*dt+du*dv*t(), + b1 = (FT(4)*r()*s()-t()*t())*dw+(FT(4)*r()*ds+FT(4)*dr*s()- + FT(2)*t()*dt)*w()-u()*u()*ds - + FT(2)*u()*du*s()-v()*v()*dr-FT(2)*v()*dv*r()+u()*v()*dt+ + (u()*dv+du*v())*t(), + b0 = (FT(4)*r()*s()-t()*t())*w() -u()*u()*s()-v()*v()*r()+u()*v()*t(), - c3 = -FT(3)*a1*b3 + FT(2)*a2*b2, - c2 = -FT(6)*a0*b3 - a1*b2 + FT(4)*a2*b1, - c1 = -FT(4)*a0*b2 + a1*b1 + FT(6)*a2*b0, - c0 = -FT(2)*a0*b1 + FT(3)*a1*b0; + c3 = -FT(3)*a1*b3 + FT(2)*a2*b2, + c2 = -FT(6)*a0*b3 - a1*b2 + FT(4)*a2*b1, + c1 = -FT(4)*a0*b2 + a1*b1 + FT(6)*a2*b0, + c0 = -FT(2)*a0*b1 + FT(3)*a1*b0; - if ( CGAL_is_zero( c0)) return 0; // E(0) is the smallest ellipse + if ( CGAL_is_zero( c0)) return 0; // E(0) is the smallest ellipse - double roots[3]; - int nr_roots = CGAL_solve_cubic - (CGAL_to_double(c3), CGAL_to_double(c2), - CGAL_to_double(c1), CGAL_to_double(c0), - roots[0], roots[1], roots[2]); - CGAL_kernel_precondition (nr_roots > 0); // minimum exists - return CGAL_best_value (roots, nr_roots, - CGAL_to_double(a2), CGAL_to_double(a1), - CGAL_to_double(a0), CGAL_to_double(b3), - CGAL_to_double(b2), CGAL_to_double(b1), - CGAL_to_double(b0)); + double roots[3]; + int nr_roots = CGAL_solve_cubic + (CGAL_to_double(c3), CGAL_to_double(c2), + CGAL_to_double(c1), CGAL_to_double(c0), + roots[0], roots[1], roots[2]); + CGAL_kernel_precondition (nr_roots > 0); // minimum exists + return CGAL_best_value (roots, nr_roots, + CGAL_to_double(a2), CGAL_to_double(a1), + CGAL_to_double(a0), CGAL_to_double(b3), + CGAL_to_double(b2), CGAL_to_double(b1), + CGAL_to_double(b0)); } @end @@ -2596,23 +2603,23 @@ be positive. @macro = @begin double CGAL_best_value (double *values, int nr_values, - double a2, double a1, double a0, - double b3, double b2, double b1, double b0) + double a2, double a1, double a0, + double b3, double b2, double b1, double b0) { bool det_positive = false; double d, q, max_det = 0.0, det, best; for (int i=0; i 0.0) - if (!det_positive || (det > max_det)) { - max_det = det; - best = x; - det_positive = true; - } - } + if (!det_positive || (det > max_det)) { + max_det = det; + best = x; + det_positive = true; + } + } CGAL_kernel_precondition (det_positive); return best; } @@ -2629,8 +2636,8 @@ Here is the set method at coordinate level. @macro += @begin void set (RT r_, RT s_, RT t_, RT u_, RT v_, RT w_) { - _r = r_; _s = s_; _t = t_; _u = u_; _v = v_; _w = w_; - analyse(); + _r = r_; _s = s_; _t = t_; _u = u_; _v = v_; _w = w_; + analyse(); } @end @@ -2638,8 +2645,8 @@ Here is the set method at coordinate level. @macro += @begin void set (FT r_, FT s_, FT t_, FT u_, FT v_, FT w_) { - _r = r_; _s = s_; _t = t_; _u = u_; _v = v_; _w = w_; - analyse(); + _r = r_; _s = s_; _t = t_; _u = u_; _v = v_; _w = w_; + analyse(); } @end @@ -2655,8 +2662,8 @@ orientation, all other derived data are taken over. @macro += @begin void set_opposite () { - _r = -r(); _s = -s(); _t = -t(); _u = -u(); _v = -v(); _w = -w(); - o = CGAL_opposite(orientation()); + _r = -r(); _s = -s(); _t = -t(); _u = -u(); _v = -v(); _w = -w(); + o = CGAL_opposite(orientation()); } @end @@ -2664,8 +2671,8 @@ orientation, all other derived data are taken over. @macro += @begin void set_opposite () { - _r = -r(); _s = -s(); _t = -t(); _u = -u(); _v = -v(); _w = -w(); - o = CGAL_opposite(orientation()); + _r = -r(); _s = -s(); _t = -t(); _u = -u(); _v = -v(); _w = -w(); + o = CGAL_opposite(orientation()); } @end @@ -2725,34 +2732,34 @@ w &=& (-y_1x_2+x_1y_2)(-y_3x_4+x_3y_4). @macro += @begin void set_linepair (const PT &p1, const PT &p2, const PT &p3, - const PT &p4, const DA &da = DA()) + const PT &p4, const DA &da = DA()) { - RT x1, y1, h1, x2, y2, h2, x3, y3, h3, x4, y4, h4; - da.get (p1, x1, y1, h1); - da.get (p2, x2, y2, h2); - da.get (p3, x3, y3, h3); - da.get (p4, x4, y4, h4); - - // precondition: p1 != p2, p3 != p4 - CGAL_kernel_precondition - ( ((x1*h2 != x2*h1) || (y1*h2 != y2*h1)) && - ((x3*h4 != x4*h3) || (y3*h4 != y4*h3)) ); + RT x1, y1, h1, x2, y2, h2, x3, y3, h3, x4, y4, h4; + da.get (p1, x1, y1, h1); + da.get (p2, x2, y2, h2); + da.get (p3, x3, y3, h3); + da.get (p4, x4, y4, h4); + + // precondition: p1 != p2, p3 != p4 + CGAL_kernel_precondition + ( ((x1*h2 != x2*h1) || (y1*h2 != y2*h1)) && + ((x3*h4 != x4*h3) || (y3*h4 != y4*h3)) ); - RT h1x2_x1h2 = h1*x2-x1*h2; - RT h3x4_x3h4 = h3*x4-x3*h4; - RT y1h2_h1y2 = y1*h2-h1*y2; - RT y3h4_h3y4 = y3*h4-h3*y4; - RT x1y2_y1x2 = x1*y2-y1*x2; - RT x3y4_y3x4 = x3*y4-y3*x4; + RT h1x2_x1h2 = h1*x2-x1*h2; + RT h3x4_x3h4 = h3*x4-x3*h4; + RT y1h2_h1y2 = y1*h2-h1*y2; + RT y3h4_h3y4 = y3*h4-h3*y4; + RT x1y2_y1x2 = x1*y2-y1*x2; + RT x3y4_y3x4 = x3*y4-y3*x4; - _r = y1h2_h1y2 * y3h4_h3y4; - _s = h1x2_x1h2 * h3x4_x3h4; - _t = h1x2_x1h2 * y3h4_h3y4 + y1h2_h1y2 * h3x4_x3h4; - _u = x1y2_y1x2 * y3h4_h3y4 + y1h2_h1y2 * x3y4_y3x4; - _v = x1y2_y1x2 * h3x4_x3h4 + h1x2_x1h2 * x3y4_y3x4; - _w = x1y2_y1x2 * x3y4_y3x4; + _r = y1h2_h1y2 * y3h4_h3y4; + _s = h1x2_x1h2 * h3x4_x3h4; + _t = h1x2_x1h2 * y3h4_h3y4 + y1h2_h1y2 * h3x4_x3h4; + _u = x1y2_y1x2 * y3h4_h3y4 + y1h2_h1y2 * x3y4_y3x4; + _v = x1y2_y1x2 * h3x4_x3h4 + h1x2_x1h2 * x3y4_y3x4; + _w = x1y2_y1x2 * x3y4_y3x4; - analyse(); + analyse(); } @end @@ -2763,32 +2770,32 @@ replacing values $h_1,\ldots,h_4$ by 1. @macro += @begin void set_linepair (const PT &p1, const PT &p2, const PT &p3, const PT &p4) { - FT x1, y1, x2, y2, x3, y3, x4, y4; - dao.get (p1, x1, y1); - dao.get (p2, x2, y2); - dao.get (p3, x3, y3); - dao.get (p4, x4, y4); + FT x1, y1, x2, y2, x3, y3, x4, y4; + dao.get (p1, x1, y1); + dao.get (p2, x2, y2); + dao.get (p3, x3, y3); + dao.get (p4, x4, y4); - // precondition: p1 != p2, p3 != p4 - CGAL_kernel_precondition - ( ((x1 != x2) || (y1 != y2)) && - ((x3 != x4) || (y3 != y4)) ); + // precondition: p1 != p2, p3 != p4 + CGAL_kernel_precondition + ( ((x1 != x2) || (y1 != y2)) && + ((x3 != x4) || (y3 != y4)) ); - FT x2_x1 = x2-x1; - FT x4_x3 = x4-x3; - FT y1_y2 = y1-y2; - FT y3_y4 = y3-y4; - FT x1y2_y1x2 = x1*y2-y1*x2; - FT x3y4_y3x4 = x3*y4-y3*x4; + FT x2_x1 = x2-x1; + FT x4_x3 = x4-x3; + FT y1_y2 = y1-y2; + FT y3_y4 = y3-y4; + FT x1y2_y1x2 = x1*y2-y1*x2; + FT x3y4_y3x4 = x3*y4-y3*x4; - _r = y1_y2 * y3_y4; - _s = x2_x1 * x4_x3; - _t = x2_x1 * y3_y4 + y1_y2 * x4_x3; - _u = x1y2_y1x2 * y3_y4 + y1_y2 * x3y4_y3x4; - _v = x1y2_y1x2 * x4_x3 + x2_x1 * x3y4_y3x4; - _w = x1y2_y1x2 * x3y4_y3x4; + _r = y1_y2 * y3_y4; + _s = x2_x1 * x4_x3; + _t = x2_x1 * y3_y4 + y1_y2 * x4_x3; + _u = x1y2_y1x2 * y3_y4 + y1_y2 * x3y4_y3x4; + _v = x1y2_y1x2 * x4_x3 + x2_x1 * x3y4_y3x4; + _w = x1y2_y1x2 * x3y4_y3x4; - analyse(); + analyse(); } @end @@ -2877,56 +2884,56 @@ was positive, we still need to flip the representation. @macro += @begin void set_ellipse (const PT &p1, const PT &p2, const PT &p3) { - RT x1, y1, h1, x2, y2, h2, x3, y3, h3; - dao.get (p1, x1, y1, h1); - dao.get (p2, x2, y2, h2); - dao.get (p3, x3, y3, h3); + RT x1, y1, h1, x2, y2, h2, x3, y3, h3; + dao.get (p1, x1, y1, h1); + dao.get (p2, x2, y2, h2); + dao.get (p3, x3, y3, h3); // precondition: p1, p2, p3 not collinear - RT det = -h1*x3*y2+h3*x1*y2+h1*x2*y3-h2*x1*y3+h2*x3*y1-h3*x2*y1; - CGAL_kernel_precondition (!CGAL_is_zero (det)); + RT det = -h1*x3*y2+h3*x1*y2+h1*x2*y3-h2*x1*y3+h2*x3*y1-h3*x2*y1; + CGAL_kernel_precondition (!CGAL_is_zero (det)); - RT x1x1 = x1*x1, y1y1 = y1*y1, - x2x2 = x2*x2, y2y2 = y2*y2, - x3x3 = x3*x3, y3y3 = y3*y3, // x_i^2, y_i^2 - x1h1 = x1*h1, y1h1 = y1*h1, - x2h2 = x2*h2, y2h2 = y2*h2, - x3h3 = x3*h3, y3h3 = y3*h3, // x_i h_i, y_i h_i - h1h1 = h1*h1, - h2h2 = h2*h2, - h3h3 = h3*h3, // h_i^2 - two = RT(2); // 2 + RT x1x1 = x1*x1, y1y1 = y1*y1, + x2x2 = x2*x2, y2y2 = y2*y2, + x3x3 = x3*x3, y3y3 = y3*y3, // x_i^2, y_i^2 + x1h1 = x1*h1, y1h1 = y1*h1, + x2h2 = x2*h2, y2h2 = y2*h2, + x3h3 = x3*h3, y3h3 = y3*h3, // x_i h_i, y_i h_i + h1h1 = h1*h1, + h2h2 = h2*h2, + h3h3 = h3*h3, // h_i^2 + two = RT(2); // 2 - _r = y1y1*h2h2*h3h3 - y1h1*y2h2*h3h3 - y1h1*h2h2*y3h3 + - h1h1*y2y2*h3h3 - h1h1*y2h2*y3h3 + h1h1*h2h2*y3y3; + _r = y1y1*h2h2*h3h3 - y1h1*y2h2*h3h3 - y1h1*h2h2*y3h3 + + h1h1*y2y2*h3h3 - h1h1*y2h2*y3h3 + h1h1*h2h2*y3y3; - _s = x1x1*h2h2*h3h3 - x1h1*x2h2*h3h3 - x1h1*h2h2*x3h3 + - h1h1*x2x2*h3h3 - h1h1*x2h2*x3h3 + h1h1*h2h2*x3x3; + _s = x1x1*h2h2*h3h3 - x1h1*x2h2*h3h3 - x1h1*h2h2*x3h3 + + h1h1*x2x2*h3h3 - h1h1*x2h2*x3h3 + h1h1*h2h2*x3x3; - _t = -two*x1*y1*h2h2*h3h3 + x1h1*y2h2*h3h3 + x1h1*h2h2*y3h3 + - y1h1*x2h2*h3h3 -two*h1h1*x2*y2*h3h3 + h1h1*x2h2*y3h3 + - y1h1*h2h2*x3h3 + h1h1*y2h2*x3h3 -two*h1h1*h2h2*x3*y3; + _t = -two*x1*y1*h2h2*h3h3 + x1h1*y2h2*h3h3 + x1h1*h2h2*y3h3 + + y1h1*x2h2*h3h3 -two*h1h1*x2*y2*h3h3 + h1h1*x2h2*y3h3 + + y1h1*h2h2*x3h3 + h1h1*y2h2*x3h3 -two*h1h1*h2h2*x3*y3; - _u = -(h1h1*y2y2*x3h3 - h1h1*x2*y2*y3h3 - h1h1*y2h2*x3*y3 + - x1h1*h2h2*y3y3 + h1h1*x2h2*y3y3 +y1y1*x2h2*h3h3 + - y1y1*h2h2*x3h3 - x1*y1*y2h2*h3h3 - y1h1*x2*y2*h3h3 - - x1*y1*h2h2*y3h3 - y1h1*h2h2*x3*y3 + x1h1*y2y2*h3h3); + _u = -(h1h1*y2y2*x3h3 - h1h1*x2*y2*y3h3 - h1h1*y2h2*x3*y3 + + x1h1*h2h2*y3y3 + h1h1*x2h2*y3y3 +y1y1*x2h2*h3h3 + + y1y1*h2h2*x3h3 - x1*y1*y2h2*h3h3 - y1h1*x2*y2*h3h3 - + x1*y1*h2h2*y3h3 - y1h1*h2h2*x3*y3 + x1h1*y2y2*h3h3); - _v = -(h1h1*x2x2*y3h3 - h1h1*x2*y2*x3h3 - h1h1*x2h2*x3*y3 + - y1h1*h2h2*x3x3 + h1h1*y2h2*x3x3 +x1x1*y2h2*h3h3 + - x1x1*h2h2*y3h3 - x1*y1*x2h2*h3h3 - x1h1*x2*y2*h3h3 - - x1*y1*h2h2*x3h3 - x1h1*h2h2*x3*y3 + y1h1*x2x2*h3h3); + _v = -(h1h1*x2x2*y3h3 - h1h1*x2*y2*x3h3 - h1h1*x2h2*x3*y3 + + y1h1*h2h2*x3x3 + h1h1*y2h2*x3x3 +x1x1*y2h2*h3h3 + + x1x1*h2h2*y3h3 - x1*y1*x2h2*h3h3 - x1h1*x2*y2*h3h3 - + x1*y1*h2h2*x3h3 - x1h1*h2h2*x3*y3 + y1h1*x2x2*h3h3); - _w = y1y1*x2h2*x3h3 - x1*y1*y2h2*x3h3 - y1h1*x2*y2*x3h3 + - y1h1*y2h2*x3x3 - x1*y1*x2h2*y3h3 + y1h1*x2x2*y3h3 - - y1h1*x2h2*x3*y3 + x1h1*y2y2*x3h3 + x1x1*y2h2*y3h3 - - x1h1*x2*y2*y3h3 - x1h1*y2h2*x3*y3 + x1h1*x2h2*y3y3; + _w = y1y1*x2h2*x3h3 - x1*y1*y2h2*x3h3 - y1h1*x2*y2*x3h3 + + y1h1*y2h2*x3x3 - x1*y1*x2h2*y3h3 + y1h1*x2x2*y3h3 - + y1h1*x2h2*x3*y3 + x1h1*y2y2*x3h3 + x1x1*y2h2*y3h3 - + x1h1*x2*y2*y3h3 - x1h1*y2h2*x3*y3 + x1h1*x2h2*y3y3; - type = CGAL_ELLIPSE; - degenerate = trivial = empty = false; - o = CGAL_NEGATIVE; - if (CGAL_is_positive (det)) set_opposite (); - + type = CGAL_ELLIPSE; + degenerate = trivial = empty = false; + o = CGAL_NEGATIVE; + if (CGAL_is_positive (det)) set_opposite (); + } @end @@ -2937,49 +2944,49 @@ $h_1,h_2,h_3$ to 1. @macro += @begin void set_ellipse (const PT &p1, const PT &p2, const PT &p3) { - FT x1, y1, x2, y2, x3, y3; - dao.get (p1, x1, y1); - dao.get (p2, x2, y2); - dao.get (p3, x3, y3); + FT x1, y1, x2, y2, x3, y3; + dao.get (p1, x1, y1); + dao.get (p2, x2, y2); + dao.get (p3, x3, y3); - // precondition: p1, p2, p3 not collinear - FT det = -x3*y2+x1*y2+x2*y3-x1*y3+x3*y1-x2*y1; - CGAL_kernel_precondition (!CGAL_is_zero (det)); + // precondition: p1, p2, p3 not collinear + FT det = -x3*y2+x1*y2+x2*y3-x1*y3+x3*y1-x2*y1; + CGAL_kernel_precondition (!CGAL_is_zero (det)); - FT x1x1 = x1*x1, y1y1 = y1*y1, - x2x2 = x2*x2, y2y2 = y2*y2, - x3x3 = x3*x3, y3y3 = y3*y3, // x_i^2, y_i^2 - two = FT(2); + FT x1x1 = x1*x1, y1y1 = y1*y1, + x2x2 = x2*x2, y2y2 = y2*y2, + x3x3 = x3*x3, y3y3 = y3*y3, // x_i^2, y_i^2 + two = FT(2); - _r = y1y1 - y1*y2 - y1*y3 + - y2y2 - y2*y3 + y3y3; + _r = y1y1 - y1*y2 - y1*y3 + + y2y2 - y2*y3 + y3y3; - _s = x1x1 - x1*x2 - x1*x3 + - x2x2 - x2*x3 + x3x3; + _s = x1x1 - x1*x2 - x1*x3 + + x2x2 - x2*x3 + x3x3; - _t = -two*x1*y1 + x1*y2 + x1*y3 + - y1*x2 -two*x2*y2 + x2*y3 + - y1*x3 + y2*x3 -two*x3*y3; + _t = -two*x1*y1 + x1*y2 + x1*y3 + + y1*x2 -two*x2*y2 + x2*y3 + + y1*x3 + y2*x3 -two*x3*y3; - _u = -(y2y2*x3 - x2*y2*y3 - y2*x3*y3 + - x1*y3y3 + x2*y3y3 + y1y1*x2 + - y1y1*x3 - x1*y1*y2 - y1*x2*y2 - - x1*y1*y3 - y1*x3*y3 + x1*y2y2); + _u = -(y2y2*x3 - x2*y2*y3 - y2*x3*y3 + + x1*y3y3 + x2*y3y3 + y1y1*x2 + + y1y1*x3 - x1*y1*y2 - y1*x2*y2 - + x1*y1*y3 - y1*x3*y3 + x1*y2y2); - _v = -(x2x2*y3 - x2*y2*x3 - x2*x3*y3 + - y1*x3x3 + y2*x3x3 + x1x1*y2 + - x1x1*y3 - x1*y1*x2 - x1*x2*y2 - - x1*y1*x3 - x1*x3*y3 + y1*x2x2); + _v = -(x2x2*y3 - x2*y2*x3 - x2*x3*y3 + + y1*x3x3 + y2*x3x3 + x1x1*y2 + + x1x1*y3 - x1*y1*x2 - x1*x2*y2 - + x1*y1*x3 - x1*x3*y3 + y1*x2x2); - _w = y1y1*x2*x3 - x1*y1*y2*x3 - y1*x2*y2*x3 + - y1*y2*x3x3 - x1*y1*x2*y3 + y1*x2x2*y3 - - y1*x2*x3*y3 + x1*y2y2*x3 + x1x1*y2*y3 - - x1*x2*y2*y3 - x1*y2*x3*y3 + x1*x2*y3y3; + _w = y1y1*x2*x3 - x1*y1*y2*x3 - y1*x2*y2*x3 + + y1*y2*x3x3 - x1*y1*x2*y3 + y1*x2x2*y3 - + y1*x2*x3*y3 + x1*y2y2*x3 + x1x1*y2*y3 - + x1*x2*y2*y3 - x1*y2*x3*y3 + x1*x2*y3y3; - type = CGAL_ELLIPSE; - degenerate = trivial = empty = false; - o = CGAL_NEGATIVE; - if (CGAL_is_positive (det)) set_opposite(); + type = CGAL_ELLIPSE; + degenerate = trivial = empty = false; + o = CGAL_NEGATIVE; + if (CGAL_is_positive (det)) set_opposite(); } @end @@ -2995,14 +3002,14 @@ also have a method available. @macro += @begin void set_ellipse (const PT &p1, const PT &p2, - const PT &p3, const PT &p4, - CGAL_Orientation _o = CGAL_POSITIVE) + const PT &p3, const PT &p4, + CGAL_Orientation _o = CGAL_POSITIVE) { - CGAL_ConicHPA2 pair1, pair2; - set_two_linepairs (p1, p2, p3, p4, pair1, pair2); - set_ellipse (pair1, pair2); - analyse (); - if (o != _o) set_opposite(); + CGAL_ConicHPA2 pair1, pair2; + set_two_linepairs (p1, p2, p3, p4, pair1, pair2); + set_ellipse (pair1, pair2); + analyse (); + if (o != _o) set_opposite(); } @end @@ -3010,14 +3017,14 @@ also have a method available. @macro += @begin void set_ellipse (const PT &p1, const PT &p2, - const PT &p3, const PT &p4, - CGAL_Orientation _o = CGAL_POSITIVE) + const PT &p3, const PT &p4, + CGAL_Orientation _o = CGAL_POSITIVE) { - CGAL_ConicCPA2 pair1, pair2; - set_two_linepairs (p1, p2, p3, p4, pair1, pair2); - set_ellipse (pair1, pair2); - analyse(); - if (o != _o) set_opposite(); + CGAL_ConicCPA2 pair1, pair2; + set_two_linepairs (p1, p2, p3, p4, pair1, pair2); + set_ellipse (pair1, pair2); + analyse(); + if (o != _o) set_opposite(); } @end @@ -3046,32 +3053,32 @@ nontrivial conic through the points. @macro += @begin void set (const PT &p1, const PT &p2, const PT &p3, const PT &p4, - const PT &p5, CGAL_Orientation _o = CGAL_POSITIVE) + const PT &p5, CGAL_Orientation _o = CGAL_POSITIVE) { - CGAL_ConicHPA2 c1; c1.set_linepair (p1, p2, p3, p4); - CGAL_ConicHPA2 c2; c2.set_linepair (p1, p4, p2, p3); - set_linear_combination (c2.evaluate (p5), c1, - -c1.evaluate (p5), c2); - analyse (); - // precondition: all points distinct <=> conic nontrivial - CGAL_kernel_precondition (!is_trivial()); - if (o != _o) set_opposite(); + CGAL_ConicHPA2 c1; c1.set_linepair (p1, p2, p3, p4); + CGAL_ConicHPA2 c2; c2.set_linepair (p1, p4, p2, p3); + set_linear_combination (c2.evaluate (p5), c1, + -c1.evaluate (p5), c2); + analyse (); + // precondition: all points distinct <=> conic nontrivial + CGAL_kernel_precondition (!is_trivial()); + if (o != _o) set_opposite(); } @end @macro += @begin void set (const PT &p1, const PT &p2, const PT &p3, const PT &p4, - const PT &p5, CGAL_Orientation _o = CGAL_POSITIVE) + const PT &p5, CGAL_Orientation _o = CGAL_POSITIVE) { - CGAL_ConicCPA2 c1; c1.set_linepair (p1, p2, p3, p4); - CGAL_ConicCPA2 c2; c2.set_linepair (p1, p4, p2, p3); - set_linear_combination (c2.evaluate (p5), c1, - -c1.evaluate (p5), c2); - analyse (); - // precondition: all points distinct <=> conic nontrivial - CGAL_kernel_precondition (!is_trivial()); - if (o != _o) set_opposite(); + CGAL_ConicCPA2 c1; c1.set_linepair (p1, p2, p3, p4); + CGAL_ConicCPA2 c2; c2.set_linepair (p1, p4, p2, p3); + set_linear_combination (c2.evaluate (p5), c1, + -c1.evaluate (p5), c2); + analyse (); + // precondition: all points distinct <=> conic nontrivial + CGAL_kernel_precondition (!is_trivial()); + if (o != _o) set_opposite(); } @end @@ -3085,21 +3092,21 @@ nontrivial conic through the points. template< class _PT, class _DA> ostream& operator << ( ostream& os, CGAL_ConicHPA2<_PT,_DA> const& c) { - return( os << c.r() << ' ' << c.s() << ' ' << c.t() << ' ' - << c.u() << ' ' << c.v() << ' ' << c.w()); + return( os << c.r() << ' ' << c.s() << ' ' << c.t() << ' ' + << c.u() << ' ' << c.v() << ' ' << c.w()); } template< class _PT, class _DA> istream& operator >> ( istream& is, CGAL_ConicHPA2<_PT,_DA>& c) { - typedef CGAL_ConicHPA2<_PT,_DA> Conic; - typedef _DA::RT RT; + typedef CGAL_ConicHPA2<_PT,_DA> Conic; + typedef typename _DA::RT RT; - RT r, s, t, u, v, w; - is >> r >> s >> t >> u >> v >> w; - c.set( r, s, t, u, v, w); + RT r, s, t, u, v, w; + is >> r >> s >> t >> u >> v >> w; + c.set( r, s, t, u, v, w); - return( is); + return( is); } @end @@ -3107,21 +3114,21 @@ nontrivial conic through the points. template< class _PT, class _DA> ostream& operator << ( ostream& os, CGAL_ConicCPA2<_PT,_DA> const& c) { - return( os << c.r() << ' ' << c.s() << ' ' << c.t() << ' ' - << c.u() << ' ' << c.v() << ' ' << c.w()); + return( os << c.r() << ' ' << c.s() << ' ' << c.t() << ' ' + << c.u() << ' ' << c.v() << ' ' << c.w()); } template< class _PT, class _DA> istream& operator >> ( istream& is, CGAL_ConicCPA2<_PT,_DA>& c) { - typedef CGAL_ConicCPA2<_PT,_DA> Conic; - typedef _DA::FT FT; + typedef CGAL_ConicCPA2<_PT,_DA> Conic; + typedef typename _DA::FT FT; - FT r, s, t, u, v, w; - is >> r >> s >> t >> u >> v >> w; - c.set( r, s, t, u, v, w); + FT r, s, t, u, v, w; + is >> r >> s >> t >> u >> v >> w; + c.set( r, s, t, u, v, w); - return( is); + return( is); } @end @@ -3280,8 +3287,8 @@ Here is the class @prg{CGAL_ConicHPA2}\ldots @("2D Conic",@1, "Optimisation/Conic_2", "Bernd Gärtner ", - "Sven Schönherr", - "ETH Zurich (Bernd Gärtner )", + "Sven Schönherr", + "ETH Zurich (Bernd Gärtner )", "$Revision$","$Date$") @end diff --git a/Packages/Min_ellipse_2/web/Min_ellipse_2.aw b/Packages/Min_ellipse_2/web/Min_ellipse_2.aw index 34460a316a9..3d433eb6c3d 100644 --- a/Packages/Min_ellipse_2/web/Min_ellipse_2.aw +++ b/Packages/Min_ellipse_2/web/Min_ellipse_2.aw @@ -200,15 +200,15 @@ The class interface looks as follows. template < class _Traits > class CGAL_Min_ellipse_2 { public: - @ + @ private: - // private data members - @ + // private data members + @ - // copying and assignment not allowed! - CGAL_Min_ellipse_2( CGAL_Min_ellipse_2<_Traits> const&); - CGAL_Min_ellipse_2<_Traits>& + // copying and assignment not allowed! + CGAL_Min_ellipse_2( CGAL_Min_ellipse_2<_Traits> const&); + CGAL_Min_ellipse_2<_Traits>& operator = ( CGAL_Min_ellipse_2<_Traits> const&); @ @@ -217,43 +217,43 @@ The class interface looks as follows. // ==================== public: - // Access functions and predicates - // ------------------------------- - @ + // Access functions and predicates + // ------------------------------- + @ - @ + @ - @ + @ - @ + @ private: - // Privat member functions - // ----------------------- - @ + // Privat member functions + // ----------------------- + @ - @ + @ public: - // Constructors - // ------------ - @ + // Constructors + // ------------ + @ - // Destructor - // ---------- - @ + // Destructor + // ---------- + @ - // Modifiers - // --------- - @ + // Modifiers + // --------- + @ - // Validity check - // -------------- - @ + // Validity check + // -------------- + @ - // Miscellaneous - // ------------- - @ + // Miscellaneous + // ------------- + @ }; @end @@ -279,30 +279,30 @@ section, so we do not comment on it here. // creation CGAL_Min_ellipse_2( const Point* first, - const Point* last, - bool randomize = false, - CGAL_Random& random = CGAL_random, - Traits const& traits = Traits()); + const Point* last, + bool randomize = false, + CGAL_Random& random = CGAL_random, + Traits const& traits = Traits()); CGAL_Min_ellipse_2( list::const_iterator first, - list::const_iterator last, - bool randomize = false, - CGAL_Random& random = CGAL_random, - Traits const& traits = Traits()); + list::const_iterator last, + bool randomize = false, + CGAL_Random& random = CGAL_random, + Traits const& traits = Traits()); CGAL_Min_ellipse_2( istream_iterator first, - istream_iterator last, - bool randomize = false, - CGAL_Random& random = CGAL_random, - Traits const& traits = Traits()) + istream_iterator last, + bool randomize = false, + CGAL_Random& random = CGAL_random, + Traits const& traits = Traits()) CGAL_Min_ellipse_2( Traits const& traits = Traits()); CGAL_Min_ellipse_2( Point const& p, - Traits const& traits = Traits()); + Traits const& traits = Traits()); CGAL_Min_ellipse_2( Point const& p, - Point const& q, - Traits const& traits = Traits()); + Point const& q, + Traits const& traits = Traits()); CGAL_Min_ellipse_2( Point const& p1, - Point const& p2, - Point const& p3, - Traits const& traits = Traits()); + Point const& p2, + Point const& p3, + Traits const& traits = Traits()); ~CGAL_Min_ellipse_2( ); // access functions @@ -352,7 +352,7 @@ section, so we do not comment on it here. First, the traits class object is stored. @macro += @begin - Traits tco; // traits class object + Traits tco; // traits class object @end The points of $P$ are internally stored as a linked list that allows to @@ -360,7 +360,7 @@ bring points to the front of the list in constant time. We use the sequence container \ccc{list} from STL~\cite{sl-stl-95}. @macro += @begin - list points; // doubly linked list of points + list points; // doubly linked list of points @end The support set $S$ of at most five support points is stored in an @@ -374,8 +374,8 @@ because the SGI compiler (mipspro CC 7.1) does not accept a static array here. @macro += @begin - int n_support_points; // number of support points - Point* support_points; // array of support points + int n_support_points; // number of support points + Point* support_points; // array of support points @end Finally, the actual ellipse is stored in a variable \ccc{ellipse} @@ -407,91 +407,91 @@ compute $me(P)=me(P,\emptyset)$. @macro += @begin // STL-like constructor for C array and vector CGAL_Min_ellipse_2( const Point* first, - const Point* last, - bool randomize = false, - CGAL_Random& random = CGAL_random, - Traits const& traits = Traits()) - : tco( traits) + const Point* last, + bool randomize = false, + CGAL_Random& random = CGAL_random, + Traits const& traits = Traits()) + : tco( traits) { - // allocate support points' array - support_points = new Point[ 5]; + // allocate support points' array + support_points = new Point[ 5]; - // range not empty? - if ( ( last-first) > 0) { + // range not empty? + if ( ( last-first) > 0) { - // store points - if ( randomize) { + // store points + if ( randomize) { - // shuffle points at random - vector v( first, last); - random_shuffle( v.begin(), v.end(), random); - copy( v.begin(), v.end(), back_inserter( points)); } - else - copy( first, last, back_inserter( points)); } + // shuffle points at random + vector v( first, last); + random_shuffle( v.begin(), v.end(), random); + copy( v.begin(), v.end(), back_inserter( points)); } + else + copy( first, last, back_inserter( points)); } - // compute me - me( points.end(), 0); + // compute me + me( points.end(), 0); } // STL-like constructor for list CGAL_Min_ellipse_2( list::const_iterator first, - list::const_iterator last, - bool randomize = false, - CGAL_Random& random = CGAL_random, - Traits const& traits = Traits()) - : tco( traits) + list::const_iterator last, + bool randomize = false, + CGAL_Random& random = CGAL_random, + Traits const& traits = Traits()) + : tco( traits) { - // allocate support points' array - support_points = new Point[ 5]; + // allocate support points' array + support_points = new Point[ 5]; - // compute number of points - list::size_type n = 0; - CGAL__distance( first, last, n); - if ( n > 0) { + // compute number of points + list::size_type n = 0; + CGAL__distance( first, last, n); + if ( n > 0) { - // store points - if ( randomize) { + // store points + if ( randomize) { - // shuffle points at random - vector v; - v.reserve( n); - copy( first, last, back_inserter( v)); - random_shuffle( v.begin(), v.end(), random); - copy( v.begin(), v.end(), back_inserter( points)); } - else - copy( first, last, back_inserter( points)); } + // shuffle points at random + vector v; + v.reserve( n); + copy( first, last, back_inserter( v)); + random_shuffle( v.begin(), v.end(), random); + copy( v.begin(), v.end(), back_inserter( points)); } + else + copy( first, last, back_inserter( points)); } - // compute me - me( points.end(), 0); + // compute me + me( points.end(), 0); } // STL-like constructor for input stream iterator istream_iterator CGAL_Min_ellipse_2( istream_iterator first, - istream_iterator last, - bool randomize = false, - CGAL_Random& random = CGAL_random, - Traits const& traits = Traits()) - : tco( traits) + istream_iterator last, + bool randomize = false, + CGAL_Random& random = CGAL_random, + Traits const& traits = Traits()) + : tco( traits) { - // allocate support points' array - support_points = new Point[ 5]; + // allocate support points' array + support_points = new Point[ 5]; - // range not empty? - if ( first != last) { + // range not empty? + if ( first != last) { - // store points - if ( randomize) { + // store points + if ( randomize) { - // shuffle points at random - vector v; - copy( first, last, back_inserter( v)); - random_shuffle( v.begin(), v.end(), random); - copy( v.begin(), v.end(), back_inserter( points)); } - else - copy( first, last, back_inserter( points)); } + // shuffle points at random + vector v; + copy( first, last, back_inserter( v)); + random_shuffle( v.begin(), v.end(), random); + copy( v.begin(), v.end(), back_inserter( points)); } + else + copy( first, last, back_inserter( points)); } - // compute me - me( points.end(), 0); + // compute me + me( points.end(), 0); } @end @@ -511,114 +511,114 @@ For $|S|=0$, we get the default constructor, building $me(\emptyset)$. // default constructor inline CGAL_Min_ellipse_2( Traits const& traits = Traits()) - : tco( traits), n_support_points( 0) + : tco( traits), n_support_points( 0) { - // allocate support points' array - support_points = new Point[ 5]; + // allocate support points' array + support_points = new Point[ 5]; - // initialize ellipse - tco.ellipse.set(); + // initialize ellipse + tco.ellipse.set(); - CGAL_optimisation_postcondition( is_empty()); + CGAL_optimisation_postcondition( is_empty()); } // constructor for one point inline CGAL_Min_ellipse_2( Point const& p, Traits const& traits = Traits()) - : tco( traits), points( 1, p), n_support_points( 1) + : tco( traits), points( 1, p), n_support_points( 1) { - // allocate support points' array - support_points = new Point[ 5]; + // allocate support points' array + support_points = new Point[ 5]; - // initialize ellipse - support_points[ 0] = p; - tco.ellipse.set( p); + // initialize ellipse + support_points[ 0] = p; + tco.ellipse.set( p); - CGAL_optimisation_postcondition( is_degenerate()); + CGAL_optimisation_postcondition( is_degenerate()); } // constructor for two points inline CGAL_Min_ellipse_2( Point const& p, - Point const& q, - Traits const& traits = Traits()) - : tco( traits) + Point const& q, + Traits const& traits = Traits()) + : tco( traits) { - // allocate support points' array - support_points = new Point[ 5]; + // allocate support points' array + support_points = new Point[ 5]; - // store points - points.push_back( p); - points.push_back( q); + // store points + points.push_back( p); + points.push_back( q); - // compute me - me( points.end(), 0); + // compute me + me( points.end(), 0); } // constructor for three points inline CGAL_Min_ellipse_2( Point const& p1, - Point const& p2, - Point const& p3, - Traits const& traits = Traits()) - : tco( traits) + Point const& p2, + Point const& p3, + Traits const& traits = Traits()) + : tco( traits) { - // allocate support points' array - support_points = new Point[ 5]; + // allocate support points' array + support_points = new Point[ 5]; - // store points - points.push_back( p1); - points.push_back( p2); - points.push_back( p3); + // store points + points.push_back( p1); + points.push_back( p2); + points.push_back( p3); - // compute me - me( points.end(), 0); + // compute me + me( points.end(), 0); } // constructor for four points inline CGAL_Min_ellipse_2( Point const& p1, - Point const& p2, - Point const& p3, - Point const& p4, - Traits const& traits = Traits()) - : tco( traits) + Point const& p2, + Point const& p3, + Point const& p4, + Traits const& traits = Traits()) + : tco( traits) { - // allocate support points' array - support_points = new Point[ 5]; + // allocate support points' array + support_points = new Point[ 5]; - // store points - points.push_back( p1); - points.push_back( p2); - points.push_back( p3); - points.push_back( p4); + // store points + points.push_back( p1); + points.push_back( p2); + points.push_back( p3); + points.push_back( p4); - // compute me - me( points.end(), 0); + // compute me + me( points.end(), 0); } // constructor for five points inline CGAL_Min_ellipse_2( Point const& p1, - Point const& p2, - Point const& p3, - Point const& p4, - Point const& p5, - Traits const& traits = Traits()) - : tco( traits) + Point const& p2, + Point const& p3, + Point const& p4, + Point const& p5, + Traits const& traits = Traits()) + : tco( traits) { - // allocate support points' array - support_points = new Point[ 5]; + // allocate support points' array + support_points = new Point[ 5]; - // store points - points.push_back( p1); - points.push_back( p2); - points.push_back( p3); - points.push_back( p4); - points.push_back( p5); + // store points + points.push_back( p1); + points.push_back( p2); + points.push_back( p3); + points.push_back( p4); + points.push_back( p5); - // compute me - me( points.end(), 0); + // compute me + me( points.end(), 0); } @end @@ -628,8 +628,8 @@ The destructor only frees the memory of the support points' array. inline ~CGAL_Min_ellipse_2( ) { - // free support points' array - delete[] support_points; + // free support points' array + delete[] support_points; } @end @@ -649,14 +649,14 @@ First, we define the \ccc{number_of_...} methods. int number_of_points( ) const { - return( points.size()); + return( points.size()); } inline int number_of_support_points( ) const { - return( n_support_points); + return( n_support_points); } @end @@ -668,28 +668,28 @@ Then, we have the access functions for points and support points. Point_iterator points_begin( ) const { - return( points.begin()); + return( points.begin()); } inline Point_iterator points_end( ) const { - return( points.end()); + return( points.end()); } inline Support_point_iterator support_points_begin( ) const { - return( support_points); + return( support_points); } inline Support_point_iterator support_points_end( ) const { - return( support_points+n_support_points); + return( support_points+n_support_points); } // random access for support points @@ -697,9 +697,9 @@ Then, we have the access functions for points and support points. Point const& support_point( int i) const { - CGAL_optimisation_precondition( (i >= 0) && - (i < number_of_support_points())); - return( support_points[ i]); + CGAL_optimisation_precondition( (i >= 0) && + (i < number_of_support_points())); + return( support_points[ i]); } @end @@ -711,7 +711,7 @@ Finally, the access function \ccc{ellipse}. Ellipse const& ellipse( ) const { - return( tco.ellipse); + return( tco.ellipse); } @end @@ -728,14 +728,14 @@ define them \ccc{inline} and put them in a separate macro. bool is_empty( ) const { - return( number_of_support_points() == 0); + return( number_of_support_points() == 0); } inline bool is_degenerate( ) const { - return( number_of_support_points() < 2); + return( number_of_support_points() < 2); } @end @@ -748,28 +748,28 @@ corresponding predicates of class \ccc{Ellipse}. CGAL_Bounded_side bounded_side( Point const& p) const { - return( tco.ellipse.bounded_side( p)); + return( tco.ellipse.bounded_side( p)); } inline bool has_on_bounded_side( Point const& p) const { - return( tco.ellipse.has_on_bounded_side( p)); + return( tco.ellipse.has_on_bounded_side( p)); } inline bool has_on_boundary( Point const& p) const { - return( tco.ellipse.has_on_boundary( p)); + return( tco.ellipse.has_on_boundary( p)); } inline bool has_on_unbounded_side( Point const& p) const { - return( tco.ellipse.has_on_unbounded_side( p)); + return( tco.ellipse.has_on_unbounded_side( p)); } @end @@ -793,21 +793,21 @@ Section~\ref{sec:algo}. void insert( Point const& p) { - // p not in current ellipse? - if ( has_on_unbounded_side( p)) { + // p not in current ellipse? + if ( has_on_unbounded_side( p)) { - // p new support point - support_points[ 0] = p; + // p new support point + support_points[ 0] = p; - // recompute me - me( points.end(), 1); + // recompute me + me( points.end(), 1); - // store p as the first point in list - points.push_front( p); } - else + // store p as the first point in list + points.push_front( p); } + else - // append p to the end of the list - points.push_back( p); + // append p to the end of the list + points.push_back( p); } @end @@ -828,26 +828,26 @@ the range $[\mbox{\ccc{first}},\mbox{\ccc{last}})$ a call \ccc{insert(p)}. void insert( const Point* first, const Point* last) { - for ( ; first != last; ++first) - insert( *first); + for ( ; first != last; ++first) + insert( *first); } inline void insert( list::const_iterator first, - list::const_iterator last ) + list::const_iterator last ) { - for ( ; first != last; ++first) - insert( *first); + for ( ; first != last; ++first) + insert( *first); } inline void insert( istream_iterator first, - istream_iterator last ) + istream_iterator last ) { - for ( ; first != last; ++first) - insert( *first); + for ( ; first != last; ++first) + insert( *first); } @end @@ -858,9 +858,9 @@ empty ellipse. @macro += @begin void clear( ) { - points.erase( points.begin(), points.end()); - n_support_points = 0; - tco.ellipse.set(); + points.erase( points.begin(), points.end()); + n_support_points = 0; + tco.ellipse.set(); } @end @@ -885,24 +885,24 @@ interfaces of other classes. bool is_valid( bool verbose = false, int level = 0) const { - CGAL_Verbose_ostream verr( verbose); - verr << endl; - verr << "CGAL_Min_ellipse_2::" << endl; - verr << "is_valid( true, " << level << "):" << endl; - verr << " |P| = " << number_of_points() - << ", |S| = " << number_of_support_points() << endl; + CGAL_Verbose_ostream verr( verbose); + verr << endl; + verr << "CGAL_Min_ellipse_2::" << endl; + verr << "is_valid( true, " << level << "):" << endl; + verr << " |P| = " << number_of_points() + << ", |S| = " << number_of_support_points() << endl; - // containment check (a) - @ + // containment check (a) + @ - // support set checks (b)+(c) (not yet implemented) - @! + // support set checks (b)+(c) (not yet implemented) + @! - // alternative support set check - @ + // alternative support set check + @ - verr << " object is valid!" << endl; - return( true); + verr << " object is valid!" << endl; + return( true); } @end @@ -913,11 +913,11 @@ points in \ccc{points}. verr << " a) containment check..." << flush; Point_iterator point_iter; for ( point_iter = points_begin(); - point_iter != points_end(); - ++point_iter) - if ( has_on_unbounded_side( *point_iter)) - return( CGAL__optimisation_is_valid_fail( verr, - "ellipse does not contain all points")); + point_iter != points_end(); + ++point_iter) + if ( has_on_unbounded_side( *point_iter)) + return( CGAL__optimisation_is_valid_fail( verr, + "ellipse does not contain all points")); verr << "passed." << endl; @end @@ -928,11 +928,11 @@ support points in \ccc{support_points}. verr << " +) support set check..." << flush; Support_point_iterator support_point_iter; for ( support_point_iter = support_points_begin(); - support_point_iter != support_points_end(); - ++support_point_iter) - if ( ! has_on_boundary( *support_point_iter)) - return( CGAL__optimisation_is_valid_fail( verr, - "ellipse does not have all \ + support_point_iter != support_points_end(); + ++support_point_iter) + if ( ! has_on_boundary( *support_point_iter)) + return( CGAL__optimisation_is_valid_fail( verr, + "ellipse does not have all \ support points on the boundary")); verr << "passed." << endl; @end @@ -948,7 +948,7 @@ traits class object. Traits const& traits( ) const { - return( tco); + return( tco); } @end @@ -968,71 +968,71 @@ traits class object. ostream& operator << ( ostream& os, CGAL_Min_ellipse_2<_Traits> const& min_ellipse) { - typedef typename CGAL_Min_ellipse_2<_Traits>::Point Point; + typedef typename CGAL_Min_ellipse_2<_Traits>::Point Point; - switch ( CGAL_get_mode( os)) { + switch ( CGAL_get_mode( os)) { - case CGAL_IO::PRETTY: - os << endl; - os << "CGAL_Min_ellipse_2( |P| = "<< min_ellipse.number_of_points() - << ", |S| = " << min_ellipse.number_of_support_points() << endl; - os << " P = {" << endl; - os << " "; - copy( min_ellipse.points_begin(), min_ellipse.points_end(), - ostream_iterator( os, ",\n ")); - os << "}" << endl; - os << " S = {" << endl; - os << " "; - copy( min_ellipse.support_points_begin(), - min_ellipse.support_points_end(), - ostream_iterator( os, ",\n ")); - os << "}" << endl; - os << " ellipse = " << min_ellipse.ellipse() << endl; - os << ")" << endl; - break; + case CGAL_IO::PRETTY: + os << endl; + os << "CGAL_Min_ellipse_2( |P| = "<< min_ellipse.number_of_points() + << ", |S| = " << min_ellipse.number_of_support_points() << endl; + os << " P = {" << endl; + os << " "; + copy( min_ellipse.points_begin(), min_ellipse.points_end(), + ostream_iterator( os, ",\n ")); + os << "}" << endl; + os << " S = {" << endl; + os << " "; + copy( min_ellipse.support_points_begin(), + min_ellipse.support_points_end(), + ostream_iterator( os, ",\n ")); + os << "}" << endl; + os << " ellipse = " << min_ellipse.ellipse() << endl; + os << ")" << endl; + break; - case CGAL_IO::ASCII: - copy( min_ellipse.points_begin(), min_ellipse.points_end(), - ostream_iterator( os, "\n")); - break; + case CGAL_IO::ASCII: + copy( min_ellipse.points_begin(), min_ellipse.points_end(), + ostream_iterator( os, "\n")); + break; - case CGAL_IO::BINARY: - copy( min_ellipse.points_begin(), min_ellipse.points_end(), - ostream_iterator( os)); - break; + case CGAL_IO::BINARY: + copy( min_ellipse.points_begin(), min_ellipse.points_end(), + ostream_iterator( os)); + break; - default: - CGAL_optimisation_assertion_msg( false, - "CGAL_get_mode( os) invalid!"); - break; } + default: + CGAL_optimisation_assertion_msg( false, + "CGAL_get_mode( os) invalid!"); + break; } - return( os); + return( os); } template < class Traits > istream& operator >> ( istream& is, CGAL_Min_ellipse_2& min_ellipse) { - switch ( CGAL_get_mode( is)) { + switch ( CGAL_get_mode( is)) { - case CGAL_IO::PRETTY: - cerr << endl; - cerr << "Stream must be in ascii or binary mode" << endl; - break; + case CGAL_IO::PRETTY: + cerr << endl; + cerr << "Stream must be in ascii or binary mode" << endl; + break; - case CGAL_IO::ASCII: - case CGAL_IO::BINARY: - typedef typename CGAL_Min_ellipse_2::Point Point; - typedef istream_iterator Is_it; - min_ellipse.clear(); - min_ellipse.insert( Is_it( is), Is_it()); - break; + case CGAL_IO::ASCII: + case CGAL_IO::BINARY: + typedef typename CGAL_Min_ellipse_2::Point Point; + typedef istream_iterator Is_it; + min_ellipse.clear(); + min_ellipse.insert( Is_it( is), Is_it()); + break; - default: - CGAL_optimisation_assertion_msg( false, "CGAL_IO::mode invalid!"); - break; } + default: + CGAL_optimisation_assertion_msg( false, "CGAL_IO::mode invalid!"); + break; } - return( is); + return( is); } @end @@ -1050,37 +1050,37 @@ noting that $|B| \leq 5$. void compute_ellipse( ) { - switch ( n_support_points) { - case 5: - tco.ellipse.set( support_points[ 0], - support_points[ 1], - support_points[ 2], - support_points[ 3], - support_points[ 4]); + switch ( n_support_points) { + case 5: + tco.ellipse.set( support_points[ 0], + support_points[ 1], + support_points[ 2], + support_points[ 3], + support_points[ 4]); break; - case 4: - tco.ellipse.set( support_points[ 0], - support_points[ 1], - support_points[ 2], - support_points[ 3]); + case 4: + tco.ellipse.set( support_points[ 0], + support_points[ 1], + support_points[ 2], + support_points[ 3]); break; - case 3: - tco.ellipse.set( support_points[ 0], - support_points[ 1], - support_points[ 2]); + case 3: + tco.ellipse.set( support_points[ 0], + support_points[ 1], + support_points[ 2]); break; - case 2: - tco.ellipse.set( support_points[ 0], support_points[ 1]); - break; - case 1: - tco.ellipse.set( support_points[ 0]); - break; - case 0: - tco.ellipse.set( ); - break; - default: - CGAL_optimisation_assertion( ( n_support_points >= 0) && - ( n_support_points <= 5) ); } + case 2: + tco.ellipse.set( support_points[ 0], support_points[ 1]); + break; + case 1: + tco.ellipse.set( support_points[ 0]); + break; + case 0: + tco.ellipse.set( ); + break; + default: + CGAL_optimisation_assertion( ( n_support_points >= 0) && + ( n_support_points <= 5) ); } } @end @@ -1097,31 +1097,31 @@ pseudocode above. void me( Point_iterator const& last, int n_sp) { - // compute ellipse through support points - n_support_points = n_sp; - compute_ellipse(); - if ( n_sp == 5) return; + // compute ellipse through support points + n_support_points = n_sp; + compute_ellipse(); + if ( n_sp == 5) return; - // test first n points - list::iterator point_iter( points.begin()); - for ( ; last != point_iter; ) { - Point const& p( *point_iter); + // test first n points + list::iterator point_iter( points.begin()); + for ( ; last != point_iter; ) { + Point const& p( *point_iter); - // p not in current ellipse? - if ( has_on_unbounded_side( p)) { + // p not in current ellipse? + if ( has_on_unbounded_side( p)) { - // recursive call with p as additional support point - support_points[ n_sp] = p; - me( point_iter, n_sp+1); + // recursive call with p as additional support point + support_points[ n_sp] = p; + me( point_iter, n_sp+1); - // move current point to front - if ( point_iter != points.begin()) { // p not first? - points.push_front( p); - points.erase( point_iter++); } - else - ++point_iter; } - else - ++point_iter; } + // move current point to front + if ( point_iter != points.begin()) { // p not first? + points.push_front( p); + points.erase( point_iter++); } + else + ++point_iter; } + else + ++point_iter; } } @end @@ -1152,19 +1152,18 @@ The class interface looks as follows. @macro = @begin template < class _R > class CGAL_Optimisation_ellipse_2 { - friend - ostream& operator<< ( ostream&,CGAL_Optimisation_ellipse_2<_R> const&); - friend - istream& operator<< ( istream&,CGAL_Optimisation_ellipse_2<_R> &); - friend - CGAL_Window_stream& operator<< ( CGAL_Window_stream&, - CGAL_Optimisation_ellipse_2<_R> const&); + friend ostream& operator << CGAL_NULL_TMPL_ARGS ( + ostream&, CGAL_Optimisation_ellipse_2<_R> const&); + friend istream& operator << CGAL_NULL_TMPL_ARGS ( + istream&, CGAL_Optimisation_ellipse_2<_R> &); + friend CGAL_Window_stream& operator << CGAL_NULL_TMPL_ARGS ( + CGAL_Window_stream&, CGAL_Optimisation_ellipse_2<_R> const&); public: - @ + @ private: - // private data members - @ + // private data members + @ @ @@ -1172,21 +1171,21 @@ The class interface looks as follows. // ==================== public: - // Set functions - // ------------- - @ + // Set functions + // ------------- + @ - // Access functions - // ---------------- - @ + // Access functions + // ---------------- + @ - // Equality tests - // -------------- - @ + // Equality tests + // -------------- + @ - // Predicates - // ---------- - @ + // Predicates + // ---------- + @ }; @end @@ -1199,8 +1198,10 @@ section, so we do not comment on it here. @macro = @begin // types typedef _R R; + typedef typename _R::RT RT; + typedef typename _R::FT FT; typedef CGAL_Point_2 Point; - typedef CGAL_Conic_2 Conic; + typedef CGAL_Conic_2 Conic; /************************************************************************** WORKAROUND: The GNU compiler (g++ 2.7.2[.*]) does not accept types @@ -1214,9 +1215,9 @@ section, so we do not comment on it here. void set( Point const& p, Point const& q); void set( Point const& p1, Point const& p2, Point const& p3); void set( Point const& p1, Point const& p2, - Point const& p3, Point const& p4); + Point const& p3, Point const& p4); void set( Point const& p1, Point const& p2, - Point const& p3, Point const& p4, Point const& p5); + Point const& p3, Point const& p4, Point const& p5); // access functions int number_of_boundary_points() @@ -1243,7 +1244,7 @@ The representation of the ellipse depends on the number of given boundary points, stored in \ccc{n_boundary_points}. @macro += @begin - int n_boundary_points; // number of boundary points + int n_boundary_points; // number of boundary points @end In the degenerate cases with zero to two boundary points, the given @@ -1251,7 +1252,7 @@ points are stored directly in \ccc{boundary_point1} and \ccc{boundary_point2}, resp. @macro += @begin - Point boundary_point1, boundary_point2; // two boundary points + Point boundary_point1, boundary_point2; // two boundary points @end Given three or five points, the ellipse is represented as a conic, @@ -1262,7 +1263,7 @@ coordinates~\cite{gs-seefe-97a}. Therefore the ellipse is represented implicitly as a linear combination of two conics. @macro += @begin - Conic conic1, conic2; // two conics + Conic conic1, conic2; // two conics @end Finally, in the case of four boundary points, we need the gradient @@ -1270,7 +1271,7 @@ vector of the linear combination for the volume derivative in the in-ellipse test. @macro += @begin - _R::RT dr, ds, dt, du, dv, dw; // the gradient vector + RT dr, ds, dt, du, dv, dw; // the gradient vector @end @! ---------------------------------------------------------------------------- @@ -1290,56 +1291,56 @@ its boundary points. void set( ) { - n_boundary_points = 0; + n_boundary_points = 0; } inline void set( Point const& p) { - n_boundary_points = 1; - boundary_point1 = p; + n_boundary_points = 1; + boundary_point1 = p; } inline void set( Point const& p, Point const& q) { - n_boundary_points = 2; - boundary_point1 = p; - boundary_point2 = q; + n_boundary_points = 2; + boundary_point1 = p; + boundary_point2 = q; } inline void set( Point const& p1, Point const& p2, Point const& p3) { - n_boundary_points = 3; - conic1.set_ellipse( p1, p2, p3); + n_boundary_points = 3; + conic1.set_ellipse( p1, p2, p3); } inline void set( Point const& p1, Point const& p2, Point const& p3, Point const& p4) { - n_boundary_points = 4; - Conic::set_two_linepairs( p1, p2, p3, p4, conic1, conic2); - dr = R::RT( 0); - ds = conic1.r() * conic2.s() - conic2.r() * conic1.s(), - dt = conic1.r() * conic2.t() - conic2.r() * conic1.t(), - du = conic1.r() * conic2.u() - conic2.r() * conic1.u(), - dv = conic1.r() * conic2.v() - conic2.r() * conic1.v(), - dw = conic1.r() * conic2.w() - conic2.r() * conic1.w(); + n_boundary_points = 4; + Conic::set_two_linepairs( p1, p2, p3, p4, conic1, conic2); + dr = RT( 0); + ds = conic1.r() * conic2.s() - conic2.r() * conic1.s(), + dt = conic1.r() * conic2.t() - conic2.r() * conic1.t(), + du = conic1.r() * conic2.u() - conic2.r() * conic1.u(), + dv = conic1.r() * conic2.v() - conic2.r() * conic1.v(), + dw = conic1.r() * conic2.w() - conic2.r() * conic1.w(); } inline void set( Point const&, Point const&, - Point const&, Point const&, Point const& p5) + Point const&, Point const&, Point const& p5) { - n_boundary_points = 5; - conic1.set( conic1, conic2, p5); - conic1.analyse(); + n_boundary_points = 5; + conic1.set( conic1, conic2, p5); + conic1.analyse(); } @end @@ -1351,7 +1352,7 @@ its boundary points. int number_of_boundary_points( ) const { - return( n_boundary_points); + return( n_boundary_points); } @end @@ -1362,39 +1363,39 @@ its boundary points. bool operator == ( CGAL_Optimisation_ellipse_2 const& e) const { - if ( n_boundary_points != e.n_boundary_points) - return( false); + if ( n_boundary_points != e.n_boundary_points) + return( false); - switch ( n_boundary_points) { - case 0: - return( true); - case 1: - return( boundary_point1 == e.boundary_point1); - case 2: - return( ( ( boundary_point1 == e.boundary_point1) - && ( boundary_point2 == e.boundary_point2)) - || ( ( boundary_point1 == e.boundary_point2) - && ( boundary_point2 == e.boundary_point1))); - case 3: - case 5: - return( conic1 == e.conic1); - case 4: - return( ( ( conic1 == e.conic1) - && ( conic2 == e.conic2)) - || ( ( conic1 == e.conic2) - && ( conic2 == e.conic1))); - default: - CGAL_optimisation_assertion( ( n_boundary_points >= 0) - && ( n_boundary_points <= 5)); } - // keeps g++ happy - return( false); + switch ( n_boundary_points) { + case 0: + return( true); + case 1: + return( boundary_point1 == e.boundary_point1); + case 2: + return( ( ( boundary_point1 == e.boundary_point1) + && ( boundary_point2 == e.boundary_point2)) + || ( ( boundary_point1 == e.boundary_point2) + && ( boundary_point2 == e.boundary_point1))); + case 3: + case 5: + return( conic1 == e.conic1); + case 4: + return( ( ( conic1 == e.conic1) + && ( conic2 == e.conic2)) + || ( ( conic1 == e.conic2) + && ( conic2 == e.conic1))); + default: + CGAL_optimisation_assertion( ( n_boundary_points >= 0) + && ( n_boundary_points <= 5)); } + // keeps g++ happy + return( false); } inline bool operator != ( CGAL_Optimisation_ellipse_2 const& e) const { - return( ! operator == ( e)); + return( ! operator == ( e)); } @end @@ -1412,73 +1413,73 @@ one. CGAL_Bounded_side bounded_side( Point const& p) const { - switch ( n_boundary_points) { - case 0: - return( CGAL_ON_UNBOUNDED_SIDE); - case 1: - return( ( p == boundary_point1) ? - CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); - case 2: - return( ( p == boundary_point1) - || ( p == boundary_point2) - || ( CGAL_are_ordered_along_line( - boundary_point1, p, boundary_point2)) ? - CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); - case 3: - case 5: - return( conic1.convex_side( p)); - case 4: { - Conic c; - c.set( conic1, conic2, p); - c.analyse(); - if ( ! c.is_ellipse()) { - c.set_ellipse( conic1, conic2); - c.analyse(); - return( c.convex_side( p)); } - else { - int tau_star = -c.vol_derivative( dr, ds, dt, du, dv, dw); - return( CGAL_static_cast( CGAL_Bounded_side, - CGAL_sign( tau_star))); } } - default: - CGAL_optimisation_assertion( ( n_boundary_points >= 0) && - ( n_boundary_points <= 5) ); } - // keeps g++ happy - return( CGAL_Bounded_side( 0)); + switch ( n_boundary_points) { + case 0: + return( CGAL_ON_UNBOUNDED_SIDE); + case 1: + return( ( p == boundary_point1) ? + CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); + case 2: + return( ( p == boundary_point1) + || ( p == boundary_point2) + || ( CGAL_are_ordered_along_line( + boundary_point1, p, boundary_point2)) ? + CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); + case 3: + case 5: + return( conic1.convex_side( p)); + case 4: { + Conic c; + c.set( conic1, conic2, p); + c.analyse(); + if ( ! c.is_ellipse()) { + c.set_ellipse( conic1, conic2); + c.analyse(); + return( c.convex_side( p)); } + else { + int tau_star = -c.vol_derivative( dr, ds, dt, du, dv, dw); + return( CGAL_static_cast( CGAL_Bounded_side, + CGAL_sign( tau_star))); } } + default: + CGAL_optimisation_assertion( ( n_boundary_points >= 0) && + ( n_boundary_points <= 5) ); } + // keeps g++ happy + return( CGAL_Bounded_side( 0)); } inline bool has_on_bounded_side( Point const& p) const { - return( bounded_side( p) == CGAL_ON_BOUNDED_SIDE); + return( bounded_side( p) == CGAL_ON_BOUNDED_SIDE); } inline bool has_on_boundary( Point const& p) const { - return( bounded_side( p) == CGAL_ON_BOUNDARY); + return( bounded_side( p) == CGAL_ON_BOUNDARY); } inline bool has_on_unbounded_side( Point const& p) const { - return( bounded_side( p) == CGAL_ON_UNBOUNDED_SIDE); + return( bounded_side( p) == CGAL_ON_UNBOUNDED_SIDE); } inline bool is_empty( ) const { - return( n_boundary_points == 0); + return( n_boundary_points == 0); } inline bool is_degenerate( ) const { - return( n_boundary_points < 3); + return( n_boundary_points < 3); } @end @@ -1500,96 +1501,96 @@ one. ostream& operator << ( ostream& os, CGAL_Optimisation_ellipse_2<_R> const& e) { - const char* const empty = ""; - const char* const pretty_head = "CGAL_Optimisation_ellipse_2( "; - const char* const pretty_sep = ", "; - const char* const pretty_tail = ")"; - const char* const ascii_sep = " "; + const char* const empty = ""; + const char* const pretty_head = "CGAL_Optimisation_ellipse_2( "; + const char* const pretty_sep = ", "; + const char* const pretty_tail = ")"; + const char* const ascii_sep = " "; - const char* head = empty; - const char* sep = empty; - const char* tail = empty; + const char* head = empty; + const char* sep = empty; + const char* tail = empty; - switch ( CGAL_get_mode( os)) { - case CGAL_IO::PRETTY: - head = pretty_head; - sep = pretty_sep; - tail = pretty_tail; - break; - case CGAL_IO::ASCII: - sep = ascii_sep; - break; - case CGAL_IO::BINARY: - break; - default: - CGAL_optimisation_assertion_msg( false, - "CGAL_get_mode( os) invalid!"); - break; } + switch ( CGAL_get_mode( os)) { + case CGAL_IO::PRETTY: + head = pretty_head; + sep = pretty_sep; + tail = pretty_tail; + break; + case CGAL_IO::ASCII: + sep = ascii_sep; + break; + case CGAL_IO::BINARY: + break; + default: + CGAL_optimisation_assertion_msg( false, + "CGAL_get_mode( os) invalid!"); + break; } - os << head << e.n_boundary_points; - switch ( e.n_boundary_points) { - case 0: - break; - case 1: - os << sep << e.boundary_point1; - break; - case 2: - os << sep << e.boundary_point1 - << sep << e.boundary_point2; - break; - case 3: - case 5: - os << sep << e.conic1; - break; - case 4: - os << sep << e.conic1 - << sep << e.conic2; - break; } - os << tail; + os << head << e.n_boundary_points; + switch ( e.n_boundary_points) { + case 0: + break; + case 1: + os << sep << e.boundary_point1; + break; + case 2: + os << sep << e.boundary_point1 + << sep << e.boundary_point2; + break; + case 3: + case 5: + os << sep << e.conic1; + break; + case 4: + os << sep << e.conic1 + << sep << e.conic2; + break; } + os << tail; - return( os); + return( os); } template < class _R > istream& operator >> ( istream& is, CGAL_Optimisation_ellipse_2<_R>& e) { - switch ( CGAL_get_mode( is)) { + switch ( CGAL_get_mode( is)) { - case CGAL_IO::PRETTY: - cerr << endl; - cerr << "Stream must be in ascii or binary mode" << endl; - break; + case CGAL_IO::PRETTY: + cerr << endl; + cerr << "Stream must be in ascii or binary mode" << endl; + break; - case CGAL_IO::ASCII: - case CGAL_IO::BINARY: - CGAL_read( is, e.n_boundary_points); - switch ( e.n_boundary_points) { - case 0: - break; - case 1: - is >> e.boundary_point1; - break; - case 2: - is >> e.boundary_point1 - >> e.boundary_point2; - break; - case 3: - case 5: - is >> e.conic1; - break; - case 4: - is >> e.conic1 - >> e.conic2; - break; } - break; + case CGAL_IO::ASCII: + case CGAL_IO::BINARY: + CGAL_read( is, e.n_boundary_points); + switch ( e.n_boundary_points) { + case 0: + break; + case 1: + is >> e.boundary_point1; + break; + case 2: + is >> e.boundary_point1 + >> e.boundary_point2; + break; + case 3: + case 5: + is >> e.conic1; + break; + case 4: + is >> e.conic1 + >> e.conic2; + break; } + break; - default: - CGAL_optimisation_assertion_msg( false, - "CGAL_get_mode( is) invalid!"); - break; } + default: + CGAL_optimisation_assertion_msg( false, + "CGAL_get_mode( is) invalid!"); + break; } - return( is); + return( is); } @end @@ -1665,7 +1666,7 @@ it is declared \ccc{friend}. CGAL_Orientation orientation( Point const& p, Point const& q, Point const& r) const { - typedef _DA::FT FT; + typedef typename _DA::FT FT; FT px; FT py; @@ -1694,15 +1695,15 @@ it is declared \ccc{friend}. typedef _PT PT; typedef _DA DA; - typedef CGAL_ConicCPA2< PT, DA> CT; - typedef _DA::FT FT; + typedef CGAL_ConicCPA2< PT, DA> CT; + typedef typename _DA::FT FT; private: // data members - int n_boundary_points; // number of boundary points - PT boundary_point1, boundary_point2; // two boundary points - CT conic1, conic2; // two conics - FT dr, ds, dt, du, dv, dw; // the gradient vector + int n_boundary_points; // number of boundary points + PT boundary_point1, boundary_point2; // two boundary points + CT conic1, conic2; // two conics + FT dr, ds, dt, du, dv, dw; // the gradient vector public: // types @@ -1710,114 +1711,114 @@ it is declared \ccc{friend}. // creation CGAL__Min_ellipse_2_adapterC2__Ellipse( DA const& da) - : conic1( da), conic2( da) - { } + : conic1( da), conic2( da) + { } - void - set( ) - { - n_boundary_points = 0; - } + void + set( ) + { + n_boundary_points = 0; + } - void - set( Point const& p) - { - n_boundary_points = 1; - boundary_point1 = p; - } + void + set( Point const& p) + { + n_boundary_points = 1; + boundary_point1 = p; + } - void - set( Point const& p, Point const& q) - { - n_boundary_points = 2; - boundary_point1 = p; - boundary_point2 = q; - } + void + set( Point const& p, Point const& q) + { + n_boundary_points = 2; + boundary_point1 = p; + boundary_point2 = q; + } - void - set( Point const& p1, Point const& p2, Point const& p3) - { - n_boundary_points = 3; - conic1.set_ellipse( p1, p2, p3); - } + void + set( Point const& p1, Point const& p2, Point const& p3) + { + n_boundary_points = 3; + conic1.set_ellipse( p1, p2, p3); + } - void - set( Point const& p1, Point const& p2, - Point const& p3, Point const& p4) - { - n_boundary_points = 4; - CT::set_two_linepairs( p1, p2, p3, p4, conic1, conic2); - dr = FT( 0); - ds = conic1.r() * conic2.s() - conic2.r() * conic1.s(), - dt = conic1.r() * conic2.t() - conic2.r() * conic1.t(), - du = conic1.r() * conic2.u() - conic2.r() * conic1.u(), - dv = conic1.r() * conic2.v() - conic2.r() * conic1.v(), - dw = conic1.r() * conic2.w() - conic2.r() * conic1.w(); - } + void + set( Point const& p1, Point const& p2, + Point const& p3, Point const& p4) + { + n_boundary_points = 4; + CT::set_two_linepairs( p1, p2, p3, p4, conic1, conic2); + dr = FT( 0); + ds = conic1.r() * conic2.s() - conic2.r() * conic1.s(), + dt = conic1.r() * conic2.t() - conic2.r() * conic1.t(), + du = conic1.r() * conic2.u() - conic2.r() * conic1.u(), + dv = conic1.r() * conic2.v() - conic2.r() * conic1.v(), + dw = conic1.r() * conic2.w() - conic2.r() * conic1.w(); + } - void - set( Point const&, Point const&, - Point const&, Point const&, Point const& p5) - { - n_boundary_points = 5; - conic1.set( conic1, conic2, p5); - conic1.analyse(); - } + void + set( Point const&, Point const&, + Point const&, Point const&, Point const& p5) + { + n_boundary_points = 5; + conic1.set( conic1, conic2, p5); + conic1.analyse(); + } // predicates CGAL_Bounded_side bounded_side( Point const& p) const { - switch ( n_boundary_points) { - case 0: - return( CGAL_ON_UNBOUNDED_SIDE); - case 1: - return( ( p == boundary_point1) ? - CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); - case 2: - return( ( p == boundary_point1) - || ( p == boundary_point2) - || ( CGAL_are_ordered_along_lineC2( boundary_point1, p, - boundary_point2, conic1.da())) ? - CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); - case 3: - case 5: - return( conic1.convex_side( p)); - case 4: { - CT c( conic1.da()); - c.set( conic1, conic2, p); - c.analyse(); - if ( ! c.is_ellipse()) { - c.set_ellipse( conic1, conic2); - c.analyse(); - return( c.convex_side( p)); } - else { - int tau_star = -c.vol_derivative( dr, ds, dt, du, dv, dw); - return( CGAL_static_cast( CGAL_Bounded_side, - CGAL_sign( tau_star))); } } - default: - CGAL_optimisation_assertion( ( n_boundary_points >= 0) && - ( n_boundary_points <= 5) ); } - // keeps g++ happy - return( CGAL_Bounded_side( 0)); + switch ( n_boundary_points) { + case 0: + return( CGAL_ON_UNBOUNDED_SIDE); + case 1: + return( ( p == boundary_point1) ? + CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); + case 2: + return( ( p == boundary_point1) + || ( p == boundary_point2) + || ( CGAL_are_ordered_along_lineC2( boundary_point1, p, + boundary_point2, conic1.da())) ? + CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); + case 3: + case 5: + return( conic1.convex_side( p)); + case 4: { + CT c( conic1.da()); + c.set( conic1, conic2, p); + c.analyse(); + if ( ! c.is_ellipse()) { + c.set_ellipse( conic1, conic2); + c.analyse(); + return( c.convex_side( p)); } + else { + int tau_star = -c.vol_derivative( dr, ds, dt, du, dv, dw); + return( CGAL_static_cast( CGAL_Bounded_side, + CGAL_sign( tau_star))); } } + default: + CGAL_optimisation_assertion( ( n_boundary_points >= 0) && + ( n_boundary_points <= 5) ); } + // keeps g++ happy + return( CGAL_Bounded_side( 0)); } bool has_on_bounded_side( Point const& p) const { - return( bounded_side( p) == CGAL_ON_BOUNDED_SIDE); + return( bounded_side( p) == CGAL_ON_BOUNDED_SIDE); } bool has_on_boundary( Point const& p) const { - return( bounded_side( p) == CGAL_ON_BOUNDARY); + return( bounded_side( p) == CGAL_ON_BOUNDARY); } bool has_on_unbounded_side( Point const& p) const { - return( bounded_side( p) == CGAL_ON_UNBOUNDED_SIDE); + return( bounded_side( p) == CGAL_ON_UNBOUNDED_SIDE); } bool @@ -1837,32 +1838,32 @@ it is declared \ccc{friend}. operator == ( CGAL__Min_ellipse_2_adapterC2__Ellipse<_PT,_DA> const& e) const { - if ( n_boundary_points != e.n_boundary_points) - return( false); + if ( n_boundary_points != e.n_boundary_points) + return( false); - switch ( n_boundary_points) { - case 0: - return( true); - case 1: - return( boundary_point1 == e.boundary_point1); - case 2: - return( ( ( boundary_point1 == e.boundary_point1) - && ( boundary_point2 == e.boundary_point2)) - || ( ( boundary_point1 == e.boundary_point2) - && ( boundary_point2 == e.boundary_point1))); - case 3: - case 5: - return( conic1 == e.conic1); - case 4: - return( ( ( conic1 == e.conic1) - && ( conic2 == e.conic2)) - || ( ( conic1 == e.conic2) - && ( conic2 == e.conic1))); - default: - CGAL_optimisation_assertion( ( n_boundary_points >= 0) - && ( n_boundary_points <= 5)); } - // keeps g++ happy - return( false); + switch ( n_boundary_points) { + case 0: + return( true); + case 1: + return( boundary_point1 == e.boundary_point1); + case 2: + return( ( ( boundary_point1 == e.boundary_point1) + && ( boundary_point2 == e.boundary_point2)) + || ( ( boundary_point1 == e.boundary_point2) + && ( boundary_point2 == e.boundary_point1))); + case 3: + case 5: + return( conic1 == e.conic1); + case 4: + return( ( ( conic1 == e.conic1) + && ( conic2 == e.conic2)) + || ( ( conic1 == e.conic2) + && ( conic2 == e.conic1))); + default: + CGAL_optimisation_assertion( ( n_boundary_points >= 0) + && ( n_boundary_points <= 5)); } + // keeps g++ happy + return( false); } // I/O @@ -1871,55 +1872,55 @@ it is declared \ccc{friend}. operator << ( ostream& os, CGAL__Min_ellipse_2_adapterC2__Ellipse<_PT,_DA> const& e) { - const char* const empty = ""; - const char* const pretty_head = - "CGAL_Min_ellipse_2_adapterC2::Ellipse( "; - const char* const pretty_sep = ", "; - const char* const pretty_tail = ")"; - const char* const ascii_sep = " "; + const char* const empty = ""; + const char* const pretty_head = + "CGAL_Min_ellipse_2_adapterC2::Ellipse( "; + const char* const pretty_sep = ", "; + const char* const pretty_tail = ")"; + const char* const ascii_sep = " "; - const char* head = empty; - const char* sep = empty; - const char* tail = empty; + const char* head = empty; + const char* sep = empty; + const char* tail = empty; - switch ( CGAL_get_mode( os)) { - case CGAL_IO::PRETTY: - head = pretty_head; - sep = pretty_sep; - tail = pretty_tail; - break; - case CGAL_IO::ASCII: - sep = ascii_sep; - break; - case CGAL_IO::BINARY: - break; - default: - CGAL_optimisation_assertion_msg( false, - "CGAL_get_mode( os) invalid!"); - break; } + switch ( CGAL_get_mode( os)) { + case CGAL_IO::PRETTY: + head = pretty_head; + sep = pretty_sep; + tail = pretty_tail; + break; + case CGAL_IO::ASCII: + sep = ascii_sep; + break; + case CGAL_IO::BINARY: + break; + default: + CGAL_optimisation_assertion_msg( false, + "CGAL_get_mode( os) invalid!"); + break; } - os << head << e.n_boundary_points; - switch ( e.n_boundary_points) { - case 0: - break; - case 1: - os << sep << e.boundary_point1; - break; - case 2: - os << sep << e.boundary_point1 - << sep << e.boundary_point2; - break; - case 3: - case 5: - os << sep << e.conic1; - break; - case 4: - os << sep << e.conic1 - << sep << e.conic2; - break; } - os << tail; + os << head << e.n_boundary_points; + switch ( e.n_boundary_points) { + case 0: + break; + case 1: + os << sep << e.boundary_point1; + break; + case 2: + os << sep << e.boundary_point1 + << sep << e.boundary_point2; + break; + case 3: + case 5: + os << sep << e.conic1; + break; + case 4: + os << sep << e.conic1 + << sep << e.conic2; + break; } + os << tail; - return( os); + return( os); } friend @@ -1936,25 +1937,25 @@ it is declared \ccc{friend}. case CGAL_IO::ASCII: case CGAL_IO::BINARY: - CGAL_read( is, e.n_boundary_points); - switch ( e.n_boundary_points) { - case 0: - break; - case 1: - is >> e.boundary_point1; - break; - case 2: - is >> e.boundary_point1 - >> e.boundary_point2; - break; - case 3: - case 5: - is >> e.conic1; - break; - case 4: - is >> e.conic1 - >> e.conic2; - break; } + CGAL_read( is, e.n_boundary_points); + switch ( e.n_boundary_points) { + case 0: + break; + case 1: + is >> e.boundary_point1; + break; + case 2: + is >> e.boundary_point1 + >> e.boundary_point2; + break; + case 3: + case 5: + is >> e.conic1; + break; + case 4: + is >> e.conic1 + >> e.conic2; + break; } break; default: @@ -2006,7 +2007,7 @@ it is declared \ccc{friend}. typedef _DA DA; // nested types - typedef PT Point; + typedef PT Point; typedef CGAL__Min_ellipse_2_adapterH2__Ellipse Ellipse; private: @@ -2039,7 +2040,7 @@ it is declared \ccc{friend}. CGAL_Orientation orientation( Point const& p, Point const& q, Point const& r) const { - typedef _DA::RT RT; + typedef typename _DA::RT RT; RT phx; RT phy; @@ -2072,15 +2073,15 @@ it is declared \ccc{friend}. typedef _PT PT; typedef _DA DA; - typedef CGAL_ConicHPA2< PT, DA> CT; - typedef _DA::RT RT; + typedef CGAL_ConicHPA2< PT, DA> CT; + typedef typename _DA::RT RT; private: // data members - int n_boundary_points; // number of boundary points - PT boundary_point1, boundary_point2; // two boundary points - CT conic1, conic2; // two conics - RT dr, ds, dt, du, dv, dw; // the gradient vector + int n_boundary_points; // number of boundary points + PT boundary_point1, boundary_point2; // two boundary points + CT conic1, conic2; // two conics + RT dr, ds, dt, du, dv, dw; // the gradient vector public: // types @@ -2088,114 +2089,114 @@ it is declared \ccc{friend}. // creation CGAL__Min_ellipse_2_adapterH2__Ellipse( DA const& da) - : conic1( da), conic2( da) - { } + : conic1( da), conic2( da) + { } - void - set( ) - { - n_boundary_points = 0; - } + void + set( ) + { + n_boundary_points = 0; + } - void - set( Point const& p) - { - n_boundary_points = 1; - boundary_point1 = p; - } + void + set( Point const& p) + { + n_boundary_points = 1; + boundary_point1 = p; + } - void - set( Point const& p, Point const& q) - { - n_boundary_points = 2; - boundary_point1 = p; - boundary_point2 = q; - } + void + set( Point const& p, Point const& q) + { + n_boundary_points = 2; + boundary_point1 = p; + boundary_point2 = q; + } - void - set( Point const& p1, Point const& p2, Point const& p3) - { - n_boundary_points = 3; - conic1.set_ellipse( p1, p2, p3); - } + void + set( Point const& p1, Point const& p2, Point const& p3) + { + n_boundary_points = 3; + conic1.set_ellipse( p1, p2, p3); + } - void - set( Point const& p1, Point const& p2, - Point const& p3, Point const& p4) - { - n_boundary_points = 4; - CT::set_two_linepairs( p1, p2, p3, p4, conic1, conic2); - dr = RT( 0); - ds = conic1.r() * conic2.s() - conic2.r() * conic1.s(), - dt = conic1.r() * conic2.t() - conic2.r() * conic1.t(), - du = conic1.r() * conic2.u() - conic2.r() * conic1.u(), - dv = conic1.r() * conic2.v() - conic2.r() * conic1.v(), - dw = conic1.r() * conic2.w() - conic2.r() * conic1.w(); - } + void + set( Point const& p1, Point const& p2, + Point const& p3, Point const& p4) + { + n_boundary_points = 4; + CT::set_two_linepairs( p1, p2, p3, p4, conic1, conic2); + dr = RT( 0); + ds = conic1.r() * conic2.s() - conic2.r() * conic1.s(), + dt = conic1.r() * conic2.t() - conic2.r() * conic1.t(), + du = conic1.r() * conic2.u() - conic2.r() * conic1.u(), + dv = conic1.r() * conic2.v() - conic2.r() * conic1.v(), + dw = conic1.r() * conic2.w() - conic2.r() * conic1.w(); + } - void - set( Point const&, Point const&, - Point const&, Point const&, Point const& p5) - { - n_boundary_points = 5; - conic1.set( conic1, conic2, p5); - conic1.analyse(); - } + void + set( Point const&, Point const&, + Point const&, Point const&, Point const& p5) + { + n_boundary_points = 5; + conic1.set( conic1, conic2, p5); + conic1.analyse(); + } // predicates CGAL_Bounded_side bounded_side( Point const& p) const { - switch ( n_boundary_points) { - case 0: - return( CGAL_ON_UNBOUNDED_SIDE); - case 1: - return( ( p == boundary_point1) ? - CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); - case 2: - return( ( p == boundary_point1) - || ( p == boundary_point2) - || ( CGAL_are_ordered_along_lineH2( boundary_point1, p, - boundary_point2, conic1.da())) ? - CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); - case 3: - case 5: - return( conic1.convex_side( p)); - case 4: { - CT c( conic1.da()); - c.set( conic1, conic2, p); - c.analyse(); - if ( ! c.is_ellipse()) { - c.set_ellipse( conic1, conic2); - c.analyse(); - return( c.convex_side( p)); } - else { - int tau_star = -c.vol_derivative( dr, ds, dt, du, dv, dw); - return( CGAL_static_cast( CGAL_Bounded_side, - CGAL_sign( tau_star))); } } - default: - CGAL_optimisation_assertion( ( n_boundary_points >= 0) && - ( n_boundary_points <= 5) ); } - // keeps g++ happy - return( CGAL_Bounded_side( 0)); + switch ( n_boundary_points) { + case 0: + return( CGAL_ON_UNBOUNDED_SIDE); + case 1: + return( ( p == boundary_point1) ? + CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); + case 2: + return( ( p == boundary_point1) + || ( p == boundary_point2) + || ( CGAL_are_ordered_along_lineH2( boundary_point1, p, + boundary_point2, conic1.da())) ? + CGAL_ON_BOUNDARY : CGAL_ON_UNBOUNDED_SIDE); + case 3: + case 5: + return( conic1.convex_side( p)); + case 4: { + CT c( conic1.da()); + c.set( conic1, conic2, p); + c.analyse(); + if ( ! c.is_ellipse()) { + c.set_ellipse( conic1, conic2); + c.analyse(); + return( c.convex_side( p)); } + else { + int tau_star = -c.vol_derivative( dr, ds, dt, du, dv, dw); + return( CGAL_static_cast( CGAL_Bounded_side, + CGAL_sign( tau_star))); } } + default: + CGAL_optimisation_assertion( ( n_boundary_points >= 0) && + ( n_boundary_points <= 5) ); } + // keeps g++ happy + return( CGAL_Bounded_side( 0)); } bool has_on_bounded_side( Point const& p) const { - return( bounded_side( p) == CGAL_ON_BOUNDED_SIDE); + return( bounded_side( p) == CGAL_ON_BOUNDED_SIDE); } bool has_on_boundary( Point const& p) const { - return( bounded_side( p) == CGAL_ON_BOUNDARY); + return( bounded_side( p) == CGAL_ON_BOUNDARY); } bool has_on_unbounded_side( Point const& p) const { - return( bounded_side( p) == CGAL_ON_UNBOUNDED_SIDE); + return( bounded_side( p) == CGAL_ON_UNBOUNDED_SIDE); } bool @@ -2215,32 +2216,32 @@ it is declared \ccc{friend}. operator == ( CGAL__Min_ellipse_2_adapterH2__Ellipse<_PT,_DA> const& e) const { - if ( n_boundary_points != e.n_boundary_points) - return( false); + if ( n_boundary_points != e.n_boundary_points) + return( false); - switch ( n_boundary_points) { - case 0: - return( true); - case 1: - return( boundary_point1 == e.boundary_point1); - case 2: - return( ( ( boundary_point1 == e.boundary_point1) - && ( boundary_point2 == e.boundary_point2)) - || ( ( boundary_point1 == e.boundary_point2) - && ( boundary_point2 == e.boundary_point1))); - case 3: - case 5: - return( conic1 == e.conic1); - case 4: - return( ( ( conic1 == e.conic1) - && ( conic2 == e.conic2)) - || ( ( conic1 == e.conic2) - && ( conic2 == e.conic1))); - default: - CGAL_optimisation_assertion( ( n_boundary_points >= 0) - && ( n_boundary_points <= 5)); } - // keeps g++ happy - return( false); + switch ( n_boundary_points) { + case 0: + return( true); + case 1: + return( boundary_point1 == e.boundary_point1); + case 2: + return( ( ( boundary_point1 == e.boundary_point1) + && ( boundary_point2 == e.boundary_point2)) + || ( ( boundary_point1 == e.boundary_point2) + && ( boundary_point2 == e.boundary_point1))); + case 3: + case 5: + return( conic1 == e.conic1); + case 4: + return( ( ( conic1 == e.conic1) + && ( conic2 == e.conic2)) + || ( ( conic1 == e.conic2) + && ( conic2 == e.conic1))); + default: + CGAL_optimisation_assertion( ( n_boundary_points >= 0) + && ( n_boundary_points <= 5)); } + // keeps g++ happy + return( false); } // I/O @@ -2249,55 +2250,55 @@ it is declared \ccc{friend}. operator << ( ostream& os, CGAL__Min_ellipse_2_adapterH2__Ellipse<_PT,_DA> const& e) { - const char* const empty = ""; - const char* const pretty_head = - "CGAL_Min_ellipse_2_adapterH2::Ellipse( "; - const char* const pretty_sep = ", "; - const char* const pretty_tail = ")"; - const char* const ascii_sep = " "; + const char* const empty = ""; + const char* const pretty_head = + "CGAL_Min_ellipse_2_adapterH2::Ellipse( "; + const char* const pretty_sep = ", "; + const char* const pretty_tail = ")"; + const char* const ascii_sep = " "; - const char* head = empty; - const char* sep = empty; - const char* tail = empty; + const char* head = empty; + const char* sep = empty; + const char* tail = empty; - switch ( CGAL_get_mode( os)) { - case CGAL_IO::PRETTY: - head = pretty_head; - sep = pretty_sep; - tail = pretty_tail; - break; - case CGAL_IO::ASCII: - sep = ascii_sep; - break; - case CGAL_IO::BINARY: - break; - default: - CGAL_optimisation_assertion_msg( false, - "CGAL_get_mode( os) invalid!"); - break; } + switch ( CGAL_get_mode( os)) { + case CGAL_IO::PRETTY: + head = pretty_head; + sep = pretty_sep; + tail = pretty_tail; + break; + case CGAL_IO::ASCII: + sep = ascii_sep; + break; + case CGAL_IO::BINARY: + break; + default: + CGAL_optimisation_assertion_msg( false, + "CGAL_get_mode( os) invalid!"); + break; } - os << head << e.n_boundary_points; - switch ( e.n_boundary_points) { - case 0: - break; - case 1: - os << sep << e.boundary_point1; - break; - case 2: - os << sep << e.boundary_point1 - << sep << e.boundary_point2; - break; - case 3: - case 5: - os << sep << e.conic1; - break; - case 4: - os << sep << e.conic1 - << sep << e.conic2; - break; } - os << tail; + os << head << e.n_boundary_points; + switch ( e.n_boundary_points) { + case 0: + break; + case 1: + os << sep << e.boundary_point1; + break; + case 2: + os << sep << e.boundary_point1 + << sep << e.boundary_point2; + break; + case 3: + case 5: + os << sep << e.conic1; + break; + case 4: + os << sep << e.conic1 + << sep << e.conic2; + break; } + os << tail; - return( os); + return( os); } friend @@ -2314,25 +2315,25 @@ it is declared \ccc{friend}. case CGAL_IO::ASCII: case CGAL_IO::BINARY: - CGAL_read( is, e.n_boundary_points); - switch ( e.n_boundary_points) { - case 0: - break; - case 1: - is >> e.boundary_point1; - break; - case 2: - is >> e.boundary_point1 - >> e.boundary_point2; - break; - case 3: - case 5: - is >> e.conic1; - break; - case 4: - is >> e.conic1 - >> e.conic2; - break; } + CGAL_read( is, e.n_boundary_points); + switch ( e.n_boundary_points) { + case 0: + break; + case 1: + is >> e.boundary_point1; + break; + case 2: + is >> e.boundary_point1 + >> e.boundary_point2; + break; + case 3: + case 5: + is >> e.conic1; + break; + case 4: + is >> e.conic1 + >> e.conic2; + break; } break; default: @@ -2372,18 +2373,18 @@ number type \ccc{CGAL_Gmpz} or \ccc{integer}. #ifdef CGAL_USE_LEDA # include - typedef leda_integer Rt; - typedef CGAL_Quotient< leda_integer > Ft; + typedef leda_integer Rt; + typedef CGAL_Quotient< leda_integer > Ft; #else # include - typedef CGAL_Gmpz Rt; - typedef CGAL_Quotient< CGAL_Gmpz > Ft; + typedef CGAL_Gmpz Rt; + typedef CGAL_Quotient< CGAL_Gmpz > Ft; #endif - typedef CGAL_Cartesian< Ft > RepC; - typedef CGAL_Homogeneous< Rt > RepH; - typedef CGAL_Optimisation_traits_2< RepC > TraitsC; - typedef CGAL_Optimisation_traits_2< RepH > TraitsH; + typedef CGAL_Cartesian< Ft > RepC; + typedef CGAL_Homogeneous< Rt > RepH; + typedef CGAL_Optimisation_traits_2< RepC > TraitsC; + typedef CGAL_Optimisation_traits_2< RepH > TraitsH; @end The command line option \ccc{-verbose} enables verbose output. @@ -2392,8 +2393,8 @@ The command line option \ccc{-verbose} enables verbose output. bool verbose = false; if ( ( argc > 1) && ( strcmp( argv[ 1], "-verbose") == 0)) { verbose = true; - --argc; - ++argv; } + --argc; + ++argv; } @end @! ---------------------------------------------------------------------------- @@ -2415,222 +2416,222 @@ once to ensure code coverage. void cover_Min_ellipse_2( bool verbose, Traits const&, RT const&) { - typedef CGAL_Min_ellipse_2< Traits > Min_ellipse; - typedef Min_ellipse::Point Point; - typedef Min_ellipse::Ellipse Ellipse; + typedef CGAL_Min_ellipse_2< Traits > Min_ellipse; + typedef Min_ellipse::Point Point; + typedef Min_ellipse::Ellipse Ellipse; - CGAL_Verbose_ostream verr( verbose); + CGAL_Verbose_ostream verr( verbose); - // generate `n' points at random - const int n = 20; - CGAL_Random random_x, random_y; - Point random_points[ n]; - int i; - verr << n << " random points from [0,128)^2:" << endl; - for ( i = 0; i < n; ++i) - random_points[ i] = Point( RT( random_x( 128)), - RT( random_y( 128))); - if ( verbose) - for ( i = 0; i < n; ++i) - cerr << i << ": " << random_points[ i] << endl; + // generate `n' points at random + const int n = 20; + CGAL_Random random_x, random_y; + Point random_points[ n]; + int i; + verr << n << " random points from [0,128)^2:" << endl; + for ( i = 0; i < n; ++i) + random_points[ i] = Point( RT( random_x( 128)), + RT( random_y( 128))); + if ( verbose) + for ( i = 0; i < n; ++i) + cerr << i << ": " << random_points[ i] << endl; - // cover code - verr << endl << "default constructor..."; - { - Min_ellipse me; - bool is_valid = me.is_valid( verbose); - bool is_empty = me.is_empty(); - assert( is_valid); - assert( is_empty); - } + // cover code + verr << endl << "default constructor..."; + { + Min_ellipse me; + bool is_valid = me.is_valid( verbose); + bool is_empty = me.is_empty(); + assert( is_valid); + assert( is_empty); + } - verr << endl << "one point constructor..."; - { - Min_ellipse me( random_points[ 0]); - bool is_valid = me.is_valid( verbose); - bool is_degenerate = me.is_degenerate(); - assert( is_valid); - assert( is_degenerate); - } + verr << endl << "one point constructor..."; + { + Min_ellipse me( random_points[ 0]); + bool is_valid = me.is_valid( verbose); + bool is_degenerate = me.is_degenerate(); + assert( is_valid); + assert( is_degenerate); + } - verr << endl << "two points constructor..."; - { - Min_ellipse me( random_points[ 1], - random_points[ 2]); - bool is_valid = me.is_valid( verbose); - assert( is_valid); - assert( me.number_of_points() == 2); - } + verr << endl << "two points constructor..."; + { + Min_ellipse me( random_points[ 1], + random_points[ 2]); + bool is_valid = me.is_valid( verbose); + assert( is_valid); + assert( me.number_of_points() == 2); + } - verr << endl << "three points constructor..."; - { - Min_ellipse me( random_points[ 3], - random_points[ 4], - random_points[ 5]); - bool is_valid = me.is_valid( verbose); - assert( is_valid); - assert( me.number_of_points() == 3); - } + verr << endl << "three points constructor..."; + { + Min_ellipse me( random_points[ 3], + random_points[ 4], + random_points[ 5]); + bool is_valid = me.is_valid( verbose); + assert( is_valid); + assert( me.number_of_points() == 3); + } - verr << endl << "four points constructor..."; - { - Min_ellipse me( random_points[ 6], - random_points[ 7], - random_points[ 8], - random_points[ 9]); - bool is_valid = me.is_valid( verbose); - assert( is_valid); - assert( me.number_of_points() == 4); - } + verr << endl << "four points constructor..."; + { + Min_ellipse me( random_points[ 6], + random_points[ 7], + random_points[ 8], + random_points[ 9]); + bool is_valid = me.is_valid( verbose); + assert( is_valid); + assert( me.number_of_points() == 4); + } - verr << endl << "five points constructor..."; - { - Min_ellipse me( random_points[ 10], - random_points[ 11], - random_points[ 12], - random_points[ 13], - random_points[ 14]); - bool is_valid = me.is_valid( verbose); - assert( is_valid); - assert( me.number_of_points() == 5); - } + verr << endl << "five points constructor..."; + { + Min_ellipse me( random_points[ 10], + random_points[ 11], + random_points[ 12], + random_points[ 13], + random_points[ 14]); + bool is_valid = me.is_valid( verbose); + assert( is_valid); + assert( me.number_of_points() == 5); + } - verr << endl << "Point* constructor..."; - Min_ellipse me( random_points, random_points+9); - { - Min_ellipse me2( random_points, random_points+9, true); - bool is_valid = me .is_valid( verbose); - bool is_valid2 = me2.is_valid( verbose); - assert( is_valid); - assert( is_valid2); - assert( me .number_of_points() == 9); - assert( me2.number_of_points() == 9); - assert( me.ellipse() == me2.ellipse()); - } + verr << endl << "Point* constructor..."; + Min_ellipse me( random_points, random_points+9); + { + Min_ellipse me2( random_points, random_points+9, true); + bool is_valid = me .is_valid( verbose); + bool is_valid2 = me2.is_valid( verbose); + assert( is_valid); + assert( is_valid2); + assert( me .number_of_points() == 9); + assert( me2.number_of_points() == 9); + assert( me.ellipse() == me2.ellipse()); + } - verr << endl << "list::const_iterator constructor..."; - { - Min_ellipse me1( me.points_begin(), me.points_end()); - Min_ellipse me2( me.points_begin(), me.points_end(), true); - bool is_valid1 = me1.is_valid( verbose); - bool is_valid2 = me2.is_valid( verbose); - assert( is_valid1); - assert( is_valid2); - assert( me1.number_of_points() == 9); - assert( me2.number_of_points() == 9); - assert( me.ellipse() == me1.ellipse()); - assert( me.ellipse() == me2.ellipse()); - } + verr << endl << "list::const_iterator constructor..."; + { + Min_ellipse me1( me.points_begin(), me.points_end()); + Min_ellipse me2( me.points_begin(), me.points_end(), true); + bool is_valid1 = me1.is_valid( verbose); + bool is_valid2 = me2.is_valid( verbose); + assert( is_valid1); + assert( is_valid2); + assert( me1.number_of_points() == 9); + assert( me2.number_of_points() == 9); + assert( me.ellipse() == me1.ellipse()); + assert( me.ellipse() == me2.ellipse()); + } - verr << endl << "#points already called above."; + verr << endl << "#points already called above."; - verr << endl << "points access already called above."; + verr << endl << "points access already called above."; - verr << endl << "support points access..."; - { - Point support_point; - Min_ellipse::Support_point_iterator - iter( me.support_points_begin()); + verr << endl << "support points access..."; + { + Point support_point; + Min_ellipse::Support_point_iterator + iter( me.support_points_begin()); for ( i = 0; i < me.number_of_support_points(); ++i, ++iter) { - support_point = me.support_point( i); - assert( support_point == *iter); } - Min_ellipse::Support_point_iterator - end_iter( me.support_points_end()); - assert( iter == end_iter); - } + support_point = me.support_point( i); + assert( support_point == *iter); } + Min_ellipse::Support_point_iterator + end_iter( me.support_points_end()); + assert( iter == end_iter); + } - verr << endl << "ellipse access already called above..."; + verr << endl << "ellipse access already called above..."; - verr << endl << "in-ellipse predicates..."; - { - Point p; - CGAL_Bounded_side bounded_side; - bool has_on_bounded_side; - bool has_on_boundary; - bool has_on_unbounded_side; - for ( i = 0; i < 9; ++i) { - p = random_points[ i]; - bounded_side = me.bounded_side( p); - has_on_bounded_side = me.has_on_bounded_side( p); - has_on_boundary = me.has_on_boundary( p); - has_on_unbounded_side = me.has_on_unbounded_side( p); - assert( bounded_side != CGAL_ON_UNBOUNDED_SIDE); - assert( has_on_bounded_side || has_on_boundary); - assert( ! has_on_unbounded_side); } - } + verr << endl << "in-ellipse predicates..."; + { + Point p; + CGAL_Bounded_side bounded_side; + bool has_on_bounded_side; + bool has_on_boundary; + bool has_on_unbounded_side; + for ( i = 0; i < 9; ++i) { + p = random_points[ i]; + bounded_side = me.bounded_side( p); + has_on_bounded_side = me.has_on_bounded_side( p); + has_on_boundary = me.has_on_boundary( p); + has_on_unbounded_side = me.has_on_unbounded_side( p); + assert( bounded_side != CGAL_ON_UNBOUNDED_SIDE); + assert( has_on_bounded_side || has_on_boundary); + assert( ! has_on_unbounded_side); } + } - verr << endl << "is_... predicates already called above."; + verr << endl << "is_... predicates already called above."; - verr << endl << "single point insert..."; - me.insert( random_points[ 9]); - { - bool is_valid = me.is_valid( verbose); - assert( is_valid); - assert( me.number_of_points() == 10); - } + verr << endl << "single point insert..."; + me.insert( random_points[ 9]); + { + bool is_valid = me.is_valid( verbose); + assert( is_valid); + assert( me.number_of_points() == 10); + } - verr << endl << "Point* insert..."; - me.insert( random_points+10, random_points+n); - { - bool is_valid = me.is_valid( verbose); - assert( is_valid); - assert( me.number_of_points() == n); - } + verr << endl << "Point* insert..."; + me.insert( random_points+10, random_points+n); + { + bool is_valid = me.is_valid( verbose); + assert( is_valid); + assert( me.number_of_points() == n); + } - verr << endl << "list::const_iterator insert..."; - { - Min_ellipse me2; - me2.insert( me.points_begin(), me.points_end()); - bool is_valid = me2.is_valid( verbose); - assert( is_valid); - assert( me2.number_of_points() == n); - - verr << endl << "clear..."; - me2.clear(); - is_valid = me2.is_valid( verbose); - bool is_empty = me2.is_empty(); - assert( is_valid); - assert( is_empty); - } + verr << endl << "list::const_iterator insert..."; + { + Min_ellipse me2; + me2.insert( me.points_begin(), me.points_end()); + bool is_valid = me2.is_valid( verbose); + assert( is_valid); + assert( me2.number_of_points() == n); + + verr << endl << "clear..."; + me2.clear(); + is_valid = me2.is_valid( verbose); + bool is_empty = me2.is_empty(); + assert( is_valid); + assert( is_empty); + } - verr << endl << "validity check already called several times."; + verr << endl << "validity check already called several times."; - verr << endl << "traits class access..."; - { - Traits traits( me.traits()); - } + verr << endl << "traits class access..."; + { + Traits traits( me.traits()); + } - verr << endl << "I/O..."; - { - verr << endl << " writing `test_Min_ellipse_2.ascii'..."; - ofstream os( "test_Min_ellipse_2.ascii"); - CGAL_set_ascii_mode( os); - os << me; - } - { - verr << endl << " writing `test_Min_ellipse_2.pretty'..."; - ofstream os( "test_Min_ellipse_2.pretty"); - CGAL_set_pretty_mode( os); - os << me; - } - { - verr << endl << " writing `test_Min_ellipse_2.binary'..."; - ofstream os( "test_Min_ellipse_2.binary"); - CGAL_set_binary_mode( os); - os << me; - } - { - verr << endl << " reading `test_Min_ellipse_2.ascii'..."; - Min_ellipse me_in; - ifstream is( "test_Min_ellipse_2.ascii"); - CGAL_set_ascii_mode( is); - is >> me_in; - bool is_valid = me_in.is_valid( verbose); - assert( is_valid); - assert( me_in.number_of_points() == n); - assert( me_in.ellipse() == me.ellipse()); - } - verr << endl; + verr << endl << "I/O..."; + { + verr << endl << " writing `test_Min_ellipse_2.ascii'..."; + ofstream os( "test_Min_ellipse_2.ascii"); + CGAL_set_ascii_mode( os); + os << me; + } + { + verr << endl << " writing `test_Min_ellipse_2.pretty'..."; + ofstream os( "test_Min_ellipse_2.pretty"); + CGAL_set_pretty_mode( os); + os << me; + } + { + verr << endl << " writing `test_Min_ellipse_2.binary'..."; + ofstream os( "test_Min_ellipse_2.binary"); + CGAL_set_binary_mode( os); + os << me; + } + { + verr << endl << " reading `test_Min_ellipse_2.ascii'..."; + Min_ellipse me_in; + ifstream is( "test_Min_ellipse_2.ascii"); + CGAL_set_ascii_mode( is); + is >> me_in; + bool is_valid = me_in.is_valid( verbose); + assert( is_valid); + assert( me_in.number_of_points() == n); + assert( me_in.ellipse() == me.ellipse()); + } + verr << endl; } @end @@ -2789,33 +2790,33 @@ end of each file. @macro = @begin while ( argc > 1) { - typedef CGAL_Min_ellipse_2< TraitsH > Min_ellipse; - typedef Min_ellipse::Point Point; - typedef Min_ellipse::Ellipse Ellipse; + typedef CGAL_Min_ellipse_2< TraitsH > Min_ellipse; + typedef Min_ellipse::Point Point; + typedef Min_ellipse::Ellipse Ellipse; - CGAL_Verbose_ostream verr( verbose); + CGAL_Verbose_ostream verr( verbose); - // read points from file - verr << endl << "input file: `" << argv[ 1] << "'" << flush; + // read points from file + verr << endl << "input file: `" << argv[ 1] << "'" << flush; - list points; - int n, x, y; - ifstream in( argv[ 1]); - in >> n; - assert( in); - for ( int i = 0; i < n; ++i) { - in >> x >> y; - assert( in); - points.push_back( Point( x, y)); } + list points; + int n, x, y; + ifstream in( argv[ 1]); + in >> n; + assert( in); + for ( int i = 0; i < n; ++i) { + in >> x >> y; + assert( in); + points.push_back( Point( x, y)); } - // compute and check min_ellipse - Min_ellipse me2( points.begin(), points.end()); - bool is_valid = me2.is_valid( verbose); - assert( is_valid); + // compute and check min_ellipse + Min_ellipse me2( points.begin(), points.end()); + bool is_valid = me2.is_valid( verbose); + assert( is_valid); - // next file - --argc; - ++argv; } + // next file + --argc; + ++argv; } @end @! ========================================================================== @@ -2850,8 +2851,8 @@ end of each file. #ifndef CGAL_OPTIMISATION_ASSERTIONS_H # include #endif - #ifndef CGAL_OPTIMISATION_MISC_H - # include + #ifndef CGAL_OPTIMISATION_BASIC_H + # include #endif #ifndef CGAL_PROTECT_LIST_H # include @@ -2999,9 +3000,9 @@ end of each file. template < class PT, class DA > bool CGAL_are_ordered_along_lineC2( PT const& p, PT const& q, PT const& r, - DA const& da) + DA const& da) { - typedef DA::FT FT; + typedef typename DA::FT FT; FT px; FT py; @@ -3014,17 +3015,17 @@ end of each file. da.get( q, qx, qy); da.get( r, rx, ry); - // p,q,r collinear? - if ( ! CGAL_is_zero( ( px-rx) * ( qy-ry) - ( py-ry) * ( qx-rx))) - return( false); + // p,q,r collinear? + if ( ! CGAL_is_zero( ( px-rx) * ( qy-ry) - ( py-ry) * ( qx-rx))) + return( false); - // p,q,r vertical? - if ( px != rx) - return( ( ( px < qx) && ( qx < rx)) - || ( ( rx < qx) && ( qx < px))); - else - return( ( ( py < qy) && ( qy < ry)) - || ( ( ry < qy) && ( qy < py))); + // p,q,r vertical? + if ( px != rx) + return( ( ( px < qx) && ( qx < rx)) + || ( ( rx < qx) && ( qx < px))); + else + return( ( ( py < qy) && ( qy < ry)) + || ( ( ry < qy) && ( qy < py))); } @ @@ -3066,9 +3067,9 @@ end of each file. template < class PT, class DA > bool CGAL_are_ordered_along_lineH2( PT const& p, PT const& q, PT const& r, - DA const& da) + DA const& da) { - typedef DA::RT RT; + typedef typename DA::RT RT; RT phx; RT phy; @@ -3084,18 +3085,18 @@ end of each file. da.get( q, qhx, qhy, qhw); da.get( r, rhx, rhy, rhw); - // p,q,r collinear? + // p,q,r collinear? if ( ! CGAL_is_zero( ( phx*rhw - rhx*phw) * ( qhy*rhw - rhy*qhw) - - ( phy*rhw - rhy*phw) * ( qhx*rhw - rhx*qhw))) - return( false); + - ( phy*rhw - rhy*phw) * ( qhx*rhw - rhx*qhw))) + return( false); - // p,q,r vertical? - if ( phx*rhw != rhx*phw) - return( ( ( phx*qhw < qhx*phw) && ( qhx*rhw < rhx*qhw)) - || ( ( rhx*qhw < qhx*rhw) && ( qhx*phw < phx*qhw))); - else - return( ( ( phy*qhw < qhy*phw) && ( qhy*rhw < rhy*qhw)) - || ( ( rhy*qhw < qhy*rhw) && ( qhy*phw < phy*qhw))); + // p,q,r vertical? + if ( phx*rhw != rhx*phw) + return( ( ( phx*qhw < qhx*phw) && ( qhx*rhw < rhx*qhw)) + || ( ( rhx*qhw < qhx*rhw) && ( qhx*phw < phx*qhw))); + else + return( ( ( phy*qhw < qhy*phw) && ( qhy*rhw < rhy*qhw)) + || ( ( rhy*qhw < qhy*rhw) && ( qhy*phw < phy*qhw))); } @ @@ -3133,21 +3134,21 @@ end of each file. main( int argc, char* argv[]) { // command line options - // -------------------- - // option `-verbose' - @ + // -------------------- + // option `-verbose' + @ - // code coverage - // ------------- - @ + // code coverage + // ------------- + @ // adapters test // ------------- @ - // external test sets - // ------------------- - @ + // external test sets + // ------------------- + @ } @ @@ -3163,20 +3164,20 @@ end of each file. @macro (1) many = @begin @("2D Smallest Enclosing Ellipse",@1, - "Optimisation/Min_ellipse_2", + "Optimisation/Min_ellipse_2", "Sven Schönherr ", "Bernd Gärtner", - "ETH Zurich (Bernd Gärtner )", - "$Revision$","$Date$") + "ETH Zurich (Bernd Gärtner )", + "$Revision$","$Date$") @end @macro (1) many = @begin @("2D Optimisation Ellipse",@1, - "Optimisation/Min_ellipse_2", + "Optimisation/Min_ellipse_2", "Sven Schönherr ", "Bernd Gärtner", - "ETH Zurich (Bernd Gärtner )", - "$Revision$","$Date$") + "ETH Zurich (Bernd Gärtner )", + "$Revision$","$Date$") @end @! ============================================================================ @! Bibliography