From f488b9baf93080bdcd68f4944ed7c95e3e01434f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 20 May 2016 14:44:01 +0200 Subject: [PATCH] Changes after Laurent's review --- .../include/CGAL/Cartesian/Weighted_point_2.h | 16 +- .../include/CGAL/Cartesian/Weighted_point_3.h | 16 +- .../include/CGAL/predicates/kernel_ftC3.h | 100 +++++++++++ .../CGAL/Homogeneous/Homogeneous_base.h | 1 - .../Homogeneous/Regular_triangulation_rtH2.h | 156 ------------------ .../Homogeneous/Regular_triangulation_rtH3.h | 103 ------------ .../CGAL/Homogeneous/Weighted_point_2.h | 17 +- .../CGAL/Homogeneous/Weighted_point_3.h | 19 ++- .../CGAL/Homogeneous/basic_constructionsH2.h | 63 +++++++ ...uctions_on_weighted_points_homogeneous_2.h | 92 ----------- .../CGAL/Homogeneous/function_objects.h | 4 +- .../CGAL/Homogeneous/predicates_on_pointsH2.h | 124 ++++++++++++++ .../CGAL/Homogeneous/predicates_on_pointsH3.h | 73 ++++++++ Installation/changes.html | 21 ++- Kernel_23/doc/Kernel_23/CGAL/Point_2.h | 5 + Kernel_23/doc/Kernel_23/CGAL/Point_3.h | 5 + .../doc/Kernel_23/CGAL/Weighted_point_2.h | 5 + .../doc/Kernel_23/CGAL/squared_distance_2.h | 4 +- .../Concepts/FunctionObjectConcepts.h | 24 +++ .../include/CGAL/Kernel/function_objects.h | 1 - ...redicates_on_weighted_points_cartesian_3.h | 134 --------------- .../CGAL/Mesh_3/Creator_weighted_point_3.h | 3 - .../include/CGAL/Mesh_3/min_dihedral_angle.h | 24 +-- .../Concepts/RegularTriangulationTraits_2.h | 4 +- .../test_regular_triangulation_2.cpp | 15 +- .../Concepts/RegularTriangulationTraits_3.h | 3 +- 26 files changed, 484 insertions(+), 548 deletions(-) delete mode 100644 Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH2.h delete mode 100644 Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH3.h delete mode 100644 Homogeneous_kernel/include/CGAL/Homogeneous/constructions_on_weighted_points_homogeneous_2.h delete mode 100644 Kernel_23/include/CGAL/predicates/predicates_on_weighted_points_cartesian_3.h diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_2.h index a9d58313a10..6ed2208c033 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_2.h @@ -1,10 +1,14 @@ -// Copyright (c) 1999-2004 INRIA Sophia-Antipolis (France). -// All rights reserved. +// Copyright (c) 1999 +// Utrecht University (The Netherlands), +// ETH Zurich (Switzerland), +// INRIA Sophia-Antipolis (France), +// Max-Planck-Institute Saarbruecken (Germany), +// and Tel-Aviv University (Israel). All rights reserved. // -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_3.h index 349626ea3cb..1b0b23785f6 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Weighted_point_3.h @@ -1,10 +1,14 @@ -// Copyright (c) 1999-2004 INRIA Sophia-Antipolis (France). -// All rights reserved. +// Copyright (c) 1999 +// Utrecht University (The Netherlands), +// ETH Zurich (Switzerland), +// INRIA Sophia-Antipolis (France), +// Max-Planck-Institute Saarbruecken (Germany), +// and Tel-Aviv University (Israel). All rights reserved. // -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. diff --git a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h index 00d47400432..d7e684cf26b 100644 --- a/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h +++ b/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h @@ -686,6 +686,106 @@ power_testC3(const FT &pwt, const FT &qwt) } +template < class FT > +Comparison_result +compare_power_distanceC3( + const FT &px, const FT &py, const FT &pz, + const FT &qx, const FT &qy, const FT &qz, const FT &qw, + const FT &rx, const FT &ry, const FT &rz, const FT &rw) +{ + FT dqx = qx - px; + FT dqy = qy - py; + FT dqz = qz - pz; + FT drx = rx - px; + FT dry = ry - py; + FT drz = rz - pz; + return CGAL_NTS compare(dqx*dqx + dqy*dqy + dqz*dqz - qw, + drx*drx + dry*dry + drz*drz - rw); +} + + +//return the sign of the power test of weighted point (sx,sy,sz,sw) +//with respect to the smallest sphere orthogonal to +//p,q,r +template< class FT > +CGAL_MEDIUM_INLINE +Sign +in_smallest_orthogonal_sphereC3( + const FT &px, const FT &py, const FT &pz, const FT &pw, + const FT &qx, const FT &qy, const FT &qz, const FT &qw, + const FT &rx, const FT &ry, const FT &rz, const FT &rw, + const FT &sx, const FT &sy, const FT &sz, const FT &sw) +{ + // Translate p to origin and compute determinants + FT qpx = qx-px; + FT qpy = qy-py; + FT qpz = qz-pz; + + FT rpx = rx-px; + FT rpy = ry-py; + FT rpz = rz-pz; + + FT qq = CGAL_NTS square(qpx) + CGAL_NTS square(qpy) + CGAL_NTS square(qpz); + FT rr = CGAL_NTS square(rpx) + CGAL_NTS square(rpy) + CGAL_NTS square(rpz); + FT qr = qpx*rpx + qpy*rpy + qpz*rpz; + + FT qpw = qq - qw + pw ; + FT rpw = rr - rw + pw ; + + FT den = determinant(qq,qr, + qr,rr); + FT detq = determinant(qpw,qr, + rpw,rr); + FT detr = determinant(qq,qpw, + qr,rpw); + + // Smallest smallest orthogonal sphere center + // c = detq/2*den q + detr/2*den r (origin at p) + // square radius c^2 - pw + + FT spx = sx-px; + FT spy = sy-py; + FT spz = sz-pz; + FT ss = CGAL_NTS square(spx) + CGAL_NTS square(spy) + CGAL_NTS square(spz); + FT sq = spx*qpx + spy*qpy + spz*qpz; + FT sr = spx*rpx + spy*rpy + spz*rpz; + + CGAL_assertion( ! CGAL_NTS is_zero(den) ); + // return sign of (c- s)^2 - (c^2 - pw) - sw note that den >= 0 - + return CGAL_NTS sign( den*(ss - sw + pw)- detq*sq - detr*sr); +} + + + +// return the sign of the power test of weighted point (rx,ry,rz,rw) + // with respect to the smallest sphere orthogoanal to +// p,q +template< class FT > +Sign +in_smallest_orthogonal_sphereC3( + const FT &px, const FT &py, const FT &pz, const FT &pw, + const FT &qx, const FT &qy, const FT &qz, const FT &qw, + const FT &rx, const FT &ry, const FT &rz, const FT &rw) +{ + FT FT2(2); + FT FT4(4); + FT dpx = px - qx; + FT dpy = py - qy; + FT dpz = pz - qz; + FT dpw = pw - qw; + FT dp2 = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + CGAL_NTS square(dpz); + FT drx = rx - (px + qx)/FT2; + FT dry = ry - (py + qy)/FT2; + FT drz = rz - (pz + qz)/FT2; + FT drw = rw - (pw + qw)/FT2; + FT dr2 = CGAL_NTS square(drx) + CGAL_NTS square(dry) + CGAL_NTS square(drz); + FT dpr = dpx*drx + dpy*dry +dpz*drz; + return CGAL_NTS sign (dr2 - dp2/FT4 + dpr*dpw/dp2 - drw ); +} + + + + } //namespace CGAL #endif // CGAL_PREDICATES_KERNEL_FTC3_H diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h index 19c5fd3e107..a819dc1a232 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Homogeneous_base.h @@ -70,7 +70,6 @@ #include #include #include -#include #include #include diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH2.h deleted file mode 100644 index bbea67b1d83..00000000000 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH2.h +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) 1999 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 3 of the License, -// or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// -// Author(s) : Sylvain Pion -// Mariette Yvinec - -#ifndef CGAL_REGULAR_TRIANGULATION_RTH2_H -#define CGAL_REGULAR_TRIANGULATION_RTH2_H - -// This file contains the low level homogeneous predicates -// used by the 2D regular triangulation. - -namespace CGAL { - - template -Comparison_result -compare_power_distanceH2(const RT& phx, const RT& phy, const RT& phw, - const Quotient& pwt, - const RT& qhx, const RT& qhy, const RT& qhw, - const Quotient& qwt, - const RT& rhx, const RT& rhy, const RT& rhw) -{ - // returns SMALLER if r is closer to p w.r.t. the power metric - RT dphx = rhx * phw - phx * rhw; - RT dphy = rhy * phw - phy * rhw; - RT dqhx = rhx * qhw - qhx * rhw; - RT dqhy = rhy * qhw - qhy * rhw; - RT dphw = CGAL_NTS square(phw); - RT dqhw = CGAL_NTS square(qhw); - RT drhw = CGAL_NTS square(rhw); - - RT npwt = pwt.numerator(); - RT dpwt = pwt.denominator(); - RT nqwt = qwt.numerator(); - RT dqwt = qwt.denominator(); - - - RT dh1 = (CGAL_NTS square(dphx) + CGAL_NTS square(dphy))*dpwt - npwt * dphw * drhw; - RT dh2 = (CGAL_NTS square(dqhx) + CGAL_NTS square(dqhy))*dqwt - nqwt * dqhw * drhw; - return CGAL_NTS compare(dh1 * dqhw * dqwt, dh2 * dphw * dpwt ); -} - - -template -Oriented_side -power_testH2( const RT &phx, const RT &phy, const RT &phw, const Quotient &pwt, - const RT &qhx, const RT &qhy, const RT &qhw, const Quotient &qwt, - const RT &rhx, const RT &rhy, const RT &rhw, const Quotient &rwt, - const RT &thx, const RT &thy, const RT &thw, const Quotient &twt) -{ - RT npwt = pwt.numerator(); - RT dpwt = pwt.denominator(); - RT nqwt = qwt.numerator(); - RT dqwt = qwt.denominator(); - RT nrwt = rwt.numerator(); - RT drwt = rwt.denominator(); - RT ntwt = twt.numerator(); - RT dtwt = twt.denominator(); - - RT dphx = phx*phw; - RT dphy = phy*phw; - RT dphw = CGAL_NTS square(phw); - RT dpz = (CGAL_NTS square(phx) + CGAL_NTS square(phy))*dpwt - npwt*dphw; - - RT dqhx = qhx*qhw; - RT dqhy = qhy*qhw; - RT dqhw = CGAL_NTS square(qhw); - RT dqz = (CGAL_NTS square(qhx) + CGAL_NTS square(qhy))*dqwt - nqwt*dqhw; - - RT drhx = rhx*rhw; - RT drhy = rhy*rhw; - RT drhw = CGAL_NTS square(rhw); - RT drz = (CGAL_NTS square(rhx) + CGAL_NTS square(rhy)) *drwt - nrwt*drhw; - - RT dthx = thx*thw; - RT dthy = thy*thw; - RT dthw = CGAL_NTS square(thw); - RT dtz = (CGAL_NTS square(thx) + CGAL_NTS square(thy))*dtwt - ntwt*dthw; - - dthx *= dtwt; - dthy *= dtwt; - dthw *= dtwt; - - return sign_of_determinant(dphx, dphy, dpz, dphw, - dqhx, dqhy, dqz, dqhw, - drhx, drhy, drz, drhw, - dthx, dthy, dtz, dthw); -} - - -template -Oriented_side -power_testH2( const RT &phx, const RT &phy, const RT &phw, const Quotient &pwt, - const RT &qhx, const RT &qhy, const RT &qhw, const Quotient &qwt, - const RT &thx, const RT &thy, const RT &thw, const Quotient &twt) -{ - RT npwt = pwt.numerator(); - RT dpwt = pwt.denominator(); - RT nqwt = qwt.numerator(); - RT dqwt = qwt.denominator(); - RT ntwt = twt.numerator(); - RT dtwt = twt.denominator(); - - // Test if we can project on the (x) axis. If not, then on the - // (y) axis - RT pa, qa, ta; - - if (phx * qhw != qhx * phw ) - { - pa = phx*phw; - qa = qhx*qhw; - ta = thx*thw; - } - else - { - pa = phy*phw; - qa = qhy*qhw; - ta = thy*thw; - } - - RT dphw = CGAL_NTS square(phw); - RT dpz = (CGAL_NTS square(phx) + CGAL_NTS square(phy))*dpwt - npwt*dphw; - - RT dqhw = CGAL_NTS square(qhw); - RT dqz = (CGAL_NTS square(qhx) + CGAL_NTS square(qhy))*dqwt - nqwt*dqhw; - - RT dthw = CGAL_NTS square(thw); - RT dtz = (CGAL_NTS square(thx) + CGAL_NTS square(thy))*dtwt - ntwt*dthw; - - pa *= dtwt; - qa *= dtwt; - ta *= dtwt; - - return CGAL_NTS compare(pa, qa) * sign_of_determinant(pa, dpz, dphw, - qa, dqz, dqhw, - ta, dtz, dthw); -} - -} //namespace CGAL - -#endif // CGAL_REGULAR_TRIANGULATION_RTH2_H diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH3.h deleted file mode 100644 index 05b5f7af5f5..00000000000 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Regular_triangulation_rtH3.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 1999 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 3 of the License, -// or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// -// Author(s) : Sylvain Pion - -#ifndef CGAL_REGULAR_TRIANGULATION_RTH3_H -#define CGAL_REGULAR_TRIANGULATION_RTH3_H - -// This file contains the low level homogeneous predicates -// used by the 3D regular triangulation. - -#include - -namespace CGAL { - -template -Oriented_side -power_testH3( - const RT &phx, const RT &phy, const RT &phz, const RT &phw, const Quotient &pwt, - const RT &qhx, const RT &qhy, const RT &qhz, const RT &qhw, const Quotient &qwt, - const RT &rhx, const RT &rhy, const RT &rhz, const RT &rhw, const Quotient &rwt, - const RT &shx, const RT ­, const RT &shz, const RT &shw, const Quotient &swt, - const RT &thx, const RT &thy, const RT &thz, const RT &thw, const Quotient &twt) -{ - RT npwt = pwt.numerator(); - RT dpwt = pwt.denominator(); - RT nqwt = qwt.numerator(); - RT dqwt = qwt.denominator(); - RT nrwt = rwt.numerator(); - RT drwt = rwt.denominator(); - RT nswt = swt.numerator(); - RT dswt = swt.denominator(); - RT ntwt = twt.numerator(); - RT dtwt = twt.denominator(); - - RT dphx = phx*phw; - RT dphy = phy*phw; - RT dphz = phz*phw; - RT dphw = CGAL_NTS square(phw); - RT dpz = (CGAL_NTS square(phx) + CGAL_NTS square(phy) + - CGAL_NTS square(phz))*dpwt - npwt*dphw; - - RT dqhx = qhx*qhw; - RT dqhy = qhy*qhw; - RT dqhz = qhz*qhw; - RT dqhw = CGAL_NTS square(qhw); - RT dqz = (CGAL_NTS square(qhx) + CGAL_NTS square(qhy) + - CGAL_NTS square(qhz))*dqwt - nqwt*dqhw; - - RT drhx = rhx*rhw; - RT drhy = rhy*rhw; - RT drhz = rhz*rhw; - RT drhw = CGAL_NTS square(rhw); - RT drz = (CGAL_NTS square(rhx) + CGAL_NTS square(rhy) + - CGAL_NTS square(rhz))*drwt - nrwt*drhw; - - RT dshx = shx*shw; - RT dshy = shy*shw; - RT dshz = shz*shw; - RT dshw = CGAL_NTS square(shw); - RT dsz = (CGAL_NTS square(shx) + CGAL_NTS square(shy) + - CGAL_NTS square(shz))*dswt - nswt*dshw; - - RT dthx = thx*thw; - RT dthy = thy*thw; - RT dthz = thz*thw; - RT dthw = CGAL_NTS square(thw); - RT dtz = (CGAL_NTS square(thx) + CGAL_NTS square(thy) + - CGAL_NTS square(thz))*dtwt - ntwt*dthw; - - dthx *= dtwt; - dthy *= dtwt; - dthz *= dtwt; - dthw *= dtwt; - - return - sign_of_determinant(dphx, dphy, dphz, dpz, dphw, - dqhx, dqhy, dqhz, dqz, dqhw, - drhx, drhy, drhz, drz, drhw, - dshx, dshy, dshz, dsz, dshw, - dthx, dthy, dthz, dtz, dthw); -} - -// The 2 degenerate are not speed critical, and they are quite boring and error -// prone to write, so we use the Cartesian version, using FT. - -} //namespace CGAL - -#endif // CGAL_REGULAR_TRIANGULATION_RTH3_H diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_2.h index 484b870c1b0..1d749cf4a7c 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_2.h @@ -1,10 +1,14 @@ -// Copyright (c) 1999-2004 INRIA Sophia-Antipolis (France). -// All rights reserved. +// Copyright (c) 1999 +// Utrecht University (The Netherlands), +// ETH Zurich (Switzerland), +// INRIA Sophia-Antipolis (France), +// Max-Planck-Institute Saarbruecken (Germany), +// and Tel-Aviv University (Israel). All rights reserved. // -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. @@ -14,7 +18,6 @@ // // $URL$ // $Id$ -// // // Author(s) : Mariette Yvinec // Sylvain Pion diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_3.h index bb4f6466dd5..232e61050b7 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Weighted_point_3.h @@ -1,10 +1,14 @@ -// Copyright (c) 1999-2004 INRIA Sophia-Antipolis (France). -// All rights reserved. +// Copyright (c) 1999 +// Utrecht University (The Netherlands), +// ETH Zurich (Switzerland), +// INRIA Sophia-Antipolis (France), +// Max-Planck-Institute Saarbruecken (Germany), +// and Tel-Aviv University (Israel). All rights reserved. // -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. @@ -13,8 +17,7 @@ // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ -// $Id$ -// +// $Id$ // // Author(s) : Mariette Yvinec // Sylvain Pion diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/basic_constructionsH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/basic_constructionsH2.h index 15a5dd5992a..1151ef55ce0 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/basic_constructionsH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/basic_constructionsH2.h @@ -71,6 +71,69 @@ squared_distance( const PointH2& p, const PointH2& q ) return FT( sq_dist_numerator ) / FT( sq_dist_denominator ); } + +template < class RT, class We> +void +weighted_circumcenterH2( const RT &phx, const RT &phy, const RT &phw, + const We &pwt, + const RT &qhx, const RT &qhy, const RT &qhw, + const We &qwt, + const RT &rhx, const RT &rhy, const RT &rhw, + const We &rwt, + RT &vvx, RT &vvy, RT &vvw ) +{ + +// RT qx_px = ( qhx*qhw*phw*phw - phx*phw*qhw*qhw ); +// RT qy_py = ( qhy*qhw*phw*phw - phy*phw*qhw*qhw ); +// RT rx_px = ( rhx*rhw*phw*phw - phx*phw*rhw*rhw ); +// RT ry_py = ( rhy*rhw*phw*phw - phy*phw*rhw*rhw ); + +// //intersection of the two radical axis of (qp) and (rp) +// RT px2_py2_rx2_ry_2 = +// phx*phx*rhw*rhw + phy*phy*rhw*rhw - rhx*rhx*phw*phw - +// rhy*rhy*phw*phw - RT(pwt*pwt) + RT(rwt*rwt); +// RT px2_py2_qx2_qy_2 = +// phx*phx*qhw*qhw + phy*phy*qhw*qhw - qhx*qhx*phw*phw - +// qhy*qhy*phw*phw - RT(pwt*pwt) + RT(qwt*qwt); + +// vvx = qy_py * px2_py2_rx2_ry_2 - ry_py * px2_py2_qx2_qy_2; +// vvy = rx_px * px2_py2_qx2_qy_2 - qx_px * px2_py2_rx2_ry_2; +// vvw = RT(2) * ( qx_px * ry_py - rx_px * qy_py ); + + RT a1, b1, c1; + RT a2, b2, c2; + radical_axisH2(phx,phy,phw,pwt,qhx,qhy,qhw,qwt,a1,b1,c1); + radical_axisH2(phx,phy,phw,pwt,rhx,rhy,rhw,rwt,a2,b2,c2); + vvx = b1*c2 - c1*b2; + vvy = c1*a2 - c2*a1; + vvw = a1*b2 - a2*b1; +} + + + + +template < class RT , class FT> +void +radical_axisH2(const RT &phx, const RT &phy, const RT &phw, const FT &pwt, + const RT &qhx, const RT &qhy, const RT &qhw, const FT &qwt, + RT &a, RT &b, RT &c ) +{ + Rational_traits rt; + RT npwt = rt.numerator(pwt); + RT dpwt = rt.denominator(pwt); + RT nqwt = rt.numerator(qwt); + RT dqwt = rt.denominator(qwt); + + a = RT(2) * ( phx*phw*qhw*qhw - qhx*qhw*phw*phw ); + b = RT(2) * ( phy*phw*qhw*qhw - qhy*qhw*phw*phw ); + c = (- phx*phx*qhw*qhw - phy*phy*qhw*qhw + + qhx*qhx*phw*phw + qhy*qhy*phw*phw) * dpwt * dqwt + + npwt*dqwt*phw*phw*qhw*qhw - nqwt*dpwt*phw*phw*qhw*qhw; + +} + + + } //namespace CGAL #endif // CGAL_BASIC_CONSTRUCTIONSH2_H diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/constructions_on_weighted_points_homogeneous_2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/constructions_on_weighted_points_homogeneous_2.h deleted file mode 100644 index 51793c58419..00000000000 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/constructions_on_weighted_points_homogeneous_2.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 1997 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// -// Author(s) : Julia Flototto, Mariette Yvinec - - -#ifndef CGAL_CONSTRUCTIONS_ON_WEIGHTED_POINTS_HOMOGENEOUS_2_H -#define CGAL_CONSTRUCTIONS_ON_WEIGHTED_POINTS_HOMOGENEOUS_2_H - -namespace CGAL { - -template < class RT, class We> -void -weighted_circumcenterH2( const RT &phx, const RT &phy, const RT &phw, - const We &pwt, - const RT &qhx, const RT &qhy, const RT &qhw, - const We &qwt, - const RT &rhx, const RT &rhy, const RT &rhw, - const We &rwt, - RT &vvx, RT &vvy, RT &vvw ) -{ - -// RT qx_px = ( qhx*qhw*phw*phw - phx*phw*qhw*qhw ); -// RT qy_py = ( qhy*qhw*phw*phw - phy*phw*qhw*qhw ); -// RT rx_px = ( rhx*rhw*phw*phw - phx*phw*rhw*rhw ); -// RT ry_py = ( rhy*rhw*phw*phw - phy*phw*rhw*rhw ); - -// //intersection of the two radical axis of (qp) and (rp) -// RT px2_py2_rx2_ry_2 = -// phx*phx*rhw*rhw + phy*phy*rhw*rhw - rhx*rhx*phw*phw - -// rhy*rhy*phw*phw - RT(pwt*pwt) + RT(rwt*rwt); -// RT px2_py2_qx2_qy_2 = -// phx*phx*qhw*qhw + phy*phy*qhw*qhw - qhx*qhx*phw*phw - -// qhy*qhy*phw*phw - RT(pwt*pwt) + RT(qwt*qwt); - -// vvx = qy_py * px2_py2_rx2_ry_2 - ry_py * px2_py2_qx2_qy_2; -// vvy = rx_px * px2_py2_qx2_qy_2 - qx_px * px2_py2_rx2_ry_2; -// vvw = RT(2) * ( qx_px * ry_py - rx_px * qy_py ); - - RT a1, b1, c1; - RT a2, b2, c2; - radical_axisH2(phx,phy,phw,pwt,qhx,qhy,qhw,qwt,a1,b1,c1); - radical_axisH2(phx,phy,phw,pwt,rhx,rhy,rhw,rwt,a2,b2,c2); - vvx = b1*c2 - c1*b2; - vvy = c1*a2 - c2*a1; - vvw = a1*b2 - a2*b1; -} - - - - -template < class RT , class FT> -void -radical_axisH2(const RT &phx, const RT &phy, const RT &phw, const FT &pwt, - const RT &qhx, const RT &qhy, const RT &qhw, const FT &qwt, - RT &a, RT &b, RT &c ) -{ - Rational_traits rt; - RT npwt = rt.numerator(pwt); - RT dpwt = rt.denominator(pwt); - RT nqwt = rt.numerator(qwt); - RT dqwt = rt.denominator(qwt); - - a = RT(2) * ( phx*phw*qhw*qhw - qhx*qhw*phw*phw ); - b = RT(2) * ( phy*phw*qhw*qhw - qhy*qhw*phw*phw ); - c = (- phx*phx*qhw*qhw - phy*phy*qhw*qhw - + qhx*qhx*phw*phw + qhy*qhy*phw*phw) * dpwt * dqwt - + npwt*dqwt*phw*phw*qhw*qhw - nqwt*dpwt*phw*phw*qhw*qhw; - -} - - - - - -} //namespace CGAL -#endif //CGAL_CONSTRUCTIONS_ON_WEIGHTED_POINTS_HOMOGENEOUS_2_H diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index 1ef425882e9..fe1008676c7 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -29,8 +29,8 @@ #include #include #include -#include -#include +#include +#include namespace CGAL { diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/predicates_on_pointsH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/predicates_on_pointsH2.h index e5df601c86a..43bfad85860 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/predicates_on_pointsH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/predicates_on_pointsH2.h @@ -60,6 +60,130 @@ _where_wrt_L_wedge( const PointH2& p, const PointH2& q ) return ON_ORIENTED_BOUNDARY; } +template +Comparison_result +compare_power_distanceH2(const RT& phx, const RT& phy, const RT& phw, + const Quotient& pwt, + const RT& qhx, const RT& qhy, const RT& qhw, + const Quotient& qwt, + const RT& rhx, const RT& rhy, const RT& rhw) +{ + // returns SMALLER if r is closer to p w.r.t. the power metric + RT dphx = rhx * phw - phx * rhw; + RT dphy = rhy * phw - phy * rhw; + RT dqhx = rhx * qhw - qhx * rhw; + RT dqhy = rhy * qhw - qhy * rhw; + RT dphw = CGAL_NTS square(phw); + RT dqhw = CGAL_NTS square(qhw); + RT drhw = CGAL_NTS square(rhw); + + RT npwt = pwt.numerator(); + RT dpwt = pwt.denominator(); + RT nqwt = qwt.numerator(); + RT dqwt = qwt.denominator(); + + + RT dh1 = (CGAL_NTS square(dphx) + CGAL_NTS square(dphy))*dpwt - npwt * dphw * drhw; + RT dh2 = (CGAL_NTS square(dqhx) + CGAL_NTS square(dqhy))*dqwt - nqwt * dqhw * drhw; + return CGAL_NTS compare(dh1 * dqhw * dqwt, dh2 * dphw * dpwt ); +} + + +template +Oriented_side +power_testH2( const RT &phx, const RT &phy, const RT &phw, const Quotient &pwt, + const RT &qhx, const RT &qhy, const RT &qhw, const Quotient &qwt, + const RT &rhx, const RT &rhy, const RT &rhw, const Quotient &rwt, + const RT &thx, const RT &thy, const RT &thw, const Quotient &twt) +{ + RT npwt = pwt.numerator(); + RT dpwt = pwt.denominator(); + RT nqwt = qwt.numerator(); + RT dqwt = qwt.denominator(); + RT nrwt = rwt.numerator(); + RT drwt = rwt.denominator(); + RT ntwt = twt.numerator(); + RT dtwt = twt.denominator(); + + RT dphx = phx*phw; + RT dphy = phy*phw; + RT dphw = CGAL_NTS square(phw); + RT dpz = (CGAL_NTS square(phx) + CGAL_NTS square(phy))*dpwt - npwt*dphw; + + RT dqhx = qhx*qhw; + RT dqhy = qhy*qhw; + RT dqhw = CGAL_NTS square(qhw); + RT dqz = (CGAL_NTS square(qhx) + CGAL_NTS square(qhy))*dqwt - nqwt*dqhw; + + RT drhx = rhx*rhw; + RT drhy = rhy*rhw; + RT drhw = CGAL_NTS square(rhw); + RT drz = (CGAL_NTS square(rhx) + CGAL_NTS square(rhy)) *drwt - nrwt*drhw; + + RT dthx = thx*thw; + RT dthy = thy*thw; + RT dthw = CGAL_NTS square(thw); + RT dtz = (CGAL_NTS square(thx) + CGAL_NTS square(thy))*dtwt - ntwt*dthw; + + dthx *= dtwt; + dthy *= dtwt; + dthw *= dtwt; + + return sign_of_determinant(dphx, dphy, dpz, dphw, + dqhx, dqhy, dqz, dqhw, + drhx, drhy, drz, drhw, + dthx, dthy, dtz, dthw); +} + + +template +Oriented_side +power_testH2( const RT &phx, const RT &phy, const RT &phw, const Quotient &pwt, + const RT &qhx, const RT &qhy, const RT &qhw, const Quotient &qwt, + const RT &thx, const RT &thy, const RT &thw, const Quotient &twt) +{ + RT npwt = pwt.numerator(); + RT dpwt = pwt.denominator(); + RT nqwt = qwt.numerator(); + RT dqwt = qwt.denominator(); + RT ntwt = twt.numerator(); + RT dtwt = twt.denominator(); + + // Test if we can project on the (x) axis. If not, then on the + // (y) axis + RT pa, qa, ta; + + if (phx * qhw != qhx * phw ) + { + pa = phx*phw; + qa = qhx*qhw; + ta = thx*thw; + } + else + { + pa = phy*phw; + qa = qhy*qhw; + ta = thy*thw; + } + + RT dphw = CGAL_NTS square(phw); + RT dpz = (CGAL_NTS square(phx) + CGAL_NTS square(phy))*dpwt - npwt*dphw; + + RT dqhw = CGAL_NTS square(qhw); + RT dqz = (CGAL_NTS square(qhx) + CGAL_NTS square(qhy))*dqwt - nqwt*dqhw; + + RT dthw = CGAL_NTS square(thw); + RT dtz = (CGAL_NTS square(thx) + CGAL_NTS square(thy))*dtwt - ntwt*dthw; + + pa *= dtwt; + qa *= dtwt; + ta *= dtwt; + + return CGAL_NTS compare(pa, qa) * sign_of_determinant(pa, dpz, dphw, + qa, dqz, dqhw, + ta, dtz, dthw); +} + #if 0 // Unused, undocumented, un-functorized. template < class R > diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/predicates_on_pointsH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/predicates_on_pointsH3.h index b1f809189b0..49008abbc40 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/predicates_on_pointsH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/predicates_on_pointsH3.h @@ -27,6 +27,7 @@ #define CGAL_PREDICATES_ON_POINTSH3_H #include +#include namespace CGAL { @@ -125,6 +126,78 @@ bool less_z(const PointH3 &p, const PointH3 &q) { return (p.hz() * q.hw() < q.hz() * p.hw() ); } + + +template +Oriented_side +power_testH3( + const RT &phx, const RT &phy, const RT &phz, const RT &phw, const Quotient &pwt, + const RT &qhx, const RT &qhy, const RT &qhz, const RT &qhw, const Quotient &qwt, + const RT &rhx, const RT &rhy, const RT &rhz, const RT &rhw, const Quotient &rwt, + const RT &shx, const RT ­, const RT &shz, const RT &shw, const Quotient &swt, + const RT &thx, const RT &thy, const RT &thz, const RT &thw, const Quotient &twt) +{ + RT npwt = pwt.numerator(); + RT dpwt = pwt.denominator(); + RT nqwt = qwt.numerator(); + RT dqwt = qwt.denominator(); + RT nrwt = rwt.numerator(); + RT drwt = rwt.denominator(); + RT nswt = swt.numerator(); + RT dswt = swt.denominator(); + RT ntwt = twt.numerator(); + RT dtwt = twt.denominator(); + + RT dphx = phx*phw; + RT dphy = phy*phw; + RT dphz = phz*phw; + RT dphw = CGAL_NTS square(phw); + RT dpz = (CGAL_NTS square(phx) + CGAL_NTS square(phy) + + CGAL_NTS square(phz))*dpwt - npwt*dphw; + + RT dqhx = qhx*qhw; + RT dqhy = qhy*qhw; + RT dqhz = qhz*qhw; + RT dqhw = CGAL_NTS square(qhw); + RT dqz = (CGAL_NTS square(qhx) + CGAL_NTS square(qhy) + + CGAL_NTS square(qhz))*dqwt - nqwt*dqhw; + + RT drhx = rhx*rhw; + RT drhy = rhy*rhw; + RT drhz = rhz*rhw; + RT drhw = CGAL_NTS square(rhw); + RT drz = (CGAL_NTS square(rhx) + CGAL_NTS square(rhy) + + CGAL_NTS square(rhz))*drwt - nrwt*drhw; + + RT dshx = shx*shw; + RT dshy = shy*shw; + RT dshz = shz*shw; + RT dshw = CGAL_NTS square(shw); + RT dsz = (CGAL_NTS square(shx) + CGAL_NTS square(shy) + + CGAL_NTS square(shz))*dswt - nswt*dshw; + + RT dthx = thx*thw; + RT dthy = thy*thw; + RT dthz = thz*thw; + RT dthw = CGAL_NTS square(thw); + RT dtz = (CGAL_NTS square(thx) + CGAL_NTS square(thy) + + CGAL_NTS square(thz))*dtwt - ntwt*dthw; + + dthx *= dtwt; + dthy *= dtwt; + dthz *= dtwt; + dthw *= dtwt; + + return - sign_of_determinant(dphx, dphy, dphz, dpz, dphw, + dqhx, dqhy, dqhz, dqz, dqhw, + drhx, drhy, drhz, drz, drhw, + dshx, dshy, dshz, dsz, dshw, + dthx, dthy, dthz, dtz, dthw); +} + +// The 2 degenerate are not speed critical, and they are quite boring and error +// prone to write, so we use the Cartesian version, using FT. + } //namespace CGAL #endif // CGAL_PREDICATES_ON_POINTSH3_H diff --git a/Installation/changes.html b/Installation/changes.html index 52b9f50eea6..5a259c94444 100644 --- a/Installation/changes.html +++ b/Installation/changes.html @@ -146,7 +146,12 @@ and src/ directories). - + +

Linear Kernel

+
    +
  • Added a 2D and 3D weighted point class and predicates and constructions. +
  • +
@@ -164,6 +169,20 @@ and src/ directories). +

2D Triangulations

+
    +
  • Breaking change: Removed the arbitrary dimensional weighted point class.
  • +
  • Breaking change: Removed the class Regular_triangulation_filtered_traits_2
  • +
  • Breaking change:The number type of weighted points in regular triangulations is no longer + a template parameter but the field type of the geometric traits class.
  • +
+ +

3D Triangulations

+
    +
  • Breaking change: Removed the class Regular_triangulation_filtered_traits_3
  • +
  • Breaking change: The number type of weighted points in regular triangulations is no longer + a template parameter but the field type of the geometric traits class.
  • +
diff --git a/Kernel_23/doc/Kernel_23/CGAL/Point_2.h b/Kernel_23/doc/Kernel_23/CGAL/Point_2.h index 737328e0159..76164f40016 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Point_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Point_2.h @@ -84,6 +84,11 @@ introduces a point `p` initialized to `(x,y)`. */ Point_2(const Kernel::FT &x, const Kernel::FT &y); +/*! +introduces a point from a weighted point. +*/ +Point_2(const Kernel::Weighted_point_2 &wp); + /// @} /// \name Operations diff --git a/Kernel_23/doc/Kernel_23/CGAL/Point_3.h b/Kernel_23/doc/Kernel_23/CGAL/Point_3.h index 15902d3aa93..82efc70fe34 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Point_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Point_3.h @@ -65,6 +65,11 @@ introduces a point `p` initialized to `(x,y,z)`. */ Point_3(const Kernel::FT &x, const Kernel::FT &y, const Kernel::FT &z); +/*! +introduces a point from a weighted point. +*/ +Point_3(const Kernel::Weighted_point_3 &wp); + /// @} /// \name Operations diff --git a/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_2.h b/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_2.h index 22cdb2a9dd7..634ed2da5f5 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_2.h @@ -37,6 +37,11 @@ introduces a weighted point from point `p` and weight `w`. */ Weighted_point_2(const Point_2& p, Kernel::FT& w); +/*! +introduces a weighted point with coordinates `x`, `y`, and weight 0. +*/ + Weighted_point_2(const Kernel::FT& x, const Kernel::FT& y); + /// @} diff --git a/Kernel_23/doc/Kernel_23/CGAL/squared_distance_2.h b/Kernel_23/doc/Kernel_23/CGAL/squared_distance_2.h index e1cf0a2ed41..51419680bb1 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/squared_distance_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/squared_distance_2.h @@ -28,6 +28,7 @@ In 2D, the types `Type1` and `Type2` can be any of the following: - `Segment_2` - `Triangle_2` +as well as any combination of `Kernel::Point_2` and `Kernel::Weighted_point_2` In 3D, the types `Type1` and `Type2` can be any of the following: @@ -38,7 +39,8 @@ following: - `Segment_3` - `Plane_3` -as well as the combination `Point_3`/`Triangle_3`. +as well as combinations `Point_3`/`Triangle_3`, +and `Weighted_point_3`/`Triangle_3`. \sa `compare_distance_to_point_grp` \sa `compare_signed_distance_to_line_grp` diff --git a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h index a9d2354db62..dde3aca5009 100644 --- a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h +++ b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h @@ -2524,6 +2524,7 @@ public: - `Kernel::Segment_2` - `Kernel::Triangle_2` + as well as any combination of `Kernel::Point_2` and `Kernel::Weighted_point_2` */ Kernel::FT operator()(Type1 obj1, Type2 obj2); @@ -2558,6 +2559,8 @@ public: - `Kernel::Ray_3` - `Kernel::Segment_3` - `Kernel::Plane_3` + + as well as any combination of `Kernel::Point_3` and `Kernel::Weighted_point_3` */ Kernel::FT operator()(Type1 obj1, Type2 obj2); @@ -5592,6 +5595,11 @@ public: */ Kernel::Point_2 operator()(const CGAL::Origin &CGAL::ORIGIN); + /*! + extracts the bare point from the weighted point. + */ + Kernel::Point_2 operator()(const CGAL::Weighted_point_2& wp); + ///@} }; /* end Kernel::ConstructPoint_2 */ @@ -5617,6 +5625,11 @@ public: */ Kernel::Point_3 operator()(const CGAL::Origin &CGAL::ORIGIN); + /*! + extracts the bare point from the weighted point. + */ + Kernel::Point_3 operator()(const CGAL::Weighted_point_3& wp); + ///@} }; /* end Kernel::ConstructPoint_3 */ @@ -5732,6 +5745,17 @@ public: */ class ConstructRadicalAxis_2 { + /// \name Operations + /// A model of this concept must provide: + /// @{ + + /*! + returns the radical line of the weighted points. + */ + Kernel::Line_2 operator() + (const Kernel::Weighted_point_2& wp1, + const Kernel::Weighted_point_2& wp2); + /// @} }; diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index a844f35f5dc..3b7602af44e 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -37,7 +37,6 @@ #include #include #include -#include #include // for Compute_dihedral_angle diff --git a/Kernel_23/include/CGAL/predicates/predicates_on_weighted_points_cartesian_3.h b/Kernel_23/include/CGAL/predicates/predicates_on_weighted_points_cartesian_3.h deleted file mode 100644 index 453120013f3..00000000000 --- a/Kernel_23/include/CGAL/predicates/predicates_on_weighted_points_cartesian_3.h +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 1997 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 3 of the License, -// or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ - -// $Id$ -// -// -// Author(s) : Tran Kai Frank DA - -#ifndef CGAL_PREDICATES_ON_WEIGHTED_POINTS_CARTESIAN_3 -#define CGAL_PREDICATES_ON_WEIGHTED_POINTS_CARTESIAN_3 - -#include -#include - -namespace CGAL { - -template < class FT > -Comparison_result -compare_power_distanceC3( - const FT &px, const FT &py, const FT &pz, - const FT &qx, const FT &qy, const FT &qz, const FT &qw, - const FT &rx, const FT &ry, const FT &rz, const FT &rw) -{ - FT dqx = qx - px; - FT dqy = qy - py; - FT dqz = qz - pz; - FT drx = rx - px; - FT dry = ry - py; - FT drz = rz - pz; - return CGAL_NTS compare(dqx*dqx + dqy*dqy + dqz*dqz - qw, - drx*drx + dry*dry + drz*drz - rw); -} - - -//return the sign of the power test of weighted point (sx,sy,sz,sw) -//with respect to the smallest sphere orthogonal to -//p,q,r -template< class FT > -CGAL_MEDIUM_INLINE -Sign -in_smallest_orthogonal_sphereC3( - const FT &px, const FT &py, const FT &pz, const FT &pw, - const FT &qx, const FT &qy, const FT &qz, const FT &qw, - const FT &rx, const FT &ry, const FT &rz, const FT &rw, - const FT &sx, const FT &sy, const FT &sz, const FT &sw) -{ - // Translate p to origin and compute determinants - FT qpx = qx-px; - FT qpy = qy-py; - FT qpz = qz-pz; - - FT rpx = rx-px; - FT rpy = ry-py; - FT rpz = rz-pz; - - FT qq = CGAL_NTS square(qpx) + CGAL_NTS square(qpy) + CGAL_NTS square(qpz); - FT rr = CGAL_NTS square(rpx) + CGAL_NTS square(rpy) + CGAL_NTS square(rpz); - FT qr = qpx*rpx + qpy*rpy + qpz*rpz; - - FT qpw = qq - qw + pw ; - FT rpw = rr - rw + pw ; - - FT den = determinant(qq,qr, - qr,rr); - FT detq = determinant(qpw,qr, - rpw,rr); - FT detr = determinant(qq,qpw, - qr,rpw); - - // Smallest smallest orthogonal sphere center - // c = detq/2*den q + detr/2*den r (origin at p) - // square radius c^2 - pw - - FT spx = sx-px; - FT spy = sy-py; - FT spz = sz-pz; - FT ss = CGAL_NTS square(spx) + CGAL_NTS square(spy) + CGAL_NTS square(spz); - FT sq = spx*qpx + spy*qpy + spz*qpz; - FT sr = spx*rpx + spy*rpy + spz*rpz; - - CGAL_assertion( ! CGAL_NTS is_zero(den) ); - // return sign of (c- s)^2 - (c^2 - pw) - sw note that den >= 0 - - return CGAL_NTS sign( den*(ss - sw + pw)- detq*sq - detr*sr); -} - - - -// return the sign of the power test of weighted point (rx,ry,rz,rw) - // with respect to the smallest sphere orthogoanal to -// p,q -template< class FT > -Sign -in_smallest_orthogonal_sphereC3( - const FT &px, const FT &py, const FT &pz, const FT &pw, - const FT &qx, const FT &qy, const FT &qz, const FT &qw, - const FT &rx, const FT &ry, const FT &rz, const FT &rw) -{ - FT FT2(2); - FT FT4(4); - FT dpx = px - qx; - FT dpy = py - qy; - FT dpz = pz - qz; - FT dpw = pw - qw; - FT dp2 = CGAL_NTS square(dpx) + CGAL_NTS square(dpy) + CGAL_NTS square(dpz); - FT drx = rx - (px + qx)/FT2; - FT dry = ry - (py + qy)/FT2; - FT drz = rz - (pz + qz)/FT2; - FT drw = rw - (pw + qw)/FT2; - FT dr2 = CGAL_NTS square(drx) + CGAL_NTS square(dry) + CGAL_NTS square(drz); - FT dpr = dpx*drx + dpy*dry +dpz*drz; - return CGAL_NTS sign (dr2 - dp2/FT4 + dpr*dpw/dp2 - drw ); -} - - - - -//------------------------------------------------------------------- -} //namespace CGAL -//------------------------------------------------------------------- - -#endif //CGAL_PREDICATES_ON_WEIGHTED_POINTS_CARTESIAN_3 diff --git a/Mesh_3/include/CGAL/Mesh_3/Creator_weighted_point_3.h b/Mesh_3/include/CGAL/Mesh_3/Creator_weighted_point_3.h index fd779803445..437cef43387 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Creator_weighted_point_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Creator_weighted_point_3.h @@ -56,9 +56,6 @@ public: /// We do not pass \c const \c Arg_& because \c Arg_ is a ring number type Weighted_point operator()(Arg_ a1, Arg_ a2, Arg_ a3) const { - // AF: check this - //typedef typename Weighted_point::Point Bare_point; - // return Weighted_point(Bare_point(a1,a2,a3)); return Weighted_point(a1,a2,a3); } diff --git a/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h b/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h index d9d7dc3766f..fab392e5733 100644 --- a/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h +++ b/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h @@ -85,10 +85,10 @@ minimum_dihedral_angle( template typename K::FT minimum_dihedral_angle( - const typename K::Bare_point& p0, - const typename K::Bare_point& p1, - const typename K::Bare_point& p2, - const typename K::Bare_point& p3, + const typename K::Point_3& p0, + const typename K::Point_3& p1, + const typename K::Point_3& p2, + const typename K::Point_3& p3, K k = K()) { typedef typename K::FT FT; @@ -101,12 +101,16 @@ minimum_dihedral_angle( typename K::Compute_scalar_product_3 sp = k.compute_scalar_product_3_object(); - typename K::Vector_3 v01 = p1-p0; - typename K::Vector_3 v02 = p2-p0; - typename K::Vector_3 v03 = p3-p0; - typename K::Vector_3 v12 = p2-p1; - typename K::Vector_3 v13 = p3-p1; - typename K::Vector_3 v23 = p3-p2; + typename K::Construct_vector_3 cv = + k.construct_vector_3_object(); + + + typename K::Vector_3 v01 = cv(p0,p1); + typename K::Vector_3 v02 = cv(p0,p2); + typename K::Vector_3 v03 = cv(p0,p3); + typename K::Vector_3 v12 = cv(p1,p2); + typename K::Vector_3 v13 = cv(p1,p3); + typename K::Vector_3 v23 = cv(p2,p3); typename K::Vector_3 v_01_02 = cp(v01,v02); FT a_012 = v_01_02*v_01_02; diff --git a/Triangulation_2/doc/Triangulation_2/Concepts/RegularTriangulationTraits_2.h b/Triangulation_2/doc/Triangulation_2/Concepts/RegularTriangulationTraits_2.h index 6e8f02c1c40..d221b52dc55 100644 --- a/Triangulation_2/doc/Triangulation_2/Concepts/RegularTriangulationTraits_2.h +++ b/Triangulation_2/doc/Triangulation_2/Concepts/RegularTriangulationTraits_2.h @@ -37,8 +37,8 @@ Another name for the point type. typedef unspecified_type Bare_point; /*! -The weighted point type. It has to be -a model of the concept `Kernel::WeightedPoint_2`. +The weighted point type. It has to be a model of the concept `Kernel::WeightedPoint_2`, +and it must be implicitely convertible from and to `Bare_point`. */ typedef unspecified_type Weighted_point_2; diff --git a/Triangulation_2/test/Triangulation_2/test_regular_triangulation_2.cpp b/Triangulation_2/test/Triangulation_2/test_regular_triangulation_2.cpp index 24ae4ccdca7..665353e2cd5 100644 --- a/Triangulation_2/test/Triangulation_2/test_regular_triangulation_2.cpp +++ b/Triangulation_2/test/Triangulation_2/test_regular_triangulation_2.cpp @@ -29,19 +29,6 @@ #include -#if 0 -typedef CGAL::Simple_cartesian > K; - -int main() -{ - K::Weighted_point_2 wp(K::Point_2(7.8, 1),2); - std::cout << wp << std::endl; - std::cout << wp.x() << std::endl; - std::cout << K::Compute_x_2()(wp.point()) << std::endl; - return 0; -} - -#else typedef CGAL::Regular_triangulation_euclidean_traits_2 RGt; @@ -71,4 +58,4 @@ int main() std::cout << "done" << std::endl; return 0; } -#endif + diff --git a/Triangulation_3/doc/Triangulation_3/Concepts/RegularTriangulationTraits_3.h b/Triangulation_3/doc/Triangulation_3/Concepts/RegularTriangulationTraits_3.h index 03c4063b435..5a140be84ab 100644 --- a/Triangulation_3/doc/Triangulation_3/Concepts/RegularTriangulationTraits_3.h +++ b/Triangulation_3/doc/Triangulation_3/Concepts/RegularTriangulationTraits_3.h @@ -56,7 +56,8 @@ or the weighted point \f$ {p}^{(w)}=(p,w_p)\f$. /// @{ /*! -The weighted point type. +The weighted point type. It has to be a model of the concept `Kernel::WeightedPoint_3`, +and it must be implicitely convertible from and to `Bare_point`. */ typedef unspecified_type Weighted_point_3;