From 83f35c687c5654fcc5e52da5e9e9c903869d272c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 16 Oct 2018 15:46:40 +0200 Subject: [PATCH 001/203] WIP tests and compose() --- .../CGAL/Cartesian/Aff_transformation_2.h | 8 + .../CGAL/Cartesian/Aff_transformation_rep_2.h | 20 ++ .../include/CGAL/Cartesian/Reflection_rep_2.h | 207 ++++++++++++++++++ .../include/CGAL/Cartesian/Rotation_rep_2.h | 14 +- .../include/CGAL/Cartesian/Scaling_rep_2.h | 9 + .../CGAL/Cartesian/Translation_rep_2.h | 10 + .../doc/Kernel_23/CGAL/Aff_transformation_2.h | 10 + .../CGAL/_test_cls_aff_transformation_2.h | 44 +++- 8 files changed, 320 insertions(+), 2 deletions(-) create mode 100644 Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_2.h index e3c836b438c..de2c30bb680 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_2.h @@ -37,6 +37,7 @@ template < class R > class Aff_transformation_repC2; template < class R > class Translation_repC2; template < class R > class Rotation_repC2; template < class R > class Scaling_repC2; +template < class R > class Reflection_repC2; } //namespace CGAL @@ -44,6 +45,7 @@ template < class R > class Scaling_repC2; #include #include #include +#include namespace CGAL { @@ -107,6 +109,11 @@ public: else initialize_with(Scaling_repC2(s)); } + + Aff_transformationC2(const Reflection, const Line_2& l) + { + initialize_with(Reflection_repC2(l)); + } // The general case: // a 3x2 matrix for the operations combining rotation, scaling, translation @@ -128,6 +135,7 @@ public: { initialize_with(Aff_transformation_repC2(m11/w, m12/w, m21/w, m22/w)); } + Point_2 transform(const Point_2 &p) const diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h index 935f9135f4f..29ba0a2b713 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h @@ -63,6 +63,9 @@ public: virtual Aff_transformation_2 compose( const Scaling_repC2 &t) const = 0; + + virtual Aff_transformation_2 compose( + const Reflection_repC2 &t) const = 0; virtual Aff_transformation_2 inverse() const = 0; virtual bool is_even() const = 0; @@ -86,6 +89,7 @@ public: friend class Translation_repC2; friend class Rotation_repC2; friend class Scaling_repC2; +friend class Reflection_repC2; Aff_transformation_repC2() {} @@ -131,6 +135,7 @@ friend class Scaling_repC2; Aff_transformation_2 compose(const Translation_repC2 &t) const; Aff_transformation_2 compose(const Rotation_repC2 &t) const; Aff_transformation_2 compose(const Scaling_repC2 &t) const; + Aff_transformation_2 compose(const Reflection_repC2 &t) const; bool is_even() const { @@ -252,6 +257,21 @@ compose(const Scaling_repC2 &t) const t.scalefactor_ * t23); } +template < class R > +CGAL_KERNEL_LARGE_INLINE +typename Aff_transformation_repC2::Aff_transformation_2 +Aff_transformation_repC2:: +compose(const Reflection_repC2 &r) const +{ + return Aff_transformation_2( + t11*r.cosinus_+t12*r.sinus_, + t11*r.sinus_-t12*r.cosinus_, + t11*r.t13()+t12*r.t23()+t13, + t21*r.cosinus_+t22*r.sinus_, + t21*r.sinus_-t22*r.cosinus_, + t21*r.t13()+t22*r.t23()+t23); +} + } //namespace CGAL #endif // CGAL_CARTESIAN_AFF_TRANSFORMATION_REP_2_H diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h new file mode 100644 index 00000000000..5b9dcf3bcac --- /dev/null +++ b/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h @@ -0,0 +1,207 @@ +// Copyright (c) 2018 +// 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 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$ +// SPDX-License-Identifier: LGPL-3.0+ +// +// +// Author(s) : Maxime Gimeno + +#ifndef CGAL_CARTESIAN_REFLECTION_REP_2_H +#define CGAL_CARTESIAN_REFLECTION_REP_2_H +#include +namespace CGAL { + +template < class R > +class Reflection_repC2: public Aff_transformation_rep_baseC2 +{ + friend class Translation_repC2; + friend class Rotation_repC2; + friend class Scaling_repC2; + friend class Aff_transformation_repC2; + friend class Reflection_repC2; + +public: + typedef Aff_transformation_rep_baseC2 Aff_t_base; + typedef typename Aff_t_base::FT FT; + typedef typename Aff_t_base::Point_2 Point_2; + typedef typename Aff_t_base::Vector_2 Vector_2; + typedef typename Aff_t_base::Direction_2 Direction_2; +typedef typename CGAL::Line_2 Line_2; + typedef typename Aff_t_base::Aff_transformation_2 Aff_transformation_2; + typedef Aff_transformation_repC2 Transformation; + typedef Reflection_repC2 Reflection; + typedef Scaling_repC2 Scaling; + typedef Rotation_repC2 Rotation; + typedef Translation_repC2 Translation; + + Reflection_repC2(const Line_2 &l) : + line(l) + { + if(l.a() == 0) + t = -Vector_2(0, l.c()/l.b()); + else + t = -Vector_2(l.c()/l.a(),0); + + Vector_2 l_to_v = l.to_vector(), + Ox = Vector_2(1,0); + FT scal = l_to_v * Ox; //= |L|*cos(a) + FT det = l_to_v.y();// = |L|*sin(a) + sinus_ = 2*det*scal/l_to_v.squared_length(); //sin(2a) = 2*sin(a)*cos(a) + FT sq_cos = scal*scal/l_to_v.squared_length(); //cos(a)*cos(a) + cosinus_ = 2*sq_cos-1; + } + + ~Reflection_repC2() + {} + + Point_2 transform(const Point_2 &p) const + { + return Point_2( + cosinus_*p.x()+sinus_*p.y()-cosinus_*t.x()-sinus_*t.y()+t.x(), + sinus_*p.x()-cosinus_*p.y()-sinus_*t.x()+cosinus_*t.y()+t.y()); + } + + Vector_2 transform(const Vector_2 &p) const + { + return Vector_2( + cosinus_*p.x()+sinus_*p.y()-cosinus_*t.x()-sinus_*t.y()+t.x(), + sinus_*p.x()-cosinus_*p.y()-sinus_*t.x()+cosinus_*t.y()+t.y()); + } + + Direction_2 transform(const Direction_2 &d) const + { + + return transform(d.vector()).direction(); + } + + Aff_transformation_2 operator*(const Aff_t_base &t) const + { + return t.compose(*this); + } + + Aff_transformation_2 compose(const Translation &tr) const + { + return Aff_transformation_2(cosinus_, sinus_, t13()+tr.translationvector_.x(), + sinus_, -cosinus_, t23()+tr.translationvector_.y()); + } + + Aff_transformation_2 compose(const Scaling &s) const + { + return Aff_transformation_2(s.scalefactor_ * cosinus_, + s.scalefactor_ * sinus_, + s.scalefactor_ * t13(), + s.scalefactor_ * sinus_, + -s.scalefactor_ * cosinus_, + s.scalefactor_ * t23()); + } + + Aff_transformation_2 compose(const Transformation &tr) const + { + return Aff_transformation_2( + cosinus_*tr.t11+sinus_*tr.t21, cosinus_*tr.t12+sinus_*tr.t22, cosinus_*(tr.t13-t.x())+sinus_*(tr.t23-t.y())+t.x(), + sinus_*(tr.t11)-cosinus_*(tr.t21), sinus_*(tr.t12)-cosinus_*(tr.t22), sinus_*(tr.t13-t.x())-cosinus_*(tr.t23-t.y())+t.y()); + } + + Aff_transformation_2 compose(const Rotation &r) const + { + return Aff_transformation_2( + r.cosinus_*cosinus_-r.sinus_*sinus_, + r.cosinus_*sinus_+r.sinus_*cosinus_, + r.cosinus_*t13() + -r.sinus_*t23(), + r.sinus_*cosinus_+r.cosinus_*sinus_, + r.sinus_*sinus_-r.cosinus_*cosinus_, + r.sinus_*t13() + +r.cosinus_*t23()); + } + + Aff_transformation_2 compose(const Reflection &r) const + { + return Aff_transformation_2( + cosinus_*r.cosinus_+sinus_*r.sinus_, + cosinus_*r.sinus_-r.cosinus_*sinus_, + sinus_*(-r.cosinus_*r.t.x()-r.sinus_*r.t.y()+r.t.x()-t.x())-cosinus_*(-r.sinus_*r.t.x()+r.cosinus_*r.t.y()+r.t.y()-t.y()) + t.x(), + sinus_*r.cosinus_-cosinus_*r.sinus_, + sinus_*r.sinus_+cosinus_*r.cosinus_, + sinus_*(-r.cosinus_*r.t.x()-r.sinus_*r.t.y()+r.t.x()-t.x())-cosinus_*(-r.sinus_*r.t.x()+r.cosinus_*r.t.y()+r.t.y()-t.y())+t.y() + ); + } + + Aff_transformation_2 inverse() const + { + return Aff_transformation_2(REFLECTION, line); + } + + bool is_even() const + { + return true; + } + + FT cartesian(int i, int j) const + { + switch (i) + { + case 0: switch (j) + { + case 0: return cosinus_; + case 1: return sinus_; + default: return FT(0); + } + case 1: switch (j) + { + case 0: return sinus_; + case 1: return -cosinus_; + default: return FT(0); + } + case 2: switch (j) + { + case 0: return FT(0); + case 1: return FT(0); + default: return FT(1); + } + } + return FT(0); + } + + std::ostream &print(std::ostream &os) const + { + os << "Aff_transformationC2(" << sinus_ << ", " << cosinus_ << "; "<< t <<")"; + return os; + } + + //convevience functions for composition + FT t13()const + { + return FT(-cosinus_*t.x()-sinus_*t.y()+t.x()); + } + FT t23()const + { + return FT(-sinus_*t.x()+cosinus_*t.y()+t.y()); + } + +private: + const Line_2& line; + Vector_2 t; + FT sinus_, cosinus_; +}; + +} //namespace CGAL + +#endif // CGAL_CARTESIAN_REFLECTION_REP_2_H diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Rotation_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Rotation_rep_2.h index cf876f8511e..439d66f0139 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Rotation_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Rotation_rep_2.h @@ -36,6 +36,7 @@ class Rotation_repC2: public Aff_transformation_rep_baseC2 friend class Aff_transformation_repC2; friend class Translation_repC2; friend class Scaling_repC2; +friend class Reflection_repC2; public: typedef Aff_transformation_rep_baseC2 Aff_t_base; @@ -48,6 +49,7 @@ public: typedef Translation_repC2 Translation; typedef Rotation_repC2 Rotation; typedef Scaling_repC2 Scaling; + typedef Reflection_repC2 Reflection; Rotation_repC2() {} @@ -126,6 +128,17 @@ public: t.scalefactor_*cosinus_); } + Aff_transformation_2 compose(const Reflection &r) const + { + return Aff_transformation_2( + r.cosinus_*cosinus_+r.sinus_*sinus_, + -r.cosinus_*sinus_+r.sinus_*cosinus_, + r.t13(), + r.sinus_*cosinus_-r.cosinus_*sinus_, + -r.sinus_*sinus_-r.cosinus_*cosinus_ + , r.t23()); + } + Aff_transformation_2 compose(const Transformation &t) const { return Aff_transformation_2(cosinus_*t.t11 + sinus_*t.t12, @@ -135,7 +148,6 @@ public: -sinus_*t.t21 + cosinus_*t.t22, t.t23); } - bool is_even() const { return true; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h index d98313e689f..98060af73e4 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h @@ -34,6 +34,7 @@ class Scaling_repC2: public Aff_transformation_rep_baseC2 friend class Aff_transformation_repC2; friend class Translation_repC2; friend class Rotation_repC2; +friend class Reflection_repC2; public: typedef Aff_transformation_rep_baseC2 Aff_t_base; @@ -45,6 +46,7 @@ public: typedef Aff_transformation_repC2 Transformation; typedef Translation_repC2 Translation; typedef Rotation_repC2 Rotation; + typedef Reflection_repC2 Reflection; typedef Scaling_repC2 Scaling; Scaling_repC2() @@ -96,6 +98,13 @@ public: scalefactor_ * t.cosinus_); } + Aff_transformation_2 compose(const Reflection &r) const + { + FT ft0(0); + return Aff_transformation_2(scalefactor_*r.cosinus_, scalefactor_*r.sinus_,-r.cosinus_*r.t.x()-r.sinus_*r.t.y()+r.t.x(), + scalefactor_*r.sinus_, -scalefactor_*r.cosinus_, -r.sinus_*r.t.x()+r.cosinus_*r.t.y()-r.t.y()); + } + Aff_transformation_2 compose(const Scaling &t) const { return Aff_transformation_2(SCALING, scalefactor_*t.scalefactor_); diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_2.h index 9bab526c7be..4b1fc030fa3 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_2.h @@ -36,6 +36,7 @@ class Translation_repC2 : public Aff_transformation_rep_baseC2 friend class Aff_transformation_repC2; friend class Rotation_repC2; friend class Scaling_repC2; +friend class Reflection_repC2; public: typedef typename R::FT FT; @@ -43,6 +44,7 @@ public: typedef Aff_transformation_repC2 Transformation; typedef Translation_repC2 Translation; typedef Rotation_repC2 Rotation; + typedef Reflection_repC2 Reflection; typedef Scaling_repC2 Scaling; typedef typename Aff_t_base::Point_2 Point_2; typedef typename Aff_t_base::Vector_2 Vector_2; @@ -114,6 +116,14 @@ public: + t.t22*translationvector_.y() + t.t23); } + + Aff_transformation_2 compose(const Reflection &r) const + { + return Aff_transformation_2(r.cosinus_, r.sinus_, + r.cosinus_*(translationvector_.x()-r.t.x())+r.sinus_*(translationvector_.y() - r.t.y()) +r.t.x(), + r.sinus_, -r.cosinus_, + r.sinus_*(translationvector_.x()-r.t.x())-r.cosinus_*(translationvector_.y() - r.t.y())+r.t.y()); + } Aff_transformation_2 inverse() const { diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h index 7e888aa8b1a..16ef907a0ef 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h @@ -38,6 +38,7 @@ therefore do not appear in the constructors. \sa `Rotation` \sa `Scaling` \sa `Translation` +\sa `Reflection` \sa `rational_rotation_approximation_grp` \cgalHeading{Example} @@ -127,6 +128,15 @@ Aff_transformation_2(const Scaling, const Kernel::RT &s, const Kernel::RT &hw = RT(1)); +/*! +introduces a reflection by a line `l`. +\attention Angles manipulation restrain this operation to FTs for which sqrt is defined. + +\todo find a better formulation +*/ +Aff_transformation_2(const Reflection, +const Line_2& l); + /*! introduces a general affine transformation in the \f$3 \times 3\f$ matrix form diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h index 23aff3a4c96..8c8459f03b8 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h @@ -116,7 +116,7 @@ _test_cls_aff_transformation_2(const R& ) CGAL::Aff_transformation_2 xrefl(-n4, n0, n0, n0, n4, n0, n4 ); - + CGAL::Aff_transformation_2 gat4( gat3); CGAL::Aff_transformation_2 gat5( n7, n9, @@ -551,6 +551,7 @@ _test_cls_aff_transformation_2(const R& ) assert( FT( ident.hm(2,1) ) / FT( ident.hm(2,2) ) == FTzero ); assert( FT( ident.hm(2,2) ) / FT( ident.hm(2,2) ) == FTone ); + // samples // cartesian == m assert( gat1.cartesian(1,2) == gat1.m(1,2) ); @@ -577,6 +578,47 @@ _test_cls_aff_transformation_2(const R& ) assert( ident.homogeneous(1,2) == ident.hm(1,2) ); assert( gscale.homogeneous(1,1) == gscale.hm(1,1) ); + //tests for reflection + CGAL::Aff_transformation_2 refl(CGAL::REFLECTION, CGAL::Line_2( + CGAL::Point_2(1,3), + CGAL::Point_2(2,1))); + CGAL::Point_2 p(4,2); + assert(p.transform(refl) == CGAL::Point_2(0,0)); + + + //with translation + CGAL::Aff_transformation_2 trans(CGAL::TRANSLATION, CGAL::Vector_2(1,-2)); + CGAL::Aff_transformation_2 comp1(refl*trans), + comp2(trans*refl); + p1 = p.transform(trans); + p1 = p1.transform(refl); + assert(p1 == CGAL::Point_2(1,-2)); + assert(p1 == p.transform(comp1)); + p1 = p.transform(refl); + p1 = p1.transform(trans); + assert(p1 == p.transform(comp2)); + //with scaling + CGAL::Aff_transformation_2 scal(CGAL::SCALING, 2); + comp1 = refl*scal; + comp2 = scal*refl; + p1 = p.transform(scal); + p1 = p1.transform(refl); + assert(p1 == p.transform(comp1)); + p1 = p.transform(refl); + p1 = p1.transform(scal); + assert(p1 == p.transform(comp2)); + //with rotation + CGAL::Aff_transformation_2 rot(CGAL::ROTATION, 1, 0); + comp1 = refl*rot; + comp2 = rot*refl; + p1 = p.transform(rot); + p1 = p1.transform(refl); + assert(p1 == p.transform(comp1)); + p1 = p.transform(refl); + p1 = p1.transform(rot); + assert(p1 == p.transform(comp2)); + //with reflection + //with transformation std::cout << "done" << std::endl; return true; } From 33b7172715cb728918dcd8b809592b429393f865 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 16 Oct 2018 16:57:57 +0200 Subject: [PATCH 002/203] Fix homogeneous code --- .../CGAL/Cartesian/Aff_transformation_rep_2.h | 10 +++------- .../include/CGAL/Cartesian/Reflection_rep_2.h | 20 +++++++++++-------- .../CGAL/Homogeneous/Aff_transformationH2.h | 6 ++---- .../CGAL/_test_cls_aff_transformation_2.h | 20 +++++++++++++++++++ 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h index 29ba0a2b713..5a723f8ca5d 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h @@ -263,13 +263,9 @@ typename Aff_transformation_repC2::Aff_transformation_2 Aff_transformation_repC2:: compose(const Reflection_repC2 &r) const { - return Aff_transformation_2( - t11*r.cosinus_+t12*r.sinus_, - t11*r.sinus_-t12*r.cosinus_, - t11*r.t13()+t12*r.t23()+t13, - t21*r.cosinus_+t22*r.sinus_, - t21*r.sinus_-t22*r.cosinus_, - t21*r.t13()+t22*r.t23()+t23); + return Aff_transformation_2( + r.cosinus_*t11+r.sinus_*t21, r.cosinus_*t12+r.sinus_*t22, r.cosinus_*(t13-r.t.x())+r.sinus_*(t23-r.t.y())+r.t.x(), + r.sinus_*(t11)-r.cosinus_*(t21), r.sinus_*(t12)-r.cosinus_*(t22), r.sinus_*(t13-r.t.x())-r.cosinus_*(t23-r.t.y())+r.t.y()); } } //namespace CGAL diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h index 5b9dcf3bcac..9561eed7ded 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h @@ -115,8 +115,12 @@ typedef typename CGAL::Line_2 Line_2; Aff_transformation_2 compose(const Transformation &tr) const { return Aff_transformation_2( - cosinus_*tr.t11+sinus_*tr.t21, cosinus_*tr.t12+sinus_*tr.t22, cosinus_*(tr.t13-t.x())+sinus_*(tr.t23-t.y())+t.x(), - sinus_*(tr.t11)-cosinus_*(tr.t21), sinus_*(tr.t12)-cosinus_*(tr.t22), sinus_*(tr.t13-t.x())-cosinus_*(tr.t23-t.y())+t.y()); + tr.t11*cosinus_+tr.t12*sinus_, + tr.t11*sinus_-tr.t12*cosinus_, + tr.t11*t13()+tr.t12*t23()+tr.t13, + tr.t21*cosinus_+tr.t22*sinus_, + tr.t21*sinus_-tr.t22*cosinus_, + tr.t21*t13()+tr.t22*t23()+tr.t23); } Aff_transformation_2 compose(const Rotation &r) const @@ -136,12 +140,12 @@ typedef typename CGAL::Line_2 Line_2; { return Aff_transformation_2( cosinus_*r.cosinus_+sinus_*r.sinus_, - cosinus_*r.sinus_-r.cosinus_*sinus_, - sinus_*(-r.cosinus_*r.t.x()-r.sinus_*r.t.y()+r.t.x()-t.x())-cosinus_*(-r.sinus_*r.t.x()+r.cosinus_*r.t.y()+r.t.y()-t.y()) + t.x(), - sinus_*r.cosinus_-cosinus_*r.sinus_, - sinus_*r.sinus_+cosinus_*r.cosinus_, - sinus_*(-r.cosinus_*r.t.x()-r.sinus_*r.t.y()+r.t.x()-t.x())-cosinus_*(-r.sinus_*r.t.x()+r.cosinus_*r.t.y()+r.t.y()-t.y())+t.y() - ); + r.cosinus_*sinus_-r.sinus_*cosinus_, + r.cosinus_*(t13()-r.t.x()) + r.sinus_*(t23()-r.t.y())+r.t.x(), + + r.sinus_*cosinus_ - r.cosinus_*sinus_, + r.sinus_*sinus_+r.cosinus_*cosinus_, + r.sinus_*(t13()-r.t.x()) -r.cosinus_*(t23()-r.t.y())+r.t.y()); } Aff_transformation_2 inverse() const diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH2.h index c14000e1b02..35b30d14941 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH2.h @@ -453,14 +453,12 @@ class Reflection_repH2 : public Aff_transformation_rep_baseH2 virtual Direction_2 transform(const Direction_2 & d) const - { return transform( Vector_2(d) ).direction(); } + { return transform( d.vector() ).direction(); } virtual Aff_transformationH2 inverse() const { - return Aff_transformationH2( - static_cast< Aff_transformation_rep_baseH2* > - ( const_cast< Reflection_repH2*> (this) ) ); + return Aff_transformationH2(REFLECTION, l); } virtual bool diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h index 8c8459f03b8..4fe856c0cdb 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h @@ -618,7 +618,27 @@ _test_cls_aff_transformation_2(const R& ) p1 = p1.transform(rot); assert(p1 == p.transform(comp2)); //with reflection + CGAL::Aff_transformation_2 refl2(CGAL::REFLECTION, CGAL::Line_2( + CGAL::Point_2(0,0), + CGAL::Point_2(1,1))); + comp1 = refl*refl2; + comp2 = refl2*refl; + p1 = p.transform(refl2); + p1 = p1.transform(refl); + assert(p1 == p.transform(comp1)); + p1 = p.transform(refl); + p1 = p1.transform(refl2); + assert(p1 == p.transform(comp2)); //with transformation + CGAL::Aff_transformation_2 afft(1,2,3,4,5,6); + comp1 = refl*afft; + comp2 = afft*refl; + p1 = p.transform(afft); + p1 = p1.transform(refl); + assert(p1 == p.transform(comp1)); + p1 = p.transform(refl); + p1 = p1.transform(afft); + assert(p1 == p.transform(comp2)); std::cout << "done" << std::endl; return true; } From a6e610c8bcbcc3484a2a0009a65d457af3bdff73 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 17 Oct 2018 09:18:52 +0200 Subject: [PATCH 003/203] Remove warning about sqrt in the doc, it is not true anymore. --- Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h index 16ef907a0ef..f07ab398a22 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h @@ -130,9 +130,6 @@ const Kernel::RT &hw = RT(1)); /*! introduces a reflection by a line `l`. -\attention Angles manipulation restrain this operation to FTs for which sqrt is defined. - -\todo find a better formulation */ Aff_transformation_2(const Reflection, const Line_2& l); From 571e87b751d77b951b0e2cec703388535151ec1b Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 17 Oct 2018 12:17:50 +0200 Subject: [PATCH 004/203] Enhancements --- .../include/CGAL/Cartesian/Reflection_rep_2.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h index 9561eed7ded..71e209f60be 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h @@ -51,17 +51,15 @@ typedef typename CGAL::Line_2 Line_2; typedef Rotation_repC2 Rotation; typedef Translation_repC2 Translation; - Reflection_repC2(const Line_2 &l) : - line(l) + Reflection_repC2(const Line_2 &l) { if(l.a() == 0) t = -Vector_2(0, l.c()/l.b()); else t = -Vector_2(l.c()/l.a(),0); - Vector_2 l_to_v = l.to_vector(), - Ox = Vector_2(1,0); - FT scal = l_to_v * Ox; //= |L|*cos(a) + Vector_2 l_to_v = l.to_vector(); + FT scal = l_to_v.x(); //Projection of l_to_v on Ox. = |L|*cos(a) FT det = l_to_v.y();// = |L|*sin(a) sinus_ = 2*det*scal/l_to_v.squared_length(); //sin(2a) = 2*sin(a)*cos(a) FT sq_cos = scal*scal/l_to_v.squared_length(); //cos(a)*cos(a) @@ -150,7 +148,8 @@ typedef typename CGAL::Line_2 Line_2; Aff_transformation_2 inverse() const { - return Aff_transformation_2(REFLECTION, line); + return Aff_transformation_2(cartesian(0,0), cartesian(0,1), cartesian(0,2), + cartesian(1,0), cartesian(1,1), cartesian(1,2)); } bool is_even() const @@ -201,7 +200,6 @@ typedef typename CGAL::Line_2 Line_2; } private: - const Line_2& line; Vector_2 t; FT sinus_, cosinus_; }; From 83ebc55607fbdadb325d2f90c4c56f07b8c75831 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 14 Jan 2019 09:41:28 +0100 Subject: [PATCH 005/203] Don't make CGAL::Reflection_repC2 friend with itself. --- Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h index 71e209f60be..33cc545a354 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h @@ -35,7 +35,6 @@ class Reflection_repC2: public Aff_transformation_rep_baseC2 friend class Rotation_repC2; friend class Scaling_repC2; friend class Aff_transformation_repC2; - friend class Reflection_repC2; public: typedef Aff_transformation_rep_baseC2 Aff_t_base; From f9ff07de8141e834d5665bee6228b6381b8b9e79 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 15 Jan 2019 09:01:31 +0100 Subject: [PATCH 006/203] Fix warning --- Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h index 98060af73e4..6eeb72323e9 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h @@ -100,7 +100,6 @@ public: Aff_transformation_2 compose(const Reflection &r) const { - FT ft0(0); return Aff_transformation_2(scalefactor_*r.cosinus_, scalefactor_*r.sinus_,-r.cosinus_*r.t.x()-r.sinus_*r.t.y()+r.t.x(), scalefactor_*r.sinus_, -scalefactor_*r.cosinus_, -r.sinus_*r.t.x()+r.cosinus_*r.t.y()-r.t.y()); } From 07566226a3e6b1e7f17b12914b8924540ea6aca1 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 27 Jan 2019 12:17:45 +0100 Subject: [PATCH 007/203] Drop unused template parameter from Lazy. --- Filtered_kernel/include/CGAL/Lazy.h | 62 ++++++++++------------ Filtered_kernel/include/CGAL/Lazy_kernel.h | 2 +- Number_types/include/CGAL/Lazy_exact_nt.h | 4 +- 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index c54296e8767..09588df9988 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -61,42 +61,42 @@ template class Lazy_kernel_base; -template class Lazy; +template class Lazy; template class Lazy_exact_nt; -template +template inline const AT& -approx(const Lazy& l) +approx(const Lazy& l) { return l.approx(); } // Where is this one (non-const) needed ? Is it ? -template +template inline AT& -approx(Lazy& l) +approx(Lazy& l) { return l.approx(); } -template +template inline const ET& -exact(const Lazy& l) +exact(const Lazy& l) { return l.exact(); } -template +template inline unsigned -depth(const Lazy& l) +depth(const Lazy& l) { return l.depth(); } @@ -158,10 +158,10 @@ print_at(std::ostream& os, const std::pair & at) } -template +template inline void -print_dag(const Lazy& l, std::ostream& os, int level = 0) +print_dag(const Lazy& l, std::ostream& os, int level = 0) { l.print_dag(os, level); } @@ -723,7 +723,7 @@ public: //____________________________________________________________ // The handle class -template +template class Lazy : public Handle { template Self; + typedef Lazy Self; typedef Lazy_rep Self_rep; typedef AT_ AT; // undocumented @@ -1098,7 +1098,7 @@ public: // In a first version we assume that the references are of type Lazy, // and that the result type is void -template +template struct Lazy_functor_2_1 { static const bool Protection = true; @@ -1166,7 +1166,6 @@ struct Lazy_functor_2_2 typedef void result_type; typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; typedef typename LK::E2A E2A; AC ac; @@ -1178,12 +1177,12 @@ public: void operator()(const L1& l1, const L2& l2, R1& r1, R2& r2) const { - typedef Lazy Handle_1; - typedef Lazy Handle_2; + typedef Lazy Handle_1; + typedef Lazy Handle_2; CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - typedef Lazy, std::pair, EFT, E2A> Lazy_pair; + typedef Lazy, std::pair, E2A> Lazy_pair; Lazy_pair lv(new Lazy_rep_2_2(ac, ec, l1, l2)); // lv->approx() is a std::pair; r1 = R1(Handle_1(new Lazy_rep_1 >, First >, E2A, Lazy_pair>(First >(), First >(), lv))); @@ -1208,11 +1207,10 @@ struct Lazy_intersect_with_iterators static const bool Protection = true; typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; typedef typename LK::E2A E2A; typedef void result_type; - typedef Lazy Lazy_object; - typedef Lazy, std::vector, EFT, E2A> Lazy_vector; + typedef Lazy Lazy_object; + typedef Lazy, std::vector, E2A> Lazy_vector; AC ac; EC ec; @@ -1287,13 +1285,12 @@ struct Lazy_construction_object typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; typedef typename LK::E2A E2A; typedef typename AC::result_type AT; typedef typename EC::result_type ET; typedef Object result_type; - typedef Lazy Lazy_object; + typedef Lazy Lazy_object; AC ac; EC ec; @@ -1535,7 +1532,6 @@ struct Lazy_construction_variant { typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; typedef typename LK::E2A E2A; @@ -1569,7 +1565,7 @@ struct Lazy_construction_variant { Protect_FPU_rounding P; try { - Lazy lazy(new Lazy_rep_2(AC(), EC(), l1, l2)); + Lazy lazy(new Lazy_rep_2(AC(), EC(), l1, l2)); // the approximate result requires the trait with types from the AK AT approx_v = lazy.approx(); @@ -1582,7 +1578,7 @@ struct Lazy_construction_variant { } // the static visitor fills the result_type with the correct unwrapped type - internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy > visitor(res, lazy); + internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy > visitor(res, lazy); boost::apply_visitor(visitor, *approx_v); return res; @@ -1618,7 +1614,7 @@ struct Lazy_construction_variant { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - Lazy lazy(new Lazy_rep_3(AC(), EC(), l1, l2, l3)); + Lazy lazy(new Lazy_rep_3(AC(), EC(), l1, l2, l3)); // the approximate result requires the trait with types from the AK AT approx_v = lazy.approx(); @@ -1631,7 +1627,7 @@ struct Lazy_construction_variant { } // the static visitor fills the result_type with the correct unwrapped type - internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy > visitor(res, lazy); + internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy > visitor(res, lazy); boost::apply_visitor(visitor, *approx_v); return res; @@ -1670,7 +1666,6 @@ struct Lazy_construction { typedef typename boost::remove_cv< typename boost::remove_reference < typename EC::result_type >::type >::type ET; - typedef typename EK::FT EFT; typedef typename Default::Get::type E2A; typedef typename Type_mapper::type result_type; @@ -1682,7 +1677,7 @@ struct Lazy_construction { template \ result_type \ operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \ - typedef Lazy< AT, ET, EFT, E2A> Handle; \ + typedef Lazy< AT, ET, E2A> Handle; \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ Protect_FPU_rounding P; \ try { \ @@ -1701,7 +1696,7 @@ struct Lazy_construction { result_type operator()() const { - typedef Lazy Handle; + typedef Lazy Handle; return result_type( Handle(new Lazy_rep_0()) ); } @@ -1717,7 +1712,6 @@ struct Lazy_construction typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; typedef typename Default::Get::type E2A; template @@ -1749,7 +1743,7 @@ struct result { \ typename cpp11::result_of< EC(BOOST_PP_ENUM_PARAMS(n, E)) >::type >::type >::type ET; \ typedef typename boost::remove_cv< typename boost::remove_reference < \ typename cpp11::result_of< AC(BOOST_PP_ENUM_PARAMS(n, A)) >::type >::type >::type AT; \ - typedef Lazy< AT, ET, EFT, E2A> Handle; \ + typedef Lazy< AT, ET, E2A> Handle; \ typedef typename cpp11::result_of::type result_type; \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ Protect_FPU_rounding P; \ @@ -1771,7 +1765,7 @@ struct result { \ { typedef typename cpp11::result_of::type AT; typedef typename cpp11::result_of::type ET; - typedef Lazy Handle; + typedef Lazy Handle; typedef typename Type_mapper< typename cpp11::result_of::type ,AK, LK>::type result_type; return result_type( Handle(new Lazy_rep_0()) ); diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 2639a9f7027..90e18354df0 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -164,7 +164,7 @@ public: typedef CGAL::Object Object_3; #define CGAL_Kernel_obj(X) \ - typedef Lazy X; + typedef Lazy X; CGAL_Kernel_obj(Data_accessor_2) CGAL_Kernel_obj(Conic_2) diff --git a/Number_types/include/CGAL/Lazy_exact_nt.h b/Number_types/include/CGAL/Lazy_exact_nt.h index d1ffc105ccf..a71fb9328ab 100644 --- a/Number_types/include/CGAL/Lazy_exact_nt.h +++ b/Number_types/include/CGAL/Lazy_exact_nt.h @@ -344,14 +344,14 @@ struct Lazy_exact_Max : public Lazy_exact_binary // The real number type, handle class template class Lazy_exact_nt - : public Lazy, ET_, Lazy_exact_nt, To_interval > + : public Lazy, ET_, To_interval > , boost::ordered_euclidian_ring_operators2< Lazy_exact_nt, int > , boost::ordered_euclidian_ring_operators2< Lazy_exact_nt, double > { public: typedef Lazy_exact_nt Self; - typedef Lazy, ET_, Self, To_interval > Base; + typedef Lazy, ET_, To_interval > Base; typedef typename Base::Self_rep Self_rep; typedef typename Base::ET ET; // undocumented From cbddd4575a1abc44015623c25f7abdaa0aa53392 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 27 Jan 2019 15:16:38 +0100 Subject: [PATCH 008/203] One more occurence of Lazy this code is not used (unfinished), but it still gets included in the test, probably so it doesn't bitrot too fast. --- NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h | 1 - 1 file changed, 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index bce1522a0fe..4ae80544fcf 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -79,7 +79,6 @@ struct Lazy_cartesian_types typedef Lazy< typename Get_type::type, typename Get_type::type, - typename Get_type::type, E2A_> type; }; template struct Type { From 34cbb9cd4b920dc4ba0486ae97f0b71f49a2d3ab Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 3 Feb 2019 23:16:28 +0100 Subject: [PATCH 009/203] Make Epeck_d work & C++14-only cleanups Still some rough edges: 1) double tab[]={.1,.2,.3}; Point_d p(tab+0,tab+3); lazily stores iterators to tab, so tab had better still be alive when we need update_exact. 2) One functor (point on a sphere) cannot be done exactly exactly with a representation center+squared radius. 3) Several hacks that make this not as generic as it should be. --- Filtered_kernel/include/CGAL/Lazy.h | 264 +++++++----------- Filtered_kernel/include/CGAL/Lazy_kernel.h | 12 +- Installation/include/CGAL/config.h | 6 + NewKernel_d/include/CGAL/Epeck_d.h | 17 +- .../CGAL/NewKernel_d/Cartesian_LA_base.h | 1 + .../include/CGAL/NewKernel_d/Coaffine.h | 6 + .../CGAL/NewKernel_d/Kernel_d_interface.h | 19 +- .../NewKernel_d/Kernel_object_converter.h | 12 + .../include/CGAL/NewKernel_d/Lazy_cartesian.h | 129 ++++++++- .../CGAL/NewKernel_d/Types/Hyperplane.h | 1 + .../include/CGAL/NewKernel_d/Types/Sphere.h | 1 + .../CGAL/NewKernel_d/Types/Weighted_point.h | 1 + .../include/CGAL/NewKernel_d/Vector/array.h | 2 + .../include/CGAL/NewKernel_d/Vector/mix.h | 1 + .../CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h | 3 +- .../CGAL/NewKernel_d/Wrapper/Point_d.h | 7 + .../NewKernel_d/function_objects_cartesian.h | 2 +- .../include/CGAL/iterator_from_indices.h | 3 +- NewKernel_d/test/NewKernel_d/Epick_d.cpp | 17 +- 19 files changed, 296 insertions(+), 208 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 09588df9988..58a6c67f42e 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -107,27 +109,27 @@ depth(const Lazy& l) inline const T & exact (const T& d) { return d; } \ inline unsigned depth (const T& ) { return 0; } - -CGAL_LAZY_FORWARD(long double) -CGAL_LAZY_FORWARD(double) -CGAL_LAZY_FORWARD(float) -CGAL_LAZY_FORWARD(int) -CGAL_LAZY_FORWARD(unsigned int) -CGAL_LAZY_FORWARD(long) -CGAL_LAZY_FORWARD(unsigned long) -#ifdef CGAL_USE_LONG_LONG -CGAL_LAZY_FORWARD(long long) -CGAL_LAZY_FORWARD(unsigned long long) -#endif -CGAL_LAZY_FORWARD(Return_base_tag) -CGAL_LAZY_FORWARD(Null_vector) -CGAL_LAZY_FORWARD(Origin) -CGAL_LAZY_FORWARD(Orientation) CGAL_LAZY_FORWARD(Bbox_2) CGAL_LAZY_FORWARD(Bbox_3) - #undef CGAL_LAZY_FORWARD +templateinline std::enable_if_t::value||std::is_enum::value, T> approx(T d){return d;} +templateinline std::enable_if_t::value||std::is_enum::value, T> exact (T d){return d;} +templateinline std::enable_if_t::value||std::is_enum::value, unsigned> depth(T){return 0;} + +// For tag classes: Return_base_tag, Homogeneous_tag, Null_vector, Origin +templateinline std::enable_if_t::value, T> exact(T){return {};} +templateinline std::enable_if_t::value, T> approx(T){return {};} +templateinline std::enable_if_t::value, unsigned> depth(T){return 0;} + +// For an iterator, exact/approx applies to the objects it points to +template ::value>> +auto exact(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::exact(u);});} +template ::value>> +auto approx(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::approx(u);});} +template ::value>> +unsigned depth(T const& t) {return 1;} // FIXME: depth(*t) would be better when t is valid, but not for end iterators, and the true answer would iterate on the range, but we can't do that with only one iterator... We need to replace iterators with ranges to solve that. + #ifdef CGAL_LAZY_KERNEL_DEBUG template void @@ -311,6 +313,51 @@ public: }; +template +class Lazy_rep_n : + public Lazy_rep< AT, ET, E2A >, private EC +{ + // Lazy_rep_0 does not inherit from EC or take a parameter AC. It has different constructors. + static_assert(sizeof...(L)>0, "Use Lazy_rep_0 instead"); + template friend class Lazy_kernel_base; + mutable std::tuple l; // L...l; is not yet allowed. + const EC& ec() const { return *this; } + template + void update_exact_helper(std::index_sequence) const { + this->et = new ET(ec()( CGAL::exact( std::get(l) ) ... ) ); + this->at = E2A()(*(this->et)); + l = std::tuple{}; + } + public: + void update_exact() const { + update_exact_helper(std::make_index_sequence{}); + } + Lazy_rep_n(const AC& ac, const EC& ec, L const&...ll) : + Lazy_rep(ac(CGAL::approx(ll)...)), EC(ec), l(ll...) + { + this->set_depth(std::max({ -1, (int)CGAL::depth(ll)...}) + 1); + } +#ifdef CGAL_LAZY_KERNEL_DEBUG + private: + template + void print_dag_helper(std::ostream& os, int level, std::index_sequence) const { + this->print_at_et(os, level); + if(this->is_lazy()){ +# ifdef CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID + CGAL::msg(os, level, typeid(AC).name()); +# endif + CGAL::msg(os, level, "DAG with " "3" " child nodes:"); + using expander = int[]; + expander{0,(CGAL::print_dag(std::get(l), os, level+1),0)...}; + } + } + public: + void print_dag(std::ostream& os, int level) const { + print_dag_helper(os, level, std::make_index_sequence{}); + } +#endif +}; + //____________________________________________________________ // The rep for the leaf node @@ -352,116 +399,6 @@ public: #define CGAL_LEXACT(z,n,t) CGAL::exact( l##n ) #define CGAL_LARGS(z, n, t) L##n const& l##n -#define CGAL_TMAP(z, n, d) typename Type_mapper< L##n, d##K, LK >::type -#define CGAL_PRUNE_TREE(z, n, d) l##n = L##n (); -#define CGAL_LINIT(z, n, d) l##n(l##n) -#define CGAL_LN(z, n, d) d(l##n) -#define CGAL_MLIST(z, n, d) mutable L##n l##n; - -//____________________________________________________________ - -template -class Lazy_rep_1 - : public Lazy_rep - , private EC -{ - typedef Lazy_rep Base; - - mutable L1 l1_; - - const EC& ec() const { return *this; } - -public: - - void - update_exact() const - { - this->et = new ET(ec()(CGAL::exact(l1_))); - this->at = E2A()(*(this->et)); - // Prune lazy tree - l1_ = L1(); - } - - Lazy_rep_1(const AC& ac, const EC& ec, const L1& l1) - : Lazy_rep(ac(CGAL::approx(l1))), EC(ec), l1_(l1) - { - this->set_depth(CGAL::depth(l1_) + 1); - } - -#ifdef CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID -# define CGAL_LAZY_PRINT_TYPEID CGAL::msg(os, level, typeid(AC).name()); -#else // not CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID -# define CGAL_LAZY_PRINT_TYPEID -#endif // not CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID - -#ifdef CGAL_LAZY_KERNEL_DEBUG - void - print_dag(std::ostream& os, int level) const - { - this->print_at_et(os, level); - if(this->is_lazy()){ - CGAL_LAZY_PRINT_TYPEID - CGAL::msg(os, level, "DAG with one child node:"); - CGAL::print_dag(l1_, os, level+1); - } - } -#endif -}; - -#ifdef CGAL_LAZY_KERNEL_DEBUG -# define CGAL_PRINT_DAG_LN(z, n, d) \ - CGAL::print_dag(l##n, os, level+1); -# define CGAL_LAZY_REP_PRINT_DAG(n) \ - void print_dag(std::ostream& os, int level) const { \ - this->print_at_et(os, level); \ - if(this->is_lazy()){ \ - CGAL_LAZY_PRINT_TYPEID \ - CGAL::msg(os, level, "DAG with " #n " child nodes:"); \ - BOOST_PP_REPEAT(n, CGAL_PRINT_DAG_LN, _) \ - } \ - } -#else // not CGAL_LAZY_KERNEL_DEBUG -# define CGAL_LAZY_REP_PRINT_DAG(n) -#endif // not CGAL_LAZY_KERNEL_DEBUG - -#define CGAL_LAZY_REP(z, n, d) \ - template< typename AT, typename ET, typename AC, typename EC, typename E2A, BOOST_PP_ENUM_PARAMS(n, typename L)> \ -class Lazy_rep_##n :public Lazy_rep< AT, \ - ET, \ - E2A >, \ - private EC \ -{ \ - \ - template \ - friend class Lazy_kernel_base; \ - BOOST_PP_REPEAT(n, CGAL_MLIST, _) \ - const EC& ec() const { return *this; } \ -public: \ - void update_exact() const { \ - this->et = new ET(ec()( BOOST_PP_ENUM(n, CGAL_LEXACT, _) ) ); \ - this->at = E2A()(*(this->et)); \ - BOOST_PP_REPEAT(n, CGAL_PRUNE_TREE, _) \ - } \ - Lazy_rep_##n(const AC& ac, const EC&, BOOST_PP_ENUM(n, CGAL_LARGS, _)) \ - : Lazy_rep(ac( BOOST_PP_ENUM(n, CGAL_LN, CGAL::approx) )), BOOST_PP_ENUM(n, CGAL_LINIT, _) \ - { this->set_depth(max_n( BOOST_PP_ENUM(n, CGAL_LN, CGAL::depth) ) + 1); } \ - \ - CGAL_LAZY_REP_PRINT_DAG(n) \ -}; - -BOOST_PP_REPEAT_FROM_TO(2, 9, CGAL_LAZY_REP, _) - -#undef CGAL_TMAP -#undef CGAL_PRUNE_TREE -#undef CGAL_LINIT -#undef CGAL_LAZY_REP -#undef CGAL_LN -#undef CGAL_MLIST -#undef CGAL_PRINT_DAG_LN -#undef CGAL_LAZY_REP_PRINT_DAG #undef CGAL_LAZY_PRINT_TYPEID template < typename K1, typename K2 > @@ -854,6 +791,8 @@ struct Lazy_construction_bbox template struct Lazy_construction_nt { + Lazy_construction_nt(){} + Lazy_construction_nt(LK const&){} static const bool Protection = true; @@ -878,30 +817,23 @@ struct Lazy_construction_nt { BOOST_PP_REPEAT_FROM_TO(1, 6, CGAL_RESULT_NT, _) -#define CGAL_NT_OPERATOR(z, n, d) \ - template \ - typename cpp11::result_of::type \ - operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \ - BOOST_PP_REPEAT(n, CGAL_TYPEMAP_EC, L) \ - BOOST_PP_REPEAT(n, CGAL_TYPEMAP_AC, L) \ - typedef typename boost::remove_cv< typename boost::remove_reference < \ - typename cpp11::result_of< EC(BOOST_PP_ENUM_PARAMS(n, E)) >::type >::type >::type ET; \ - typedef typename boost::remove_cv< typename boost::remove_reference < \ - typename cpp11::result_of< AC(BOOST_PP_ENUM_PARAMS(n, A)) >::type >::type >::type AT; \ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ - Protect_FPU_rounding P; \ - try { \ - return new Lazy_rep_##n, BOOST_PP_ENUM_PARAMS(n, L) >(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)); \ - } catch (Uncertain_conversion_exception&) { \ - CGAL_BRANCH_PROFILER_BRANCH(tmp); \ - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); \ - return new Lazy_rep_0 >(ec( BOOST_PP_ENUM(n, CGAL_LEXACT, _) )); \ - } \ - } \ + template + auto operator()(L const&...l) const -> + Lazy_exact_nt>> + { + typedef std::remove_cv_t> ET; + typedef std::remove_cv_t> AT; + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_n, L... >(ac, ec, l...); + } catch (Uncertain_conversion_exception&) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0 >(ec( CGAL::exact(l)... )); + } + } - BOOST_PP_REPEAT_FROM_TO(1, 6, CGAL_NT_OPERATOR, _) - -#undef INTERVAL_OPERATOR #undef CGAL_RESULT_NT }; @@ -1185,8 +1117,8 @@ public: typedef Lazy, std::pair, E2A> Lazy_pair; Lazy_pair lv(new Lazy_rep_2_2(ac, ec, l1, l2)); // lv->approx() is a std::pair; - r1 = R1(Handle_1(new Lazy_rep_1 >, First >, E2A, Lazy_pair>(First >(), First >(), lv))); - r2 = R2(Handle_2(new Lazy_rep_1 >, Second >, E2A, Lazy_pair>(Second >(), Second >(), lv))); + r1 = R1(Handle_1(new Lazy_rep_n >, First >, E2A, Lazy_pair>(First >(), First >(), lv))); + r2 = R2(Handle_2(new Lazy_rep_n >, Second >, E2A, Lazy_pair>(Second >(), Second >(), lv))); } catch (Uncertain_conversion_exception&) { CGAL_BRANCH_PROFILER_BRANCH(tmp); Protect_FPU_rounding P2(CGAL_FE_TONEAREST); @@ -1232,7 +1164,7 @@ public: for (unsigned int i = 0; i < lv.approx().size(); i++) { // FIXME : I'm not sure how this work... #define CGAL_Kernel_obj(X) if (object_cast(& (lv.approx()[i]))) { \ - *it++ = make_object(typename LK::X(new Lazy_rep_1, \ + *it++ = make_object(typename LK::X(new Lazy_rep_n, \ Ith, E2A, Lazy_vector> \ (Ith(i), Ith(i), lv))); \ continue; \ @@ -1304,14 +1236,14 @@ public: CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - Lazy_object lo(new Lazy_rep_1(ac, ec, l1)); + Lazy_object lo(new Lazy_rep_n(ac, ec, l1)); if(lo.approx().is_empty()) return Object(); #define CGAL_Kernel_obj(X) \ if (object_cast(& (lo.approx()))) { \ - typedef Lazy_rep_1< typename AK::X, typename EK::X, Object_cast, Object_cast, E2A, Lazy_object> Lcr; \ + typedef Lazy_rep_n< typename AK::X, typename EK::X, Object_cast, Object_cast, E2A, Lazy_object> Lcr; \ Lcr * lcr = new Lcr(Object_cast(), Object_cast(), lo); \ return make_object(typename LK::X(lcr)); \ } @@ -1337,14 +1269,14 @@ public: CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - Lazy_object lo(new Lazy_rep_2(ac, ec, l1, l2)); + Lazy_object lo(new Lazy_rep_n(ac, ec, l1, l2)); if(lo.approx().is_empty()) return Object(); #define CGAL_Kernel_obj(X) \ if (object_cast(& (lo.approx()))) { \ - typedef Lazy_rep_1, Object_cast, E2A, Lazy_object> Lcr; \ + typedef Lazy_rep_n, Object_cast, E2A, Lazy_object> Lcr; \ Lcr * lcr = new Lcr(Object_cast(), Object_cast(), lo); \ return make_object(typename LK::X(lcr)); \ } @@ -1360,7 +1292,7 @@ public: std::vector V;\ V.resize(v_ptr->size()); \ for (unsigned int i = 0; i < v_ptr->size(); i++) { \ - V[i] = typename LK::X(new Lazy_rep_1, \ + V[i] = typename LK::X(new Lazy_rep_n, \ Ith_for_intersection, E2A, Lazy_object> \ (Ith_for_intersection(i), Ith_for_intersection(i), lo)); \ } \ @@ -1391,14 +1323,14 @@ CGAL_Kernel_obj(Point_3) CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - Lazy_object lo(new Lazy_rep_3(ac, ec, l1, l2, l3)); + Lazy_object lo(new Lazy_rep_n(ac, ec, l1, l2, l3)); if(lo.approx().is_empty()) return Object(); #define CGAL_Kernel_obj(X) \ if (object_cast(& (lo.approx()))) { \ - typedef Lazy_rep_1, Object_cast, E2A, Lazy_object> Lcr; \ + typedef Lazy_rep_n, Object_cast, E2A, Lazy_object> Lcr; \ Lcr * lcr = new Lcr(Object_cast(), Object_cast(), lo); \ return make_object(typename LK::X(lcr)); \ } @@ -1469,7 +1401,7 @@ struct Fill_lazy_variant_visitor_2 : boost::static_visitor<> { typedef typename Type_mapper::type EKT; typedef typename Type_mapper::type LKT; - typedef Lazy_rep_1, Variant_cast, typename LK::E2A, Origin> Lcr; + typedef Lazy_rep_n, Variant_cast, typename LK::E2A, Origin> Lcr; Lcr * lcr = new Lcr(Variant_cast(), Variant_cast(), *o); *r = LKT(lcr); @@ -1484,7 +1416,7 @@ struct Fill_lazy_variant_visitor_2 : boost::static_visitor<> { std::vector V; V.resize(t.size()); for (unsigned int i = 0; i < t.size(); i++) { - V[i] = LKT(new Lazy_rep_1, + V[i] = LKT(new Lazy_rep_n, Ith_for_intersection, typename LK::E2A, Origin> (Ith_for_intersection(i), Ith_for_intersection(i), *o)); } @@ -1565,7 +1497,7 @@ struct Lazy_construction_variant { Protect_FPU_rounding P; try { - Lazy lazy(new Lazy_rep_2(AC(), EC(), l1, l2)); + Lazy lazy(new Lazy_rep_n(AC(), EC(), l1, l2)); // the approximate result requires the trait with types from the AK AT approx_v = lazy.approx(); @@ -1614,7 +1546,7 @@ struct Lazy_construction_variant { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - Lazy lazy(new Lazy_rep_3(AC(), EC(), l1, l2, l3)); + Lazy lazy(new Lazy_rep_n(AC(), EC(), l1, l2, l3)); // the approximate result requires the trait with types from the AK AT approx_v = lazy.approx(); @@ -1681,7 +1613,7 @@ struct Lazy_construction { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ Protect_FPU_rounding P; \ try { \ - return result_type( Handle(new Lazy_rep_##n(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)))); \ + return result_type( Handle(new Lazy_rep_n(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)))); \ } catch (Uncertain_conversion_exception&) { \ CGAL_BRANCH_PROFILER_BRANCH(tmp); \ Protect_FPU_rounding P2(CGAL_FE_TONEAREST); \ @@ -1748,7 +1680,7 @@ struct result { \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ Protect_FPU_rounding P; \ try { \ - return result_type( Handle(new Lazy_rep_##n(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)))); \ + return result_type( Handle(new Lazy_rep_n(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)))); \ } catch (Uncertain_conversion_exception&) { \ CGAL_BRANCH_PROFILER_BRANCH(tmp); \ Protect_FPU_rounding P2(CGAL_FE_TONEAREST); \ diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 90e18354df0..1009198e04d 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -330,7 +330,7 @@ public: FT operator()(const Weighted_point_2& p) const { - typedef Lazy_rep_3 LR; - typedef Lazy_rep_3 LR; - typedef Lazy_rep_3 #include #include +#include #include - +// TODO: add static filters somewhere namespace CGAL { -#define CGAL_BASE \ - Cartesian_base_d::Type, Dim> -template -struct Epeck_d_help1 -: CGAL_BASE -{ - CGAL_CONSTEXPR Epeck_d_help1(){} - CGAL_CONSTEXPR Epeck_d_help1(int d):CGAL_BASE(d){} -}; +#define CGAL_KA Cartesian_base_d +#define CGAL_KE Cartesian_base_d::Type, Dim> +template using Epeck_d_help1 = Lazy_cartesian>; +#undef CGAL_KE +#undef CGAL_KA #undef CGAL_BASE #define CGAL_BASE \ Kernel_d_interface< \ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h index 632ee0ef9e7..533b953331c 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h @@ -88,6 +88,7 @@ struct Cartesian_LA_base_d : public Dimension_base ::add::type ::add::type ::add::type + ::add::type Object_list; typedef typeset< Point_cartesian_const_iterator_tag>::type diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h index a9307329fc1..d60b5d896a8 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h @@ -321,6 +321,12 @@ template struct In_flat_power_side_of_power_sphere_raw : private Store } + +// For the lazy kernel +inline CartesianDKernelFunctors::Flat_orientation const& exact(CartesianDKernelFunctors::Flat_orientation const& o){return o;} +inline CartesianDKernelFunctors::Flat_orientation const& approx(CartesianDKernelFunctors::Flat_orientation const& o){return o;} +inline unsigned depth(CartesianDKernelFunctors::Flat_orientation const&){return 0;} + CGAL_KD_DEFAULT_TYPE(Flat_orientation_tag,(CGAL::CartesianDKernelFunctors::Flat_orientation),(),()); CGAL_KD_DEFAULT_FUNCTOR(In_flat_orientation_tag,(CartesianDKernelFunctors::In_flat_orientation),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); CGAL_KD_DEFAULT_FUNCTOR(In_flat_side_of_oriented_sphere_tag,(CartesianDKernelFunctors::In_flat_side_of_oriented_sphere),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index c1cb7ce07e1..f6463dda4dd 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -151,30 +151,33 @@ template struct Kernel_d_interface : public Base_ { CGAL_FUNCTOR_INIT_STORE(Construct_cartesian_const_iterator_d) typedef typename Get_functor >::type CPI; typedef typename Get_functor >::type CVI; - // FIXME: The following sometimes breaks compilation. The typedef below forces instantiation of this, which forces Point_d, which itself (in the wrapper) needs the derived kernel to tell it what the base kernel is, and that's a cycle. The exact circumstances are not clear, g++ and clang++ are ok in both C++03 and C++11, it is only clang in C++11 without CGAL_CXX11 that breaks. For now, rely on result_type. + // FIXME: The following sometimes breaks compilation. The typedef below forces instantiation of this, which forces Point_d, which itself (in the wrapper) needs the derived kernel to tell it what the base kernel is, and that's a cycle. The exact circumstances are not clear, g++ and clang++ are ok in both C++03 and C++11, it is only clang in C++11 without CGAL_CXX11 that breaks. Relying on CPI::result_type is great for Epick_d but not Epeck_d. //typedef typename CGAL::decay::type>::type result_type; - typedef typename CGAL::decay::type result_type; + //typedef typename CGAL::decay::type result_type; + //typedef decltype(std::declval()(std::declval(),Begin_tag{})) result_type; + // HACK + typedef typename Base::Point_cartesian_const_iterator result_type; // Kernel_d requires a common iterator type for points and vectors // TODO: provide this mixed functor in preKernel? //CGAL_static_assertion((boost::is_same::type>::type, result_type>::value)); - CGAL_static_assertion((boost::is_same::type, result_type>::value)); + //CGAL_static_assertion((boost::is_same::type, result_type>::value)); template - result_type operator()(Point_d const&p, Tag_ t)const{ + auto operator()(Point_d const&p, Tag_ t)const{ return CPI(this->kernel())(p,t); } template - result_type operator()(typename First_if_different::Type const&v, Tag_ t)const{ + auto operator()(typename First_if_different::Type const&v, Tag_ t)const{ return CVI(this->kernel())(v,t); } template - result_type operator()(Obj const&o)const{ + auto operator()(Obj const&o)const{ return operator()(o, Begin_tag()); } - result_type operator()(Point_d const&p, int)const{ + auto operator()(Point_d const&p, int)const{ return operator()(p, End_tag()); } - result_type operator()(typename First_if_different::Type const&v, int)const{ + auto operator()(typename First_if_different::Type const&v, int)const{ return operator()(v, End_tag()); } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h index 9d8c2280297..152b4f47eda 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h @@ -95,6 +95,18 @@ template struct KO_converter{ } }; +template struct KO_converter{ + typedef typename Get_type::type argument_type; + typedef typename Get_type::type result_type; + template + result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& s) const { + typename Get_functor::type f(k1); + typename Get_functor::type g(k1); + typename Get_functor >::type cib(k2); + return cib(conv(f(s)),conv(g(s))); + } +}; + template struct KO_converter{ typedef typename Get_type::type argument_type; typedef typename Get_type::type result_type; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 4ae80544fcf..1912ce7f214 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace CGAL { @@ -61,6 +62,47 @@ namespace internal { }; } +template +struct Lazy_construction2 { + static const bool Protection = true; + + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename LK::E2A E2A; + typedef typename Get_functor::type AC; + typedef typename Get_functor::type EC; + typedef typename map_result_tag::type result_tag; + typedef typename Get_type::type AT; + typedef typename Get_type::type ET; + typedef typename Get_type::type result_type; + // same as Handle = Lazy< AT, ET, E2A> + + Lazy_construction2(){} + Lazy_construction2(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; + + template + std::enable_if_t<(sizeof...(L)>0), result_type> operator()(L const&...l) const { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_n(ac, ec, l...); + } catch (Uncertain_conversion_exception&) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0(ec(CGAL::exact(l)...)); + } + } + // FIXME: this forces us to have default constructors for all types, try to make its instantiation lazier + result_type operator()() const + { + return new Lazy_rep_0(); + } + +#undef CGAL_CONSTRUCTION_OPERATOR +}; + template struct Lazy_cartesian_types { @@ -103,20 +145,30 @@ struct Lazy_cartesian_types }; template -struct Lazy_cartesian : Dimension_base, +struct Lazy_cartesian : Lazy_cartesian_types > { - //CGAL_CONSTEXPR Lazy_cartesian(){} - //CGAL_CONSTEXPR Lazy_cartesian(int d):Base_(d){} + CGAL_CONSTEXPR Lazy_cartesian(){} + CGAL_CONSTEXPR Lazy_cartesian(int d):ak(d),ek(d){} //TODO: Do we want to store an AK and an EK? Or just references? //FIXME: references would be better I guess. //TODO: In any case, make sure that we don't end up storing this kernel for //nothing (it is not empty but references empty kernels or something) - AK_ ak; EK_ ek; + CGAL_NO_UNIQUE_ADDRESS AK_ ak; + CGAL_NO_UNIQUE_ADDRESS EK_ ek; AK_ const& approximate_kernel()const{return ak;} EK_ const& exact_kernel()const{return ek;} + int dimension()const{return ak.dimension();} + void set_dimension(int dim){ak.set_dimension(dim);ek.set_dimension(dim);} + + // For compilers that do not handle [[no_unique_address]] + typedef boost::mpl::and_< + internal::Do_not_store_kernel, + internal::Do_not_store_kernel > Do_not_store_kernel; + + typedef typename EK_::Dimension Dimension; // ? typedef Lazy_cartesian Self; typedef Lazy_cartesian_types Base; //typedef typename Default::Get::type Kernel; @@ -124,8 +176,18 @@ struct Lazy_cartesian : Dimension_base, typedef AK_ Approximate_kernel; typedef EK_ Exact_kernel; typedef E2A_ E2A; - typedef Approx_converter C2A; - typedef Exact_converter C2E; + //typedef Approx_converter C2A; + //typedef Exact_converter C2E; + struct C2A { + C2A(){} + C2A(Kernel const&, Approximate_kernel const&){} + templatedecltype(auto)operator()(T const&t)const{return CGAL::approx(t);} + }; + struct C2E { + C2E(){} + C2E(Kernel const&, Exact_kernel const&){} + templatedecltype(auto)operator()(T const&t)const{return CGAL::exact(t);} + }; typedef typename Exact_kernel::Rep_tag Rep_tag; typedef typename Exact_kernel::Kernel_tag Kernel_tag; @@ -151,12 +213,58 @@ struct Lazy_cartesian : Dimension_base, template struct Functor { typedef typename Get_functor::type FA; typedef typename Get_functor::type FE; - typedef Lazy_construction type; + typedef Lazy_construction2 type; + }; + template struct Functor { + typedef typename Get_functor::type FA; + struct type { + FA fa; + type(){} + type(Kernel const&k):fa(k.approximate_kernel()){} + template + int operator()(P const&p)const{return fa(CGAL::approx(p));} + }; + }; + template struct Functor { + typedef typename Get_functor::type FA; + struct type { + FA fa; + type(){} + type(Kernel const&k):fa(k.approximate_kernel()){} + template + int operator()(V const&v)const{return fa(CGAL::approx(v));} + }; + }; + template struct Functor { + // Don't filter that one, as there is no guarantee that the interval + // basis would be in any way related to the exact basis, the most obvious + // difference being the order of the vectors. + // Don't try to be generic until we have more than just this one. + typedef typename Get_functor::type FE; + typedef typename Get_type::type AT; + typedef typename Get_type::type ET; + typedef typename Base::template Type::type V; // Lazy + struct type { + FE fe; + type(){} + type(Kernel const&k):fe(k.exact_kernel()){} + template + void operator()(Iter i, Iter e, Oter o)const{ + fe(CGAL::exact(i), CGAL::exact(e), + boost::make_function_output_iterator( + [&o](ET const&v){ + *o++ = V(new Lazy_rep_0(v)); + } + ) + ); + } + }; }; - //typedef typename Iterator::type Point_cartesian_const_iterator; - //typedef typename Iterator::type Vector_cartesian_const_iterator; + typedef typename Base::template Iterator::type Point_cartesian_const_iterator; + typedef typename Base::template Iterator::type Vector_cartesian_const_iterator; + // This is really specific to point/vector coordinate iterators template struct Construct_iter : private Store_kernel { Construct_iter(){} @@ -169,7 +277,8 @@ struct Lazy_cartesian : Dimension_base, } template result_type operator()(T const& t,End_tag)const{ - return result_type(t,Self().dimension(),this->kernel()); + typedef typename Get_functor::type PD; + return result_type(t,PD(this->kernel().approximate_kernel())(CGAL::approx(t)),this->kernel()); } }; template struct Functor { diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Hyperplane.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Hyperplane.h index 1a32b080bed..21333780d2c 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Hyperplane.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Hyperplane.h @@ -33,6 +33,7 @@ template class Hyperplane { FT_ s_; public: + Hyperplane(){} Hyperplane(Vector_ const&v, FT_ const&s): v_(v), s_(s) {} // TODO: Add a piecewise constructor? diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h index ff82aec26a5..b6c12e11c83 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h @@ -30,6 +30,7 @@ template class Sphere { FT_ r2_; public: + Sphere(){} Sphere(Point_ const&p, FT_ const&r2): c_(p), r2_(r2) {} // TODO: Add a piecewise constructor? diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h index ed0c7d71191..8bb92abdcfe 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h @@ -31,6 +31,7 @@ template class Weighted_point { FT_ w_; public: + Weighted_point(){} Weighted_point(Point_ const&p, FT_ const&w): c_(p), w_(w) {} // TODO: Add a piecewise constructor? diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h index 6f9aa5bb3f2..f600134e0e4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h @@ -162,6 +162,8 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) } }; +// Do not try to instantiate the above +template struct Array_vector {}; } #endif diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/mix.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/mix.h index de8aac8845a..2e7145f6003 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/mix.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/mix.h @@ -33,6 +33,7 @@ struct Mix_vector }; }; +// FIXME: shouldn't we dispatch based on Max_dim_ instead? template struct Mix_vector, Max_dim_> : Static_::template Rebind_dimension, Max_dim_>::Other diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h index 4d5147dbffc..a97529bf6e7 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h @@ -145,9 +145,8 @@ struct Cartesian_wrap : public Base_ B b; type(){} type(Self const&k):b(k){} - typedef typename B::result_type result_type; #ifdef CGAL_CXX11 - template result_type operator()(U&&...u)const{ + template decltype(auto) operator()(U&&...u)const{ return b(internal::Forward_rep()(u)...); } #else diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index a4013b983d3..643828d9733 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -156,6 +156,13 @@ public: return PDBase()(rep()); } + friend auto operator==(Point_d const&p, Point_d const&q) { + typedef typename Get_functor::type EPBase; + return EPBase()(p.rep(), q.rep()); + } + + friend auto operator!=(Point_d const&p, Point_d const&q) { return !(p==q); } + /* Direction_d direction() const { diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 1e7a34b3e1e..94bd1e2ab76 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -462,7 +462,7 @@ template struct Linear_base : private Store_kernel { typedef typename R::LA::Dynamic_matrix Matrix; template - result_type operator()(Iter f, Iter e, Oter&o)const{ + result_type operator()(Iter f, Iter e, Oter o)const{ typename Get_functor::type c(this->kernel()); typename Get_functor::type vd(this->kernel()); typename Get_functor >::type cv(this->kernel()); diff --git a/NewKernel_d/include/CGAL/iterator_from_indices.h b/NewKernel_d/include/CGAL/iterator_from_indices.h index 22e772a5031..895a5f47916 100644 --- a/NewKernel_d/include/CGAL/iterator_from_indices.h +++ b/NewKernel_d/include/CGAL/iterator_from_indices.h @@ -50,7 +50,7 @@ class Iterator_from_indices typedef std::ptrdiff_t index_t; Container_* cont; index_t index; - Coord_access ca; + CGAL_NO_UNIQUE_ADDRESS Coord_access ca; void increment(){ ++index; } void decrement(){ --index; } void advance(std::ptrdiff_t n){ index+=n; } @@ -66,6 +66,7 @@ class Iterator_from_indices return ca(*cont,index); } public: + Iterator_from_indices(){} Iterator_from_indices(Container_& cont_,std::size_t n) : cont(&cont_), index(n) {} template diff --git a/NewKernel_d/test/NewKernel_d/Epick_d.cpp b/NewKernel_d/test/NewKernel_d/Epick_d.cpp index 30aa5f79882..503450d96d7 100644 --- a/NewKernel_d/test/NewKernel_d/Epick_d.cpp +++ b/NewKernel_d/test/NewKernel_d/Epick_d.cpp @@ -11,6 +11,7 @@ int main() //#define BOOST_RESULT_OF_USE_DECLTYPE 1 #include +#include #include #include @@ -121,7 +122,6 @@ void test2(){ typedef typename K1::Oriented_side_d OS; typedef typename K1::Orthogonal_vector_d OV; typedef typename K1::Point_dimension_d PD; - typedef typename K1::Point_of_sphere_d PS; typedef typename K1::Point_to_vector_d PV; typedef typename K1::Vector_to_point_d VP; typedef typename K1::Barycentric_coordinates_d BC; @@ -190,7 +190,6 @@ void test2(){ OS os Kinit(oriented_side_d_object); OV ov Kinit(orthogonal_vector_d_object); PD pd Kinit(point_dimension_d_object); - PS ps Kinit(point_of_sphere_d_object); PV pv Kinit(point_to_vector_d_object); VP vp Kinit(vector_to_point_d_object); BC bc Kinit(barycentric_coordinates_d_object); @@ -356,6 +355,8 @@ void test2(){ #endif P z0=cp( 0+2,5-3); P z1=cp(-5+2,0-3); + assert(abs(sd(z0,z1)-50)<.0001); + assert(ed(z0,z0) && !ed(z0,z1)); P z2=cp( 3+2,4-3); P tabz[]={z0,z1,z2}; Sp sp = csp(tabz+0,tabz+3); @@ -368,6 +369,8 @@ void test2(){ assert(abs(sp.squared_radius()-25)<.0001); #if 1 // Fails for an exact kernel + typedef typename K1::Point_of_sphere_d PS; + PS ps Kinit(point_of_sphere_d_object); P psp0=ps(sp,0); P psp1=ps(sp,1); P psp2=ps(sp,2); @@ -423,12 +426,15 @@ template struct Construct_point3_helper { Construct_point3_helper(CP const& x) : cp(x) {} template typename CP::result_type operator()(T1 const&t1, T2 const&t2, T3 const&t3)const{ - double tab[]={(double)t1,(double)t2,(double)t3}; + //double tab[]={(double)t1,(double)t2,(double)t3}; + // The lazy kernel stores iterators, not a vector, so the array must stay alive until update_exact()! For the tests I am keeping the memory leak for now, it is more convenient. + double*tab=new double[3]{(double)t1,(double)t2,(double)t3}; return cp(tab+0,tab+3); } template typename CP::result_type operator()(T1 const&t1, T2 const&t2, T3 const&t3, T4 const&t4)const{ - double tab[]={(double)t1,(double)t2,(double)t3}; + // Same discussion as above + double*tab=new double[3]{(double)t1,(double)t2,(double)t3}; return cp(tab+0,tab+3,t4); } }; @@ -690,6 +696,9 @@ int main(){ test2(); test3(); test3(); + //test2>>(); + //test3>>(); + //test3>(); } #endif From 05eaf8f4f6a9180f4b6496a69938cd07676c5479 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 4 Feb 2019 21:56:31 +0100 Subject: [PATCH 010/203] Document Epeck_d. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 143 +++++++++++++++++++ Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 1 + Kernel_d/doc/Kernel_d/Kernel_d.txt | 16 +++ Kernel_d/doc/Kernel_d/PackageDescription.txt | 1 + 4 files changed, 161 insertions(+) create mode 100644 Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h new file mode 100644 index 00000000000..ac607f9f53c --- /dev/null +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -0,0 +1,143 @@ + +namespace CGAL { + +/*! +\ingroup PkgKernelDKernels + +A model for `Kernel_d`, minus `Kernel_d::Point_of_sphere_d`, that uses %Cartesian coordinates to represent the +geometric objects. + +This kernel is default constructible and copyable. It does not carry any +state so it is possible to use objects created by one instance with +functors created by another one. + +This kernel supports construction of points from `double` %Cartesian +coordinates. It provides exact geometric predicates and constructions. The +geometric predicates are made exact without sacrificing speed thanks to the use +of filters. The geometric constructions are made exact without sacrificing +speed thanks to a lazy mechanism, similar to `Epeck`. A construction creates an +approximate object, and stores a directed acyclic graph (DAG) of the operation +and arguments used. When an operation needs more precision on an object than is +currently available, which should be rare, CGAL reconstructs exactly all the +ancestors of the object and replaces this part of the graph with exact objects. +This should be transparent for users, those details do not affect the +functionality, but they can cause surprising running time where the costly part +of an algorithm is not the construction itself, but a seemingly trivial use +afterwards that causes exact reconstruction of a large part of the structure. + +`Sphere_d` is represented internally with a center and a squared radius, and the exact type used by the kernel is a rational type. This means that `Kernel_d::Point_of_sphere_d` cannot be implemented exactly in dimensions up to 3 (higher dimensions would require a decomposition of an integer as a sum of `d` squares), so currently it is not provided at all. + +\tparam DimensionTag is a tag representing the dimension of the +ambient Euclidean space. It may be either `Dimension_tag` where `d` is +an integer +or `Dynamic_dimension_tag`. In the latter case, the dimension of the space is specified for each point when it is constructed, so it does not need to be known at compile-time. + + +\attention Only the interfaces specific to this class are listed below. Refer to the +concepts for the rest. + +\attention Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors. Constructing a `Point_d` with iterators is done lazily, see below. + +\attention Ancient compilers like gcc-4.2 or icc 14 are not supported, but gcc-4.4 and +icc 15 work. + +\attention This kernel requires the \ref thirdpartyEigen "Eigen" library. + + + +\cgalModels `Kernel_d` +\cgalModels `DelaunayTriangulationTraits` +\cgalModels `RegularTriangulationTraits` +\cgalModels `SearchTraits` +\cgalModels `RangeSearchTraits` + +\sa `CGAL::Cartesian_d` +\sa `CGAL::Homogeneous_d` +\sa `CGAL::Epick_d` + +*/ +template< typename DimensionTag > +struct Epeck_d { +/*! +represents a point in the Euclidean space +\cgalModels `DefaultConstructible` +\cgalModels `Assignable` +*/ +class Point_d { +public: +/*! introduces a point with coordinates (x0, x1, ...) where the number of + coordinates matches the dimension. + \pre `DimensionTag` is a fixed dimension, not `Dynamic_dimension_tag`. */ +Point_d(double x0, double x1, ...); + +/*! introduces a point with coordinate set `[first,end)`. + \pre If `DimensionTag` is a fixed dimension, it matches `distance(first,end)`. + \tparam ForwardIterator has its value type that is convertible to `double`. + \bug{Lazy construction} This constructor stores the iterators and may use + them at any later time, when an exact construction is needed. This means + that if `[first,end)` points to some buffer, it has to remain alive at + least as long as the point. + */ +template +Point_d(ForwardIterator first, ForwardIterator end); + +/*! returns the i'th coordinate of a point. + \pre `i` is non-negative and less than the dimension. */ +double operator[](int i)const; + +/*! returns an iterator pointing to the zeroth Cartesian coordinate. */ +Cartesian_const_iterator_d cartesian_begin()const; +/*! returns an iterator pointing beyond the last Cartesian coordinate. */ +Cartesian_const_iterator_d cartesian_end()const; +}; + +/*! +represents a weighted point in the Euclidean space +\cgalModels `DefaultConstructible` +\cgalModels `Assignable` +*/ +class Weighted_point_d { +public: +/*! introduces a weighted point with point p and weight w. */ +Weighted_point_d(const Point_d& p, const double& w); +/*! extracts the point of a weighted point. */ +Point_d point() const; +/*! extracts the weight of a weighted point. */ +double weight() const; +}; + +/*! \cgalModels `Kernel_d::Center_of_sphere_d` + */ +class Construct_circumcenter_d { +public: +/*! returns the center of the sphere defined by `A=tuple[first,last)`. The sphere is centered in the affine hull of A and passes through all the points of A. The order of the points of A does not matter. + \pre A is affinely independant. + \tparam ForwardIterator has `Epeck_d::Point_d` as value type. + */ +template +Point_d operator()(ForwardIterator first, ForwardIterator last); +}; +class Compute_squared_radius_d { +public: +/*! returns the radius of the sphere defined by `A=tuple[first,last)`. The sphere is centered in the affine hull of A and passes through all the points of A. The order of the points of A does not matter. + \pre A is affinely independant. + \tparam ForwardIterator has `Epeck_d::Point_d` as value type. + */ +template +Point_d operator()(ForwardIterator first, ForwardIterator last); +}; +/*! \cgalModels `Kernel_d::Side_of_bounded_sphere_d` + */ +class Side_of_bounded_sphere_d { +public: +/*! returns the relative position of point p to the sphere defined by `A=tuple[first,last)`. The sphere is centered in the affine hull of A and passes through all the points of A. The order of the points of A does not matter. + \pre A is affinely independant. + \tparam ForwardIterator has `Epeck_d::Point_d` as value type. + */ +template +Bounded_side operator()(ForwardIterator first, ForwardIterator last, const Point_d&p); +}; +Construct_circumcenter_d construct_circumcenter_d_object(); +Compute_squared_radius_d compute_squared_radius_d_object(); +}; /* end Epeck_d */ +} /* end namespace CGAL */ diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index ce9133544be..ab6ac6e5f5d 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -43,6 +43,7 @@ icc 15 work. \sa `CGAL::Cartesian_d` \sa `CGAL::Homogeneous_d` +\sa `CGAL::Epeck_d` */ template< typename DimensionTag > diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index bdfa7b73a6e..09469675ec6 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -224,6 +224,22 @@ Note that it provides few interfaces in addition to those documented in the `Kernel_d` concept. In particular, the type of a point is only available as `Epick_d::%Point_d`, not `Point_d>`. +\subsection Kernel_dEpickKernel Epeck_d Kernel + +The kernel `Epeck_d`, short for Exact Predicates Exact +Constructions Kernel is a kernel particularly useful when the dimension of +the space is known at compile-time; The template parameter `DimensionTag` is then +`Dimension_tag` where `d` is an integer representing the dimension. It +may also be used with parameter `Dynamic_dimension_tag`, in which case the +dimension does not need to be known at compile-time. +It uses a %Cartesian representation and +supports construction of points from `double` coordinates. It provides exact +geometric predicates and constructions. + +Note that it provides few interfaces in addition to those documented in the +`Kernel_d` concept. In particular, the type of a point is only available as +`Epeck_d::%Point_d`, not `Point_d>`. + \subsection Kernel_dNamingconventions Naming Conventions diff --git a/Kernel_d/doc/Kernel_d/PackageDescription.txt b/Kernel_d/doc/Kernel_d/PackageDescription.txt index a2a4f31cbf3..b2e0d977672 100644 --- a/Kernel_d/doc/Kernel_d/PackageDescription.txt +++ b/Kernel_d/doc/Kernel_d/PackageDescription.txt @@ -49,6 +49,7 @@ - `CGAL::Cartesian_d` - `CGAL::Homogeneous_d` - `CGAL::Epick_d` +- `CGAL::Epeck_d` ## %Kernel Objects ## - `CGAL::Point_d` From 540a7d312bff4e42c4a7d1d9e1d0de0c84507ca5 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 4 Feb 2019 22:14:37 +0100 Subject: [PATCH 011/203] Try adding some \cgalModifBegin/End. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 2 +- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 4 +++- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index ac607f9f53c..3d0a7adaad3 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -5,7 +5,7 @@ namespace CGAL { \ingroup PkgKernelDKernels A model for `Kernel_d`, minus `Kernel_d::Point_of_sphere_d`, that uses %Cartesian coordinates to represent the -geometric objects. +geometric objects. This kernel is default constructible and copyable. It does not carry any state so it is possible to use objects created by one instance with diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index ab6ac6e5f5d..29c2f3738d9 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -4,8 +4,9 @@ namespace CGAL { /*! \ingroup PkgKernelDKernels +\cgalModifBegin A model for `Kernel_d` that uses %Cartesian coordinates to represent the -geometric objects. +geometric objects. This kernel is default constructible and copyable. It does not carry any state so it is possible to use objects created by one instance with @@ -127,3 +128,4 @@ Construct_circumcenter_d construct_circumcenter_d_object(); Compute_squared_radius_d compute_squared_radius_d_object(); }; /* end Epick_d */ } /* end namespace CGAL */ +/// \cgalModifEnd diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 09469675ec6..17bdcf363c8 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -224,6 +224,7 @@ Note that it provides few interfaces in addition to those documented in the `Kernel_d` concept. In particular, the type of a point is only available as `Epick_d::%Point_d`, not `Point_d>`. +\cgalModifBegin \subsection Kernel_dEpickKernel Epeck_d Kernel The kernel `Epeck_d`, short for Exact Predicates Exact @@ -239,6 +240,7 @@ geometric predicates and constructions. Note that it provides few interfaces in addition to those documented in the `Kernel_d` concept. In particular, the type of a point is only available as `Epeck_d::%Point_d`, not `Point_d>`. +\cgalModifEnd \subsection Kernel_dNamingconventions Naming Conventions From e0efdb377214ba5e71fff66d8cbc76cdbf012295 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 4 Feb 2019 22:27:46 +0100 Subject: [PATCH 012/203] Pasto --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 17bdcf363c8..9ff972cbc63 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -225,7 +225,7 @@ Note that it provides few interfaces in addition to those documented in the `Epick_d::%Point_d`, not `Point_d>`. \cgalModifBegin -\subsection Kernel_dEpickKernel Epeck_d Kernel +\subsection Kernel_dEpeckKernel Epeck_d Kernel The kernel `Epeck_d`, short for Exact Predicates Exact Constructions Kernel is a kernel particularly useful when the dimension of From f24c875c1651e2b505ca1a070ba8825f5b0d8879 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 4 Feb 2019 22:38:01 +0100 Subject: [PATCH 013/203] \bug doesn't have a title --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 3d0a7adaad3..0301322ec12 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -73,7 +73,7 @@ Point_d(double x0, double x1, ...); /*! introduces a point with coordinate set `[first,end)`. \pre If `DimensionTag` is a fixed dimension, it matches `distance(first,end)`. \tparam ForwardIterator has its value type that is convertible to `double`. - \bug{Lazy construction} This constructor stores the iterators and may use + \bug This constructor stores the iterators and may use them at any later time, when an exact construction is needed. This means that if `[first,end)` points to some buffer, it has to remain alive at least as long as the point. From 050a9663b99381c0618918cc2b8a79258583e501 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 5 Feb 2019 20:43:01 +0100 Subject: [PATCH 014/203] Attribution --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 9ff972cbc63..10531d1bc56 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -556,7 +556,7 @@ evolution of the low-dimensional kernel. The kernel was revised based on suggestions by Hervé Brönnimann, Michael Hoffmann, and Stefan Schirra. -Epick_d was added by Marc Glisse in 2014. +Marc Glisse added Epick_d in 2014 and Epeck_d in 2019. \subsection Kernel_dAcknowledgments Acknowledgments From 140e407bf8160970a136266b2cbf00c72d6cbfa7 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 5 Feb 2019 20:43:40 +0100 Subject: [PATCH 015/203] No need to warn about gcc-4.2 if it is C++14-only. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 3 --- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 0301322ec12..6a58b594230 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -38,9 +38,6 @@ concepts for the rest. \attention Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors. Constructing a `Point_d` with iterators is done lazily, see below. -\attention Ancient compilers like gcc-4.2 or icc 14 are not supported, but gcc-4.4 and -icc 15 work. - \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 29c2f3738d9..9916144bf8f 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -29,9 +29,6 @@ concepts for the rest. \attention Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors. -\attention Ancient compilers like gcc-4.2 or icc 14 are not supported, but gcc-4.4 and -icc 15 work. - \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. From 678f911a4759192e006f5cb5a377337536e321d3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 13:56:05 +0100 Subject: [PATCH 016/203] C++14 tweaks --- .travis.yml | 2 +- Filtered_kernel/include/CGAL/Lazy.h | 42 +++++++++++++------ .../include/CGAL/NewKernel_d/Lazy_cartesian.h | 2 - .../CGAL/NewKernel_d/Wrapper/Point_d.h | 3 +- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 981151439f8..08fff7246ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,7 +63,7 @@ before_script: - sudo chmod +x /usr/bin/doxygen - mkdir -p build - cd build -- cmake -DCMAKE_CXX_FLAGS="-std=c++11" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. +- cmake -DCMAKE_CXX_FLAGS="-std=c++1y" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. - make - sudo make install &>/dev/null - cd .. diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 58a6c67f42e..54e558ee7be 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -237,7 +238,7 @@ struct Depth_base { template class Lazy_rep : public Rep, public Depth_base { - Lazy_rep (const Lazy_rep&); // cannot be copied. + Lazy_rep (const Lazy_rep&) = delete; // cannot be copied. public: @@ -247,13 +248,15 @@ public: mutable ET *et; Lazy_rep () - : at(), et(NULL){} + : at(), et(nullptr){} - Lazy_rep (const AT& a) - : at(a), et(NULL){} + template + Lazy_rep (A&& a) + : at(std::forward(a)), et(nullptr){} - Lazy_rep (const AT& a, const ET& e) - : at(a), et(new ET(e)) {} + template + Lazy_rep (A&& a, E&& e) + : at(std::forward(a)), et(new ET(std::forward(e))) {} const AT& approx() const { @@ -332,8 +335,9 @@ class Lazy_rep_n : void update_exact() const { update_exact_helper(std::make_index_sequence{}); } - Lazy_rep_n(const AC& ac, const EC& ec, L const&...ll) : - Lazy_rep(ac(CGAL::approx(ll)...)), EC(ec), l(ll...) + template + Lazy_rep_n(const AC& ac, const EC& ec, LL&&...ll) : + Lazy_rep(ac(CGAL::approx(ll)...)), EC(ec), l(std::forward(ll)...) { this->set_depth(std::max({ -1, (int)CGAL::depth(ll)...}) + 1); } @@ -377,14 +381,23 @@ public: Lazy_rep_0() : Lazy_rep() {} - Lazy_rep_0(const AT& a, const ET& e) - : Lazy_rep(a, e) {} + template + Lazy_rep_0(A&& a, E&& e) + : Lazy_rep(std::forward(a), std::forward(e)) {} +#if 0 + // unused. Find a less ambiguous placeholder if necessary Lazy_rep_0(const AT& a, void*) : Lazy_rep(a) {} +#endif - Lazy_rep_0(const ET& e) - : Lazy_rep(E2A()(e), e) {} + // E2A()(e) and std::forward(e) could be evaluated in any order, but + // that's ok, "forward" itself does not modify e, it may only mark it as + // modifyable by the outer call, which is obviously sequenced after the inner + // call E2A()(e). + template + Lazy_rep_0(E&& e) + : Lazy_rep(E2A()(e), std::forward(e)) {} void print_dag(std::ostream& os, int level) const @@ -722,6 +735,11 @@ public : PTR = new Lazy_rep_0(e); } + Lazy(ET&& e) + { + PTR = new Lazy_rep_0(std::move(e)); + } + const AT& approx() const { return ptr()->approx(); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 1912ce7f214..c62f3bbfde4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -211,8 +211,6 @@ struct Lazy_cartesian : typedef Lazy_construction_nt type; }; template struct Functor { - typedef typename Get_functor::type FA; - typedef typename Get_functor::type FE; typedef Lazy_construction2 type; }; template struct Functor { diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index 643828d9733..831ec157762 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -311,7 +311,8 @@ operator>>(std::istream &is, Point_d & p) for(int i=0;i Date: Wed, 6 Feb 2019 14:49:17 +0100 Subject: [PATCH 017/203] CGAL requires C++14. --- Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake index 9171c8a813d..4a7640ae3f2 100644 --- a/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake @@ -101,6 +101,10 @@ function(CGAL_setup_CGAL_dependencies target) target_compile_definitions(${target} ${keyword} CGAL_TEST_SUITE=1) endif() + # CGAL now requires C++14. `decltype(auto)` is used as a marker of + # C++14. + target_compile_features(${target} ${keyword} cxx_decltype_auto) + use_CGAL_Boost_support(${target} ${keyword}) foreach(dir ${CGAL_INCLUDE_DIRS}) From cdf197e82db115f7393cc917459bf36e731707c5 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 6 Feb 2019 15:00:19 +0100 Subject: [PATCH 018/203] Misplaced \cgalModifBegin \cgalModifEnd --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 2 ++ Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 6a58b594230..4cc88de7db7 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -4,6 +4,7 @@ namespace CGAL { /*! \ingroup PkgKernelDKernels +\cgalModifBegin A model for `Kernel_d`, minus `Kernel_d::Point_of_sphere_d`, that uses %Cartesian coordinates to represent the geometric objects. @@ -138,3 +139,4 @@ Construct_circumcenter_d construct_circumcenter_d_object(); Compute_squared_radius_d compute_squared_radius_d_object(); }; /* end Epeck_d */ } /* end namespace CGAL */ +/// \cgalModifEnd diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 9916144bf8f..92bc498016e 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -4,7 +4,6 @@ namespace CGAL { /*! \ingroup PkgKernelDKernels -\cgalModifBegin A model for `Kernel_d` that uses %Cartesian coordinates to represent the geometric objects. @@ -125,4 +124,3 @@ Construct_circumcenter_d construct_circumcenter_d_object(); Compute_squared_radius_d compute_squared_radius_d_object(); }; /* end Epick_d */ } /* end namespace CGAL */ -/// \cgalModifEnd From ba3bc8476f70b3cf4d3369319ec9d96380b8c4a9 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 6 Feb 2019 15:00:54 +0100 Subject: [PATCH 019/203] Fix automatic links --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 7 ++++--- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 4cc88de7db7..3b34dab7a8b 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -16,10 +16,11 @@ This kernel supports construction of points from `double` %Cartesian coordinates. It provides exact geometric predicates and constructions. The geometric predicates are made exact without sacrificing speed thanks to the use of filters. The geometric constructions are made exact without sacrificing -speed thanks to a lazy mechanism, similar to `Epeck`. A construction creates an +speed thanks to a lazy mechanism, similar to +`Exact_predicates_exact_constructions_kernel`. A construction creates an approximate object, and stores a directed acyclic graph (DAG) of the operation and arguments used. When an operation needs more precision on an object than is -currently available, which should be rare, CGAL reconstructs exactly all the +currently available, which should be rare, %CGAL reconstructs exactly all the ancestors of the object and replaces this part of the graph with exact objects. This should be transparent for users, those details do not affect the functionality, but they can cause surprising running time where the costly part @@ -37,7 +38,7 @@ or `Dynamic_dimension_tag`. In the latter case, the dimension of the space is sp \attention Only the interfaces specific to this class are listed below. Refer to the concepts for the rest. -\attention Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors. Constructing a `Point_d` with iterators is done lazily, see below. +\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. Constructing a `Point_d` with iterators is done lazily, see below. \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 10531d1bc56..50c0d8f4a06 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -228,7 +228,7 @@ Note that it provides few interfaces in addition to those documented in the \subsection Kernel_dEpeckKernel Epeck_d Kernel The kernel `Epeck_d`, short for Exact Predicates Exact -Constructions Kernel is a kernel particularly useful when the dimension of +Constructions %Kernel is a kernel particularly useful when the dimension of the space is known at compile-time; The template parameter `DimensionTag` is then `Dimension_tag` where `d` is an integer representing the dimension. It may also be used with parameter `Dynamic_dimension_tag`, in which case the From 446edec0868d5a0e34db02c3fe80f28ed56f7351 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 15:10:37 +0100 Subject: [PATCH 020/203] Replicate Laurent's patch from Epeck_d to Epick_d (same content) --- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 92bc498016e..947ea7b3c6d 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -26,7 +26,7 @@ or `Dynamic_dimension_tag`. In the latter case, the dimension of the space is sp \attention Only the interfaces specific to this class are listed below. Refer to the concepts for the rest. -\attention Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors. +\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. From 7c5a55d8a8d06874296f4ebeedc2eb76008f2fe0 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 15:13:14 +0100 Subject: [PATCH 021/203] Replicate Laurent's patch from Epeck_d to Epick_d (same content) --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 50c0d8f4a06..2808516bb04 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -210,7 +210,7 @@ type `LinearAlgebra`. \subsection Kernel_dEpickKernel Epick_d Kernel The kernel `Epick_d`, short for Exact Predicates Inexact -Constructions Kernel is a kernel particularly useful when the dimension of +Constructions %Kernel is a kernel particularly useful when the dimension of the space is known at compile-time; The template parameter `DimensionTag` is then `Dimension_tag` where `d` is an integer representing the dimension. It may also be used with parameter `Dynamic_dimension_tag`, in which case the From 0b60bb191c31f934f60e9223618d2289672725bb Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 15:39:16 +0100 Subject: [PATCH 022/203] Compute_squared_radius_d gives a FT, not a Point_d. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 2 +- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 3b34dab7a8b..d2f3b9ec2ca 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -123,7 +123,7 @@ public: \tparam ForwardIterator has `Epeck_d::Point_d` as value type. */ template -Point_d operator()(ForwardIterator first, ForwardIterator last); +FT operator()(ForwardIterator first, ForwardIterator last); }; /*! \cgalModels `Kernel_d::Side_of_bounded_sphere_d` */ diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 947ea7b3c6d..8325f349e0a 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -107,7 +107,7 @@ public: \tparam ForwardIterator has `Epick_d::Point_d` as value type. */ template -Point_d operator()(ForwardIterator first, ForwardIterator last); +FT operator()(ForwardIterator first, ForwardIterator last); }; /*! \cgalModels `Kernel_d::Side_of_bounded_sphere_d` */ From 65fcf810f5fe259c0cf7e68ed246a9c54b45163c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 15:52:05 +0100 Subject: [PATCH 023/203] Symmetrize HasModel/IsModel for Epeck_d. --- .../doc/Spatial_searching/Concepts/RangeSearchTraits.h | 1 + Spatial_searching/doc/Spatial_searching/Concepts/SearchTraits.h | 1 + .../doc/Triangulation/Concepts/DelaunayTriangulationTraits.h | 1 + .../doc/Triangulation/Concepts/RegularTriangulationTraits.h | 1 + Triangulation/doc/Triangulation/Concepts/TriangulationTraits.h | 1 + 5 files changed, 5 insertions(+) diff --git a/Spatial_searching/doc/Spatial_searching/Concepts/RangeSearchTraits.h b/Spatial_searching/doc/Spatial_searching/Concepts/RangeSearchTraits.h index 56281b811fc..e0af4b8a2a7 100644 --- a/Spatial_searching/doc/Spatial_searching/Concepts/RangeSearchTraits.h +++ b/Spatial_searching/doc/Spatial_searching/Concepts/RangeSearchTraits.h @@ -11,6 +11,7 @@ range search queries in a model of `SpatialTree`. \cgalHasModel `CGAL::Cartesian_d` \cgalHasModel `CGAL::Homogeneous_d` \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` \cgalHasModel `CGAL::Search_traits_2` \cgalHasModel `CGAL::Search_traits_3` diff --git a/Spatial_searching/doc/Spatial_searching/Concepts/SearchTraits.h b/Spatial_searching/doc/Spatial_searching/Concepts/SearchTraits.h index 2abebf75c0b..ae9f9d0363f 100644 --- a/Spatial_searching/doc/Spatial_searching/Concepts/SearchTraits.h +++ b/Spatial_searching/doc/Spatial_searching/Concepts/SearchTraits.h @@ -8,6 +8,7 @@ parameter of the search classes. \cgalHasModel `CGAL::Cartesian_d` \cgalHasModel `CGAL::Homogeneous_d` \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` \cgalHasModel `CGAL::Search_traits_2` \cgalHasModel `CGAL::Search_traits_3` \cgalHasModel `CGAL::Search_traits_d` diff --git a/Triangulation/doc/Triangulation/Concepts/DelaunayTriangulationTraits.h b/Triangulation/doc/Triangulation/Concepts/DelaunayTriangulationTraits.h index f5d6345384c..65aa17e3478 100644 --- a/Triangulation/doc/Triangulation/Concepts/DelaunayTriangulationTraits.h +++ b/Triangulation/doc/Triangulation/Concepts/DelaunayTriangulationTraits.h @@ -10,6 +10,7 @@ a Delaunay triangulation. It corresponds to the first template parameter of the \cgalRefines `TriangulationTraits` \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` \sa `TriangulationTraits` */ diff --git a/Triangulation/doc/Triangulation/Concepts/RegularTriangulationTraits.h b/Triangulation/doc/Triangulation/Concepts/RegularTriangulationTraits.h index ca0e3a0d9cd..265c25171ba 100644 --- a/Triangulation/doc/Triangulation/Concepts/RegularTriangulationTraits.h +++ b/Triangulation/doc/Triangulation/Concepts/RegularTriangulationTraits.h @@ -10,6 +10,7 @@ a regular triangulation. It corresponds to the first template parameter of the c \cgalRefines `TriangulationTraits` \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` \sa `TriangulationTraits` */ diff --git a/Triangulation/doc/Triangulation/Concepts/TriangulationTraits.h b/Triangulation/doc/Triangulation/Concepts/TriangulationTraits.h index 9791e86d42f..bba42a5dcff 100644 --- a/Triangulation/doc/Triangulation/Concepts/TriangulationTraits.h +++ b/Triangulation/doc/Triangulation/Concepts/TriangulationTraits.h @@ -15,6 +15,7 @@ then optimized using spatial sorting. This is not required if the points are inserted one by one. \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` \sa `DelaunayTriangulationTraits` */ From 4a2f14f6491984f1fcc177383df96fbfcf3e5e13 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 15:54:08 +0100 Subject: [PATCH 024/203] Symmetrize HasModel/IsModel for Epeck_d. --- Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h b/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h index 121402955d7..4de476b3f58 100644 --- a/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h +++ b/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h @@ -21,6 +21,7 @@ replacing operators, especially for equality testing. \cgalHasModel `CGAL::Cartesian_d` \cgalHasModel `CGAL::Homogeneous_d` \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` */ class Kernel_d { public: From 788435813427a5867d7898a7d268ce93b2238716 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 7 Feb 2019 09:51:55 +0100 Subject: [PATCH 025/203] Initialize 'point' to silenc ea warning. --- Polygon/include/CGAL/Polygon_2/Polygon_2_impl.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Polygon/include/CGAL/Polygon_2/Polygon_2_impl.h b/Polygon/include/CGAL/Polygon_2/Polygon_2_impl.h index 54606b33729..e0fde2d498b 100644 --- a/Polygon/include/CGAL/Polygon_2/Polygon_2_impl.h +++ b/Polygon/include/CGAL/Polygon_2/Polygon_2_impl.h @@ -95,15 +95,20 @@ operator>>(std::istream &is, Polygon_2& p) int n = 0; // number of vertices is >> n; typename Traits_P::Point_2 point; - + if (is) { - p.erase(p.vertices_begin(),p.vertices_end()); - for (int i=0; i> point; + p.erase(p.vertices_begin(),p.vertices_end()); + for (int i=0; i> point ) + { p.push_back(point); } + else + { + return is; + } + } } - return is; } From 49b3f3648fa80995034e7625a9b1054b0a8f8b57 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 7 Feb 2019 11:04:03 +0100 Subject: [PATCH 026/203] Try to upgrade Travis configuration to Xenial --- .travis.yml | 4 ++-- .travis/template.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08fff7246ba..3ef035a8021 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: cpp -dist: trusty +dist: xenial sudo: required git: depth: 3 @@ -63,7 +63,7 @@ before_script: - sudo chmod +x /usr/bin/doxygen - mkdir -p build - cd build -- cmake -DCMAKE_CXX_FLAGS="-std=c++1y" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. +- cmake -DCMAKE_CXX_FLAGS="-std=c++1y" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. - make - sudo make install &>/dev/null - cd .. diff --git a/.travis/template.txt b/.travis/template.txt index 1632aa16cbf..bed69a294d4 100644 --- a/.travis/template.txt +++ b/.travis/template.txt @@ -1,5 +1,5 @@ language: cpp -dist: trusty +dist: xenial sudo: required git: depth: 3 @@ -19,7 +19,7 @@ before_script: - sudo chmod +x /usr/bin/doxygen - mkdir -p build - cd build -- cmake -DCMAKE_CXX_FLAGS="-std=c++11" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. +- cmake -DCMAKE_CXX_FLAGS="-std=c++1y" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. - make - sudo make install &>/dev/null - cd .. From 5ef0977d67cc5d0549deeaf158ba0bb0a276cef9 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 12:34:17 +0100 Subject: [PATCH 027/203] Use Vector_dimension on vectors --- Filtered_kernel/include/CGAL/Lazy.h | 6 ++--- .../NewKernel_d/function_objects_cartesian.h | 25 ++++++++----------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 54e558ee7be..08e51fec51c 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -124,11 +124,11 @@ templateinline std::enable_if_t::value, T> approx(T){r templateinline std::enable_if_t::value, unsigned> depth(T){return 0;} // For an iterator, exact/approx applies to the objects it points to -template ::value>> +template ::value>> auto exact(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::exact(u);});} -template ::value>> +template ::value>> auto approx(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::approx(u);});} -template ::value>> +template ::value>> unsigned depth(T const& t) {return 1;} // FIXME: depth(*t) would be better when t is valid, but not for end iterators, and the true answer would iterate on the range, but we can't do that with only one iterator... We need to replace iterators with ranges to solve that. #ifdef CGAL_LAZY_KERNEL_DEBUG diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 94bd1e2ab76..0d41eb59707 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -208,8 +208,7 @@ template struct Orientation_of_vectors : private Store_kernel { template result_type operator()(Iter f, Iter e)const{ typename Get_functor::type c(this->kernel()); - typename Get_functor::type vd(this->kernel()); - // FIXME: Uh? Using it on a vector ?! + typename Get_functor::type vd(this->kernel()); Vector const& v0=*f; int d=vd(v0); Matrix m(d,d); @@ -241,7 +240,7 @@ template struct Orientation_of_vectors : private Store_kernel { }; } -CGAL_KD_DEFAULT_FUNCTOR(Orientation_of_vectors_tag,(CartesianDKernelFunctors::Orientation_of_vectors),(Vector_tag),(Point_dimension_tag,Compute_vector_cartesian_coordinate_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Orientation_of_vectors_tag,(CartesianDKernelFunctors::Orientation_of_vectors),(Vector_tag),(Vector_dimension_tag,Compute_vector_cartesian_coordinate_tag)); namespace CartesianDKernelFunctors { template struct Linear_rank : private Store_kernel { @@ -255,11 +254,10 @@ template struct Linear_rank : private Store_kernel { template result_type operator()(Iter f, Iter e)const{ typename Get_functor::type c(this->kernel()); - typename Get_functor::type vd(this->kernel()); + typename Get_functor::type vd(this->kernel()); std::ptrdiff_t n=std::distance(f,e); if (n==0) return 0; Vector const& v0 = *f; - // FIXME: Uh? Using it on a vector ?! int d=vd(v0); Matrix m(d,n); for(int j=0;j struct Linear_rank : private Store_kernel { }; } -CGAL_KD_DEFAULT_FUNCTOR(Linear_rank_tag,(CartesianDKernelFunctors::Linear_rank),(Vector_tag),(Point_dimension_tag,Compute_vector_cartesian_coordinate_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Linear_rank_tag,(CartesianDKernelFunctors::Linear_rank),(Vector_tag),(Vector_dimension_tag,Compute_vector_cartesian_coordinate_tag)); namespace CartesianDKernelFunctors { template struct Linearly_independent : private Store_kernel { @@ -286,9 +284,8 @@ template struct Linearly_independent : private Store_kernel { template result_type operator()(Iter f, Iter e)const{ - typename Get_functor::type vd(this->kernel()); + typename Get_functor::type vd(this->kernel()); std::ptrdiff_t n=std::distance(f,e); - // FIXME: Uh? Using it on a vector ?! int d=vd(*f); if (n>d) return false; typename Get_functor::type lr(this->kernel()); @@ -297,7 +294,7 @@ template struct Linearly_independent : private Store_kernel { }; } -CGAL_KD_DEFAULT_FUNCTOR(Linearly_independent_tag,(CartesianDKernelFunctors::Linearly_independent),(Vector_tag),(Point_dimension_tag,Linear_rank_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Linearly_independent_tag,(CartesianDKernelFunctors::Linearly_independent),(Vector_tag),(Vector_dimension_tag,Linear_rank_tag)); namespace CartesianDKernelFunctors { template struct Contained_in_linear_hull : private Store_kernel { @@ -311,10 +308,9 @@ template struct Contained_in_linear_hull : private Store_kernel { template result_type operator()(Iter f, Iter e,V const&w)const{ typename Get_functor::type c(this->kernel()); - typename Get_functor::type vd(this->kernel()); + typename Get_functor::type vd(this->kernel()); std::ptrdiff_t n=std::distance(f,e); if (n==0) return false; - // FIXME: Uh? Using it on a vector ?! int d=vd(w); Matrix m(d,n+1); for(int i=0; f!=e; ++f,++i){ @@ -336,7 +332,7 @@ template struct Contained_in_linear_hull : private Store_kernel { }; } -CGAL_KD_DEFAULT_FUNCTOR(Contained_in_linear_hull_tag,(CartesianDKernelFunctors::Contained_in_linear_hull),(Vector_tag),(Point_dimension_tag,Compute_vector_cartesian_coordinate_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Contained_in_linear_hull_tag,(CartesianDKernelFunctors::Contained_in_linear_hull),(Vector_tag),(Vector_dimension_tag,Compute_vector_cartesian_coordinate_tag)); namespace CartesianDKernelFunctors { template struct Affine_rank : private Store_kernel { @@ -464,12 +460,11 @@ template struct Linear_base : private Store_kernel { template result_type operator()(Iter f, Iter e, Oter o)const{ typename Get_functor::type c(this->kernel()); - typename Get_functor::type vd(this->kernel()); + typename Get_functor::type vd(this->kernel()); typename Get_functor >::type cv(this->kernel()); std::ptrdiff_t n=std::distance(f,e); if (n==0) return; Vector const& v0 = *f; - // FIXME: Uh? Using it on a vector ?! int d=vd(v0); Matrix m(d,n); for(int j=0;j struct Linear_base : private Store_kernel { }; } -CGAL_KD_DEFAULT_FUNCTOR(Linear_base_tag,(CartesianDKernelFunctors::Linear_base),(Vector_tag),(Point_dimension_tag,Compute_vector_cartesian_coordinate_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Linear_base_tag,(CartesianDKernelFunctors::Linear_base),(Vector_tag),(Vector_dimension_tag,Compute_vector_cartesian_coordinate_tag)); #if 0 namespace CartesianDKernelFunctors { From 530238db1a2f0bd076b454654326d821c5a5484d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 14:54:30 +0100 Subject: [PATCH 028/203] Remove some C++98 code to unclutter the files a bit. --- .../CGAL/NewKernel_d/Cartesian_LA_functors.h | 38 --------- .../CGAL/NewKernel_d/Cartesian_filter_NT.h | 26 ------ .../CGAL/NewKernel_d/Define_kernel_types.h | 5 -- .../CGAL/NewKernel_d/Filtered_predicate2.h | 29 ------- .../CGAL/NewKernel_d/Kernel_d_interface.h | 17 ---- .../include/CGAL/NewKernel_d/LA_eigen/LA.h | 6 +- .../CGAL/NewKernel_d/LA_eigen/constructors.h | 2 - .../NewKernel_d/Types/Aff_transformation.h | 13 --- .../include/CGAL/NewKernel_d/Types/Segment.h | 2 +- .../include/CGAL/NewKernel_d/functor_tags.h | 4 - NewKernel_d/include/CGAL/NewKernel_d/utils.h | 85 +------------------ NewKernel_d/include/CGAL/argument_swaps.h | 19 ----- .../include/CGAL/iterator_from_indices.h | 4 - .../include/CGAL/transforming_iterator.h | 5 -- .../include/CGAL/transforming_pair_iterator.h | 5 -- NewKernel_d/include/CGAL/typeset.h | 43 ---------- 16 files changed, 6 insertions(+), 297 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h index b15b44fe3ec..da49afa43c2 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h @@ -31,35 +31,9 @@ namespace CGAL { namespace CartesianDVectorBase { -#ifndef CGAL_CXX11 -namespace internal { -template struct Construct_LA_vector_ { - struct Never_use {}; - void operator()(Never_use)const; -}; -#define CGAL_CODE(Z,N,_) template struct Construct_LA_vector_ > { \ - typedef typename R::Constructor Constructor; \ - typedef typename Get_type::type RT; \ - typedef typename R::Vector_ result_type; \ - result_type operator() \ - (BOOST_PP_ENUM_PARAMS(N,RT const& t)) const { \ - return typename Constructor::Values()(BOOST_PP_ENUM_PARAMS(N,t)); \ - } \ - result_type operator() \ - (BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N),RT const& t)) const { \ - return typename Constructor::Values_divide()(t##N,BOOST_PP_ENUM_PARAMS(N,t)); \ - } \ - }; -BOOST_PP_REPEAT_FROM_TO(2, 11, CGAL_CODE, _ ) -#undef CGAL_CODE -} -#endif template struct Construct_LA_vector : private Store_kernel -#ifndef CGAL_CXX11 -, public internal::Construct_LA_vector_ -#endif { //CGAL_FUNCTOR_INIT_IGNORE(Construct_LA_vector) CGAL_FUNCTOR_INIT_STORE(Construct_LA_vector) @@ -87,12 +61,9 @@ template struct Construct_LA_vector result_type operator()(result_type const& v)const{ return v; } -#ifdef CGAL_CXX11 result_type operator()(result_type&& v)const{ return std::move(v); } -#endif -#ifdef CGAL_CXX11 template typename std::enable_if::value && boost::is_same, Dimension>::value, @@ -108,9 +79,6 @@ template struct Construct_LA_vector operator()(U&&...u)const{ return Apply_to_last_then_rest()(typename Constructor::Values_divide(),std::forward(u)...); } -#else - using internal::Construct_LA_vector_::operator(); -#endif template inline typename boost::enable_if,result_type>::type operator() (Iter f,Iter g,Cartesian_tag t)const @@ -178,13 +146,7 @@ template struct Compute_cartesian_coordinate { typedef typename R::Vector_ first_argument_type; typedef int second_argument_type; typedef Tag_true Is_exact; -#ifdef CGAL_CXX11 typedef decltype(std::declval()[0]) result_type; -#else - typedef RT const& result_type; - // RT const& doesn't work with some LA (Eigen2 for instance) so we - // should use plain RT or find a way to detect this. -#endif result_type operator()(first_argument_type const& v,int i)const{ return v[i]; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h index d4219348199..99144377986 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h @@ -49,7 +49,6 @@ struct Cartesian_filter_NT : public Base_ type(Cartesian_filter_NT const&k):p1(reinterpret_cast(k)),p2(reinterpret_cast(k)){} //FIXME: if predicate's constructor takes a kernel as argument, how do we translate that? reinterpret_cast is really ugly and possibly unsafe. -#ifdef CGAL_CXX11 template result_type operator()(U&&...u)const{ { Protect_FPU_rounding p; @@ -60,31 +59,6 @@ struct Cartesian_filter_NT : public Base_ } return p2(std::forward(u)...); } -#else - result_type operator()()const{ // does it make sense to have 0 argument? - { - Protect_FPU_rounding p; - try { - typename P1::result_type res=p1(); - if(is_certain(res)) return get_certain(res); - } catch (Uncertain_conversion_exception&) {} - } - return p2(); - } -#define CGAL_CODE(Z,N,_) template result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t))const{ \ - { \ - Protect_FPU_rounding p; \ - try { \ - typename P1::result_type res=p1(BOOST_PP_ENUM_PARAMS(N,t)); \ - if(is_certain(res)) return get_certain(res); \ - } catch (Uncertain_conversion_exception&) {} \ - } \ - return p2(BOOST_PP_ENUM_PARAMS(N,t)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - -#endif }; }; }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Define_kernel_types.h b/NewKernel_d/include/CGAL/NewKernel_d/Define_kernel_types.h index 92f39a7e842..74df9d5b232 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Define_kernel_types.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Define_kernel_types.h @@ -23,11 +23,6 @@ #include #include #include -#ifdef CGAL_CXX11 -#include -#else -#include -#endif namespace CGAL { namespace internal { diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h index 920a7d70735..1fff3e19a49 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h @@ -81,7 +81,6 @@ public: : ep(k.exact_kernel()), ap(k.approximate_kernel()), c2e(k,k.exact_kernel()), c2a(k,k.approximate_kernel()) {} -#ifdef CGAL_CXX11 template result_type operator()(Args&&... args) const @@ -103,34 +102,6 @@ public: Protect_FPU_rounding p(CGAL_FE_TONEAREST); return ep(c2e(std::forward(args))...); } -#else - -#define CGAL_VAR(Z,N,C) C(a##N) -#define CGAL_CODE(Z,N,_) \ - template \ - result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a)) const \ - { \ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ - { \ - Protect_FPU_rounding p; \ - try \ - { \ - Ares res = ap(BOOST_PP_ENUM(N,CGAL_VAR,c2a)); \ - if (is_certain(res)) \ - return get_certain(res); \ - } \ - catch (Uncertain_conversion_exception&) {} \ - } \ - CGAL_BRANCH_PROFILER_BRANCH(tmp); \ - Protect_FPU_rounding p(CGAL_FE_TONEAREST); \ - return ep(BOOST_PP_ENUM(N,CGAL_VAR,c2e)); \ - } - BOOST_PP_REPEAT_FROM_TO(1, 10, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR - -#endif }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index f6463dda4dd..9210cb07600 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -89,7 +89,6 @@ template struct Kernel_d_interface : public Base_ { Point_d operator()(Weighted_point_d const&wp)const{ return typename Get_functor::type(this->kernel())(wp); } -#ifdef CGAL_CXX11 Point_d operator()(Weighted_point_d &wp)const{ return typename Get_functor::type(this->kernel())(wp); } @@ -100,26 +99,10 @@ template struct Kernel_d_interface : public Base_ { return typename Get_functor::type(this->kernel())(std::move(wp)); } template -# if CGAL_CXX14 decltype(auto) -# else - Point_d -# endif operator()(T&&...t)const{ return CP(this->kernel())(std::forward(t)...); - //return CP(this->kernel())(t...); } -#else // not CGAL_CXX11 -# define CGAL_CODE(Z,N,_) template \ - Point_d operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t))const{ \ - return CP(this->kernel())(BOOST_PP_ENUM_PARAMS(N,t)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -# undef CGAL_CODE - Point_d operator()()const{ \ - return CP(this->kernel())(); \ - } -#endif // not CGAL_CXX11 }; typedef typename Get_functor >::type Construct_vector_d; typedef typename Get_functor >::type Construct_segment_d; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/LA.h b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/LA.h index 57507b27815..b3d23ea32e3 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/LA.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/LA.h @@ -58,11 +58,7 @@ template struct LA_eigen { #if (EIGEN_WORLD_VERSION>=3) typedef NT const* Vector_const_iterator; #else - typedef Iterator_from_indices Vector_const_iterator; + typedef Iterator_from_indices Vector_const_iterator; #endif templatestatic Vector_const_iterator vector_begin(Vec_ const&a){ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h index 23c143891e5..f61f80a79f0 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h @@ -99,7 +99,6 @@ namespace CGAL { } }; -#ifdef CGAL_CXX11 struct Initializer_list { // Fix T==NT? template @@ -107,7 +106,6 @@ namespace CGAL { return Iterator()(l.size(),l.begin(),l.end()); } }; -#endif struct Values { #ifdef CGAL_CXX11 diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Aff_transformation.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Aff_transformation.h index f1da46fa1a2..cf0465bbcaa 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Aff_transformation.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Aff_transformation.h @@ -36,21 +36,8 @@ template struct Construct_aff_transformation { CGAL_FUNCTOR_INIT_IGNORE(Construct_aff_transformation) typedef R_ R; typedef typename Get_type::type result_type; -#ifdef CGAL_CXX11 template result_type operator()(T&&...)const{return result_type();} -#else - result_type operator()()const{ - return result_type(); - } -#define CGAL_CODE(Z,N,_) template \ - result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const& BOOST_PP_INTERCEPT))const{ \ - return result_type(); \ - } - BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_CODE, _ ) -#undef CGAL_CODE - -#endif }; } CGAL_KD_DEFAULT_TYPE(Aff_transformation_tag,(CGAL::Aff_transformation),(),()); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h index dc3047e05f2..cca4b3d6754 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h @@ -35,7 +35,7 @@ template class Segment { public: //typedef Segmentd Segment; #ifdef CGAL_CXX11 - //FIXME: don't forward directly, piecewise_constuct should call the point construction functor (I guess? or is it unnecessary?) + //FIXME: don't forward directly, piecewise_construct should call the point construction functor (I guess? or is it unnecessary?) template::type...>,std::tuple>::value>::type> Segment(U&&...u):data(std::forward(u)...){} #else diff --git a/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h b/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h index 3ed395c4403..58fbef78dd7 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h @@ -22,10 +22,8 @@ #define CGAL_FUNCTOR_TAGS_H #include // for Null_tag #include -#ifdef CGAL_CXX11 #include #include -#endif #include #include #include @@ -42,10 +40,8 @@ namespace CGAL { : K::template Type {}; template struct Get_functor : K::template Functor {}; -#ifdef CGAL_CXX11 template using Type = typename Get_type::type; template using Functor = typename Get_functor::type; -#endif class Null_type {~Null_type();}; // no such object should be created diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index b4f44752983..fa4c043138a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -29,19 +29,12 @@ // http://lists.boost.org/boost-users/2014/11/83291.php #endif -#ifdef CGAL_CXX11 #include #include #define CGAL_FORWARDABLE(T) T&& #define CGAL_FORWARD(T,t) std::forward(t) #define CGAL_MOVE(t) std::move(t) #define CGAL_CONSTEXPR constexpr -#else -#define CGAL_FORWARDABLE(T) T const& -#define CGAL_FORWARD(T,t) t -#define CGAL_MOVE(t) t -#define CGAL_CONSTEXPR -#endif #include #include #include @@ -50,11 +43,7 @@ #include #include -#ifdef CGAL_CXX11 #define CGAL_BOOSTD std:: -#else -#define CGAL_BOOSTD boost:: -#endif namespace CGAL { namespace internal { @@ -81,17 +70,10 @@ struct Has_type_different_from // like std::forward, except for basic types where it does a cast, to // avoid issues with narrowing conversions -#ifdef CGAL_CXX11 template inline typename std::conditional::value&&std::is_arithmetic::type>::value,T,U&&>::type forward_safe(V&& u) { return std::forward(u); } -#else - template inline U const& forward_safe(U const& u) { - return u; - } -#endif -#ifdef CGAL_CXX11 template struct Constructible_from_each; template struct Constructible_from_each{ enum { value=std::is_convertible::value&&Constructible_from_each::value }; @@ -99,25 +81,12 @@ struct Has_type_different_from template struct Constructible_from_each{ enum { value=true }; }; -#else -// currently only used in C++0X code -#endif template struct Scale { -#ifndef CGAL_CXX11 - template struct result; - template struct result { - typedef FT type; - }; -#endif T const& scale; Scale(T const& t):scale(t){} template -#ifdef CGAL_CXX11 - auto operator()(FT&& x)const->decltype(scale*std::forward(x)) -#else - FT operator()(FT const& x)const -#endif + decltype(auto) operator()(FT&& x)const { return scale*CGAL_FORWARD(FT,x); } @@ -135,13 +104,9 @@ struct Has_type_different_from T const& scale; Divide(T const& t):scale(t){} template -#ifdef CGAL_CXX11 //FIXME: gcc complains for Gmpq - //auto operator()(FT&& x)const->decltype(Rational_traits().make_rational(std::forward(x),scale)) + //decltype(auto) operator()(FT&& x)const NT operator()(FT&& x)const -#else - NT operator()(FT const& x)const -#endif { return Rational_traits(). make_rational(CGAL_FORWARD(FT,x),scale); @@ -158,11 +123,7 @@ struct Has_type_different_from template < class Ret > struct multiplies { template -#ifdef CGAL_CXX11 - auto operator()(A&&a,B&&b)const->decltype(std::forward(a)*std::forward(b)) -#else - Ret operator()(A const& a, B const& b)const -#endif + decltype(auto) operator()(A&&a,B&&b)const { return CGAL_FORWARD(A,a)*CGAL_FORWARD(B,b); } @@ -170,27 +131,17 @@ struct Has_type_different_from template < class Ret > struct division { template -#ifdef CGAL_CXX11 - auto operator()(A&&a,B&&b)const->decltype(std::forward(a)/std::forward(b)) -#else - Ret operator()(A const& a, B const& b)const -#endif + decltype(auto) operator()(A&&a,B&&b)const { return CGAL_FORWARD(A,a)/CGAL_FORWARD(B,b); } }; -#ifdef CGAL_CXX11 using std::decay; -#else - template struct decay : boost::remove_cv::type> {}; -#endif template struct Type_copy_ref { typedef U type; }; template struct Type_copy_ref { typedef U& type; }; -#ifdef CGAL_CXX11 template struct Type_copy_ref { typedef U&& type; }; -#endif template struct Type_copy_cv { typedef U type; }; template struct Type_copy_cv { typedef U const type; }; template struct Type_copy_cv { typedef U volatile type; }; @@ -210,7 +161,6 @@ struct Has_type_different_from } }; -#ifdef CGAL_CXX11 template struct Indices{}; template struct Next_increasing_indices; template struct Next_increasing_indices > { @@ -232,39 +182,12 @@ struct Has_type_different_from return internal::do_call_on_tuple_elements(std::forward(f),std::move(t), typename N_increasing_indices::type()); } -#else -#define CGAL_VAR(Z,N,_) cpp0x::get(t) -#define CGAL_CODE(Z,N,_) template \ - inline Res call_on_tuple_elements(F const&f, \ - cpp0x::tuple const&t) { \ - return f(BOOST_PP_ENUM(N,CGAL_VAR,)); \ - } - template - inline Res call_on_tuple_elements(F const&f, cpp0x::tuple<>) { - return f(); - } -BOOST_PP_REPEAT_FROM_TO(1, 8, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR -#endif template struct Factory { typedef A result_type; -#ifdef CGAL_CXX11 template result_type operator()(U&&...u)const{ return A(std::forward(u)...); } -#else - result_type operator()()const{ - return A(); - } -#define CGAL_CODE(Z,N,_) template \ - result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return A(BOOST_PP_ENUM_PARAMS(N,u)); \ - } -BOOST_PP_REPEAT_FROM_TO(1, 8, CGAL_CODE, _ ) -#undef CGAL_CODE -#endif }; } diff --git a/NewKernel_d/include/CGAL/argument_swaps.h b/NewKernel_d/include/CGAL/argument_swaps.h index b23e3b6d1dc..1ebef4de555 100644 --- a/NewKernel_d/include/CGAL/argument_swaps.h +++ b/NewKernel_d/include/CGAL/argument_swaps.h @@ -30,9 +30,6 @@ #endif namespace CGAL { - -#ifdef CGAL_CXX11 - namespace internal { template struct Apply_to_last_then_rest_; @@ -55,10 +52,8 @@ struct Apply_to_last_then_rest_<0,F,T,U...> { return std::forward(f)(std::forward(t), std::forward(u)...); } }; - } // namespace internal - struct Apply_to_last_then_rest { template inline typename internal::Apply_to_last_then_rest_::result_type @@ -70,20 +65,6 @@ struct Apply_to_last_then_rest { } }; -#else // CGAL_CXX11 - -struct Apply_to_last_then_rest { -#define CGAL_CODE(Z,N,_) template \ - typename boost::result_of::type \ - operator()(F const&f, BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t), T const&t) const { \ - return f(t,BOOST_PP_ENUM_PARAMS(N,t)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE -}; - -#endif // CGAL_CXX11 - } // namespace CGAL #endif // CGAL_ARGUMENT_SWAPS_H diff --git a/NewKernel_d/include/CGAL/iterator_from_indices.h b/NewKernel_d/include/CGAL/iterator_from_indices.h index 895a5f47916..f79a3e89bf2 100644 --- a/NewKernel_d/include/CGAL/iterator_from_indices.h +++ b/NewKernel_d/include/CGAL/iterator_from_indices.h @@ -33,11 +33,7 @@ struct Default_coordinate_access { //TODO: default type for Value_: typename same_cv::type::value_type>::type template ()[0]) -#else - Value_& -#endif , class Coord_access = Default_coordinate_access > class Iterator_from_indices diff --git a/NewKernel_d/include/CGAL/transforming_iterator.h b/NewKernel_d/include/CGAL/transforming_iterator.h index 5140df7a3e6..107a42e8e87 100644 --- a/NewKernel_d/include/CGAL/transforming_iterator.h +++ b/NewKernel_d/include/CGAL/transforming_iterator.h @@ -62,12 +62,7 @@ class transforming_iterator_helper typedef std::iterator_traits Iter_traits; typedef typename Iter_traits::reference Iter_ref; typedef typename Default::Get()(std::declval())) -#else - typename boost::result_of::type - // should be reference instead of value_type -#endif >::type reference_; typedef typename Default::Get::type>::type>::type value_type; diff --git a/NewKernel_d/include/CGAL/transforming_pair_iterator.h b/NewKernel_d/include/CGAL/transforming_pair_iterator.h index 1f2b3033642..8bc7d824d1f 100644 --- a/NewKernel_d/include/CGAL/transforming_pair_iterator.h +++ b/NewKernel_d/include/CGAL/transforming_pair_iterator.h @@ -53,12 +53,7 @@ class transforming_pair_iterator_helper ::type iterator_category; typedef typename Default::Get()(std::declval::reference>(),std::declval::reference>())) -#else - typename boost::result_of::value_type,typename std::iterator_traits::value_type)>::type - // should be reference instead of value_type -#endif >::type reference; typedef typename Default::Get::type>::type>::type value_type; diff --git a/NewKernel_d/include/CGAL/typeset.h b/NewKernel_d/include/CGAL/typeset.h index 1bba56618e9..ba6a04ec37f 100644 --- a/NewKernel_d/include/CGAL/typeset.h +++ b/NewKernel_d/include/CGAL/typeset.h @@ -21,17 +21,12 @@ #ifndef CGAL_TYPESET_H #define CGAL_TYPESET_H #include -#ifdef CGAL_CXX11 #include -#else -#include -#endif // Sometimes using tuple just to list types is overkill (takes forever to // instantiate). namespace CGAL { -#ifdef CGAL_CXX11 template struct typeset; template struct typeset { typedef H head; @@ -55,33 +50,6 @@ namespace CGAL { template using contains = std::false_type; template using add = typeset; }; -#else - template struct typeset; - template, void, typeset >::type > - struct typeset { - typedef typeset type; - typedef H head; - typedef T tail; - template struct contains : - boost::mpl::if_,boost::true_type,typename tail::template contains >::type - {}; - template struct add; - //boost::mpl::if_,typeset,typeset >::type - }; - template<> struct typeset<> { - typedef typeset type; - template struct contains : boost::false_type {}; - template struct add : CGAL::typeset {}; - }; - - template - template - struct typeset::add : typeset::type> {}; - template - template - struct typeset::add : typeset {}; -#endif template struct typeset_union_ : typeset_union_::type, typename T2::tail> @@ -93,26 +61,15 @@ namespace CGAL { typedef typename T1::head H; typedef typename typeset_intersection_::type U; typedef typename -#ifdef CGAL_CXX11 std::conditional::value, -#else - boost::mpl::if_, -#endif typename U::template add::type, U>::type type; }; template struct typeset_intersection_,T> : typeset<> {}; -#ifdef CGAL_CXX11 template using typeset_union = typename typeset_union_::type; template using typeset_intersection = typename typeset_intersection_::type; -#else - template - struct typeset_union : typeset_union_::type {}; - template - struct typeset_intersection : typeset_intersection_::type {}; -#endif } #endif From cde81908d4f61d748775cd26f5a224309bc48951 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:18:09 +0100 Subject: [PATCH 029/203] Remove some C++98 code to unclutter the files a bit. --- .../NewKernel_d/Kernel_object_converter.h | 3 +- .../include/CGAL/NewKernel_d/Vector/array.h | 27 ------ .../include/CGAL/NewKernel_d/Vector/vector.h | 31 ------- .../CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h | 59 ------------- .../CGAL/NewKernel_d/Wrapper/Hyperplane_d.h | 29 ------- .../CGAL/NewKernel_d/Wrapper/Point_d.h | 32 ------- .../CGAL/NewKernel_d/Wrapper/Ref_count_obj.h | 31 ------- .../CGAL/NewKernel_d/Wrapper/Segment_d.h | 29 ------- .../CGAL/NewKernel_d/Wrapper/Sphere_d.h | 29 ------- .../CGAL/NewKernel_d/Wrapper/Vector_d.h | 32 ------- .../NewKernel_d/Wrapper/Weighted_point_d.h | 29 ------- .../NewKernel_d/function_objects_cartesian.h | 85 ------------------- 12 files changed, 1 insertion(+), 415 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h index 152b4f47eda..3022ec4997a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h @@ -42,7 +42,7 @@ struct Point_converter_help { return cp(conv(i(p,Begin_tag())),conv(i(p,End_tag()))); } }; -#ifdef CGAL_CXX11 + // This doesn't seem so useful, the compiler should be able to handle // the iterators just as efficiently. template @@ -60,7 +60,6 @@ struct Point_converter_help,K1,K2> { return help(typename N_increasing_indices::type(),k1,k2,conv,p); } }; -#endif } template struct KO_converter : internal::Point_converter_help diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h index f600134e0e4..71e17313ced 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h @@ -105,48 +105,21 @@ template struct Array_vector { }; struct Values { -#ifdef CGAL_CXX11 template Vector operator()(U&&...u) const { static_assert(sizeof...(U)<=d_,"too many arguments"); Vector a={{forward_safe(u)...}}; return a; } -#else - -#define CGAL_CODE(Z,N,_) Vector operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - CGAL_assertion(N<=d_); \ - Vector a={{BOOST_PP_ENUM_PARAMS(N,t)}}; \ - return a; \ -} -BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) -#undef CGAL_CODE - -#endif }; struct Values_divide { -#ifdef CGAL_CXX11 template Vector operator()(H const& h,U&&...u) const { static_assert(sizeof...(U)<=d_,"too many arguments"); Vector a={{Rational_traits().make_rational(std::forward(u),h)...}}; return a; } -#else - -#define CGAL_VAR(Z,N,_) Rational_traits().make_rational( t##N , h) -#define CGAL_CODE(Z,N,_) template Vector \ - operator()(H const&h, BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - CGAL_assertion(N<=d_); \ - Vector a={{BOOST_PP_ENUM(N,CGAL_VAR,_)}}; \ - return a; \ - } - BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR - -#endif }; }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h index 1c173a13901..1f2023c0785 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h @@ -100,31 +100,15 @@ template struct Vector_vector { #endif struct Values { -#ifdef CGAL_CXX11 template Vector operator()(U&&...u) const { //TODO: check the right number of {}, g++ accepts one and two Vector a={forward_safe(u)...}; return a; } -#else - -#define CGAL_VAR(Z,N,_) a.push_back(t##N); -#define CGAL_CODE(Z,N,_) Vector operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - Vector a; \ - a.reserve(N); \ - BOOST_PP_REPEAT(N,CGAL_VAR,) \ - return a; \ -} -BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR - -#endif }; struct Values_divide { -#ifdef CGAL_CXX11 template Vector operator()(H const&h,U&&...u) const { //TODO: do we want to cast at some point? @@ -133,21 +117,6 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) Vector a={Rational_traits().make_rational(std::forward(u),h)...}; return a; } -#else - -#define CGAL_VAR(Z,N,_) a.push_back(Rational_traits().make_rational( t##N ,h)); -#define CGAL_CODE(Z,N,_) template Vector \ - operator()(H const&h, BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - Vector a; \ - a.reserve(N); \ - BOOST_PP_REPEAT(N,CGAL_VAR,) \ - return a; \ - } - BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR - -#endif }; }; typedef typename Vector::const_iterator Vector_const_iterator; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h index a97529bf6e7..fb769112a4e 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h @@ -145,29 +145,9 @@ struct Cartesian_wrap : public Base_ B b; type(){} type(Self const&k):b(k){} -#ifdef CGAL_CXX11 template decltype(auto) operator()(U&&...u)const{ return b(internal::Forward_rep()(u)...); } -#else -#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CGAL_CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return b(BOOST_PP_ENUM(N,CGAL_VAR,)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE -#undef CGAL_VAR -// In case the last argument needs to be non-const. Fragile... -#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CGAL_CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u),V&v)const{ \ - return b(BOOST_PP_ENUM(N,CGAL_VAR,),internal::Forward_rep()(v)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,8,CGAL_CODE,_) -#undef CGAL_CODE -#undef CGAL_VAR -#endif }; }; @@ -187,20 +167,9 @@ struct Cartesian_wrap : public Base_ typedef typename map_result_tag::type result_tag; // FIXME: Self or Derived? typedef typename Get_type::type result_type; -#ifdef CGAL_CXX11 template result_type operator()(U&&...u)const{ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); } -#else -#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CGAL_CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return result_type(Eval_functor(),b,BOOST_PP_ENUM(N,CGAL_VAR,)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE -#undef CGAL_VAR -#endif }; }; @@ -241,23 +210,9 @@ struct Cartesian_refcount : public Base_ type(){} type(Self const&k):b(k){} typedef typename B::result_type result_type; -#ifdef CGAL_CXX11 template result_type operator()(U&&...u)const{ return b(internal::Forward_rep()(u)...); } -#else - result_type operator()()const{ - return b(); - } -#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CGAL_CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return b(BOOST_PP_ENUM(N,CGAL_VAR,)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE -#undef CGAL_VAR -#endif }; }; @@ -274,23 +229,9 @@ struct Cartesian_refcount : public Base_ type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; typedef typename Get_type::type result_type; -#ifdef CGAL_CXX11 template result_type operator()(U&&...u)const{ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); } -#else - result_type operator()()const{ - return result_type(Eval_functor(),b); - } -#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CGAL_CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return result_type(Eval_functor(),b,BOOST_PP_ENUM(N,CGAL_VAR,)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE -#undef CGAL_VAR -#endif }; }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h index 1dff1b59f20..0b9547646fb 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h @@ -26,10 +26,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif -#include namespace CGAL { namespace Wrap { @@ -67,7 +63,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Hyperplane_d(U&&...u) : Rep(CHBase()(std::forward(u)...)){} @@ -89,30 +84,6 @@ public: Hyperplane_d(Rep& v) : Rep(static_cast(v)) {} Hyperplane_d(Rep&& v) : Rep(std::move(v)) {} -#else - - Hyperplane_d() : Rep(CHBase()()) {} - - Hyperplane_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Hyperplane_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CHBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Hyperplane_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - -#endif //TODO: if OVBase returns a reference to a base vector, cast it to a //reference to a wrapper vector. Ugly but should be safe. diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index 831ec157762..d4fe244e6c3 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -31,9 +31,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif #include namespace CGAL { @@ -77,7 +74,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Point_d(U&&...u) : Rep(CPBase()(std::forward(u)...)){} @@ -107,34 +103,6 @@ public: Point_d(Origin&& v) : Rep(CPBase()(std::move(v))) {} -#else - - Point_d() : Rep(CPBase()()) {} - - Point_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Point_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CPBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Point_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - - // this one should be implicit - Point_d(Origin const& o) - : Rep(CPBase()(o)) {} - -#endif typename boost::result_of::type cartesian(int i)const{ return CCBase()(rep(),i); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h index be1de7fd5ed..403eeb6ba9f 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h @@ -29,10 +29,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif -#include // no need for a fancy interface here, people can use the Point_d wrapper on // top. @@ -67,7 +63,6 @@ public: return CGAL::get_pointee_or_identity(data); } -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Ref_count_obj(U&&...u) : data(Eval_functor(),CBase(),std::forward(u)...){} @@ -88,32 +83,6 @@ public: // Ref_count_obj(Origin&& v) // : data(Eval_functor(),CBase(),std::move(v)) {} -#else - - Ref_count_obj() : data(Eval_functor(),CBase()) {} - - Ref_count_obj(Rep const& v) : data(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Ref_count_obj(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : data(Eval_functor(),CBase(),BOOST_PP_ENUM_PARAMS(N,t)) {} \ - \ - template \ - Ref_count_obj(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : data(Eval_functor(),f,BOOST_PP_ENUM_PARAMS(N,t)) {} - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - template - Ref_count_obj(Eval_functor,F const& f) - : data(Eval_functor(),f) {} - -// // this one should be implicit -// Ref_count_obj(Origin const& o) -// : data(Eval_functor(),CBase(),o) {} - -#endif - }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Segment_d.h index 5194c8bc2bc..080960f795a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Segment_d.h @@ -28,10 +28,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif -#include namespace CGAL { namespace Wrap { @@ -70,7 +66,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Segment_d(U&&...u) : Rep(CSBase()(std::forward(u)...)){} @@ -92,30 +87,6 @@ public: Segment_d(Rep& v) : Rep(static_cast(v)) {} Segment_d(Rep&& v) : Rep(std::move(v)) {} -#else - - Segment_d() : Rep(CSBase()()) {} - - Segment_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Segment_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CSBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Segment_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - -#endif //TODO: if CSEBase returns a reference to a base point, cast it to a //reference to a wrapper point. Ugly but should be safe. diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Sphere_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Sphere_d.h index c56d7f43beb..118a01ab154 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Sphere_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Sphere_d.h @@ -26,10 +26,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif -#include namespace CGAL { namespace Wrap { @@ -67,7 +63,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Sphere_d(U&&...u) : Rep(CSBase()(std::forward(u)...)){} @@ -89,30 +84,6 @@ public: Sphere_d(Rep& v) : Rep(static_cast(v)) {} Sphere_d(Rep&& v) : Rep(std::move(v)) {} -#else - - Sphere_d() : Rep(CSBase()()) {} - - Sphere_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Sphere_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CSBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Sphere_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - -#endif //TODO: if COSBase returns a reference to a base point, cast it to a //reference to a wrapper point. Ugly but should be safe. diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h index c85a252891e..4df349df909 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h @@ -31,9 +31,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif #include namespace CGAL { @@ -75,7 +72,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Vector_d(U&&...u) : Rep(CVBase()(std::forward(u)...)){} @@ -105,34 +101,6 @@ public: Vector_d(Null_vector&& v) : Rep(CVBase()(std::move(v))) {} -#else - - Vector_d() : Rep(CVBase()()) {} - - Vector_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Vector_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CVBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Vector_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Vector_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - - // this one should be implicit - Vector_d(Null_vector const& v) - : Rep(CVBase()(v)) {} - -#endif typename boost::result_of::type cartesian(int i)const{ return CCBase()(rep(),i); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h index 3b5ceb6bb31..f86cda64c04 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h @@ -29,10 +29,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif -#include namespace CGAL { namespace Wrap { @@ -70,7 +66,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Weighted_point_d(U&&...u) : Rep(CWPBase()(std::forward(u)...)){} @@ -92,30 +87,6 @@ public: Weighted_point_d(Rep& v) : Rep(static_cast(v)) {} Weighted_point_d(Rep&& v) : Rep(std::move(v)) {} -#else - - Weighted_point_d() : Rep(CWPBase()()) {} - - Weighted_point_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Weighted_point_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CWPBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Weighted_point_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - -#endif //TODO: use references? Point_ point()const{ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 0d41eb59707..808bcafc2bb 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -35,9 +35,7 @@ #include #include #include -#ifdef CGAL_CXX11 #include -#endif namespace CGAL { namespace CartesianDKernelFunctors { @@ -73,7 +71,6 @@ template,typename R::Default_ambient_dimension>::value>::type> template =3)>::type> @@ -85,28 +82,8 @@ template l) const { return operator()(l.begin(),l.end()); } -#else - //should we make it template to avoid instantiation for wrong dim? - //or iterate outside the class? -#define CGAL_VAR(Z,J,I) m(I,J)=c(p##I,J)-c(x,J); -#define CGAL_VAR2(Z,I,N) BOOST_PP_REPEAT(N,CGAL_VAR,I) -#define CGAL_CODE(Z,N,_) \ - result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ - typename Get_functor::type c(this->kernel()); \ - Matrix m(N,N); \ - BOOST_PP_REPEAT(N,CGAL_VAR2,N) \ - return R::LA::sign_of_determinant(CGAL_MOVE(m)); \ - } - -BOOST_PP_REPEAT_FROM_TO(7, 10, CGAL_CODE, _ ) - // No need to do it for <=6, since that uses a different code path -#undef CGAL_CODE -#undef CGAL_VAR2 -#undef CGAL_VAR -#endif }; -#ifdef CGAL_CXX11 template struct Orientation_of_points,true> : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; @@ -139,40 +116,6 @@ template struct Orientation_of_points,true> return help2(Dimension_tag(),f,e); } }; -#else -#define CGAL_VAR(Z,J,I) c(p##I,J)-x##J -#define CGAL_VAR2(Z,I,N) BOOST_PP_ENUM(N,CGAL_VAR,I) -#define CGAL_VAR3(Z,N,_) Point const&p##N=*++f; -#define CGAL_VAR4(Z,N,_) RT const&x##N=c(x,N); -#define CGAL_CODE(Z,N,_) \ -template struct Orientation_of_points,true> : private Store_kernel { \ - CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) \ - typedef R_ R; \ - typedef typename Get_type::type RT; \ - typedef typename Get_type::type Point; \ - typedef typename Get_type::type result_type; \ - result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ - typename Get_functor::type c(this->kernel()); \ - BOOST_PP_REPEAT(N,CGAL_VAR4,) \ - return sign_of_determinant(BOOST_PP_ENUM(N,CGAL_VAR2,N)); \ - } \ - template \ - result_type operator()(Iter f, Iter CGAL_assertion_code(e))const{ \ - Point const&x=*f; \ - BOOST_PP_REPEAT(N,CGAL_VAR3,) \ - CGAL_assertion(++f==e); \ - return operator()(x,BOOST_PP_ENUM_PARAMS(N,p)); \ - } \ -}; - - BOOST_PP_REPEAT_FROM_TO(2, 7, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR4 -#undef CGAL_VAR3 -#undef CGAL_VAR2 -#undef CGAL_VAR - -#endif template struct Orientation_of_points,true> : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) @@ -224,7 +167,6 @@ template struct Orientation_of_vectors : private Store_kernel { return R::LA::sign_of_determinant(CGAL_MOVE(m)); } -#ifdef CGAL_CXX11 template =3)>::type> result_type operator()(U&&...u) const { return operator()({std::forward(u)...}); @@ -234,9 +176,6 @@ template struct Orientation_of_vectors : private Store_kernel { result_type operator()(std::initializer_list l) const { return operator()(l.begin(),l.end()); } -#else - //TODO -#endif }; } @@ -480,11 +419,7 @@ template struct Linear_base : private Store_kernel { for(int i=0; i < R::LA::columns(b); ++i){ //*o++ = Vector(b.col(i)); typedef -#ifdef CGAL_CXX11 decltype(std::declval()(0,0)) -#else - FT -#endif Ref; typedef Iterator_from_indices > IFI; @@ -657,7 +592,6 @@ template struct Side_of_oriented_sphere : private Store_kernel { return LA::sign_of_determinant(CGAL_MOVE(m)); } -#ifdef CGAL_CXX11 template =4)>::type> result_type operator()(U&&...u) const { return operator()({std::forward(u)...}); @@ -667,9 +601,6 @@ template struct Side_of_oriented_sphere : private Store_kernel { result_type operator()(std::initializer_list

l) const { return operator()(l.begin(),l.end()); } -#else - //TODO -#endif }; } @@ -816,7 +747,6 @@ template struct Side_of_bounded_sphere : private Store_kernel { return enum_cast (sos (f, e, p0) * op (f, e)); } -#ifdef CGAL_CXX11 template =4)>::type> result_type operator()(U&&...u) const { return operator()({std::forward(u)...}); @@ -826,9 +756,6 @@ template struct Side_of_bounded_sphere : private Store_kernel { result_type operator()(std::initializer_list

(p)...)); + return Help>()(c,x,std::forward_as_tuple(std::forward

(p)...)); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index 7b7981bc2ae..245ac8a4f38 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -149,32 +149,23 @@ struct Has_type_different_from template struct result { typedef typename std::iterator_traits::reference type; }; - template typename result::type + template decltype(auto) operator()(It const&i)const{ return *i; } }; - template struct Indices{}; - template struct Next_increasing_indices; - template struct Next_increasing_indices > { - typedef Indices type; - }; - template struct N_increasing_indices { - typedef typename Next_increasing_indices::type>::type type; - }; - template<> struct N_increasing_indices<0> { typedef Indices<> type; }; namespace internal { - template inline typename std::result_of::type - do_call_on_tuple_elements(F&&f, std::tuple&&t, Indices&&) { + template inline decltype(auto) + do_call_on_tuple_elements(F&&f, std::tuple&&t, std::index_sequence&&) { return f(std::get(std::move(t))...); } } // internal - template - inline typename std::result_of::type + template + inline decltype(auto) call_on_tuple_elements(F&&f, std::tuple&&t) { return internal::do_call_on_tuple_elements(std::forward(f),std::move(t), - typename N_increasing_indices::type()); + std::make_index_sequence()); } template struct Factory { From a17f5655e18b3d5e37e1a575fdf9f1fa276f5379 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 17:21:28 +0100 Subject: [PATCH 039/203] More [[no_unique_address]] --- Filtered_kernel/include/CGAL/Lazy.h | 40 +++++++++---------- .../CGAL/NewKernel_d/Filtered_predicate2.h | 8 ++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 08e51fec51c..60d01a032a8 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -787,8 +787,8 @@ struct Lazy_construction_bbox typedef typename LK::Exact_kernel EK; typedef typename AC::result_type result_type; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; template result_type operator()(const L1& l1) const @@ -818,8 +818,8 @@ struct Lazy_construction_nt { typedef typename LK::Exact_kernel EK; typedef typename LK::E2A E2A; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; template struct result { }; @@ -993,8 +993,8 @@ struct Lazy_cartesian_const_iterator_2 typedef typename LK::Exact_kernel EK; typedef typename LK::Cartesian_const_iterator_2 result_type; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1022,8 +1022,8 @@ struct Lazy_cartesian_const_iterator_3 typedef typename LK::Exact_kernel EK; typedef typename LK::Cartesian_const_iterator_3 result_type; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1054,8 +1054,8 @@ struct Lazy_functor_2_1 static const bool Protection = true; typedef void result_type; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1118,8 +1118,8 @@ struct Lazy_functor_2_2 typedef typename LK::Exact_kernel EK; typedef typename LK::E2A E2A; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1162,8 +1162,8 @@ struct Lazy_intersect_with_iterators typedef Lazy Lazy_object; typedef Lazy, std::vector, E2A> Lazy_vector; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1242,8 +1242,8 @@ struct Lazy_construction_object typedef Lazy Lazy_object; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1620,8 +1620,8 @@ struct Lazy_construction { typedef typename Type_mapper::type result_type; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; #define CGAL_CONSTRUCTION_OPERATOR(z, n, d ) \ template \ @@ -1670,8 +1670,8 @@ struct Lazy_construction // you are on your own }; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; // acquire the result_type of the approximate kernel, map it back to the lazy kernel object #define CGAL_RESULT(z, n, d) \ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h index 323537d6776..a35d1c5bcd3 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h @@ -55,10 +55,10 @@ class Filtered_predicate2 //TODO: pack (at least use a tuple) //FIXME: is it better to store those, or just store enough to recreate them //(i.e. possibly references to the kernels)? - EP ep; - AP ap; - C2E c2e; - C2A c2a; + CGAL_NO_UNIQUE_ADDRESS EP ep; + CGAL_NO_UNIQUE_ADDRESS AP ap; + CGAL_NO_UNIQUE_ADDRESS C2E c2e; + CGAL_NO_UNIQUE_ADDRESS C2A c2a; public: From e2ce6d9daaa3a2c5055d38f12293135032f4be16 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 21:36:13 +0100 Subject: [PATCH 040/203] Remove unnecessary overload of Side_of_oriented_sphere --- .../CGAL/NewKernel_d/function_objects_cartesian.h | 2 ++ NewKernel_d/test/NewKernel_d/Epick_d.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index bc8427d3355..979d1322762 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -551,11 +551,13 @@ template struct Side_of_oriented_sphere : private Store_kernel { typedef typename R::LA::template Rebind_dimension::Other LA; typedef typename LA::Square_matrix Matrix; + /* Undocumented, removed template result_type operator()(Iter f, Iter const& e)const{ Point const& p0=*f++; // *--e ? return this->operator()(f,e,p0); } + */ template result_type operator()(Iter f, Iter const& e, Point const& p0) const { diff --git a/NewKernel_d/test/NewKernel_d/Epick_d.cpp b/NewKernel_d/test/NewKernel_d/Epick_d.cpp index 503450d96d7..3bd63caf614 100644 --- a/NewKernel_d/test/NewKernel_d/Epick_d.cpp +++ b/NewKernel_d/test/NewKernel_d/Epick_d.cpp @@ -537,7 +537,7 @@ void test3(){ assert(abs(sd(e,a)-32)<.0001); P tab[]={a,b,c,d,e}; std::cout << po (&tab[0],tab+4) << ' '; - std::cout << sos(&tab[0],tab+5) << ' '; + std::cout << sos(&tab[1],tab+5,tab[0]) << ' '; std::cout << sbs(tab+1,tab+5,tab[0]) << std::endl; FO fo=cfo(&tab[0],tab+3); std::cout << fo; @@ -570,13 +570,13 @@ void test3(){ std::cout << ifsos(fo3,yy+0,yy+3,yy[3]) << ' '; std::cout << ifsos(fo3,yy+1,yy+4,yy[0]) << '\n'; P buf[]={cp(100,900,0),y[0],y[1],y[2],y[3]}; - std::cout << sos(buf+0,buf+5) << ' '; + std::cout << sos(buf+1,buf+5,buf[0]) << ' '; buf[1]=y[1];buf[2]=y[2];buf[3]=y[3];buf[4]=y[0]; - std::cout << sos(buf+0,buf+5) << ' '; + std::cout << sos(buf+1,buf+5,buf[0]) << ' '; buf[1]=yy[0];buf[2]=yy[1];buf[3]=yy[2];buf[4]=yy[3]; - std::cout << sos(buf+0,buf+5) << ' '; + std::cout << sos(buf+1,buf+5,buf[0]) << ' '; buf[1]=yy[1];buf[2]=yy[2];buf[3]=yy[3];buf[4]=yy[0]; - std::cout << sos(buf+0,buf+5) << '\n'; + std::cout << sos(buf+1,buf+5,buf[0]) << '\n'; assert(cah(y+0,y+3,y[3])); assert(!cah(y+0,y+3,buf[0])); assert(cl(a,a)==CGAL::EQUAL); From 28c2763f1a17c4e9a01cc0b5b2a1f8fcb7464019 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 21:39:47 +0100 Subject: [PATCH 041/203] Remove leftover macro CGAL_CONSTRUCTION_OPERATOR --- NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 3ada5ce2efe..a563746b053 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -99,8 +99,6 @@ struct Lazy_construction2 { { return new Lazy_rep_0(); } - -#undef CGAL_CONSTRUCTION_OPERATOR }; template From 224e1275229e38b12e3bbae2bb2903be5b751583 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 23:26:27 +0100 Subject: [PATCH 042/203] Experiment how we can store ranges in lazy objects. --- .../include/CGAL/NewKernel_d/Lazy_cartesian.h | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index a563746b053..02ff98ac303 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -100,6 +100,103 @@ struct Lazy_construction2 { return new Lazy_rep_0(); } }; +#if 0 +// Experiment how we can store ranges +template +class Lazy_rep_XXX : + public Lazy_rep< AT, ET, E2A >, private EC +{ + int ld; + mutable std::vector lr; + const EC& ec() const { return *this; } + public: + void update_exact() const { + this->et = new ET(ec()(ld, CGAL::exact(std::begin(lr)), CGAL::exact(std::end(lr)))); + this->at = E2A()(*(this->et)); + lr = std::vector(); // lr.clear(); lr.shrink_to_fit(); generates worse code + } + template + Lazy_rep_XXX(const AC& ac, const EC& ec, int d, Iter const& f, Iter const& e) : + Lazy_rep(ac(d, CGAL::approx(f), CGAL::approx(e))), EC(ec), ld(d), lr(f, e) + { + this->set_depth(1); // ??? Who cares + } +}; +template +class Lazy_rep_YYY : + public Lazy_rep< AT, ET, E2A >, private EC +{ + mutable std::vector lr; + mutable L l; + const EC& ec() const { return *this; } + public: + void update_exact() const { + this->et = new ET(ec()(CGAL::exact(std::begin(lr)), CGAL::exact(std::end(lr)), CGAL::exact(l))); + this->at = E2A()(*(this->et)); + lr = std::vector(); // lr.clear(); lr.shrink_to_fit(); generates worse code + l = L(); + } + template + Lazy_rep_YYY(const AC& ac, const EC& ec, Iter const& f, Iter const& e, L const& ll) : + Lazy_rep(ac(CGAL::approx(f), CGAL::approx(e), CGAL::approx(ll))), EC(ec), lr(f, e), l(ll) + { + this->set_depth(1); // ??? Who cares + } +}; +template +struct Lazy_construction2, LK> { + static const bool Protection = true; + typedef Construct_ttag T; + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename LK::E2A E2A; + typedef typename Get_functor::type AC; + typedef typename Get_functor::type EC; + typedef typename map_result_tag::type result_tag; + typedef typename Get_type::type AT; + typedef typename Get_type::type ET; + typedef typename Get_type::type result_type; + // same as Handle = Lazy< AT, ET, E2A> + typedef typename Get_type::type FT; + + Lazy_construction2(){} + Lazy_construction2(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; + + template + std::enable_if_t<(sizeof...(L)>0&&Constructible_from_each::value), result_type> operator()(L const&...l) const { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_n(ac, ec, l...); + } catch (Uncertain_conversion_exception&) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0(ec(CGAL::exact(l)...)); + } + } + template + std::enable_if_t::value,result_type> operator()(int d, Iter const& f, Iter const& e) const { + typedef typename std::iterator_traits::value_type TT; + return new Lazy_rep_XXX(ac, ec, d, f, e); + } + template + std::enable_if_t::value,result_type> operator()(Iter const& f, Iter const& e, L const&l) const { + typedef typename std::iterator_traits::value_type TT; + return new Lazy_rep_YYY(ac, ec, f, e, l); + } + template + std::enable_if_t::value,result_type> operator()(Iter const& f, Iter const& e) const { + return operator()(std::distance(f, e), f, e); + } + // FIXME: this forces us to have default constructors for all types, try to make its instantiation lazier + result_type operator()() const + { + return new Lazy_rep_0(); + } +}; +#endif template struct Lazy_cartesian_types From 6e579bb11a732c4d290bf72340985cde692f39b3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 9 Feb 2019 12:51:37 +0100 Subject: [PATCH 043/203] Avoid functors that take unpaired input iterators --- NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h | 2 ++ .../include/CGAL/NewKernel_d/function_objects_cartesian.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h index 6c81198b37d..21649ca2bf8 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h @@ -282,7 +282,7 @@ template struct In_flat_power_side_of_power_sphere_raw : private Store typedef typename LA::Square_matrix Matrix; template - result_type operator()(Flat_orientation const&o, Iter f, Iter e, IterW fw, Point const&x, Wt const&w) const { + result_type operator()(Flat_orientation const&o, Iter f, Iter const&e, IterW fw, IterW const&/*ew*/, Point const&x, Wt const&w) const { // TODO: can't work in the projection, but we should at least remove the row of 1s. typename Get_functor::type c(this->kernel()); typename Get_functor::type pd(this->kernel()); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h index a23a838ce78..4c8fc694a34 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h @@ -118,6 +118,7 @@ template struct Power_side_of_power_sphere : private Store_kernel make_transforming_iterator (f, pdw), make_transforming_iterator (e, pdw), make_transforming_iterator (f, pw), + make_transforming_iterator (e, pw), pdw (p0), pw (p0)); } @@ -138,6 +139,7 @@ template struct In_flat_power_side_of_power_sphere : private Store_ker make_transforming_iterator (f, pdw), make_transforming_iterator (e, pdw), make_transforming_iterator (f, pw), + make_transforming_iterator (e, pw), pdw (p0), pw (p0)); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 979d1322762..cf82d299a45 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -499,7 +499,7 @@ template struct Power_side_of_power_sphere_raw : private Store_kernel< typedef typename LA::Square_matrix Matrix; template - result_type operator()(IterP f, IterP const& e, IterW fw, Pt const& p0, Wt const& w0) const { + result_type operator()(IterP f, IterP const& e, IterW fw, IterW const&/*ew*/, Pt const& p0, Wt const& w0) const { typedef typename Get_functor::type Sqdo; typename Get_functor::type c(this->kernel()); typename Get_functor::type pd(this->kernel()); From 15d2b82ff875666ebd8234d8097ca90ba24f33f9 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 9 Feb 2019 22:31:31 +0100 Subject: [PATCH 044/203] Copy ranges defined by iterator pairs inside Lazy objects. --- .../include/CGAL/NewKernel_d/Lazy_cartesian.h | 193 +++++++++--------- NewKernel_d/test/NewKernel_d/Epick_d.cpp | 69 ++++--- 2 files changed, 141 insertions(+), 121 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 02ff98ac303..0fa5fa99d43 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -62,6 +62,99 @@ namespace internal { }; } +// Whenever a construction takes iterator pairs as input, whether they point to double of Lazy objects, copy the ranges inside the lazy result so they are available for update_exact(). We analyze the input to try and guess where iterator pairs are. I would prefer if each functor had a specific signature (no overload in this layer) so we wouldn't have to guess. +// FIXME: Lazy_construct_nt is also a construction and needs the same treatment. +namespace Lazy_internal { +templatestruct typelist{}; +templatestruct arg_i{}; +templatestruct arg_i_begin{}; +templatestruct arg_i_end{}; +templatestruct arg_i_ip1_range{}; +templatestruct analyze_args; +templatestruct analyze_args> { + typedef T creator; + typedef U reader; +}; +template +struct analyze_args,typelist,typelist,std::enable_if_t::value>> : +analyze_args>,typelist>,typelist> {}; +template +struct analyze_args,typelist,typelist,std::enable_if_t::value>> : +analyze_args>,typelist,arg_i_end>,typelist> {}; +template using analyze_args_for_lazy = analyze_args,typelist<>,typelist>; +templatestruct extract1; +templatestruct extract1,T>:std::tuple_element{}; +templatestruct extract1,T>{ + typedef std::tuple_element_t E; + typedef std::remove_cv_t> It; + typedef typename std::iterator_traits::value_type element_type; + // TODO: find a way to use an array of the right size, at least for the most frequent constructions + typedef std::vector type; +}; +templatedecltype(auto) +do_extract(arg_i,std::tupleconst&t) +{return std::get(t);} +templatedecltype(auto) +do_extract(arg_i_begin,std::tupleconst&t) +{return std::begin(std::get(t));} +templatedecltype(auto) +do_extract(arg_i_end,std::tupleconst&t) +{return std::end(std::get(t));} +templatedecltype(auto) +do_extract(arg_i_ip1_range,std::tupleconst&t) +{ + typedef std::tuple L; + typedef std::tuple_element_t E; + typedef std::remove_cv_t> It; + typedef typename std::iterator_traits::value_type element_type; + typedef std::vector type; + return type(std::get(t),std::get(t)); +} +templatestruct data_from_input; +templatestruct data_from_input,U> { + typedef std::tuple::type...> type; +}; +} +template +class Lazy_rep_XXX : + public Lazy_rep< AT, ET, E2A >, private EC +{ + // Lazy_rep_0 does not inherit from EC or take a parameter AC. It has different constructors. + static_assert(sizeof...(L)>0, "Use Lazy_rep_0 instead"); + template friend class Lazy_kernel_base; + typedef Lazy_internal::analyze_args_for_lazy Args; + // How to go from l to Lazy_rep's data + typedef typename Args::creator Creator; + // How to go back + typedef typename Args::reader Reader; + // what Lazy_rep should store + typedef typename Lazy_internal::data_from_input>::type LL; + mutable LL l; // L...l; is not yet allowed. + const EC& ec() const { return *this; } + template + void update_exact_helper(Lazy_internal::typelist) const { + this->et = new ET(ec()( CGAL::exact( Lazy_internal::do_extract(T{},l) ) ... ) ); + this->at = E2A()(*(this->et)); + l = LL(); // There should be a nicer way to clear. Destruction for instance. With this->et as a witness of whether l has already been destructed. + } + public: + void update_exact() const { + update_exact_helper(Reader{}); + } + template + Lazy_rep_XXX(const AC& ac, const EC& ec, LL const&...ll) : + Lazy_rep_XXX(Creator{},ac,ec,std::forward_as_tuple(ll...),ll...){}; + private: + // Currently we construct the vectors, then move them into the tuple. It would be nicer to construct them in their final destination, because eventually we will also have arrays instead of vectors. + template + Lazy_rep_XXX(Lazy_internal::typelist, const AC& ac, const EC& ec, LLL const&lll, LL const&...ll) : + Lazy_rep(ac(CGAL::approx(ll)...)), EC(ec), l(Lazy_internal::do_extract(T{},lll)...) + { + //this->set_depth(std::max({ -1, (int)CGAL::depth(ll)...}) + 1); + this->set_depth(1); // FIXME: now that we have ranges, we could actually compute the depth if we cared... + } + // TODO: print_dag needs a specific implementation for Lazy_rep_XXX +}; template struct Lazy_construction2 { static const bool Protection = true; @@ -87,7 +180,7 @@ struct Lazy_construction2 { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - return new Lazy_rep_n(ac, ec, l...); + return new Lazy_rep_XXX(ac, ec, l...); } catch (Uncertain_conversion_exception&) { CGAL_BRANCH_PROFILER_BRANCH(tmp); Protect_FPU_rounding P2(CGAL_FE_TONEAREST); @@ -95,108 +188,12 @@ struct Lazy_construction2 { } } // FIXME: this forces us to have default constructors for all types, try to make its instantiation lazier + // Actually, that may be the clearing in update_exact(). result_type operator()() const { return new Lazy_rep_0(); } }; -#if 0 -// Experiment how we can store ranges -template -class Lazy_rep_XXX : - public Lazy_rep< AT, ET, E2A >, private EC -{ - int ld; - mutable std::vector lr; - const EC& ec() const { return *this; } - public: - void update_exact() const { - this->et = new ET(ec()(ld, CGAL::exact(std::begin(lr)), CGAL::exact(std::end(lr)))); - this->at = E2A()(*(this->et)); - lr = std::vector(); // lr.clear(); lr.shrink_to_fit(); generates worse code - } - template - Lazy_rep_XXX(const AC& ac, const EC& ec, int d, Iter const& f, Iter const& e) : - Lazy_rep(ac(d, CGAL::approx(f), CGAL::approx(e))), EC(ec), ld(d), lr(f, e) - { - this->set_depth(1); // ??? Who cares - } -}; -template -class Lazy_rep_YYY : - public Lazy_rep< AT, ET, E2A >, private EC -{ - mutable std::vector lr; - mutable L l; - const EC& ec() const { return *this; } - public: - void update_exact() const { - this->et = new ET(ec()(CGAL::exact(std::begin(lr)), CGAL::exact(std::end(lr)), CGAL::exact(l))); - this->at = E2A()(*(this->et)); - lr = std::vector(); // lr.clear(); lr.shrink_to_fit(); generates worse code - l = L(); - } - template - Lazy_rep_YYY(const AC& ac, const EC& ec, Iter const& f, Iter const& e, L const& ll) : - Lazy_rep(ac(CGAL::approx(f), CGAL::approx(e), CGAL::approx(ll))), EC(ec), lr(f, e), l(ll) - { - this->set_depth(1); // ??? Who cares - } -}; -template -struct Lazy_construction2, LK> { - static const bool Protection = true; - typedef Construct_ttag T; - typedef typename LK::Approximate_kernel AK; - typedef typename LK::Exact_kernel EK; - typedef typename LK::E2A E2A; - typedef typename Get_functor::type AC; - typedef typename Get_functor::type EC; - typedef typename map_result_tag::type result_tag; - typedef typename Get_type::type AT; - typedef typename Get_type::type ET; - typedef typename Get_type::type result_type; - // same as Handle = Lazy< AT, ET, E2A> - typedef typename Get_type::type FT; - - Lazy_construction2(){} - Lazy_construction2(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} - CGAL_NO_UNIQUE_ADDRESS AC ac; - CGAL_NO_UNIQUE_ADDRESS EC ec; - - template - std::enable_if_t<(sizeof...(L)>0&&Constructible_from_each::value), result_type> operator()(L const&...l) const { - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Protect_FPU_rounding P; - try { - return new Lazy_rep_n(ac, ec, l...); - } catch (Uncertain_conversion_exception&) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return new Lazy_rep_0(ec(CGAL::exact(l)...)); - } - } - template - std::enable_if_t::value,result_type> operator()(int d, Iter const& f, Iter const& e) const { - typedef typename std::iterator_traits::value_type TT; - return new Lazy_rep_XXX(ac, ec, d, f, e); - } - template - std::enable_if_t::value,result_type> operator()(Iter const& f, Iter const& e, L const&l) const { - typedef typename std::iterator_traits::value_type TT; - return new Lazy_rep_YYY(ac, ec, f, e, l); - } - template - std::enable_if_t::value,result_type> operator()(Iter const& f, Iter const& e) const { - return operator()(std::distance(f, e), f, e); - } - // FIXME: this forces us to have default constructors for all types, try to make its instantiation lazier - result_type operator()() const - { - return new Lazy_rep_0(); - } -}; -#endif template struct Lazy_cartesian_types diff --git a/NewKernel_d/test/NewKernel_d/Epick_d.cpp b/NewKernel_d/test/NewKernel_d/Epick_d.cpp index 3bd63caf614..a088a6d263f 100644 --- a/NewKernel_d/test/NewKernel_d/Epick_d.cpp +++ b/NewKernel_d/test/NewKernel_d/Epick_d.cpp @@ -367,20 +367,6 @@ void test2(){ assert(abs(cent1[0]-2)<.0001); assert(abs(cent1[1]+3)<.0001); assert(abs(sp.squared_radius()-25)<.0001); -#if 1 - // Fails for an exact kernel - typedef typename K1::Point_of_sphere_d PS; - PS ps Kinit(point_of_sphere_d_object); - P psp0=ps(sp,0); - P psp1=ps(sp,1); - P psp2=ps(sp,2); - assert(!ed(psp0,psp1)); - assert(!ed(psp0,psp2)); - assert(!ed(psp2,psp1)); - assert(abs(sd(cent0,psp0)-25)<.0001); - assert(abs(sd(cent0,psp1)-25)<.0001); - assert(abs(sd(cent0,psp2)-25)<.0001); -#endif P x2py1 = tp(x2,y1); assert(x2py1[1]==-2); WP tw[]={cwp(cp(5,0),1.5),cwp(cp(2,std::sqrt(3)),1),cwp(cp(2,-std::sqrt(3)),1)}; @@ -416,6 +402,46 @@ void test2(){ D un10; CGAL_USE(un10); } +// Fails for an exact kernel, so I split it here +template +void test2i(){ + typedef Ker K1; + typedef typename K1::Point_d P; + typedef typename K1::Sphere_d Sp; + typedef typename K1::Point_of_sphere_d PS; + typedef typename K1::Construct_point_d CP; + typedef typename K1::Construct_sphere_d CSp; + typedef typename K1::Equal_d E; + typedef typename K1::Squared_distance_d SD; + typedef typename K1::Center_of_sphere_d COS; + Ker k +#if 0 + (2) +#endif + ; + CP cp Kinit(construct_point_d_object); + PS ps Kinit(point_of_sphere_d_object); + CSp csp Kinit(construct_sphere_d_object); + E ed Kinit(equal_d_object); + SD sd Kinit(squared_distance_d_object); + COS cos Kinit(center_of_sphere_d_object); + P z0=cp( 0+2,5-3); + P z1=cp(-5+2,0-3); + P z2=cp( 3+2,4-3); + P tabz[]={z0,z1,z2}; + Sp sp = csp(tabz+0,tabz+3); + P cent0=cos(sp); + P psp0=ps(sp,0); + P psp1=ps(sp,1); + P psp2=ps(sp,2); + assert(!ed(psp0,psp1)); + assert(!ed(psp0,psp2)); + assert(!ed(psp2,psp1)); + assert(abs(sd(cent0,psp0)-25)<.0001); + assert(abs(sd(cent0,psp1)-25)<.0001); + assert(abs(sd(cent0,psp2)-25)<.0001); +} + #if defined(BOOST_MSVC) # pragma warning(push) # pragma warning(disable: 4512) @@ -426,15 +452,12 @@ template struct Construct_point3_helper { Construct_point3_helper(CP const& x) : cp(x) {} template typename CP::result_type operator()(T1 const&t1, T2 const&t2, T3 const&t3)const{ - //double tab[]={(double)t1,(double)t2,(double)t3}; - // The lazy kernel stores iterators, not a vector, so the array must stay alive until update_exact()! For the tests I am keeping the memory leak for now, it is more convenient. - double*tab=new double[3]{(double)t1,(double)t2,(double)t3}; + double tab[]={(double)t1,(double)t2,(double)t3}; return cp(tab+0,tab+3); } template typename CP::result_type operator()(T1 const&t1, T2 const&t2, T3 const&t3, T4 const&t4)const{ - // Same discussion as above - double*tab=new double[3]{(double)t1,(double)t2,(double)t3}; + double tab[]={(double)t1,(double)t2,(double)t3}; return cp(tab+0,tab+3,t4); } }; @@ -693,12 +716,12 @@ CGAL_static_assertion((boost::is_same,CGAL::Ambient_dimen int main(){ //Broken with Linear_base_d (output iterator) //test2 >(); - test2(); + test2(); test2i(); test3(); test3(); - //test2>>(); - //test3>>(); - //test3>(); + test2>>(); + test3>>(); + test3>(); } #endif From 402279bcab9992635fa983637d30708ed948bf33 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 10 Feb 2019 12:57:40 +0100 Subject: [PATCH 045/203] Use range-for in a couple places. --- .../include/CGAL/NewKernel_d/Coaffine.h | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h index 21649ca2bf8..0596db79019 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h @@ -37,13 +37,11 @@ struct Flat_orientation { // For debugging purposes inline std::ostream& operator<< (std::ostream& o, Flat_orientation const& f) { o << "Proj: "; - for(std::vector::const_iterator i=f.proj.begin(); - i!=f.proj.end(); ++i) - o << *i << ' '; + for(int i : f.proj) + o << i << ' '; o << "\nRest: "; - for(std::vector::const_iterator i=f.rest.begin(); - i!=f.rest.end(); ++i) - o << *i << ' '; + for(int i : f.rest) + o << i << ' '; o << "\nInv: " << f.reverse; return o << '\n'; } @@ -155,8 +153,8 @@ template struct Contained_in_affine_hull : private Store_kernel { int d = (int)proj.size()+1; Matrix m (d, d); for(int i=0; i::iterator it=rest.begin();it!=rest.end();++it) { for(int i=0; i struct Contained_in_affine_hull : private Store_kernel { int d = (int)proj.size()+1; Matrix m (d, d); for(int i=0; i::iterator it=rest.begin();it!=rest.end();++it) { - for(int i=0; i Date: Sun, 10 Feb 2019 15:29:25 +0100 Subject: [PATCH 046/203] Handle computations the same as constructions. --- NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h | 10 +++++----- NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 0fa5fa99d43..8385d6c42f4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -63,7 +63,6 @@ namespace internal { } // Whenever a construction takes iterator pairs as input, whether they point to double of Lazy objects, copy the ranges inside the lazy result so they are available for update_exact(). We analyze the input to try and guess where iterator pairs are. I would prefer if each functor had a specific signature (no overload in this layer) so we wouldn't have to guess. -// FIXME: Lazy_construct_nt is also a construction and needs the same treatment. namespace Lazy_internal { templatestruct typelist{}; templatestruct arg_i{}; @@ -155,13 +154,14 @@ class Lazy_rep_XXX : } // TODO: print_dag needs a specific implementation for Lazy_rep_XXX }; +templatestruct Select_converter { typedef typename LK::E2A type; }; +templatestruct Select_converter { typedef To_interval type; }; template struct Lazy_construction2 { static const bool Protection = true; typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename LK::E2A E2A; typedef typename Get_functor::type AC; typedef typename Get_functor::type EC; typedef typename map_result_tag::type result_tag; @@ -169,6 +169,7 @@ struct Lazy_construction2 { typedef typename Get_type::type ET; typedef typename Get_type::type result_type; // same as Handle = Lazy< AT, ET, E2A> + typedef typename Select_converter::type, LK, ET>::type E2A; Lazy_construction2(){} Lazy_construction2(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} @@ -225,6 +226,7 @@ struct Lazy_cartesian_types typedef typename Select_nth_element_functor::type AF; typedef typename Select_nth_element_functor::type EF; + // TODO: we should use Lazy_construction2, but this seems ok for now, we never construct iterators from iterators. typedef typename internal::Lazy_construction_maybe_nt< Kernel_, AF, EF, is_NT_tag::value >::type nth_elem; @@ -298,9 +300,7 @@ struct Lazy_cartesian : typedef Filtered_predicate2 type; }; template struct Functor { - typedef typename Get_functor::type FA; - typedef typename Get_functor::type FE; - typedef Lazy_construction_nt type; + typedef Lazy_construction2 type; }; template struct Functor { typedef Lazy_construction2 type; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h b/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h index 58fbef78dd7..ebe4eae4382 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h @@ -199,7 +199,11 @@ namespace CGAL { typedef Null_tag value_tag; }; + templatestruct map_result_tag{typedef Null_type type;}; + templatestruct map_result_tag >{typedef T type;}; + #define CGAL_DECL_COMPUTE(X) struct X##_tag {}; \ + template<>struct map_result_tag{typedef FT_tag type;}; \ templatestruct Get_functor_category{typedef Compute_tag type;} CGAL_DECL_COMPUTE(Compute_point_cartesian_coordinate); CGAL_DECL_COMPUTE(Compute_vector_cartesian_coordinate); @@ -237,9 +241,6 @@ namespace CGAL { CGAL_DECL_ITER_OBJ(Point_cartesian_const_iterator, FT, Compute_point_cartesian_coordinate, Point); #undef CGAL_DECL_ITER_OBJ - templatestruct map_result_tag{typedef Null_type type;}; - templatestruct map_result_tag >{typedef T type;}; - templatestruct Get_functor_category,B,C> : boost::mpl::if_c::is_iterator, Construct_iterator_tag, From 66d4d3c791bcb840ba4c05baa6e32095d7c96e3b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 10 Feb 2019 15:31:34 +0100 Subject: [PATCH 047/203] The bug is fixed, remove its doc. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index d2f3b9ec2ca..e631ee2c4d0 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -38,7 +38,7 @@ or `Dynamic_dimension_tag`. In the latter case, the dimension of the space is sp \attention Only the interfaces specific to this class are listed below. Refer to the concepts for the rest. -\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. Constructing a `Point_d` with iterators is done lazily, see below. +\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. @@ -72,10 +72,6 @@ Point_d(double x0, double x1, ...); /*! introduces a point with coordinate set `[first,end)`. \pre If `DimensionTag` is a fixed dimension, it matches `distance(first,end)`. \tparam ForwardIterator has its value type that is convertible to `double`. - \bug This constructor stores the iterators and may use - them at any later time, when an exact construction is needed. This means - that if `[first,end)` points to some buffer, it has to remain alive at - least as long as the point. */ template Point_d(ForwardIterator first, ForwardIterator end); From b72341251fe4c0d18e8d06678df4c28bf356b45f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 10 Feb 2019 16:01:52 +0100 Subject: [PATCH 048/203] Allow move in conversion from an exact type ET to Lazy_exact_nt. --- Number_types/include/CGAL/Lazy_exact_nt.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Number_types/include/CGAL/Lazy_exact_nt.h b/Number_types/include/CGAL/Lazy_exact_nt.h index a71fb9328ab..f1bab3eeba1 100644 --- a/Number_types/include/CGAL/Lazy_exact_nt.h +++ b/Number_types/include/CGAL/Lazy_exact_nt.h @@ -165,6 +165,11 @@ struct Lazy_exact_Ex_Cst : public Lazy_exact_nt_rep { this->et = new ET(e); } + Lazy_exact_Ex_Cst (ET&& e) + : Lazy_exact_nt_rep(CGAL_NTS to_interval(e)) + { + this->et = new ET(std::move(e)); + } void update_exact() const { CGAL_error(); } }; @@ -376,6 +381,8 @@ public : Lazy_exact_nt (const ET & e) : Base(new Lazy_exact_Ex_Cst(e)){} + Lazy_exact_nt (ET&& e) + : Base(new Lazy_exact_Ex_Cst(std::move(e))){} template Lazy_exact_nt (const Lazy_exact_nt &x, From 80f8788fa49350ca3e024665af2f936244295c4d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 10 Feb 2019 17:49:13 +0100 Subject: [PATCH 049/203] Move Handle. Probably useless, but it can't hurt. --- STL_Extension/include/CGAL/Handle.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/STL_Extension/include/CGAL/Handle.h b/STL_Extension/include/CGAL/Handle.h index 14304c4a7b8..5b727e9883d 100644 --- a/STL_Extension/include/CGAL/Handle.h +++ b/STL_Extension/include/CGAL/Handle.h @@ -58,6 +58,14 @@ class Handle PTR->count++; } + // When the counter becomes atomic, this may avoid a few atomic operations. + Handle(Handle&& x) + { + CGAL_precondition( x.PTR != static_cast(0) ); + PTR = x.PTR; + x.PTR = nullptr; + } + ~Handle() { if ( PTR && (--PTR->count == 0)) @@ -75,6 +83,14 @@ class Handle return *this; } + Handle& + operator=(Handle&& x) + { + CGAL_precondition( x.PTR != static_cast(0) ); + std::swap(PTR, x.PTR); + return *this; + } + int refs() const { return PTR->count; } From ad14f96ac7d097c7f5f61f28636d5c57e1832a5c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 12 Feb 2019 10:16:44 +0100 Subject: [PATCH 050/203] Update a few more places to the new member name in Lazy_rep_n. --- Filtered_kernel/include/CGAL/Lazy_kernel.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 1009198e04d..491bff363bb 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -343,7 +343,7 @@ public: LR * lr = dynamic_cast(p.ptr()); if(lr && (! lr->et)){ - return lr->l2; + return std::get<2>(lr->l); } return BaseClass().compute_weight_2_object()(p); } @@ -373,7 +373,7 @@ public: LR * lr = dynamic_cast(p.ptr()); if(lr && (! lr->et)){ - return lr->l2; + return std::get<2>(lr->l); } return BaseClass().compute_weight_3_object()(p); } @@ -430,11 +430,11 @@ public: LR * lr = dynamic_cast(p.ptr()); if(lr && (! lr->et)){ - return lr->l1; + return std::get<1>(lr->l); } else { LRint* lrint = dynamic_cast(p.ptr()); if(lrint && (! lrint->et)){ - return lrint->l1; + return std::get<1>(lrint->l); } } @@ -493,11 +493,11 @@ public: LR * lr = dynamic_cast(p.ptr()); if(lr && (! lr->et)){ - return lr->l1; + return std::get<1>(lr->l); }else{ LRint* lrint = dynamic_cast(p.ptr()); if(lrint && (! lrint->et)){ - return lrint->l1; + return std::get<1>(lrint->l); } } return BaseClass().construct_point_3_object()(p); From 328f2bdbc6f9d2056e967b8d5fbc5ce025dbe361 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 12 Feb 2019 11:23:25 +0100 Subject: [PATCH 051/203] Replace -std=c++11 with c++1y. --- Scripts/developer_scripts/cgal_check_dependencies.sh | 2 +- Surface_mesh/benchmark/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/developer_scripts/cgal_check_dependencies.sh b/Scripts/developer_scripts/cgal_check_dependencies.sh index 65b989a8ca2..f270b719745 100644 --- a/Scripts/developer_scripts/cgal_check_dependencies.sh +++ b/Scripts/developer_scripts/cgal_check_dependencies.sh @@ -30,7 +30,7 @@ do fi done -cmake -DCGAL_HEADER_ONLY=FALSE -DCGAL_ENABLE_CHECK_HEADERS=TRUE -DDOXYGEN_EXECUTABLE="$DOX_PATH" -DCGAL_COPY_DEPENDENCIES=TRUE -DCMAKE_CXX_FLAGS="-std=c++11" .. +cmake -DCGAL_HEADER_ONLY=FALSE -DCGAL_ENABLE_CHECK_HEADERS=TRUE -DDOXYGEN_EXECUTABLE="$DOX_PATH" -DCGAL_COPY_DEPENDENCIES=TRUE -DCMAKE_CXX_FLAGS="-std=c++1y" .. if [ -n "$DO_CHECK_HEADERS" ]; then make -j$(nproc --all) -k check_headers fi diff --git a/Surface_mesh/benchmark/CMakeLists.txt b/Surface_mesh/benchmark/CMakeLists.txt index 8d376836e91..2c5482dcbd2 100644 --- a/Surface_mesh/benchmark/CMakeLists.txt +++ b/Surface_mesh/benchmark/CMakeLists.txt @@ -10,7 +10,7 @@ include_directories(BEFORE "../include") #add_definitions("-pg") #SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") # add_definitions("-g") -add_definitions("-std=c++11") +add_definitions("-std=c++1y") # Polyhedron add_executable(polyhedron_performance performance_2.h polyhedron_performance.h polyhedron_performance.cpp) From 730cfdc2b67699d8a916f49b143dc6a11ddbe10d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 12 Feb 2019 13:23:34 +0100 Subject: [PATCH 052/203] Missing #includes. --- NewKernel_d/include/CGAL/Epeck_d.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NewKernel_d/include/CGAL/Epeck_d.h b/NewKernel_d/include/CGAL/Epeck_d.h index ced041e0887..0ae68f32aec 100644 --- a/NewKernel_d/include/CGAL/Epeck_d.h +++ b/NewKernel_d/include/CGAL/Epeck_d.h @@ -27,7 +27,9 @@ #include #include #include +#include #include +#include // TODO: add static filters somewhere namespace CGAL { From 321268e1d1f093120e1af51c3990550f2a5cc91f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 13 Feb 2019 14:27:30 +0100 Subject: [PATCH 053/203] CGAL_CXX11 leftover --- NewKernel_d/include/CGAL/argument_swaps.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/NewKernel_d/include/CGAL/argument_swaps.h b/NewKernel_d/include/CGAL/argument_swaps.h index 1ebef4de555..8bedaff6f39 100644 --- a/NewKernel_d/include/CGAL/argument_swaps.h +++ b/NewKernel_d/include/CGAL/argument_swaps.h @@ -24,11 +24,6 @@ #include #include -#ifndef CGAL_CXX11 -#include -#include -#endif - namespace CGAL { namespace internal { From 5826d192ccf127fc984436cb9bbb18c6f125c061 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 13 Feb 2019 14:29:25 +0100 Subject: [PATCH 054/203] Move helper to STL_Extension --- .../include/CGAL/transforming_iterator.h | 0 .../include/CGAL/transforming_pair_iterator.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {NewKernel_d => STL_Extension}/include/CGAL/transforming_iterator.h (100%) rename {NewKernel_d => STL_Extension}/include/CGAL/transforming_pair_iterator.h (100%) diff --git a/NewKernel_d/include/CGAL/transforming_iterator.h b/STL_Extension/include/CGAL/transforming_iterator.h similarity index 100% rename from NewKernel_d/include/CGAL/transforming_iterator.h rename to STL_Extension/include/CGAL/transforming_iterator.h diff --git a/NewKernel_d/include/CGAL/transforming_pair_iterator.h b/STL_Extension/include/CGAL/transforming_pair_iterator.h similarity index 100% rename from NewKernel_d/include/CGAL/transforming_pair_iterator.h rename to STL_Extension/include/CGAL/transforming_pair_iterator.h From 4bc6e9713aa8f6586c3acdb2aaa06674740348e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 4 Mar 2019 13:46:28 +0100 Subject: [PATCH 055/203] add an option to create tarballs --- .../cgal_create_release_with_cmake.cmake | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake b/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake index fb190b50401..5d6efbda7e1 100644 --- a/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake +++ b/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake @@ -8,6 +8,7 @@ # CGAL_VERSION_NR=release string used to update version.h. Must be something like 1041200033 , or 104120090 # TESTSUITE=indicate if the release is meant to be used by the testsuite, default if OFF # GPL_PACKAGE_LIST=path to a file containing the list of GPL packages to include in the release. If not provided all of them are. +# GENERATE_TARBALLS=[ON/OFF] indicates if release tarballs should be created as DESTINATION cmake_minimum_required(VERSION 3.1) @@ -292,3 +293,43 @@ if(PUBLIC) # we are not creating an internal release. file(REMOVE ${release_dir}/${to_delete}) endforeach() endif() + +if (GENERATE_TARBALLS) + # create library+examples+demos+tests + execute_process( + COMMAND tar cJf ${DESTINATION}/CGAL-${CGAL_VERSION}.tar.xz -C ${DESTINATION} CGAL-${CGAL_VERSION} + RESULT_VARIABLE RESULT_VAR + OUTPUT_VARIABLE OUT_VAR + ) + + #create examples+demos + execute_process( + COMMAND tar cJf ${DESTINATION}/CGAL-${CGAL_VERSION}-examples.tar.xz -C ${DESTINATION} CGAL-${CGAL_VERSION}/examples CGAL-${CGAL_VERSION}/demo + RESULT_VARIABLE RESULT_VAR + OUTPUT_VARIABLE OUT_VAR + ) + + if(NOT PUBLIC) # we are not creating an internal release. + # Taken from create_new_release. + file(REMOVE_RECURSE ${release_dir}/test) + file(REMOVE_RECURSE ${release_dir}/package_info) + file(REMOVE_RECURSE ${release_dir}/developer_scripts) + file(REMOVE_RECURSE ${release_dir}/doc) + file(REMOVE_RECURSE ${release_dir}/include/CGAL/Test) + file(REMOVE_RECURSE ${release_dir}/include/CGAL/Testsuite/) + endif() + file(REMOVE_RECURSE ${release_dir}/demo) + file(REMOVE_RECURSE ${release_dir}/examples) + file(REMOVE_RECURSE ${release_dir}/scripts) + file(REMOVE_RECURSE ${release_dir}/doc_html) + + # create library only + execute_process( + COMMAND tar cJf ${DESTINATION}/CGAL-${CGAL_VERSION}-library.tar.xz -C ${DESTINATION} CGAL-${CGAL_VERSION} + RESULT_VARIABLE RESULT_VAR + OUTPUT_VARIABLE OUT_VAR + ) + + #remove directory + file(REMOVE_RECURSE ${release_dir}) +endif(GENERATE_TARBALLS) From 4d5521e644c804050e8968d4178e42fe35054705 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 9 Apr 2019 14:55:53 +0200 Subject: [PATCH 056/203] fix list of packages --- .travis.yml | 8 ++++---- .travis/packages.txt | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce08a952ad6..11004ecf38d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,10 +48,10 @@ env: - PACKAGE='Surface_mesh_deformation Surface_mesher Surface_mesh_parameterization ' - PACKAGE='Surface_mesh_segmentation Surface_mesh_shortest_path Surface_mesh_simplification ' - PACKAGE='Surface_mesh_skeletonization Surface_sweep_2 TDS_2 ' - - PACKAGE='TDS_3 TestPackage Testsuite ' - - PACKAGE='Three Triangulation Triangulation_2 ' - - PACKAGE='Triangulation_3 Union_find Visibility_2 ' - - PACKAGE='Voronoi_diagram_2 wininst ' + - PACKAGE='TDS_3 Testsuite Three ' + - PACKAGE='Triangulation Triangulation_2 Triangulation_3 ' + - PACKAGE='Union_find Visibility_2 Voronoi_diagram_2 ' + - PACKAGE='wininst ' compiler: clang install: - echo "$PWD" diff --git a/.travis/packages.txt b/.travis/packages.txt index 77c9b4f26a5..fa151634628 100644 --- a/.travis/packages.txt +++ b/.travis/packages.txt @@ -125,7 +125,6 @@ Surface_mesh_skeletonization Surface_sweep_2 TDS_2 TDS_3 -TestPackage Testsuite Three Triangulation From 057c37828b3628bc93fcdd41f37dd311c5060cfd Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 15 Apr 2019 12:26:03 +0200 Subject: [PATCH 057/203] Fix pragma push/pop --- NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h | 6 +++++- NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index da4746af2c0..6153c237fb3 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -72,7 +72,11 @@ public: typedef R_ R; - +#if defined(BOOST_MSVC) && (BOOST_MSVC == 1900) +# pragma warning(push) +# pragma warning(disable: 4309) +#endif + template::type...>,std::tuple >::value>::type> explicit Point_d(U&&...u) : Rep(CPBase()(std::forward(u)...)){} diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h index f055a3f1e04..f62b349b846 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h @@ -72,6 +72,10 @@ public: typedef R_ R; +#if defined(BOOST_MSVC) && (BOOST_MSVC == 1900) +# pragma warning(push) +# pragma warning(disable: 4309) +#endif template::type...>,std::tuple >::value>::type> explicit Vector_d(U&&...u) : Rep(CVBase()(std::forward(u)...)){} From 2dde8a1ddbd68409d4ae24e3efe646d9fff7a547 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 15 Apr 2019 14:51:10 +0200 Subject: [PATCH 058/203] Revert "Move Handle." This reverts commit 80f8788fa49350ca3e024665af2f936244295c4d. --- STL_Extension/include/CGAL/Handle.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/STL_Extension/include/CGAL/Handle.h b/STL_Extension/include/CGAL/Handle.h index 5b727e9883d..14304c4a7b8 100644 --- a/STL_Extension/include/CGAL/Handle.h +++ b/STL_Extension/include/CGAL/Handle.h @@ -58,14 +58,6 @@ class Handle PTR->count++; } - // When the counter becomes atomic, this may avoid a few atomic operations. - Handle(Handle&& x) - { - CGAL_precondition( x.PTR != static_cast(0) ); - PTR = x.PTR; - x.PTR = nullptr; - } - ~Handle() { if ( PTR && (--PTR->count == 0)) @@ -83,14 +75,6 @@ class Handle return *this; } - Handle& - operator=(Handle&& x) - { - CGAL_precondition( x.PTR != static_cast(0) ); - std::swap(PTR, x.PTR); - return *this; - } - int refs() const { return PTR->count; } From 8dd18734b139b47247f511215deade7deb701a7f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 16 Apr 2019 10:48:20 +0200 Subject: [PATCH 059/203] Remove name of unused argument. --- Filtered_kernel/include/CGAL/Lazy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 60d01a032a8..4369e9b28c1 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -129,7 +129,7 @@ auto exact(T const& t) {return make_transforming_iterator(t,[](auto const&u){ret template ::value>> auto approx(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::approx(u);});} template ::value>> -unsigned depth(T const& t) {return 1;} // FIXME: depth(*t) would be better when t is valid, but not for end iterators, and the true answer would iterate on the range, but we can't do that with only one iterator... We need to replace iterators with ranges to solve that. +unsigned depth(T const&) {return 1;} // FIXME: depth(*t) would be better when t is valid, but not for end iterators, and the true answer would iterate on the range, but we can't do that with only one iterator... We need to replace iterators with ranges to solve that. #ifdef CGAL_LAZY_KERNEL_DEBUG template From 92f4a7d3ad60c8e4f1b5e2d74f056873d9409d2a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 16 Apr 2019 11:43:10 +0200 Subject: [PATCH 060/203] std::abs --- NewKernel_d/test/NewKernel_d/Epick_d.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/NewKernel_d/test/NewKernel_d/Epick_d.cpp b/NewKernel_d/test/NewKernel_d/Epick_d.cpp index a088a6d263f..a86ac47685d 100644 --- a/NewKernel_d/test/NewKernel_d/Epick_d.cpp +++ b/NewKernel_d/test/NewKernel_d/Epick_d.cpp @@ -437,6 +437,7 @@ void test2i(){ assert(!ed(psp0,psp1)); assert(!ed(psp0,psp2)); assert(!ed(psp2,psp1)); + using std::abs; assert(abs(sd(cent0,psp0)-25)<.0001); assert(abs(sd(cent0,psp1)-25)<.0001); assert(abs(sd(cent0,psp2)-25)<.0001); From 6e31445f6207e98557905f11cde0859a3d3dd6ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 30 Apr 2019 15:09:36 +0200 Subject: [PATCH 061/203] fix the prev/next pointers after polyline removal --- .../internal/Corefinement/face_graph_utils.h | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h index be442040d31..54019ea09c6 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h @@ -1612,6 +1612,7 @@ void remove_unused_polylines( } } + std::vector vertices_kept; BOOST_FOREACH(vertex_descriptor v, vertices_to_remove) { bool to_remove=true; @@ -1626,7 +1627,31 @@ void remove_unused_polylines( } if (to_remove) remove_vertex(v,tm); + else + vertices_kept.push_back(v); } + + // update next/prev pointers around vertices in vertices_kept + BOOST_FOREACH(vertex_descriptor v, vertices_kept) + { + halfedge_descriptor h = halfedge(v, tm), start=GT::null_halfedge(); + + do{ + while ( !is_border(h, tm) || is_border(opposite(h, tm), tm) ) + h = opposite(next(h, tm), tm); + halfedge_descriptor in = h; + if (start==GT::null_halfedge()) + start=in; + else + if (start==in) + break; + while ( is_border(h, tm) ) + h = opposite(next(h, tm), tm); + set_next(in, opposite(h, tm), tm); + } + while(true);//this loop handles non-manifold vertices + } + BOOST_FOREACH(edge_descriptor e, edges_to_remove) remove_edge(e,tm); } From af142c74166cab440f68c90f53184d43a8e16784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 6 May 2019 09:00:09 +0200 Subject: [PATCH 062/203] Add new named parameter: face_size_map Used to pass custom maps to keep_large(st)_CCs --- BGL/include/CGAL/boost/graph/parameters_interface.h | 1 + BGL/test/BGL/test_cgal_bgl_named_params.cpp | 5 +++-- .../doc/Polygon_mesh_processing/NamedParameters.txt | 12 ++++++++++++ .../doc/Polygon_mesh_processing/dependencies | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/parameters_interface.h b/BGL/include/CGAL/boost/graph/parameters_interface.h index bd4f15d8e23..750d91fd50e 100644 --- a/BGL/include/CGAL/boost/graph/parameters_interface.h +++ b/BGL/include/CGAL/boost/graph/parameters_interface.h @@ -82,6 +82,7 @@ CGAL_add_named_parameter(use_compact_clipper_t, use_compact_clipper, use_compact CGAL_add_named_parameter(output_iterator_t, output_iterator, output_iterator) CGAL_add_named_parameter(erase_all_duplicates_t, erase_all_duplicates, erase_all_duplicates) CGAL_add_named_parameter(require_same_orientation_t, require_same_orientation, require_same_orientation) +CGAL_add_named_parameter(face_size_map_t, face_size_map, face_size_map) // List of named parameters that we use in the package 'Surface Mesh Simplification' CGAL_add_named_parameter(get_cost_policy_t, get_cost_policy, get_cost) diff --git a/BGL/test/BGL/test_cgal_bgl_named_params.cpp b/BGL/test/BGL/test_cgal_bgl_named_params.cpp index 346043ff037..e797e2b3398 100644 --- a/BGL/test/BGL/test_cgal_bgl_named_params.cpp +++ b/BGL/test/BGL/test_cgal_bgl_named_params.cpp @@ -51,7 +51,6 @@ void test(const NamedParameters& np) assert(get_param(np, CGAL::internal_np::vertex_to_vertex_map).v == 800000007); assert(get_param(np, CGAL::internal_np::halfedge_to_halfedge_map).v == 800000008); assert(get_param(np, CGAL::internal_np::face_to_face_map).v == 800000009); - // Named parameters that we use in the package 'Mesh_3' assert(get_param(np, CGAL::internal_np::vertex_feature_degree).v == 9); @@ -88,6 +87,7 @@ void test(const NamedParameters& np) assert(get_param(np, CGAL::internal_np::erase_all_duplicates).v == 48); assert(get_param(np, CGAL::internal_np::require_same_orientation).v == 49); assert(get_param(np, CGAL::internal_np::use_bool_op_to_clip_surface).v == 50); + assert(get_param(np, CGAL::internal_np::face_size_map).v == 52); // Named parameters that we use in the package 'Surface Mesh Simplification' assert(get_param(np, CGAL::internal_np::get_cost_policy).v == 34); @@ -107,7 +107,6 @@ void test(const NamedParameters& np) assert(get_param(np, CGAL::internal_np::apply_per_connected_component).v == 46); assert(get_param(np, CGAL::internal_np::output_iterator).v == 47); - // Test types // Named parameters from Boost @@ -169,6 +168,7 @@ void test(const NamedParameters& np) check_same_type<48>(get_param(np, CGAL::internal_np::erase_all_duplicates)); check_same_type<49>(get_param(np, CGAL::internal_np::require_same_orientation)); check_same_type<50>(get_param(np, CGAL::internal_np::use_bool_op_to_clip_surface)); + check_same_type<52>(get_param(np, CGAL::internal_np::face_size_map)); // Named parameters that we use in the package 'Surface Mesh Simplification' check_same_type<34>(get_param(np, CGAL::internal_np::get_cost_policy)); @@ -253,6 +253,7 @@ int main() .output_iterator(A<47>(47)) .erase_all_duplicates(A<48>(48)) .require_same_orientation(A<49>(49)) + .face_size_map(A<52>(52)) ); return EXIT_SUCCESS; diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt index 6176b34f75c..a58fed36591 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt @@ -388,6 +388,18 @@ if orientation should matter when determining whether two faces are duplicates. Default: `false` \cgalNPEnd +\cgalNPBegin{face_size_map} \anchor PMP_face_size_map +Parameter used in the functions `keep_large_connected_components()` and +`keep_largest_connected_components()` to pass a property map that gives the size of a face when +evaluating the size of a connected component (which is defined as the sum of the sizes of its faces). + +\n +Type: a class model of `ReadablePropertyMap` with +`boost::graph_traits::%face_descriptor` as key type and +a value type supporting construction from `0`, `operator+=()`, and comparisons operations. \n +Default: `CGAL::Constant_property_map` with value `1` +\cgalNPEnd + \cgalNPTableEnd */ diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/dependencies b/Polygon_mesh_processing/doc/Polygon_mesh_processing/dependencies index e9a5e6baf02..67c7449e39d 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/dependencies +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/dependencies @@ -13,4 +13,5 @@ AABB_tree Triangulation_2 Spatial_sorting Generator +Property_map From 46be9eeb5ddc8d1ea9b963db79b2bcc7a87a86d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 6 May 2019 09:05:24 +0200 Subject: [PATCH 063/203] Generalize keep_large(st)_CCs by adding an option to pass custom face pmaps --- .../connected_components.h | 75 ++++++++++++------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 855b2604f1e..3e36b4c623c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -55,16 +55,16 @@ namespace CGAL { - namespace Polygon_mesh_processing{ +namespace internal { - namespace internal { - struct MoreSecond { - typedef std::pair T; - bool operator()(const T& a, const T& b) const { - return a.second > b.second; - } - }; + struct MoreSecond + { + template + bool operator()(const std::pair& a, const std::pair& b) const { + return a.second > b.second; + } + }; // A property map template @@ -303,7 +303,17 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh FaceIndexMap fimap = choose_param(get_param(np, internal_np::face_index), get_property_map(boost::face_index, pmesh)); - //vector_property_map + // FaceSizeMap + typedef typename boost::lookup_named_param_def // default + >::type FaceSizeMap; + typedef typename boost::property_traits::value_type Face_size; + + FaceSizeMap face_size_pmap = choose_param(get_param(np, internal_np::face_size_map), + Constant_property_map(1)); + + // vector_property_map boost::vector_property_map face_cc(fimap); std::size_t num = connected_components(pmesh, face_cc, np); @@ -318,13 +328,13 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh if((num == 1)|| (nb_components_to_keep > num) ) return 0; - std::vector< std::pair > component_size(num); + std::vector > component_size(num); for(std::size_t i=0; i < num; i++) - component_size[i] = std::make_pair(i,0); + component_size[i] = std::make_pair(i, Face_size(0)); for(face_descriptor f : faces(pmesh)) - ++component_size[face_cc[f]].second; + component_size[face_cc[f]].second += get(face_size_pmap, f); // we sort the range [0, num) by component size std::sort(component_size.begin(), component_size.end(), internal::MoreSecond()); @@ -369,11 +379,12 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, * * \return the number of connected components removed (ignoring isolated vertices). */ -template -std::size_t keep_large_connected_components(PolygonMesh& pmesh - , std::size_t threshold_components_to_keep - , const NamedParameters& np) +template +std::size_t keep_large_connected_components(PolygonMesh& pmesh, + const ThresholdValueType threshold_value, + const NamedParameters& np) { typedef PolygonMesh PM; typedef typename boost::graph_traits::face_descriptor face_descriptor; @@ -386,23 +397,33 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh FaceIndexMap fim = choose_param(get_param(np, internal_np::face_index), get_property_map(boost::face_index, pmesh)); - //vector_property_map + typedef typename boost::lookup_named_param_def // default + >::type FaceSizeMap; + typedef typename boost::property_traits::value_type Face_size; + + CGAL_static_assertion((std::is_convertible::value)); + + FaceSizeMap face_size_pmap = choose_param(get_param(np, internal_np::face_size_map), + Constant_property_map(1)); + + // vector_property_map boost::vector_property_map face_cc(fim); std::size_t num = connected_components(pmesh, face_cc, np); - std::vector< std::pair > component_size(num); + std::vector component_size(num); - for(std::size_t i=0; i < num; i++) - component_size[i] = std::make_pair(i,0); + for(std::size_t i=0; i cc_to_keep; - for(std::size_t i=0; i= threshold_components_to_keep){ - cc_to_keep.push_back( component_size[i].first ); - } + for(std::size_t i=0; i= threshold_value) + cc_to_keep.push_back(i); } keep_connected_components(pmesh, cc_to_keep, face_cc, np); From 4af0254a9ac884881cadbd7e13571fd41cf1013e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 6 May 2019 09:05:57 +0200 Subject: [PATCH 064/203] Update reference manual with keep_large(st)_CCs changes --- .../connected_components.h | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 3e36b4c623c..f3fa057d325 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -264,11 +264,15 @@ void keep_connected_components(PolygonMesh& pmesh /*! * \ingroup keep_connected_components_grp - * removes the small connected components and all isolated vertices. - * Keep `nb_components_to_keep` largest connected components. + * + * removes the small connected components and all isolated vertices. + * Keep the `nb_components_to_keep` largest connected components, where the size of a connected + * component is computed as the sum of the individual sizes of all the faces of the connected component. + * By default, the size of a face is `1` (and thus the size of a connected component is the number + * of faces it contains), but it is also possible to pass custom sizes, such as the area of the face. * * Property maps for `CGAL::face_index_t` and `CGAL::vertex_index_t` - * must be either available as internal property maps + * must be either available as internal property maps * to `pmesh` or provided as \ref pmp_namedparameters "Named Parameters". * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` @@ -282,6 +286,11 @@ void keep_connected_components(PolygonMesh& pmesh * \cgalParamBegin{edge_is_constrained_map} a property map containing the constrained-or-not status of each edge of `pmesh` \cgalParamEnd * \cgalParamBegin{face_index_map} a property map containing the index of each face of `pmesh` \cgalParamEnd * \cgalParamBegin{vertex_index_map} a property map containing the index of each vertex of `pmesh` \cgalParamEnd + * \cgalParamBegin{face_size_map} + * a property map containing a size for each face of `pmesh`. The value type of this property map + * is chosen by the user, but must be constructible from `0` and support `operator+=()` and + * comparisons. + * \cgalParamEnd * \cgalNamedParamsEnd * * \return the number of connected components removed (ignoring isolated vertices). @@ -317,7 +326,7 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh boost::vector_property_map face_cc(fimap); std::size_t num = connected_components(pmesh, face_cc, np); - // Even even we do not want to keep anything we need to first + // Even if we do not want to keep anything we need to first // calculate the number of existing connected_components to get the // correct return value. if(nb_components_to_keep == 0) { @@ -358,25 +367,38 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, /*! * \ingroup keep_connected_components_grp - * removes connected components with less than a given number of faces. + * removes connected components whose size is (strictly) smaller than a given threshold value, + * where the size of a connected component is computed as the sum of the individual sizes + * of all the faces of the connected component. By default, the size of a face is `1` (and thus + * the size of a connected component is the number of faces it contains), but it is also possible + * to pass custom sizes, such as the area of the face. * * Property maps for `CGAL::face_index_t` and `CGAL::vertex_index_t` - * must be either available as internal property maps + * must be either available as internal property maps * to `pmesh` or provided as \ref pmp_namedparameters "Named Parameters". * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` + * \tparam ThresholdValueType the type of the threshold value * \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" * * \param pmesh the polygon mesh - * \param threshold_components_to_keep the number of faces a component must have so that it is kept + * \param threshold_value any connected component with a size (strictly) smaller than this value will be discarded * \param np optional \ref pmp_namedparameters "Named Parameters", amongst those described below * * \cgalNamedParamsBegin * \cgalParamBegin{edge_is_constrained_map} a property map containing the constrained-or-not status of each edge of `pmesh` \cgalParamEnd * \cgalParamBegin{face_index_map} a property map containing the index of each face of `pmesh` \cgalParamEnd * \cgalParamBegin{vertex_index_map} a property map containing the index of each vertex of `pmesh` \cgalParamEnd + * \cgalParamBegin{face_size_map} + * a property map containing a size for each face of `pmesh`. The value type of this property map + * is chosen by the user, but must be constructible from `0` and support `operator+=()` and + * comparisons. + * \cgalParamEnd * \cgalNamedParamsEnd * + * \pre If a face weight property map is passed by the user, `ThresholdValueType` must be the same + * type as the value type of the property map. Othrewise, `ThresholdValueType` must be `std::size_t`. + * * \return the number of connected components removed (ignoring isolated vertices). */ template Date: Mon, 6 May 2019 09:07:29 +0200 Subject: [PATCH 065/203] Test new keep_large(st)_CCs interface --- .../connected_component_polyhedron.cpp | 4 +- .../connected_component_surface_mesh.cpp | 99 ++++++++++++++++--- 2 files changed, 87 insertions(+), 16 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp index a0265c9ac1c..18683590532 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp @@ -50,7 +50,9 @@ void mesh_with_id(const char* argv1, const bool save_output) std::cerr << "The graph has " << num << " connected components (face connectivity)" << std::endl; - PMP::keep_largest_connected_components(sm,2); + PMP::keep_largest_connected_components(sm, 2, + CGAL::parameters::face_size_map( + CGAL::Constant_property_map(1))); if (!save_output) return; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp index d554f97328f..e953a0f7bfa 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp @@ -1,7 +1,11 @@ #include #include -#include + #include +#include +#include +#include + #include #include #include @@ -43,18 +47,33 @@ struct Constraint : public boost::put_get_helper >{ double bound; }; - -int main(int argc, char* argv[]) +template +struct Face_descriptor_area_functor { + typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef boost::graph_traits::face_descriptor face_descriptor; - const double bound = std::cos(0.7* CGAL_PI); - const char* filename = (argc > 1) ? argv[1] : "data/blobby_3cc.off"; - Mesh sm; - std::ifstream in(filename); - in >> sm; + Face_descriptor_area_functor(const G& g, const GT& gt) : g(g), gt(gt) { } - std::cout << "VEF " << num_vertices(sm) << " " << num_edges(sm) << " " << num_faces(sm) << "\n"; + double operator()(const face_descriptor f) const + { + const auto& vpm = get(CGAL::vertex_point, g); + + return gt.compute_area_3_object()(get(vpm, source(halfedge(f, g), g)), + get(vpm, target(halfedge(f, g), g)), + get(vpm, target(next(halfedge(f, g), g), g))); + } + + const G& g; + const GT& gt; +}; + +void test_CC_with_default_size_map(Mesh sm) +{ + std::cout << " -- test with default size map -- " << std::endl; + + typedef boost::graph_traits::face_descriptor face_descriptor; + + const double bound = std::cos(0.7 * CGAL_PI); std::vector cc; face_descriptor fd = *faces(sm).first; @@ -102,8 +121,11 @@ int main(int argc, char* argv[]) for (std::size_t i=0;i(copy1, bound))); + PMP::parameters::edge_is_constrained_map(Constraint(copy1, bound)) + .face_size_map(CGAL::Constant_property_map(1))); // remove cc from copy2 ff.clear(); @@ -130,9 +152,56 @@ int main(int argc, char* argv[]) CGAL::make_triangle(p,q,r,m); CGAL::make_tetrahedron(p,q,r,s,m); PMP::keep_large_connected_components(m, 4); - m.collect_garbage(); - assert( num_vertices(m) == 8); - } - return 0; + assert(vertices(m).size() == 8); + } +} + +void test_CC_with_area_size_map(Mesh sm) +{ + std::cout << " -- test with area size map -- " << std::endl; + + typedef boost::graph_traits::face_descriptor face_descriptor; + + Kernel k; + Face_descriptor_area_functor f(sm, k); + + std::cout << "We keep the " << 2 << " largest components" << std::endl; + PMP::keep_largest_connected_components(sm, 2, + PMP::parameters::face_size_map( + CGAL::internal::boost_::make_function_property_map(f))); + assert(vertices(sm).size() == 1459); + + { + Mesh m; + + Point p(0,0,0), q(1,0,0), r(0,1,0), s(0,0,1); + CGAL::make_tetrahedron(p,q,r,s,m); + CGAL::make_tetrahedron(p,q,r,s,m); + + Point t(100,100,100); + CGAL::make_triangle(p,q,t,m); + + Face_descriptor_area_functor f(m, k); + PMP::keep_large_connected_components(m, 10, + CGAL::parameters::face_size_map( + CGAL::internal::boost_::make_function_property_map(f))); + assert(vertices(m).size() == 3); + } +} + +int main(int /*argc*/, char** /*argv*/) +{ + const char* filename = "data/blobby_3cc.off"; + Mesh sm; + std::ifstream in(filename); + assert(in.good()); + in >> sm; + + std::cout << "VEF " << num_vertices(sm) << " " << num_edges(sm) << " " << num_faces(sm) << "\n"; + + test_CC_with_default_size_map(sm); + test_CC_with_area_size_map(sm); + + return EXIT_SUCCESS; } From 2bc774298009609796562107b1297b5fc6ccd1d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 6 May 2019 09:07:56 +0200 Subject: [PATCH 066/203] Continue the Great Fight against entropy (cosmetic changes) --- .../NamedParameters.txt | 2 +- .../connected_components.h | 26 ++++----- .../connected_component_polyhedron.cpp | 46 ++++++---------- .../connected_component_surface_mesh.cpp | 53 ++++++++----------- 4 files changed, 52 insertions(+), 75 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt index a58fed36591..ac03eebb50c 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt @@ -368,7 +368,7 @@ should be considered as part of the clipping volume or not. Parameter to pass an output iterator. \n \b Type : a model of `OutputIterator` \n -\b Default : `Emptyset_iterator` +\b Default : `#CGAL::Emptyset_iterator` \cgalNPEnd \cgalNPBegin{erase_all_duplicates} \anchor PMP_erase_all_duplicates diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index f3fa057d325..9a47a40380c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -295,20 +295,20 @@ void keep_connected_components(PolygonMesh& pmesh * * \return the number of connected components removed (ignoring isolated vertices). */ -template -std::size_t keep_largest_connected_components(PolygonMesh& pmesh - , std::size_t nb_components_to_keep - , const NamedParameters& np) +template +std::size_t keep_largest_connected_components(PolygonMesh& pmesh, + std::size_t nb_components_to_keep, + const NamedParameters& np) { - typedef PolygonMesh PM; - typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef PolygonMesh PM; + typedef typename boost::graph_traits::face_descriptor face_descriptor; using boost::choose_param; using boost::get_param; - //FaceIndexMap - typedef typename GetFaceIndexMap::type FaceIndexMap; + // FaceIndexMap + typedef typename GetFaceIndexMap::type FaceIndexMap; FaceIndexMap fimap = choose_param(get_param(np, internal_np::face_index), get_property_map(boost::face_index, pmesh)); @@ -408,14 +408,14 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh, const ThresholdValueType threshold_value, const NamedParameters& np) { - typedef PolygonMesh PM; - typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef PolygonMesh PM; + typedef typename boost::graph_traits::face_descriptor face_descriptor; using boost::choose_param; using boost::get_param; - //FaceIndexMap - typedef typename GetFaceIndexMap::type FaceIndexMap; + // FaceIndexMap + typedef typename GetFaceIndexMap::type FaceIndexMap; FaceIndexMap fim = choose_param(get_param(np, internal_np::face_index), get_property_map(boost::face_index, pmesh)); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp index 18683590532..ce954aa9789 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp @@ -10,7 +10,7 @@ namespace PMP = CGAL::Polygon_mesh_processing; typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; -typedef CGAL::Polyhedron_3 Mesh; +typedef CGAL::Polyhedron_3 Mesh; typedef CGAL::Polyhedron_3 Mesh_with_id; void mesh_with_id(const char* argv1, const bool save_output) @@ -23,19 +23,16 @@ void mesh_with_id(const char* argv1, const bool save_output) in >> sm; int i=0; - for(face_descriptor f : faces(sm)){ + for(face_descriptor f : faces(sm)) f->id() = i++; - } + i=0; - for(vertex_descriptor v : vertices(sm)){ + for(vertex_descriptor v : vertices(sm)) v->id() = i++; - } std::vector cc; face_descriptor fd = *faces(sm).first; - PMP::connected_component(fd, - sm, - std::back_inserter(cc)); + PMP::connected_component(fd, sm, std::back_inserter(cc)); std::cerr << cc.size() << " faces in the CC of " << &*fd << std::endl; @@ -43,8 +40,7 @@ void mesh_with_id(const char* argv1, const bool save_output) boost::property_map::type> fccmap(get(boost::face_index,sm)); - std::size_t num = PMP::connected_components(sm, - fccmap); + std::size_t num = PMP::connected_components(sm, fccmap); if (strcmp(argv1, "data/blobby_3cc.off") == 0) assert(num == 3); @@ -70,13 +66,9 @@ void mesh_no_id(const char* argv1, const bool save_output) std::ifstream in(argv1); in >> sm; - std::vector cc; face_descriptor fd = *faces(sm).first; - PMP::connected_component(fd, - sm, - std::back_inserter(cc)); - + PMP::connected_component(fd, sm, std::back_inserter(cc)); std::cerr << cc.size() << " faces in the CC of " << &*fd << std::endl; boost::property_map::type vim @@ -89,10 +81,8 @@ void mesh_no_id(const char* argv1, const bool save_output) boost::property_map::type> fccmap(fim); - std::size_t num = PMP::connected_components(sm, - fccmap, - PMP::parameters::face_index_map(fim)); - + std::size_t num = PMP::connected_components(sm, fccmap, PMP::parameters::face_index_map(fim)); + if (strcmp(argv1, "data/blobby_3cc.off") == 0) assert(num == 3); @@ -101,11 +91,8 @@ void mesh_no_id(const char* argv1, const bool save_output) // std::cout << &*f << " in connected component " << fccmap[f] << std::endl; //} - PMP::keep_largest_connected_components(sm - , 2 - , PMP::parameters::vertex_index_map(vim). - face_index_map(fim)); - + PMP::keep_largest_connected_components(sm, 2, PMP::parameters::vertex_index_map(vim) + .face_index_map(fim)); if (save_output) return; @@ -127,6 +114,7 @@ void test_border_cases() std::size_t i=0; for(face_descriptor f : faces(sm)) f->id() = i++; + i=0; for(vertex_descriptor v : vertices(sm)) v->id() = i++; @@ -172,13 +160,12 @@ void keep_nothing(const char* argv1) return; } int i=0; - for(face_descriptor f : faces(sm)){ + for(face_descriptor f : faces(sm)) f->id() = i++; - } + i=0; - for(vertex_descriptor v : vertices(sm)){ + for(vertex_descriptor v : vertices(sm)) v->id() = i++; - } PMP::keep_largest_connected_components(sm, 0); assert(num_vertices(sm) == 0); @@ -195,5 +182,6 @@ int main(int argc, char* argv[]) mesh_no_id(filename, save_output); test_border_cases(); keep_nothing(filename); - return 0; + + return EXIT_SUCCESS; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp index e953a0f7bfa..a8cd31a2829 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp @@ -17,24 +17,21 @@ typedef Kernel::Point_3 Point; typedef Kernel::Compare_dihedral_angle_3 Compare_dihedral_angle_3; typedef CGAL::Surface_mesh Mesh; - template -struct Constraint : public boost::put_get_helper >{ +struct Constraint + : public boost::put_get_helper > +{ typedef typename boost::graph_traits::edge_descriptor edge_descriptor; typedef boost::readable_property_map_tag category; typedef bool value_type; typedef bool reference; typedef edge_descriptor key_type; - Constraint() - :g(NULL) - {} + Constraint() :g(NULL) {} + Constraint(G & g, double bound) : g(&g), bound(bound) {} - Constraint(G & g, double bound) - : g(&g), bound(bound) - {} - - bool operator[](edge_descriptor e) const { + bool operator[](edge_descriptor e) const + { return compare((*g).point(source(e,*g)), (*g).point(target(e,*g)), (*g).point(target(next(halfedge(e,*g),*g),*g)), @@ -77,41 +74,33 @@ void test_CC_with_default_size_map(Mesh sm) std::vector cc; face_descriptor fd = *faces(sm).first; - CGAL::Polygon_mesh_processing::connected_component(fd, - sm, - std::back_inserter(cc)); + CGAL::Polygon_mesh_processing::connected_component(fd, sm, std::back_inserter(cc)); std::cerr << "connected components without edge constraints" << std::endl; std::cerr << cc.size() << " faces in the CC of " << fd << std::endl; - if (strcmp(filename, "data/blobby_3cc.off") == 0) - assert(cc.size() == 1452); + assert(cc.size() == 1452); std::cerr << "\nconnected components with edge constraints (dihedral angle < 3/4 pi)" << std::endl; Mesh::Property_map fccmap; - fccmap = sm.add_property_map("f:CC").first; - std::size_t num = - PMP::connected_components(sm, - fccmap - ); + fccmap = sm.add_property_map("f:CC").first; + std::size_t num = PMP::connected_components(sm, fccmap); - std::cerr << "The graph has " << num << " connected components (face connectivity)" << std::endl; - if (strcmp(filename, "data/blobby_3cc.off") == 0) - assert(num == 3); + std::cerr << "The graph has " << num << " connected components (face connectivity)" << std::endl; + assert(num == 3); - std::vector one_face_per_cc(num); - std::vector cc_size(num,0); + std::vector one_face_per_cc(num); + std::vector cc_size(num,0); - - for(face_descriptor f : faces(sm)){ - // std::cout << f << " in connected component " << fccmap[f] << std::endl; + for(face_descriptor f : faces(sm)) + { + // std::cout << f << " in connected component " << fccmap[f] << std::endl; std::size_t ccid=fccmap[f]; if (++cc_size[ccid]==1) one_face_per_cc[ccid]=f; - } + } - std::size_t id_of_cc_to_remove = - std::distance(cc_size.begin(), - std::min_element(cc_size.begin(), cc_size.end())); + std::size_t id_of_cc_to_remove = std::distance(cc_size.begin(), + std::min_element(cc_size.begin(), cc_size.end())); Mesh copy1 = sm; Mesh copy2 = sm; From cd0837e3164c7c705ed88b252f80679a7327f2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 6 May 2019 09:32:04 +0200 Subject: [PATCH 067/203] Document keep_large(st)_CCs properly --- .../Polygon_mesh_processing.txt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 004aad17948..fc2c979423f 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -706,11 +706,17 @@ enable the user to keep and remove only a selection of connected components, provided either as a range of faces that belong to the desired connected components or as a range of connected component ids (one or more per connected component). -Finally, `CGAL::Polygon_mesh_processing::keep_largest_connected_components()` -enables the user to keep only the largest connected components. This feature can -for example be useful for noisy data were small connected components -should be discarded in favour of major connected components. - +Finally, it can be useful to quickly remove some connected components, for example for noisy data +where small connected components should be discarded in favor of major connected components. +The function `CGAL::Polygon_mesh_processing::keep_largest_connected_components()` +enables the user to keep only a given number from the largest connected components. The size +of a connected component is given by the sum of the size of the faces it contains. By default, +the size of a face is `1` and thus the size of a connected component is equal to the number of faces +it contains. However, it is also possible to pass a face size map, such that the size of the face +is its area, for example. +Similarly to the previous function, the function +`CGAL::Polygon_mesh_processing::keep_large_connected_components()` can be used to discard all connected +components whose size is below a user-defined threshold. \subsection CCExample Connected Components Example From a02dba94f830d49312a3ddee09dfea2fb75ed575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 6 May 2019 11:54:40 +0200 Subject: [PATCH 068/203] Fix typos --- .../doc/Polygon_mesh_processing/NamedParameters.txt | 2 +- .../doc/Polygon_mesh_processing/Polygon_mesh_processing.txt | 2 +- .../CGAL/Polygon_mesh_processing/connected_components.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt index ac03eebb50c..164b0d811ba 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt @@ -396,7 +396,7 @@ evaluating the size of a connected component (which is defined as the sum of the \n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and -a value type supporting construction from `0`, `operator+=()`, and comparisons operations. \n +a value type supporting construction from `0`, `operator+=()`, and comparison operators. \n Default: `CGAL::Constant_property_map` with value `1` \cgalNPEnd diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index fc2c979423f..edf3e13be38 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -710,7 +710,7 @@ Finally, it can be useful to quickly remove some connected components, for examp where small connected components should be discarded in favor of major connected components. The function `CGAL::Polygon_mesh_processing::keep_largest_connected_components()` enables the user to keep only a given number from the largest connected components. The size -of a connected component is given by the sum of the size of the faces it contains. By default, +of a connected component is given by the sum of the sizes of the faces it contains; by default, the size of a face is `1` and thus the size of a connected component is equal to the number of faces it contains. However, it is also possible to pass a face size map, such that the size of the face is its area, for example. diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 9a47a40380c..4065cca8c26 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -396,8 +396,8 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, * \cgalParamEnd * \cgalNamedParamsEnd * - * \pre If a face weight property map is passed by the user, `ThresholdValueType` must be the same - * type as the value type of the property map. Othrewise, `ThresholdValueType` must be `std::size_t`. + * \pre If a face size property map is passed by the user, `ThresholdValueType` must be the same + * type as the value type of the property map. Otherwise, `ThresholdValueType` must be `std::size_t`. * * \return the number of connected components removed (ignoring isolated vertices). */ From 6d9196e5842b7b5988394ef79892a99b9cd480ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 6 May 2019 11:55:07 +0200 Subject: [PATCH 069/203] Get rid of 'double' in the SM connected component test the number of type should be determined by the kernel --- .../connected_component_surface_mesh.cpp | 63 +++++++++++-------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp index a8cd31a2829..4092a5c2fb9 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_surface_mesh.cpp @@ -17,31 +17,36 @@ typedef Kernel::Point_3 Point; typedef Kernel::Compare_dihedral_angle_3 Compare_dihedral_angle_3; typedef CGAL::Surface_mesh Mesh; -template +template struct Constraint - : public boost::put_get_helper > + : public boost::put_get_helper > { + typedef typename GT::FT FT; + typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - typedef boost::readable_property_map_tag category; - typedef bool value_type; - typedef bool reference; - typedef edge_descriptor key_type; + typedef boost::readable_property_map_tag category; + typedef bool value_type; + typedef bool reference; + typedef edge_descriptor key_type; - Constraint() :g(NULL) {} - Constraint(G & g, double bound) : g(&g), bound(bound) {} + Constraint() : g(nullptr), gt(nullptr), bound(0) {} + Constraint(const G& g, const GT& gt, const FT bound) : g(&g), gt(>), bound(bound) {} - bool operator[](edge_descriptor e) const + bool operator[](const edge_descriptor e) const { - return compare((*g).point(source(e,*g)), - (*g).point(target(e,*g)), - (*g).point(target(next(halfedge(e,*g),*g),*g)), - (*g).point(target(next(opposite(halfedge(e,*g),*g),*g),*g)), - bound) == CGAL::SMALLER; + const Mesh& rg = *g; + + return gt->compare_dihedral_angle_3_object()( + rg.point(source(e, rg)), + rg.point(target(e, rg)), + rg.point(target(next(halfedge(e, rg), rg), rg)), + rg.point(target(next(opposite(halfedge(e, rg), rg), rg), rg)), + bound) == CGAL::SMALLER; } - G* g; - Compare_dihedral_angle_3 compare; - double bound; + const G* g; + const GT* gt; + FT bound; }; template @@ -51,7 +56,7 @@ struct Face_descriptor_area_functor Face_descriptor_area_functor(const G& g, const GT& gt) : g(g), gt(gt) { } - double operator()(const face_descriptor f) const + typename GT::FT operator()(const face_descriptor f) const { const auto& vpm = get(CGAL::vertex_point, g); @@ -64,13 +69,15 @@ struct Face_descriptor_area_functor const GT& gt; }; -void test_CC_with_default_size_map(Mesh sm) +void test_CC_with_default_size_map(Mesh sm, + const Kernel& k) { std::cout << " -- test with default size map -- " << std::endl; typedef boost::graph_traits::face_descriptor face_descriptor; + typedef Kernel::FT FT; - const double bound = std::cos(0.7 * CGAL_PI); + const FT bound = std::cos(0.7 * CGAL_PI); std::vector cc; face_descriptor fd = *faces(sm).first; @@ -113,18 +120,18 @@ void test_CC_with_default_size_map(Mesh sm) // default face size map, but explicitely passed PMP::keep_connected_components(copy1, ff, - PMP::parameters::edge_is_constrained_map(Constraint(copy1, bound)) + PMP::parameters::edge_is_constrained_map(Constraint(copy1, k, bound)) .face_size_map(CGAL::Constant_property_map(1))); // remove cc from copy2 ff.clear(); ff.push_back(one_face_per_cc[id_of_cc_to_remove]); PMP::remove_connected_components(copy2, ff, - PMP::parameters::edge_is_constrained_map(Constraint(copy2, bound))); + PMP::parameters::edge_is_constrained_map(Constraint(copy2, k, bound))); std::cerr << "We keep the " << num-1 << " largest components" << std::endl; PMP::keep_largest_connected_components(sm, num-1, - PMP::parameters::edge_is_constrained_map(Constraint(sm, bound))); + PMP::parameters::edge_is_constrained_map(Constraint(sm, k, bound))); sm.collect_garbage(); copy1.collect_garbage(); @@ -146,13 +153,13 @@ void test_CC_with_default_size_map(Mesh sm) } } -void test_CC_with_area_size_map(Mesh sm) +void test_CC_with_area_size_map(Mesh sm, + const Kernel& k) { std::cout << " -- test with area size map -- " << std::endl; typedef boost::graph_traits::face_descriptor face_descriptor; - Kernel k; Face_descriptor_area_functor f(sm, k); std::cout << "We keep the " << 2 << " largest components" << std::endl; @@ -187,10 +194,12 @@ int main(int /*argc*/, char** /*argv*/) assert(in.good()); in >> sm; + Kernel k; + std::cout << "VEF " << num_vertices(sm) << " " << num_edges(sm) << " " << num_faces(sm) << "\n"; - test_CC_with_default_size_map(sm); - test_CC_with_area_size_map(sm); + test_CC_with_default_size_map(sm, k); + test_CC_with_area_size_map(sm, k); return EXIT_SUCCESS; } From 11848b41db12864c884022e8584af239c5f417ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 7 May 2019 09:34:25 +0200 Subject: [PATCH 070/203] Add a note in Polyhedron_3 that PMP::keep_largest_CCs is stronger --- Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h | 5 +++++ Polyhedron/doc/Polyhedron/dependencies | 1 + 2 files changed, 6 insertions(+) diff --git a/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h b/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h index 47811036fd6..de918b9f790 100644 --- a/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h +++ b/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h @@ -1473,6 +1473,11 @@ public: Returns the number of connected components erased (ignoring isolated vertices). The polyhedron type must support vertices, halfedges, and removal operations. + + Note that a stronger version of this function is offered by the package \ref PkgPolygonMeshProcessing : + `CGAL::Polygon_mesh_processing::keep_largest_connected_components()`, which can be called + since the class `Polyhedron_3` is a model of the requried concepts `FaceListGraph` and `MutableFaceGraph` + (see \ref BGLPolyhedral for more information). */ unsigned int keep_largest_connected_components(unsigned int nb_components_to_keep); diff --git a/Polyhedron/doc/Polyhedron/dependencies b/Polyhedron/doc/Polyhedron/dependencies index b37e2f8debe..36a8fcc9d3c 100644 --- a/Polyhedron/doc/Polyhedron/dependencies +++ b/Polyhedron/doc/Polyhedron/dependencies @@ -7,3 +7,4 @@ Stream_support HalfedgeDS Miscellany BGL +Polygon_mesh_processing From a2d5ab86cf261199892cfe86f753f2bb6877e34b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 7 May 2019 11:46:17 +0200 Subject: [PATCH 071/203] Fix typo --- .../include/CGAL/Periodic_3_regular_triangulation_traits_3.h | 2 +- Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_traits_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_traits_3.h index 891187bdcf0..d8bf30a6cc5 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_traits_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_traits_3.h @@ -77,7 +77,7 @@ public: typedef Functor_with_offset_weighted_points_adaptor_3 Compare_power_distance_3; - // Undocumented, requried for Is_Gabriel (Alpha shapes) + // Undocumented, required for Is_Gabriel (Alpha shapes) typedef Functor_with_offset_weighted_points_adaptor_3 Power_side_of_bounded_power_sphere_3; diff --git a/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h b/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h index de918b9f790..2cd739197f3 100644 --- a/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h +++ b/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h @@ -1476,7 +1476,7 @@ public: Note that a stronger version of this function is offered by the package \ref PkgPolygonMeshProcessing : `CGAL::Polygon_mesh_processing::keep_largest_connected_components()`, which can be called - since the class `Polyhedron_3` is a model of the requried concepts `FaceListGraph` and `MutableFaceGraph` + since the class `Polyhedron_3` is a model of the required concepts `FaceListGraph` and `MutableFaceGraph` (see \ref BGLPolyhedral for more information). */ unsigned int keep_largest_connected_components(unsigned int nb_components_to_keep); From 556e7006c8754fd2a49b7ee056ed6984a00210b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 8 May 2019 10:53:30 +0200 Subject: [PATCH 072/203] fix link --- Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h b/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h index 2cd739197f3..c65faaf9875 100644 --- a/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h +++ b/Polyhedron/doc/Polyhedron/CGAL/Polyhedron_3.h @@ -1475,7 +1475,7 @@ public: The polyhedron type must support vertices, halfedges, and removal operations. Note that a stronger version of this function is offered by the package \ref PkgPolygonMeshProcessing : - `CGAL::Polygon_mesh_processing::keep_largest_connected_components()`, which can be called + \link Polygon_mesh_processing::keep_largest_connected_components() `CGAL::Polygon_mesh_processing::keep_largest_connected_components()` \endlink, which can be called since the class `Polyhedron_3` is a model of the required concepts `FaceListGraph` and `MutableFaceGraph` (see \ref BGLPolyhedral for more information). */ From a36c7fe39b1c368c262ced59ca5f63b4888adace Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 7 May 2019 15:21:31 +0200 Subject: [PATCH 073/203] Write a 3mf wrapper --- Stream_support/include/CGAL/IO/read_3mf.h | 186 +++++++++++ Stream_support/include/CGAL/IO/write_3mf.h | 303 ++++++++++++++++++ .../test/Stream_support/CMakeLists.txt | 43 ++- .../test/Stream_support/test_3mf_to_sm.cpp | 147 +++++++++ 4 files changed, 676 insertions(+), 3 deletions(-) create mode 100644 Stream_support/include/CGAL/IO/read_3mf.h create mode 100644 Stream_support/include/CGAL/IO/write_3mf.h create mode 100644 Stream_support/test/Stream_support/test_3mf_to_sm.cpp diff --git a/Stream_support/include/CGAL/IO/read_3mf.h b/Stream_support/include/CGAL/IO/read_3mf.h new file mode 100644 index 00000000000..5c6cf0798d2 --- /dev/null +++ b/Stream_support/include/CGAL/IO/read_3mf.h @@ -0,0 +1,186 @@ +#ifndef READ_3MF_H +#define READ_3MF_H +#include +#include +#include +#include "Model/COM/NMR_DLLInterfaces.h" +namespace CGAL{ + +/*! + * \brief read_soups_from_3mf extracts ranges of points and triangles from the + * `MeshObject`s contained in `file_name` + * \tparam PointRanges a model of the concepts `RandomAccessContainer` and + * `BackInsertionSequence` whose `value type` is + * a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` + * whose `value type` is the point type. + * \tparam PolygonRanges a model of the concept `RandomAccessContainer` whose + * `value_type` is a model of the concept `RandomAccessContainer` + * whose `value_type` is a model of the concept `RandomAccessContainer` whose + * `value_type` is std::size_t. + * \param file_name the name of the 3mf file to read. + * \param all_points a `PointRanges` that will contain the points of the meshes + * in `file_name`. + * Each of these meshes will add a range of its points. + * \param all_polygons a `PolygonRanges` that will contain the triangles of the + * meshes in `file_name`. + * Each of these meshes will add a range of its triangles. A `triangle` of + * all_polygons[i] contains the indices of its points in all_points[i]. + * \param names will contain the name of each mesh in `file_name` if any. + * If the i'th mesh has no name, it will be called "Unknown Mesh" in names. + * \return the number of meshes processed in `file_name`. + */ +template +int read_soups_from_3mf(const std::string& file_name, PointRanges& all_points, + PolygonRanges& all_polygons, std::vector& names) +{ + typedef typename PointRanges::value_type PointRange; + typedef typename PointRange::value_type Point_3; + typedef typename PolygonRanges::value_type PolygonRange; + typedef typename PolygonRange::value_type Polygon; + DWORD nInterfaceVersionMajor, nInterfaceVersionMinor, nInterfaceVersionMicro, nbVertices, nbPolygons; + HRESULT hResult; + NMR::PLib3MFModel * pModel; + NMR::PLib3MFModelReader * pReader; + // Extract Extension of filename + std::string sReaderName("3mf"); + + hResult = NMR::lib3mf_getinterfaceversion(&nInterfaceVersionMajor, &nInterfaceVersionMinor, &nInterfaceVersionMicro); + if (hResult != LIB3MF_OK) { + std::cout << "could not get 3MF Library version: " << std::hex << hResult << std::endl; + return -1; + } + + // Create Model Instance + hResult = NMR::lib3mf_createmodel(&pModel); + if (hResult != LIB3MF_OK) { + std::cout << "could not create model: " << std::hex << hResult << std::endl; + return -1; + } + + // Create Model Reader + hResult = NMR::lib3mf_model_queryreader(pModel, sReaderName.c_str(), &pReader); + if (hResult != LIB3MF_OK) { + std::cout << "could not create model reader: " << std::hex << hResult << std::endl; + NMR::lib3mf_release(pModel); + return -1; + } + + // Import Model from File + hResult = NMR::lib3mf_reader_readfromfileutf8(pReader, file_name.c_str()); + if (hResult != LIB3MF_OK) { + std::cout << "could not parse file: " << std::hex << hResult << std::endl; + NMR::lib3mf_release(pReader); + NMR::lib3mf_release(pModel); + return -1; + } + + // Release Model Reader + NMR::lib3mf_release(pReader); + + //Iterate Model + + BOOL pbHasNext; + NMR::PLib3MFModelResourceIterator * pResourceIterator; + + hResult = NMR::lib3mf_model_getobjects(pModel, &pResourceIterator); + if (hResult != LIB3MF_OK) { + std::cout << "could not get object: " << std::hex << hResult << std::endl; + NMR::lib3mf_release(pModel); + return -1; + } + hResult = NMR::lib3mf_resourceiterator_movenext(pResourceIterator, &pbHasNext); + if (hResult != LIB3MF_OK) { + std::cout << "could not get next object: " << std::hex << hResult << std::endl; + NMR::lib3mf_release(pResourceIterator); + NMR::lib3mf_release(pModel); + return -1; + } + while (pbHasNext) { + NMR::PLib3MFModelResource * pResource; + NMR::PLib3MFModelMeshObject * pMeshObject; + NMR::PLib3MFModelComponentsObject * pComponentsObject; + NMR::ModelResourceID ResourceID; + + // get current resource + hResult = NMR::lib3mf_resourceiterator_getcurrent(pResourceIterator, &pResource); + if (hResult != LIB3MF_OK) { + std::cout << "could not get resource: " << std::hex << hResult << std::endl; + NMR::lib3mf_release(pResourceIterator); + NMR::lib3mf_release(pModel); + return -1; + } + + // get resource ID + hResult = NMR::lib3mf_resource_getresourceid(pResource, &ResourceID); + if (hResult != LIB3MF_OK) { + std::cout << "could not get resource id: " << std::hex << hResult << std::endl; + NMR::lib3mf_release(pResource); + NMR::lib3mf_release(pResourceIterator); + NMR::lib3mf_release(pModel); + return -1; + } + + // Query mesh interface + BOOL bIsMeshObject; + hResult = NMR::lib3mf_object_ismeshobject(pResource, &bIsMeshObject); + if ((hResult == LIB3MF_OK) && (bIsMeshObject)) { + std::cout << "------------------------------------------------------" << std::endl; + std::cout << "mesh object #" << ResourceID << ": " << std::endl; + + pMeshObject = pResource; + NMR::lib3mf_meshobject_getvertexcount(pMeshObject, &nbVertices); + NMR::lib3mf_meshobject_gettrianglecount(pMeshObject, &nbPolygons); + PointRange points (nbVertices); + PolygonRange triangles(nbPolygons); + DWORD nNeededChars; + std::vector pBuffer; + // Retrieve Mesh Name Length + hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, NULL, 0, &nNeededChars); + if (hResult != LIB3MF_OK) + return hResult; + + // Retrieve Mesh Name + if (nNeededChars > 0) { + pBuffer.resize(nNeededChars + 1); + hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, &pBuffer[0], nNeededChars + 1, NULL); + pBuffer[nNeededChars] = 0; + names.push_back(std::string(&pBuffer[0])); + } + else + names.push_back(std::string("Unknown Mesh")); + for(DWORD vid = 0; vid < nbVertices; ++vid) + { + NMR::MODELMESHVERTEX pVertex; + NMR::lib3mf_meshobject_getvertex(pMeshObject, vid, &pVertex); + points[vid] = + Point_3(pVertex.m_fPosition[0], + pVertex.m_fPosition[1], + pVertex.m_fPosition[2]); + } + for(DWORD pid = 0; pid < nbPolygons; ++pid) + { + NMR::MODELMESHTRIANGLE pTriangle; + NMR::lib3mf_meshobject_gettriangle(pMeshObject, pid, &pTriangle); + Polygon triangle(3); + for(DWORD i = 0; i< 3; ++i) + triangle[i] = pTriangle.m_nIndices[i]; + triangles[pid] = triangle; + } + all_points.push_back(points); + all_polygons.push_back(triangles); + } + // free instances + NMR::lib3mf_release(pResource); + hResult = NMR::lib3mf_resourceiterator_movenext(pResourceIterator, &pbHasNext); + if (hResult != LIB3MF_OK) { + std::cout << "could not get next object: " << std::hex << hResult << std::endl; + return -1; + } + } + return all_points.size(); +} + +}//end CGAL + +#endif // READ_3MF_H + diff --git a/Stream_support/include/CGAL/IO/write_3mf.h b/Stream_support/include/CGAL/IO/write_3mf.h new file mode 100644 index 00000000000..322d54495c3 --- /dev/null +++ b/Stream_support/include/CGAL/IO/write_3mf.h @@ -0,0 +1,303 @@ +// Copyright (c) 2019 Geometry Factory +// 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$ +// SPDX-License-Identifier: LGPL-3.0+ +// +// Author(s) : Maxime Gimeno + +#ifndef WRITE_3MF_H +#define WRITE_3MF_H +#include +#include +#include +#include "Model/COM/NMR_DLLInterfaces.h" +namespace CGAL{ +namespace tmf_internal{ +// Utility functions to create vertices and triangles +NMR::MODELMESHVERTEX fnCreateVertex(float x, float y, float z) +{ + NMR::MODELMESHVERTEX result; + result.m_fPosition[0] = x; + result.m_fPosition[1] = y; + result.m_fPosition[2] = z; + return result; +} +NMR::MODELMESHTRIANGLE fnCreateTriangle(int v0, int v1, int v2) +{ + NMR::MODELMESHTRIANGLE result; + result.m_nIndices[0] = v0; + result.m_nIndices[1] = v1; + result.m_nIndices[2] = v2; + return result; +} + +} //end internal + +bool add_build_item(NMR::PLib3MFModel * pModel, + NMR::PLib3MFModelMeshObject* pMeshObject) +{ + HRESULT hResult; + DWORD nErrorMessage; + LPCSTR pszErrorMessage; + // Add Build Item for Mesh + NMR::PLib3MFModelBuildItem * pBuildItem; + hResult = NMR::lib3mf_model_addbuilditem(pModel, pMeshObject, NULL, &pBuildItem); + if (hResult != LIB3MF_OK) { + std::cout << "could not create build item: " + << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(pModel, &nErrorMessage, &pszErrorMessage); + std::cout << "error #" << std::hex << nErrorMessage + << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(pMeshObject); + NMR::lib3mf_release(pModel); + return false; + } + // Release BuildItem and Mesh + NMR::lib3mf_release(pMeshObject); + NMR::lib3mf_release(pBuildItem); + return true; +} + +bool export_model_to_file(const std::string& file_name, + NMR::PLib3MFModel * pModel) +{ + HRESULT hResult; + DWORD nErrorMessage; + LPCSTR pszErrorMessage; + // Output mesh as 3MF + // Create Model Writer for 3MF + NMR::PLib3MFModelWriter * p3MFWriter; + hResult = NMR::lib3mf_model_querywriter(pModel, "3mf", &p3MFWriter); + if (hResult != LIB3MF_OK) { + std::cout << "could not create model reader: " + << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(pModel, &nErrorMessage, &pszErrorMessage); + std::cout << "error #" << std::hex << nErrorMessage + << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(pModel); + return false; + } + // Export Model into File + hResult = NMR::lib3mf_writer_writetofileutf8(p3MFWriter, file_name.c_str()); + if (hResult != LIB3MF_OK) { + std::cout << "could not write file: " << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(p3MFWriter, &nErrorMessage, &pszErrorMessage); + std::cout << "error #" << std::hex << nErrorMessage << ": " + << pszErrorMessage << std::endl; + NMR::lib3mf_release(pModel); + NMR::lib3mf_release(p3MFWriter); + return false; + } + + // Release Model Writer + NMR::lib3mf_release(p3MFWriter); + return true; +} + +template +bool write_mesh_to_model( const PointRange& points, + const PolygonRange& polygons, + const std::string& name, + NMR::PLib3MFModelMeshObject** pMeshObject, + NMR::PLib3MFModel * pModel + ) +{ + DWORD nErrorMessage; + LPCSTR pszErrorMessage; + HRESULT hResult; + // Create mesh structure + std::vector pVertices; + std::vector pTriangles; + // Create Mesh Object + hResult = NMR::lib3mf_model_addmeshobject(pModel, pMeshObject); + if (hResult != LIB3MF_OK) { + std::cout << "could not add mesh object: " << std::hex + << hResult << std::endl; + NMR::lib3mf_getlasterror(pModel, &nErrorMessage, &pszErrorMessage); + std::cout << "error #" << std::hex << nErrorMessage << ": " + << pszErrorMessage << std::endl; + NMR::lib3mf_release(pModel); + return false; + } + for( auto point : points) + { + pVertices.push_back(tmf_internal::fnCreateVertex(point.x(), point.y(), point.z())); + } + + for( auto triangle : polygons) + { + pTriangles.push_back(tmf_internal::fnCreateTriangle(triangle[0], triangle[1], triangle[2])); + } + + hResult = NMR::lib3mf_meshobject_setgeometry(*pMeshObject, pVertices.data(), + pVertices.size(), pTriangles.data(), + pTriangles.size()); + if (hResult != LIB3MF_OK) { + std::cout << "could not set mesh geometry: " + << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(*pMeshObject, &nErrorMessage, &pszErrorMessage); + std::cout << "error #" << std::hex << nErrorMessage + << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(*pMeshObject); + NMR::lib3mf_release(pModel); + return false; + } + // Set name + hResult = NMR::lib3mf_object_setnameutf8(*pMeshObject, name.c_str()); + if (hResult != LIB3MF_OK) { + std::cout << "could not set object name: " << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(*pMeshObject, &nErrorMessage, &pszErrorMessage); + std::cout << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(*pMeshObject); + NMR::lib3mf_release(pModel); + return -1; + } +} + +//remember that it adds 3 demmy vertices in the beginning, and a dummy triangle to be ignored. +template +bool write_points(const PointRange& points, + const std::string& name, + NMR::PLib3MFModelMeshObject** pMeshObject, + NMR::PLib3MFModel * pModel + ) +{ + DWORD nErrorMessage; + LPCSTR pszErrorMessage; + HRESULT hResult; + // Create mesh structure + std::vector pVertices; + // Create Mesh Object + hResult = NMR::lib3mf_model_addmeshobject(pModel, pMeshObject); + if (hResult != LIB3MF_OK) { + std::cout << "could not add mesh object: " << std::hex + << hResult << std::endl; + NMR::lib3mf_getlasterror(pModel, &nErrorMessage, &pszErrorMessage); + std::cout << "error #" << std::hex << nErrorMessage << ": " + << pszErrorMessage << std::endl; + NMR::lib3mf_release(pModel); + return false; + } + //add 3 demmy vertices to be sure to have a valid triangle and accept point sets with less than 3 vertices. + for(int i = 0; i< 3; ++i) + pVertices.push_back(tmf_internal::fnCreateVertex(0,0,0)); + for( auto point : points) + { + pVertices.push_back(tmf_internal::fnCreateVertex(point.x(), point.y(), point.z())); + } + NMR::MODELMESHTRIANGLE dummy_triangle = tmf_internal::fnCreateTriangle(0,1,2); //add a triangle to avoid lib error. + hResult = NMR::lib3mf_meshobject_setgeometry(*pMeshObject, pVertices.data(), + pVertices.size(), &dummy_triangle, 1); + if (hResult != LIB3MF_OK) { + std::cout << "could not set mesh geometry: " + << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(*pMeshObject, &nErrorMessage, &pszErrorMessage); + std::cout << "error #" << std::hex << nErrorMessage + << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(*pMeshObject); + NMR::lib3mf_release(pModel); + return false; + } + // Set name + hResult = NMR::lib3mf_object_setnameutf8(*pMeshObject, name.c_str()); + if (hResult != LIB3MF_OK) { + std::cout << "could not set object name: " << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(*pMeshObject, &nErrorMessage, &pszErrorMessage); + std::cout << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(*pMeshObject); + NMR::lib3mf_release(pModel); + return -1; + } +} + +template +bool write_point_cloud_to_model(const PointRange& points, + const std::string& name, + NMR::PLib3MFModelMeshObject** pMeshObject, + NMR::PLib3MFModel * pModel + ) +{ + std::string pc_name = name; + pc_name.append("_cgal_pc"); + write_points(points, pc_name, pMeshObject, pModel); +} + +template +bool write_polyline_to_model(const PointRange& points, + const std::string& name, + NMR::PLib3MFModelMeshObject** pMeshObject, + NMR::PLib3MFModel * pModel + ) +{ + std::string pc_name = name; + pc_name.append("_cgal_pl"); + write_points(points, pc_name, pMeshObject, pModel); +} + +/*! + * \brief write_soups_to_3mf will write the polygon soups in all_points and + * all_polygons in `file_name`, in the 3mf format. + * \tparam PointRanges a model of the concepts `RandomAccessContainer` and + * `BackInsertionSequence` whose `value type` is + * a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` + * whose `value type` is the point type. + * \tparam PolygonRanges a model of the concept `RandomAccessContainer` whose + * `value_type` is a model of the concept `RandomAccessContainer` + * whose `value_type` is a model of the concept `RandomAccessContainer` whose + * `value_type` is std::size_t. + * \param file_name the name of the 3mf file to write. + * \param all_points a `PointRanges` that contains the points of the soups + * to write. + * \param all_polygons a `PolygonRanges` that contains the triangles of the + * soups in `file_name`. + * \param names will contains the name of each mesh in `file_name`. + * \return `true` if the writing is successful, `false` otherwise. + */ +template +bool write_soups_to_3mf(const std::string& file_name, + const PointRanges& all_points, + const PolygonRanges& all_polygons, + const std::vector& names) +{ + DWORD nErrorMessage; + LPCSTR pszErrorMessage; + HRESULT hResult; + + // Create Model Instance + NMR::PLib3MFModel * pModel; + hResult = NMR::lib3mf_createmodel(&pModel); + if (hResult != LIB3MF_OK) { + std::cout << "could not create model: " << std::hex << hResult << std::endl; + return false; + } + for(std::size_t id = 0; id < all_points.size(); ++id) + { + NMR::PLib3MFModelMeshObject* pMeshObject; + std::string name; + if(names.size() > id + && ! names[id].empty()) + { + name=names[id]; + } + else + name = std::string(""); + write_mesh_to_model(all_points[id], all_polygons[id], name, &pMeshObject, pModel); + //write_mesh_object_to_model(pModel, pMeshObject); + } + return export_model_to_file(file_name, pModel); +} +}//end CGAL +#endif // WRITE_3MF_H diff --git a/Stream_support/test/Stream_support/CMakeLists.txt b/Stream_support/test/Stream_support/CMakeLists.txt index 5eb7092e2b7..ca3d81698c4 100644 --- a/Stream_support/test/Stream_support/CMakeLists.txt +++ b/Stream_support/test/Stream_support/CMakeLists.txt @@ -7,13 +7,49 @@ project( Stream_support_Tests ) cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) - if ( CGAL_FOUND ) - + set(3MF_INCLUDE_DIR "" CACHE PATH "Path to lib3MF headers") + set(3MF_LIBRARY_DIR "" CACHE PATH "Path to lib3MF library files") + if(IS_DIRECTORY "${3MF_INCLUDE_DIR}/Common") + set(3MF_FOUND true) + endif() + # create a target per cppfile file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles}) - create_single_source_cgal_program( "${cppfile}" ) + if ( "${cppfile}" STREQUAL "test_3mf_to_sm.cpp" ) + + if(3MF_FOUND) + if (WIN32) + set(LSUFFIX "dll") + set(LSUFFIXOUT ".dll") + elseif(UNIX AND NOT APPLE) + set(LSUFFIX "so") + set(LSUFFIXOUT ".so.1") + else() + set(LSUFFIX "dylib") + set(LSUFFIXOUT ".1.dylib") + endif() + include_directories(${3MF_INCLUDE_DIR}) + link_directories(${3MF_LIBRARY_DIR}) + create_single_source_cgal_program( "${cppfile}" ) + + if (WIN32) + target_link_libraries(test_3mf_to_sm PRIVATE lib3MF) + else() + # Unix prefixes the name of the library with "lib" anyway + target_link_libraries(test_3mf_to_sm PRIVATE 3MF) + if(APPLE) + target_link_directories(test_3mf_to_sm PRIVATE ${3MF_LIBRARY_DIR}/..) + endif() + endif() + + else() + message(STATUS "NOTICE: This program requires the lib3MF library, and will not be compiled.") + endif() + else() + create_single_source_cgal_program( "${cppfile}" ) + endif() endforeach() else() @@ -22,3 +58,4 @@ else() endif() + diff --git a/Stream_support/test/Stream_support/test_3mf_to_sm.cpp b/Stream_support/test/Stream_support/test_3mf_to_sm.cpp new file mode 100644 index 00000000000..ee86814d079 --- /dev/null +++ b/Stream_support/test/Stream_support/test_3mf_to_sm.cpp @@ -0,0 +1,147 @@ +//needed by functions +#include +#include +#include +#include "Model/COM/NMR_DLLInterfaces.h" +//needed by example +#include +#include +#include +#include +#include +#include +#include +#include +#include +// Use NMR namespace for the interfaces +using namespace NMR; +namespace PMP = CGAL::Polygon_mesh_processing; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; + +typedef Kernel::Point_3 Point_3; +typedef CGAL::Surface_mesh Mesh; +typedef std::vector PointRange; +typedef std::vector Polygon; +typedef std::vector PolygonRange; + +int main(int argc, char** argv) +{ +/* if( argc != 2) + { + std::cerr<<"please give an input 3mf file."; + return 1; + } + std::vector all_points; + std::vector all_polygons; + std::vector names; + std::size_t nb_meshes = + CGAL::read_soups_from_3mf(argv[1], all_points, all_polygons, names); + if(nb_meshes <0) + return 1; + for(std::size_t i = 0; i< nb_meshes; ++i) + { + PolygonRange triangles = all_polygons[i]; + PointRange points = all_points[i]; + bool ok = true; + if(!PMP::is_polygon_soup_a_polygon_mesh(triangles)) + ok = PMP::orient_polygon_soup(points, triangles); + if(!ok) + { + std::cerr<<"Object is not orientable. Skipped."<(sphere); + CGAL::make_regular_prism(10, tube, Point_3(0,-10,0), 10); + /* + all_points.clear(); + all_polygons.clear(); + names.clear(); + */ + PointRange points; + //PolygonRange triangles; + typedef boost::property_map::type VPMap; + VPMap vpm = get(boost::vertex_point, sphere); + std::unordered_map::vertex_descriptor, + std::size_t> vertex_id_map; + std::size_t i = 0; + for(auto v : sphere.vertices()) + { + points.push_back(get(vpm, v)); + vertex_id_map[v] = i++; + } + //all_points.push_back(points); + /*for(auto f : sphere.faces()) + { + Polygon triangle; + for(auto vert : CGAL::vertices_around_face(halfedge(f, sphere), sphere)) + { + triangle.push_back(vertex_id_map[vert]); + } + triangles.push_back(triangle); + } + all_polygons.push_back(triangles); + points.clear(); + triangles.clear(); + vertex_id_map.clear(); + i = 0; + + vpm = get(boost::vertex_point, tube); + for(auto v : tube.vertices()) + { + points.push_back(get(vpm, v)); + vertex_id_map[v] = i++; + } + all_points.push_back(points); + for(auto f : tube.faces()) + { + Polygon triangle; + for(auto vert : CGAL::vertices_around_face(halfedge(f, tube), tube)) + { + triangle.push_back(vertex_id_map[vert]); + } + triangles.push_back(triangle); + } + all_polygons.push_back(triangles); + names.push_back(std::string("sphere")); + names.push_back(std::string("tube")); + if(!CGAL::write_soups_to_3mf("micro.3mf", all_points, all_polygons, names)){ + std::cerr<<"an error has occured in final writing."< Date: Fri, 10 May 2019 14:58:27 +0200 Subject: [PATCH 074/203] Add reading functions for polylines and point clouds --- Stream_support/include/CGAL/IO/read_3mf.h | 323 ++++++++++++++---- .../test/Stream_support/CMakeLists.txt | 33 +- .../test/Stream_support/data/test.3mf | Bin 0 -> 2322 bytes .../test/Stream_support/test_3mf_to_sm.cpp | 74 ++-- 4 files changed, 316 insertions(+), 114 deletions(-) create mode 100644 Stream_support/test/Stream_support/data/test.3mf diff --git a/Stream_support/include/CGAL/IO/read_3mf.h b/Stream_support/include/CGAL/IO/read_3mf.h index 5c6cf0798d2..d9e477f2820 100644 --- a/Stream_support/include/CGAL/IO/read_3mf.h +++ b/Stream_support/include/CGAL/IO/read_3mf.h @@ -1,41 +1,203 @@ +// Copyright (c) 2019 Geometry Factory +// 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$ +// SPDX-License-Identifier: LGPL-3.0+ +// +// Author(s) : Maxime Gimeno + #ifndef READ_3MF_H #define READ_3MF_H #include #include #include -#include "Model/COM/NMR_DLLInterfaces.h" +#include +#include +#include namespace CGAL{ -/*! - * \brief read_soups_from_3mf extracts ranges of points and triangles from the - * `MeshObject`s contained in `file_name` - * \tparam PointRanges a model of the concepts `RandomAccessContainer` and - * `BackInsertionSequence` whose `value type` is - * a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` - * whose `value type` is the point type. - * \tparam PolygonRanges a model of the concept `RandomAccessContainer` whose - * `value_type` is a model of the concept `RandomAccessContainer` - * whose `value_type` is a model of the concept `RandomAccessContainer` whose - * `value_type` is std::size_t. - * \param file_name the name of the 3mf file to read. - * \param all_points a `PointRanges` that will contain the points of the meshes - * in `file_name`. - * Each of these meshes will add a range of its points. - * \param all_polygons a `PolygonRanges` that will contain the triangles of the - * meshes in `file_name`. - * Each of these meshes will add a range of its triangles. A `triangle` of - * all_polygons[i] contains the indices of its points in all_points[i]. - * \param names will contain the name of each mesh in `file_name` if any. - * If the i'th mesh has no name, it will be called "Unknown Mesh" in names. - * \return the number of meshes processed in `file_name`. - */ -template -int read_soups_from_3mf(const std::string& file_name, PointRanges& all_points, - PolygonRanges& all_polygons, std::vector& names) -{ - typedef typename PointRanges::value_type PointRange; +template +bool extract_soups (NMR::PLib3MFModelMeshObject *pMeshObject, + PointRange& points, + PolygonRange& triangles, + std::string& name) { + typedef typename PointRange::value_type Point_3; + typedef typename PolygonRange::value_type Polygon; + + HRESULT hResult; + DWORD nNeededChars; + std::vector pBuffer; + // Retrieve Mesh Name Length + hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, NULL, 0, &nNeededChars); + if (hResult != LIB3MF_OK) + { + std::cerr<<"Error during name extraction."; + return false; + } + + // Retrieve Mesh Name + if (nNeededChars > 0) { + pBuffer.resize(nNeededChars + 1); + hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, &pBuffer[0], nNeededChars + 1, NULL); + pBuffer[nNeededChars] = 0; + std::string temp(&pBuffer[0]); + if(temp.find("_cgal_pc") != std::string::npos + || temp.find("_cgal_pl")!= std::string::npos) //ignore point clouds and polylines + { + return false; + } + name = std::string(&pBuffer[0]); + } + else + name = std::string("Unknown Mesh"); + for(DWORD vid = 0; vid < points.size(); ++vid) + { + NMR::MODELMESHVERTEX pVertex; + NMR::lib3mf_meshobject_getvertex(pMeshObject, vid, &pVertex); + points[vid] = + Point_3(pVertex.m_fPosition[0], + pVertex.m_fPosition[1], + pVertex.m_fPosition[2]); + } + for(DWORD pid = 0; pid < triangles.size(); ++pid) + { + NMR::MODELMESHTRIANGLE pTriangle; + NMR::lib3mf_meshobject_gettriangle(pMeshObject, pid, &pTriangle); + Polygon triangle(3); + for(DWORD i = 0; i< 3; ++i) + triangle[i] = pTriangle.m_nIndices[i]; + triangles[pid] = triangle; + } + return true; +} + +template +bool extract_polylines (NMR::PLib3MFModelMeshObject *pMeshObject, + PointRange& points, + PolygonRange&, + std::string& name) { + typedef typename PointRange::value_type Point_3; + typedef typename PolygonRange::value_type Polygon; + + HRESULT hResult; + DWORD nNeededChars; + std::vector pBuffer; + // Retrieve Mesh Name Length + hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, NULL, 0, &nNeededChars); + if (hResult != LIB3MF_OK) + { + points.resize(0); + std::cerr<<"Error during name extraction."; + return false; + } + + // Retrieve Mesh Name + if (nNeededChars > 0) { + pBuffer.resize(nNeededChars + 1); + hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, &pBuffer[0], nNeededChars + 1, NULL); + pBuffer[nNeededChars] = 0; + std::string temp(&pBuffer[0]); + if(temp.find("_cgal_pl")== std::string::npos) //ignore not polylines + { + points.resize(0); + return false; + } + name = std::string(&pBuffer[0]); + } + else + { + points.resize(0); + return false; + } + points.resize(points.size()-3); + for(DWORD vid = 0; vid < points.size()-3; ++vid) //ignore dummy_vertices + { + NMR::MODELMESHVERTEX pVertex; + NMR::lib3mf_meshobject_getvertex(pMeshObject, vid+3, &pVertex); + points[vid] = + Point_3(pVertex.m_fPosition[0], + pVertex.m_fPosition[1], + pVertex.m_fPosition[2]); + } + return true; +} + +template +bool extract_point_clouds (NMR::PLib3MFModelMeshObject *pMeshObject, + PointRange& points, + PolygonRange&, + std::string& name) { + typedef typename PointRange::value_type Point_3; + typedef typename PolygonRange::value_type Polygon; + + HRESULT hResult; + DWORD nNeededChars; + std::vector pBuffer; + // Retrieve Mesh Name Length + hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, NULL, 0, &nNeededChars); + if (hResult != LIB3MF_OK) + { + std::cerr<<"Error during name extraction."; + points.resize(0); + return false; + } + + // Retrieve Mesh Name + if (nNeededChars > 0) { + pBuffer.resize(nNeededChars + 1); + hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, &pBuffer[0], nNeededChars + 1, NULL); + pBuffer[nNeededChars] = 0; + std::string temp(&pBuffer[0]); + if(temp.find("_cgal_pc")== std::string::npos) //ignore not point_cloud + { + points.resize(0); + return false; + } + name = std::string(&pBuffer[0]); + } + else{ + points.resize(0); + return false; + } + points.resize(points.size()-3); + for(DWORD vid = 0; vid < points.size()-3; ++vid) //ignore dummy_vertices + { + NMR::MODELMESHVERTEX pVertex; + NMR::lib3mf_meshobject_getvertex(pMeshObject, vid+3, &pVertex); + points[vid] = + Point_3(pVertex.m_fPosition[0], + pVertex.m_fPosition[1], + pVertex.m_fPosition[2]); + } + //ignore dummy_triangle. + return true; +} + +template +int read_from_3mf(const std::string& file_name, PointRanges& all_points, + PolygonRanges& all_polygons, std::vector& names, + std::function func + ) +{ typedef typename PointRange::value_type Point_3; - typedef typename PolygonRanges::value_type PolygonRange; typedef typename PolygonRange::value_type Polygon; DWORD nInterfaceVersionMajor, nInterfaceVersionMinor, nInterfaceVersionMicro, nbVertices, nbPolygons; HRESULT hResult; @@ -119,7 +281,6 @@ int read_soups_from_3mf(const std::string& file_name, PointRanges& all_points, NMR::lib3mf_release(pModel); return -1; } - // Query mesh interface BOOL bIsMeshObject; hResult = NMR::lib3mf_object_ismeshobject(pResource, &bIsMeshObject); @@ -132,42 +293,13 @@ int read_soups_from_3mf(const std::string& file_name, PointRanges& all_points, NMR::lib3mf_meshobject_gettrianglecount(pMeshObject, &nbPolygons); PointRange points (nbVertices); PolygonRange triangles(nbPolygons); - DWORD nNeededChars; - std::vector pBuffer; - // Retrieve Mesh Name Length - hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, NULL, 0, &nNeededChars); - if (hResult != LIB3MF_OK) - return hResult; + std::string name; - // Retrieve Mesh Name - if (nNeededChars > 0) { - pBuffer.resize(nNeededChars + 1); - hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, &pBuffer[0], nNeededChars + 1, NULL); - pBuffer[nNeededChars] = 0; - names.push_back(std::string(&pBuffer[0])); + if(func(pMeshObject, points, triangles, name)){ + all_points.push_back(points); + all_polygons.push_back(triangles); + names.push_back(name); } - else - names.push_back(std::string("Unknown Mesh")); - for(DWORD vid = 0; vid < nbVertices; ++vid) - { - NMR::MODELMESHVERTEX pVertex; - NMR::lib3mf_meshobject_getvertex(pMeshObject, vid, &pVertex); - points[vid] = - Point_3(pVertex.m_fPosition[0], - pVertex.m_fPosition[1], - pVertex.m_fPosition[2]); - } - for(DWORD pid = 0; pid < nbPolygons; ++pid) - { - NMR::MODELMESHTRIANGLE pTriangle; - NMR::lib3mf_meshobject_gettriangle(pMeshObject, pid, &pTriangle); - Polygon triangle(3); - for(DWORD i = 0; i< 3; ++i) - triangle[i] = pTriangle.m_nIndices[i]; - triangles[pid] = triangle; - } - all_points.push_back(points); - all_polygons.push_back(triangles); } // free instances NMR::lib3mf_release(pResource); @@ -180,6 +312,67 @@ int read_soups_from_3mf(const std::string& file_name, PointRanges& all_points, return all_points.size(); } +/*! + * \brief read_soups_from_3mf extracts ranges of points and triangles from the + * `MeshObject`s contained in `file_name` + * \tparam PointRanges a model of the concepts `RandomAccessContainer` and + * `BackInsertionSequence` whose `value type` is + * a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` + * whose `value type` is the point type. + * \tparam PolygonRanges a model of the concept `RandomAccessContainer` whose + * `value_type` is a model of the concept `RandomAccessContainer` + * whose `value_type` is a model of the concept `RandomAccessContainer` whose + * `value_type` is std::size_t. + * \param file_name the name of the 3mf file to read. + * \param all_points a `PointRanges` that will contain the points of the meshes + * in `file_name`. + * Each of these meshes will add a range of its points. + * \param all_polygons a `PolygonRanges` that will contain the triangles of the + * meshes in `file_name`. + * Each of these meshes will add a range of its triangles. A `triangle` of + * all_polygons[i] contains the indices of its points in all_points[i]. + * \param names will contain the name of each mesh in `file_name` if any. + * If the i'th mesh has no name, it will be called "Unknown Mesh" in names. + * \return the number of meshes processed in `file_name`. + */ +template +int read_soups_from_3mf(const std::string& file_name, PointRanges& all_points, + PolygonRanges& all_polygons, std::vector& names + ) +{ + typedef typename PointRanges::value_type PointRange; + typedef typename PolygonRanges::value_type PolygonRange; + return read_from_3mf + (file_name, all_points, all_polygons, names, extract_soups); +} + + +template +int read_polylines_from_3mf(const std::string& file_name, PointRanges& all_points, + std::vector& names + ) +{ + typedef typename PointRanges::value_type PointRange; + typedef std::vector Polygon; + typedef std::vector PolygonRange; + std::vector all_polygons; + return read_from_3mf, PointRange, PolygonRange> + (file_name, all_points, all_polygons, names, extract_polylines); +} + + +template +int read_point_clouds_from_3mf(const std::string& file_name, PointRanges& all_points, + std::vector& names + ) +{ + typedef typename PointRanges::value_type PointRange; + typedef std::vector Polygon; + typedef std::vector PolygonRange; + std::vector all_polygons; + return read_from_3mf, PointRange, PolygonRange> + (file_name, all_points, all_polygons, names, extract_point_clouds); +} }//end CGAL #endif // READ_3MF_H diff --git a/Stream_support/test/Stream_support/CMakeLists.txt b/Stream_support/test/Stream_support/CMakeLists.txt index ca3d81698c4..f9905b79012 100644 --- a/Stream_support/test/Stream_support/CMakeLists.txt +++ b/Stream_support/test/Stream_support/CMakeLists.txt @@ -8,42 +8,23 @@ cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) if ( CGAL_FOUND ) - set(3MF_INCLUDE_DIR "" CACHE PATH "Path to lib3MF headers") - set(3MF_LIBRARY_DIR "" CACHE PATH "Path to lib3MF library files") + find_path(3MF_INCLUDE_DIR + NAMES Common Model + DOC "Path to lib3MF headers" + ) if(IS_DIRECTORY "${3MF_INCLUDE_DIR}/Common") set(3MF_FOUND true) endif() - + find_library(3MF_LIBRARIES NAMES 3MF DOC "Path to the lib3MF library") + # create a target per cppfile file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles}) if ( "${cppfile}" STREQUAL "test_3mf_to_sm.cpp" ) - if(3MF_FOUND) - if (WIN32) - set(LSUFFIX "dll") - set(LSUFFIXOUT ".dll") - elseif(UNIX AND NOT APPLE) - set(LSUFFIX "so") - set(LSUFFIXOUT ".so.1") - else() - set(LSUFFIX "dylib") - set(LSUFFIXOUT ".1.dylib") - endif() include_directories(${3MF_INCLUDE_DIR}) - link_directories(${3MF_LIBRARY_DIR}) create_single_source_cgal_program( "${cppfile}" ) - - if (WIN32) - target_link_libraries(test_3mf_to_sm PRIVATE lib3MF) - else() - # Unix prefixes the name of the library with "lib" anyway - target_link_libraries(test_3mf_to_sm PRIVATE 3MF) - if(APPLE) - target_link_directories(test_3mf_to_sm PRIVATE ${3MF_LIBRARY_DIR}/..) - endif() - endif() - + target_link_libraries(test_3mf_to_sm PRIVATE ${3MF_LIBRARIES}) else() message(STATUS "NOTICE: This program requires the lib3MF library, and will not be compiled.") endif() diff --git a/Stream_support/test/Stream_support/data/test.3mf b/Stream_support/test/Stream_support/data/test.3mf new file mode 100644 index 0000000000000000000000000000000000000000..223e1185b3ef069cda761b2bff1415d1f16b3fd6 GIT binary patch literal 2322 zcmZ`*2{@E%8~$djSqEcKno^SxW5QulNXFJ!rYtA>lCcy#F|$yRP?rp6^}m>wWL%x$fu1Vfpwq000nPZvY@j z3RC>D^+5nAppDVg_6Z{R-~*9gdk_Et-Yb4x3YZ9N+65=h`4Tk5ZNGvwM+BR-M3!Qn`!)Sc>QO|AHy9U&QVGKwfk>XfSy0L3A93TDGCG;^RMR&ZK z)zba35S?R`%&XO~4E%C2%6bmlctG^w>?{8m*24QKwDns1JacrAwi*$D#Mf{%tDeh- zU#iOrn3y0?+3lKoi>NHYWKQ5b(Xh(A#?WDq@k*n9l)i*3^iRrbU-1|>;&$av_!rq2 zkExa_+vQXy%$peuj}`tttAR1`7ZFOSNV=_+JLK?`Mf>CVuJF|;8tchJ21#1j+o!&^ z4xu;Uy7-8q_vTHyYejwJgfk6n)5GEhbfrXuetw}B?6UCSz>)A-KbPU=m6g00#Rbni za_4oCCapPXqq`aRjMLK6wP1_bn|*zzhp9EMy8M=hvEYFCK>a%(qzsn`^DF)`7L>(S z7SRhv)`>8fWUU=~nu@d0)D#VD=@xJ3*A-O;PpN!BDu8GA9~P0QZD6y-jP!ON^7Zv{ z^L!^qkBym1_p$XdRzgXgoZ7c^1!gZTsVwc6>tZQdb$N|ma3MV9%+NCT*8N^D%}cIC@5D9FiXOrpTX zSQ@U4|JE5*vHjQW0ou#h{8r(;at#5NiEI-j(4P+ZNOA>q(<~@TV=Ff)Xp>4C3K5}B zL0-*J$^1t%~{dz5WOm%@L8o=njAU8x^`SD66$8jjfAUXtfjqGD;&3#K=Tx< z?WH7@f4%!SBE7^(>{%YvEajBGHg7SB)8xJVZ0ktRvqpWE)8`ND#gtITDdu<%GS-=c z&N-^o)QdV&OoI~l@KxQMmC2r)9RSm-j^w4-2e&p0&%v};`3*3&7N%zv_V1m7B%`a{ zx@9-EdS~oWlx-?dz9LE;syKy$B#Y1(D_TgJ!Ak+$S*QDZgw4sH_MHX|I6uLV<*!v8 z&3n+Ss|8fuBp*u~5rYpN^hpFb-Fns_Xm$|w932!?x*M=Mz3(VgTt@@}E4ZDcqLx-6 zxIN*;kfSKL=!I?%IwOwdigCL7*Sb3p$8v`NhS&aC_o4ADPYAHxl(@rRQO(%ppfHfM zhaj#ap-`rwz#nVYJF^aW&%SglE4WSOV`gXf>fTbKd+2yc_U;QNb5Ho)TS8{!A~8Ij zSyGdPd&Y^*KW+s%)yKv4{w_cvo{cI#UAJIGkY%d*l@x%8!9Xst9=QE!G^{y$MhpHJ zT3rq*6R|QcXuziFF{$YnQRU}o%@rhlxboo0(?@dqna^IEsUNTG%TN{{N2RRBXB-hv ztnXe%NEjUNptmh)SvfiReyQ)HcpJdwNw(*hl}U93p&eyD1q~fJUPSAI8L3Fm0@B;s zlC0QCk-Dj_-xde&T*vm*r-T020}ScLqE22oPjr-F6_qTjr>w%-x1G8E5g?_9>O280gvLI3w3k;!p>uYV)hFw-X(K7t|ovWCFBqNUz| znS(qv|E01h+#`JCga4R=?@?e9qdvb5YKL8_K)Cz52X+uZmsE3E{idZi3tUuK{N`8SD)H7r zb#;%T-?p_4Ms0tRx)x!E3WcD14sm0qr*$%&V=Qh&gTLp?u&dDK8(*U9e0iM52Zm}Q zH~I~pgh87GRc!HuPw5hALP1E~Jk_R&1r`j$X3A;07ivQK79@3z5R5;^YU1Nto^v~i zos`=N*)2K8D3naxD*@q(r{OntBGeg^a4Ms+Khrl8E#2B~-e{zIT;A@TIh$^-rS^(@ z15dlqNN4-W_Z*0}I~MFsF9^7pCtBl7=DMERc*k-YUV_!0d3IQ PolygonRange; int main(int argc, char** argv) { -/* if( argc != 2) + if( argc != 2) { std::cerr<<"please give an input 3mf file."; return 1; @@ -34,7 +34,8 @@ int main(int argc, char** argv) std::vector all_points; std::vector all_polygons; std::vector names; - std::size_t nb_meshes = + //testing reading functions. + int nb_meshes = CGAL::read_soups_from_3mf(argv[1], all_points, all_polygons, names); if(nb_meshes <0) return 1; @@ -61,17 +62,44 @@ int main(int argc, char** argv) ofs << mesh; ofs.close(); } - }*/ + } + all_points.clear(); + int nb_polylines = + CGAL::read_polylines_from_3mf(argv[1], all_points, names); + + if(nb_polylines == 0) + std::cout<<"No polyline found."<(sphere); CGAL::make_regular_prism(10, tube, Point_3(0,-10,0), 10); - /* all_points.clear(); all_polygons.clear(); names.clear(); - */ PointRange points; - //PolygonRange triangles; + PolygonRange triangles; typedef boost::property_map::type VPMap; VPMap vpm = get(boost::vertex_point, sphere); std::unordered_map::vertex_descriptor, @@ -82,8 +110,8 @@ int main(int argc, char** argv) points.push_back(get(vpm, v)); vertex_id_map[v] = i++; } - //all_points.push_back(points); - /*for(auto f : sphere.faces()) + all_points.push_back(points); + for(auto f : sphere.faces()) { Polygon triangle; for(auto vert : CGAL::vertices_around_face(halfedge(f, sphere), sphere)) @@ -117,30 +145,30 @@ int main(int argc, char** argv) all_polygons.push_back(triangles); names.push_back(std::string("sphere")); names.push_back(std::string("tube")); - if(!CGAL::write_soups_to_3mf("micro.3mf", all_points, all_polygons, names)){ - std::cerr<<"an error has occured in final writing."< Date: Mon, 13 May 2019 16:11:15 +0200 Subject: [PATCH 075/203] Replace IO API to be able to load/save several items at a time --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 173 ++++++++++-------- Polyhedron/demo/Polyhedron/MainWindow.h | 9 +- .../Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp | 33 ++-- .../Polyhedron/Plugins/IO/LAS_io_plugin.cpp | 29 +-- .../Polyhedron/Plugins/IO/Nef_io_plugin.cpp | 38 ++-- .../Polyhedron/Plugins/IO/OFF_io_plugin.cpp | 76 ++++++-- .../Plugins/IO/OFF_to_nef_io_plugin.cpp | 28 ++- .../Polyhedron/Plugins/IO/PLY_io_plugin.cpp | 79 ++++++-- .../Plugins/IO/Polylines_io_plugin.cpp | 53 ++++-- .../Polyhedron/Plugins/IO/STL_io_plugin.cpp | 40 ++-- .../Polyhedron/Plugins/IO/Surf_io_plugin.cpp | 25 ++- .../Polyhedron/Plugins/IO/XYZ_io_plugin.cpp | 38 ++-- .../Polyhedron/Plugins/IO/lcc_io_plugin.cpp | 17 +- .../Plugins/Mesh_3/C3t3_io_plugin.cpp | 131 +++++++------ .../Plugins/Mesh_3/Io_image_plugin.cpp | 30 ++- .../Plugins/PMP/Selection_plugin.cpp | 26 ++- .../Polyhedron_demo_io_plugin_interface.h | 16 +- .../CGAL/Three/Scene_3mf_item_interface.h | 4 + 18 files changed, 565 insertions(+), 280 deletions(-) create mode 100644 Three/include/CGAL/Three/Scene_3mf_item_interface.h diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 7f7978a5e8f..d9b85c33c55 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -41,7 +41,7 @@ #include #include #include - +#include #ifdef QT_SCRIPT_LIB # include # ifdef QT_SCRIPTTOOLS_LIB @@ -998,20 +998,33 @@ void MainWindow::reloadItem() { CGAL::Three::Polyhedron_demo_io_plugin_interface* fileloader = findLoader(loader_name); QFileInfo fileinfo(filename); - - CGAL::Three::Scene_item* new_item = loadItem(fileinfo, fileloader); - if(!new_item) + bool ok; + QList new_items = loadItem(fileinfo, fileloader, ok, false); + if(!ok) return; - new_item->setName(item->name()); - new_item->setColor(item->color()); - new_item->setRenderingMode(item->renderingMode()); - new_item->setVisible(item->visible()); - Scene_item_with_properties *property_item = dynamic_cast(new_item); - scene->replaceItem(scene->item_id(item), new_item, true); - if(property_item) - property_item->copyProperties(item); - new_item->invalidateOpenGLBuffers(); - item->deleteLater(); + QVariant varian = item->property("load_mates"); + if (!varian.canConvert()) + qDebug()<<"Well, that's gonna be a problem !"; + QSequentialIterable iterable = varian.value(); + // Can use foreach: + int mate_id = 0; + Q_FOREACH(const QVariant &v, iterable) + { + Scene_item* mate = v.value(); + Scene_item* new_item = new_items[mate_id]; + if(!new_item) + qDebug()<<"That too, is gonna be a problem..."; + new_item->setName(mate->name()); + new_item->setColor(mate->color()); + new_item->setRenderingMode(mate->renderingMode()); + new_item->setVisible(mate->visible()); + Scene_item_with_properties *property_item = dynamic_cast(new_item); + scene->replaceItem(scene->item_id(mate), new_item, true); + if(property_item) + property_item->copyProperties(mate); + new_item->invalidateOpenGLBuffers(); + mate->deleteLater(); + } } } @@ -1105,7 +1118,7 @@ void MainWindow::open(QString filename) // collect all io_plugins and offer them to load if the file extension match one name filter // also collect all available plugin in case of a no extension match Q_FOREACH(CGAL::Three::Polyhedron_demo_io_plugin_interface* io_plugin, io_plugins) { - if ( !io_plugin->canLoad() ) continue; + if ( !io_plugin->canLoad(fileinfo) ) continue; all_items << io_plugin->name(); if ( file_matches_filter(io_plugin->loadNameFilters(), filename.toLower()) ) { @@ -1148,71 +1161,70 @@ void MainWindow::open(QString filename) settings.setValue("OFF open directory", fileinfo.absoluteDir().absolutePath()); - CGAL::Three::Scene_item* scene_item = loadItem(fileinfo, findLoader(load_pair.first)); + loadItem(fileinfo, findLoader(load_pair.first), ok); - if(!scene_item) + if(!ok) return; this->addToRecentFiles(fileinfo.absoluteFilePath()); - selectSceneItem(scene->addItem(scene_item)); - - CGAL::Three::Scene_group_item* group = - qobject_cast(scene_item); - if(group) - scene->redraw_model(); updateViewersBboxes(true); } bool MainWindow::open(QString filename, QString loader_name) { QFileInfo fileinfo(filename); - boost::optional item_opt; + boost::optional item_opt; CGAL::Three::Scene_item* item = 0; try { item_opt = wrap_a_call_to_cpp ([this, fileinfo, loader_name]() { - return loadItem(fileinfo, findLoader(loader_name)); + bool ok; + loadItem(fileinfo, findLoader(loader_name), ok); + return ok; }, this, __FILE__, __LINE__ ); if(!item_opt) return false; - else item = *item_opt; + //else item = *item_opt; } catch(std::logic_error& e) { std::cerr << e.what() << std::endl; return false; } - selectSceneItem(scene->addItem(item)); - - CGAL::Three::Scene_group_item* group = - qobject_cast(item); - if(group) - scene->redraw_model(); - return true; } -CGAL::Three::Scene_item* MainWindow::loadItem(QFileInfo fileinfo, CGAL::Three::Polyhedron_demo_io_plugin_interface* loader) { - CGAL::Three::Scene_item* item = NULL; +QList MainWindow::loadItem(QFileInfo fileinfo, + CGAL::Three::Polyhedron_demo_io_plugin_interface* loader, + bool &ok, + bool add_to_scene) { if(!fileinfo.isFile() || !fileinfo.isReadable()) { QMessageBox::warning(this, tr("Error"), QString("File %1 is not a readable file.") .arg(fileinfo.absoluteFilePath())); } - QApplication::setOverrideCursor(Qt::WaitCursor); - - item = loader->load(fileinfo); - QApplication::restoreOverrideCursor(); - if(!item) { + CGAL::Three::Three::CursorScopeGuard guard(QCursor(Qt::WaitCursor)); + QList result = loader->load(fileinfo, ok, add_to_scene); + selectSceneItem(scene->item_id(result.back())); + if(!ok) + { + QApplication::restoreOverrideCursor(); QMessageBox::warning(this, tr("Error"), QString("Could not load item from file %1 using plugin %2") .arg(fileinfo.absoluteFilePath()).arg(loader->name())); - return 0; + return QList(); } - - item->setProperty("source filename", fileinfo.absoluteFilePath()); - item->setProperty("loader_name", loader->name()); - return item; + for(Scene_item* item : result) + { + CGAL::Three::Scene_group_item* group = + qobject_cast(item); + if(group) + scene->redraw_model(); + item->setProperty("source filename", fileinfo.absoluteFilePath()); + item->setProperty("loader_name", loader->name()); + item->setProperty("load_mates",QVariant::fromValue(result)); + } + return result; } @@ -1831,7 +1843,7 @@ void MainWindow::on_actionLoad_triggered() typedef QMap FilterPluginMap; FilterPluginMap filterPluginMap; - Q_FOREACH(CGAL::Three::Polyhedron_demo_io_plugin_interface* plugin, io_plugins) { + for(CGAL::Three::Polyhedron_demo_io_plugin_interface* plugin : io_plugins) { QStringList split_filters = plugin->loadNameFilters().split(";;"); Q_FOREACH(const QString& filter, split_filters) { FilterPluginMap::iterator it = filterPluginMap.find(filter); @@ -1877,18 +1889,25 @@ void MainWindow::on_actionLoad_triggered() std::size_t nb_item = -1; Q_FOREACH(const QString& filename, dialog.selectedFiles()) { - + CGAL::Three::Scene_item* item = NULL; if(selectedPlugin) { QFileInfo info(filename); - item = loadItem(info, selectedPlugin); - item->setColor(colors_[++nb_item]); - Scene::Item_id index = scene->addItem(item); - selectSceneItem(index); - CGAL::Three::Scene_group_item* group = - qobject_cast(item); - if(group) - scene->redraw_model(); + bool ok; + QList result = loadItem(info, selectedPlugin, ok); + if(!ok) + continue; + for(Scene_item* item : result) + { + ++nb_item; + item->setColor(colors_[nb_item]); + Scene::Item_id index = scene->addItem(item); + selectSceneItem(index); + CGAL::Three::Scene_group_item* group = + qobject_cast(item); + if(group) + scene->redraw_model(); + } this->addToRecentFiles(filename); } else { int scene_size = scene->numberOfEntries(); @@ -1901,15 +1920,19 @@ void MainWindow::on_actionLoad_triggered() void MainWindow::on_actionSaveAs_triggered() { - Scene_item* item = NULL; - - Q_FOREACH(Scene::Item_id id, scene->selectionIndices()) + QList to_save; + for(Scene::Item_id id : scene->selectionIndices()) { - item = scene->item(id); + Scene_item* item = scene->item(id); + to_save.append(item); + } + while(!to_save.empty()) + { + Scene_item* item = to_save.front(); QVector canSavePlugins; QStringList filters; QString sf; - Q_FOREACH(CGAL::Three::Polyhedron_demo_io_plugin_interface* plugin, io_plugins) { + for(CGAL::Three::Polyhedron_demo_io_plugin_interface* plugin : io_plugins) { if(plugin->canSave(item)) { canSavePlugins << plugin; filters += plugin->saveNameFilters(); @@ -1925,7 +1948,7 @@ void MainWindow::on_actionSaveAs_triggered() tr("Cannot save"), tr("The selected object %1 cannot be saved.") .arg(item->name())); - return; + return; } Q_FOREACH(QString string, filters) { @@ -1961,14 +1984,14 @@ void MainWindow::on_actionSaveAs_triggered() dir, filters.join(";;"), &sf); - + if(filename.isEmpty()) return; last_saved_dir = QFileInfo(filename).absoluteDir().path(); extensions.indexIn(sf.split(";;").first()); QString filter_ext, filename_ext; filter_ext = extensions.cap().split(" ").first();// in case of syntax like (*.a *.b) - + filter_ext.remove(")"); filter_ext.remove("("); //remove * @@ -2016,18 +2039,18 @@ void MainWindow::on_actionSaveAs_triggered() } for(auto v : CGAL::QGLViewer::QGLViewerPool()) v->update(); - save(filename, item); + save(filename, to_save); } } -void MainWindow::save(QString filename, CGAL::Three::Scene_item* item) { +void MainWindow::save(QString filename, QList& to_save) { QFileInfo fileinfo(filename); bool saved = false; - Q_FOREACH(CGAL::Three::Polyhedron_demo_io_plugin_interface* plugin, io_plugins) { - if( plugin->canSave(item) && + for(CGAL::Three::Polyhedron_demo_io_plugin_interface* plugin : io_plugins) { + if( plugin->canSave(to_save.front()) && file_matches_filter(plugin->saveNameFilters(),filename.toLower()) ) { - if(plugin->save(item, fileinfo)) + if(plugin->save(fileinfo, to_save)) { saved = true; break; @@ -2038,7 +2061,7 @@ void MainWindow::save(QString filename, CGAL::Three::Scene_item* item) { QMessageBox::warning(this, tr("Cannot save"), tr("The selected object %1 was not saved. (Maybe a wrong extension ?)") - .arg(item->name())); + .arg(to_save.front()->name())); } void MainWindow::on_actionSaveSnapshot_triggered() @@ -2470,7 +2493,7 @@ QString MainWindow::get_item_stats() for(int i=0; iitem(id); - QString classname = item->property("classname").toString(); + QString classname = item->property("classname").toString(); if(classname.isEmpty()) classname = item->metaObject()->className(); if(classnames.at(i).contains(classname)) @@ -3131,14 +3154,16 @@ void MainWindow::on_action_Save_triggered() if(QMessageBox::question(this, "Save", "Are you sure you want to override these files ?") == QMessageBox::No) return; - Scene_item* item = nullptr; - Q_FOREACH(Scene::Item_id id, scene->selectionIndices()) + QList to_save; + + for(Scene::Item_id id : scene->selectionIndices()) { - item = scene->item(id); + Scene_item* item = scene->item(id); if(!item->property("source filename").toString().isEmpty()) { QString filename = item->property("source filename").toString(); - save(filename, item); + to_save.append(item); + save(filename, to_save); } } } diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h index bae08376816..28a09278abd 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.h +++ b/Polyhedron/demo/Polyhedron/MainWindow.h @@ -87,11 +87,14 @@ public: @returns the IO plugin associated with `loader_name`*/ CGAL::Three::Polyhedron_demo_io_plugin_interface* findLoader(const QString& loader_name) const; - /*! \brief Loads an item with a given loader. + /*! \brief Loads on or more item with a given loader. * * throws `std::logic_error` if loading does not succeed or * `std::invalid_argument` if `fileinfo` specifies an invalid file*/ - CGAL::Three::Scene_item* loadItem(QFileInfo fileinfo, CGAL::Three::Polyhedron_demo_io_plugin_interface*); + QList loadItem(QFileInfo fileinfo, + CGAL::Three::Polyhedron_demo_io_plugin_interface*, + bool& ok, + bool add_to_scene=true); void computeViewerBBox(CGAL::qglviewer::Vec &min, CGAL::qglviewer::Vec &max); void updateViewerBbox(Viewer* vi, bool recenter, CGAL::qglviewer::Vec min, CGAL::qglviewer::Vec max); @@ -346,7 +349,7 @@ protected Q_SLOTS: //!Opens a dialog to save selected item if able. void on_actionSaveAs_triggered(); //!Calls the function save of the current plugin if able. - void save(QString filename, CGAL::Three::Scene_item* item); + void save(QString filename, QList& to_save); //!Calls the function saveSnapShot of the viewer. void on_actionSaveSnapshot_triggered(); //!Opens a Dialog to choose a color and make it the background color. diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp index caae0705b5c..1709c1dfa60 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp @@ -40,30 +40,31 @@ public: bool applicable(QAction*) const { return false;} QString nameFilters() const; QString name() const { return "gocad_plugin"; } - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + bool canLoad(QFileInfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item*, QFileInfo fileinfo); + bool save(QFileInfo fileinfo, QList& ); }; QString Polyhedron_demo_gocad_plugin::nameFilters() const { return "GOCAD files (*.ts)"; } -bool Polyhedron_demo_gocad_plugin::canLoad() const { +bool Polyhedron_demo_gocad_plugin::canLoad(QFileInfo) const { return true; } -CGAL::Three::Scene_item* -Polyhedron_demo_gocad_plugin::load(QFileInfo fileinfo) { +QList +Polyhedron_demo_gocad_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { // Open file std::ifstream in(fileinfo.filePath().toUtf8()); if(!in) { std::cerr << "Error! Cannot open file " << (const char*)fileinfo.filePath().toUtf8() << std::endl; - return NULL; + ok = false; + return QList(); } @@ -74,7 +75,10 @@ Polyhedron_demo_gocad_plugin::load(QFileInfo fileinfo) { if(fileinfo.size() == 0) { CGAL::Three::Three::warning( tr("The file you are trying to load is empty.")); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<(item->polyhedron()); @@ -82,7 +86,8 @@ Polyhedron_demo_gocad_plugin::load(QFileInfo fileinfo) { if(! read_gocad(P, in, name, color)){ std::cerr << "Error: Invalid polyhedron" << std::endl; delete item; - return 0; + ok = false; + return QList(); } t.stop(); @@ -98,7 +103,10 @@ Polyhedron_demo_gocad_plugin::load(QFileInfo fileinfo) { item->setColor(qcolor); } item->invalidateOpenGLBuffers(); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<(item); } -bool Polyhedron_demo_gocad_plugin::save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) +bool Polyhedron_demo_gocad_plugin:: +save(QFileInfo fileinfo,QList& items) { + Scene_item* item = items.front(); // This plugin supports polyhedrons const Scene_surface_mesh_item* sm_item = qobject_cast(item); @@ -120,6 +130,7 @@ bool Polyhedron_demo_gocad_plugin::save(const CGAL::Three::Scene_item* item, QFi out.precision (std::numeric_limits::digits10 + 2); SMesh* poly = const_cast(sm_item->polyhedron()); write_gocad(*poly, out, qPrintable(fileinfo.baseName())); + items.pop_front(); return true; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp index 37878451544..176824c2e16 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp @@ -1,8 +1,9 @@ #include "Scene_points_with_normal_item.h" #include - +#include +#include #include - +using namespace CGAL::Three; class Polyhedron_demo_las_plugin : public QObject, public CGAL::Three::Polyhedron_demo_io_plugin_interface @@ -14,19 +15,19 @@ class Polyhedron_demo_las_plugin : public: QString name() const { return "las_plugin"; } QString nameFilters() const { return "LAS files (*.las);;Compressed LAS files (*.laz)"; } - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + bool canLoad(QFileInfo fileinfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item*, QFileInfo fileinfo); + bool save(QFileInfo fileinfo,QList& ); }; -bool Polyhedron_demo_las_plugin::canLoad() const { +bool Polyhedron_demo_las_plugin::canLoad(QFileInfo fileinfo) const { return true; } -CGAL::Three::Scene_item* -Polyhedron_demo_las_plugin::load(QFileInfo fileinfo) { +QList Polyhedron_demo_las_plugin:: +load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { std::ifstream in(fileinfo.filePath().toUtf8(), std::ios_base::binary); if(!in) @@ -37,11 +38,15 @@ Polyhedron_demo_las_plugin::load(QFileInfo fileinfo) { if(!item->read_las_point_set(in)) { delete item; - return 0; + ok = false; + return QList(); } item->setName(fileinfo.completeBaseName()); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<(item); } -bool Polyhedron_demo_las_plugin::save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) +bool Polyhedron_demo_las_plugin::save(QFileInfo fileinfo,QList& items) { + Scene_item* item = items.front(); // Check extension (quietly) std::string extension = fileinfo.suffix().toUtf8().data(); if (extension != "las" && extension != "LAS") @@ -63,6 +69,7 @@ bool Polyhedron_demo_las_plugin::save(const CGAL::Three::Scene_item* item, QFile return false; std::ofstream out(fileinfo.filePath().toUtf8().data()); + items.pop_front(); return point_set_item->write_las_point_set(out); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp index 11265427374..4aab33b4e0a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp @@ -17,32 +17,37 @@ class Polyhedron_demo_io_nef_plugin : public: QString nameFilters() const; QString name() const { return "io_nef_plugin"; } - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + bool canLoad(QFileInfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item*, QFileInfo fileinfo); + bool save(QFileInfo fileinfo,QList& items); }; QString Polyhedron_demo_io_nef_plugin::nameFilters() const { return "nef files (*.nef3)"; } -bool Polyhedron_demo_io_nef_plugin::canLoad() const { +bool Polyhedron_demo_io_nef_plugin::canLoad(QFileInfo) const { return true; } -CGAL::Three::Scene_item* -Polyhedron_demo_io_nef_plugin::load(QFileInfo fileinfo) { +QList Polyhedron_demo_io_nef_plugin:: +load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { //do not try file with extension different from nef3 - if (fileinfo.suffix() != "nef3") return 0; + if (fileinfo.suffix() != "nef3") + { + ok = false; + return QList(); + } // Open file std::ifstream in(fileinfo.filePath().toUtf8()); if(!in) { std::cerr << "Error! Cannot open file " << (const char*)fileinfo.filePath().toUtf8() << std::endl; - return NULL; + ok = false; + return QList(); } // Try to read .nef3 in a polyhedron @@ -51,15 +56,22 @@ Polyhedron_demo_io_nef_plugin::load(QFileInfo fileinfo) { if(fileinfo.size() == 0) { CGAL::Three::Three::warning( tr("The file you are trying to load is empty.")); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<load(in)) { delete item; - return 0; + ok = false; + return QList(); } - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<(item); } -bool Polyhedron_demo_io_nef_plugin::save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) +bool Polyhedron_demo_io_nef_plugin::save(QFileInfo fileinfo,QList& items) { + Scene_item* item = items.front(); // This plugin supports polyhedrons and polygon soups const Scene_nef_polyhedron_item* nef_item = qobject_cast(item); @@ -79,6 +92,7 @@ bool Polyhedron_demo_io_nef_plugin::save(const CGAL::Three::Scene_item* item, QF std::ofstream out(fileinfo.filePath().toUtf8()); out.precision (std::numeric_limits::digits10 + 2); + items.pop_front(); return (nef_item && nef_item->save(out)); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp index ba869f77b9d..58edff9b8e3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp @@ -40,22 +40,21 @@ public: } QString name() const { return "off_plugin"; } QString nameFilters() const { return "OFF files (*.off);;Wavefront OBJ (*.obj)"; } - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); - CGAL::Three::Scene_item* load_off(QFileInfo fileinfo); - CGAL::Three::Scene_item* load_obj(QFileInfo fileinfo); + bool canLoad(QFileInfo fileinfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); + CGAL::Three::Scene_item* load_off(QFileInfo fileinfo); + CGAL::Three::Scene_item* load_obj(QFileInfo fileinfo); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item*, QFileInfo fileinfo); + bool save(QFileInfo fileinfo,QList& ); }; -bool Polyhedron_demo_off_plugin::canLoad() const { +bool Polyhedron_demo_off_plugin::canLoad(QFileInfo) const { return true; } - -CGAL::Three::Scene_item* -Polyhedron_demo_off_plugin::load(QFileInfo fileinfo) { +QList Polyhedron_demo_off_plugin:: +load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { if(fileinfo.size() == 0) { @@ -63,14 +62,41 @@ Polyhedron_demo_off_plugin::load(QFileInfo fileinfo) { Scene_surface_mesh_item* item = new Scene_surface_mesh_item(SMesh()); item->setName(fileinfo.completeBaseName()); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<addItem(item); + return QList()<(); + } } else if(fileinfo.suffix().toLower() == "obj"){ - return load_obj(fileinfo); + + Scene_item* item = load_obj(fileinfo); + if(item) + { + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<(); + } } - return 0; + return QList(); } @@ -183,8 +209,12 @@ bool Polyhedron_demo_off_plugin::canSave(const CGAL::Three::Scene_item* item) qobject_cast(item); } -bool Polyhedron_demo_off_plugin::save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) + +bool +Polyhedron_demo_off_plugin:: +save(QFileInfo fileinfo,QList& items) { + Scene_item* item = items.front(); // This plugin supports point sets, surface_meshes and polygon soups const Scene_points_with_normal_item* points_item = qobject_cast(item); @@ -200,12 +230,26 @@ bool Polyhedron_demo_off_plugin::save(const CGAL::Three::Scene_item* item, QFile out.precision (std::numeric_limits::digits10 + 2); if(fileinfo.suffix().toLower() == "off"){ - return (sm_item && sm_item->save(out)) || + bool res = (sm_item && sm_item->save(out)) || (soup_item && soup_item->save(out)) || (points_item && points_item->write_off_point_set(out)); + if(res){ + items.pop_front(); + return true; + } + else{ + return false; + } } if(fileinfo.suffix().toLower() == "obj"){ - return (sm_item && sm_item->save_obj(out)); + bool res = (sm_item && sm_item->save_obj(out)); + if(res) + { + items.pop_front(); + return true; + } + else + return false; } return false; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp index 5d142129b4c..dd765722381 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp @@ -16,19 +16,19 @@ class Polyhedron_demo_off_to_nef_plugin : public: QString name() const { return "off_to_nef_plugin"; } QString nameFilters() const { return "OFF files, into nef (*.off)"; } - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + bool canLoad(QFileInfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item*, QFileInfo fileinfo); + bool save(QFileInfo fileinfo,QList& ); }; -bool Polyhedron_demo_off_to_nef_plugin::canLoad() const { +bool Polyhedron_demo_off_to_nef_plugin::canLoad(QFileInfo) const { return true; } -CGAL::Three::Scene_item* -Polyhedron_demo_off_to_nef_plugin::load(QFileInfo fileinfo) { +QList Polyhedron_demo_off_to_nef_plugin:: +load(QFileInfo fileinfo, bool& ok, bool add_to_scene){ std::ifstream in(fileinfo.filePath().toUtf8()); if(!in) @@ -38,16 +38,23 @@ Polyhedron_demo_off_to_nef_plugin::load(QFileInfo fileinfo) { { CGAL::Three::Three::warning( tr("The file you are trying to load is empty.")); item->setName(fileinfo.completeBaseName()); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<load_from_off(in)) { delete item; - return 0; + ok = false; + return QList()<setName(fileinfo.baseName()); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<& items) { return false; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp index cc2c1bcd865..d72084a7e0b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp @@ -13,7 +13,7 @@ #include #include #include - +using namespace CGAL::Three; class Polyhedron_demo_ply_plugin : public QObject, public CGAL::Three::Polyhedron_demo_io_plugin_interface @@ -31,20 +31,22 @@ public: } QString name() const { return "ply_plugin"; } QString nameFilters() const { return "PLY files (*.ply)"; } - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + bool canLoad(QFileInfo fileinfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item*, QFileInfo fileinfo); + bool save(QFileInfo fileinfo,QList&); }; -bool Polyhedron_demo_ply_plugin::canLoad() const { +bool Polyhedron_demo_ply_plugin:: +canLoad(QFileInfo) const { return true; } -CGAL::Three::Scene_item* -Polyhedron_demo_ply_plugin::load(QFileInfo fileinfo) { +QList +Polyhedron_demo_ply_plugin:: +load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { std::ifstream in(fileinfo.filePath().toUtf8(), std::ios_base::binary); if(!in) @@ -55,7 +57,8 @@ Polyhedron_demo_ply_plugin::load(QFileInfo fileinfo) { if(fileinfo.size() == 0) { CGAL::Three::Three::warning( tr("The file you are trying to load is empty.")); - return 0; + ok = false; + return QList(); } // Test if input is mesh or point set @@ -99,7 +102,10 @@ Polyhedron_demo_ply_plugin::load(QFileInfo fileinfo) { sm_item->setName(fileinfo.completeBaseName()); sm_item->comments() = comments; QApplication::restoreOverrideCursor(); - return sm_item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(sm_item); + return QList()<(); } Scene_polygon_soup_item* soup_item = new Scene_polygon_soup_item; soup_item->setName(fileinfo.completeBaseName()); soup_item->load (points, polygons, fcolors, vcolors); QApplication::restoreOverrideCursor(); - return soup_item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(soup_item); + return QList()<(); } if(item->has_normals()) item->setRenderingMode(CGAL::Three::Three::defaultPointSetRenderingMode()); item->setName(fileinfo.completeBaseName()); QApplication::restoreOverrideCursor(); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<(); } bool Polyhedron_demo_ply_plugin::canSave(const CGAL::Three::Scene_item* item) @@ -152,8 +167,10 @@ bool Polyhedron_demo_ply_plugin::canSave(const CGAL::Three::Scene_item* item) || qobject_cast(item)); } -bool Polyhedron_demo_ply_plugin::save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) +bool Polyhedron_demo_ply_plugin:: +save(QFileInfo fileinfo,QList& items) { + Scene_item* item = items.front(); // Check extension (quietly) std::string extension = fileinfo.suffix().toUtf8().data(); if (extension != "ply" && extension != "PLY") @@ -179,25 +196,49 @@ bool Polyhedron_demo_ply_plugin::save(const CGAL::Three::Scene_item* item, QFile const Scene_points_with_normal_item* point_set_item = qobject_cast(item); if (point_set_item) - return point_set_item->write_ply_point_set(out, (choice == tr("Binary"))); + { + bool res = + point_set_item->write_ply_point_set(out, (choice == tr("Binary"))); + if(res) + items.pop_front(); + return res; + } // This plugin supports polygon soups const Scene_polygon_soup_item* soup_item = qobject_cast(item); if (soup_item) - return CGAL::write_PLY (out, soup_item->points(), soup_item->polygons()); + { + bool res = + CGAL::write_PLY (out, soup_item->points(), soup_item->polygons()); + if(res) + items.pop_front(); + return res; + } // This plugin supports surface meshes const Scene_surface_mesh_item* sm_item = qobject_cast(item); if (sm_item) - return CGAL::write_ply (out, *(sm_item->polyhedron()), sm_item->comments()); + { + bool res = + CGAL::write_ply (out, *(sm_item->polyhedron()), sm_item->comments()); + if(res) + items.pop_front(); + return res; + } // This plugin supports textured surface meshes const Scene_textured_surface_mesh_item* stm_item = qobject_cast(item); if (stm_item) - return CGAL::write_ply (out, *(stm_item->textured_face_graph())); + { + bool res = + CGAL::write_ply (out, *(stm_item->textured_face_graph())); + if(res) + items.pop_front(); + return res; + } return false; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp index 769c0a0587e..222f7362d2f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp @@ -45,11 +45,11 @@ public: } QString name() const { return "polylines_io_plugin"; } QString nameFilters() const { return "Polylines files (*.polylines.txt *.cgal)"; } - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + bool canLoad(QFileInfo fileinfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item*, QFileInfo fileinfo); + bool save(QFileInfo fileinfo,QList&); bool applicable(QAction* a) const { bool all_polylines_selected = true; Q_FOREACH(int index, scene->selectionIndices()) @@ -85,19 +85,21 @@ private: QAction* actionJoin_polylines; }; -bool Polyhedron_demo_polylines_io_plugin::canLoad() const { +bool Polyhedron_demo_polylines_io_plugin::canLoad(QFileInfo fileinfo) const{ return true; } -CGAL::Three::Scene_item* -Polyhedron_demo_polylines_io_plugin::load(QFileInfo fileinfo) { +QList +Polyhedron_demo_polylines_io_plugin:: +load(QFileInfo fileinfo, bool& ok, bool add_to_scene){ // Open file std::ifstream ifs(fileinfo.filePath().toUtf8()); if(!ifs) { std::cerr << "Error! Cannot open file " << (const char*)fileinfo.filePath().toUtf8() << std::endl; - return NULL; + ok = false; + return QList(); } if(fileinfo.size() == 0) @@ -105,7 +107,10 @@ Polyhedron_demo_polylines_io_plugin::load(QFileInfo fileinfo) { CGAL::Three::Three::warning( tr("The file you are trying to load is empty.")); Scene_polylines_item* item = new Scene_polylines_item; item->setName(fileinfo.completeBaseName()); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()< > polylines; @@ -123,7 +128,11 @@ Polyhedron_demo_polylines_io_plugin::load(QFileInfo fileinfo) { Scene_polylines_item::Point_3 p; ifs >> p; polyline.push_back(p); - if(!ifs.good()) return 0; + if(!ifs.good()) + { + ok = false; + return QList(); + } } std::string line_remainder; std::getline(ifs, line_remainder); @@ -136,9 +145,17 @@ Polyhedron_demo_polylines_io_plugin::load(QFileInfo fileinfo) { std::cerr << " (metadata: \"" << qPrintable(metadata) << "\")\n"; } else { } - if(ifs.bad() || ifs.fail()) return 0; + if(ifs.bad() || ifs.fail()) + { + ok = false; + return QList(); + } + } + if(counter == 0) + { + ok = false; + return QList(); } - if(counter == 0) return 0; Scene_polylines_item* item = new Scene_polylines_item; item->polylines = polylines; item->setName(fileinfo.baseName()); @@ -146,7 +163,10 @@ Polyhedron_demo_polylines_io_plugin::load(QFileInfo fileinfo) { item->setProperty("polylines metadata", polylines_metadata); std::cerr << "Number of polylines in item: " << item->polylines.size() << std::endl; item->invalidateOpenGLBuffers(); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<(item) != 0; } -bool Polyhedron_demo_polylines_io_plugin::save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) +bool Polyhedron_demo_polylines_io_plugin:: +save(QFileInfo fileinfo,QList& items) { + Scene_item* item = items.front(); const Scene_polylines_item* poly_item = qobject_cast(item); @@ -188,7 +210,10 @@ bool Polyhedron_demo_polylines_io_plugin::save(const CGAL::Three::Scene_item* it } out << std::endl; } - return (bool) out; + bool res = (bool) out; + if(res) + items.pop_front(); + return res; } void Polyhedron_demo_polylines_io_plugin::split() diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp index 523698a72f7..475fc302197 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp @@ -47,44 +47,51 @@ public: bool applicable(QAction*) const { return false;} QString nameFilters() const; QString name() const { return "stl_plugin"; } - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + bool canLoad(QFileInfo fileinfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item*, QFileInfo fileinfo); + bool save(QFileInfo fileinfo,QList&); }; QString Polyhedron_demo_stl_plugin::nameFilters() const { return "STL files (*.stl)"; } -bool Polyhedron_demo_stl_plugin::canLoad() const { +bool Polyhedron_demo_stl_plugin::canLoad(QFileInfo) const { return true; } -CGAL::Three::Scene_item* -Polyhedron_demo_stl_plugin::load(QFileInfo fileinfo) { + +QList +Polyhedron_demo_stl_plugin:: +load(QFileInfo fileinfo, bool& ok, bool add_to_scene){ // Open file std::ifstream in(fileinfo.filePath().toUtf8(), std::ios::in | std::ios::binary); if(!in) { std::cerr << "Error! Cannot open file " << (const char*)fileinfo.filePath().toUtf8() << std::endl; - return NULL; + ok = false; + return QList(); } if(fileinfo.size() == 0) { CGAL::Three::Three::warning( tr("The file you are trying to load is empty.")); Scene_surface_mesh_item* item = new Scene_surface_mesh_item(); item->setName(fileinfo.completeBaseName()); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()< > points; std::vector > triangles; if (!CGAL::read_STL(in, points, triangles)) { std::cerr << "Error: invalid STL file" << std::endl; - return NULL; + ok = false; + return QList(); } try{ @@ -98,7 +105,10 @@ Polyhedron_demo_stl_plugin::load(QFileInfo fileinfo) { else{ Scene_surface_mesh_item* item = new Scene_surface_mesh_item(SM); item->setName(fileinfo.completeBaseName()); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<setName(fileinfo.completeBaseName()); item->load(points, triangles); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<(item); } -bool Polyhedron_demo_stl_plugin::save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) +bool Polyhedron_demo_stl_plugin:: +save(QFileInfo fileinfo,QList& items) { + Scene_item* item = items.front(); const Scene_surface_mesh_item* sm_item = qobject_cast(item); @@ -144,6 +159,7 @@ bool Polyhedron_demo_stl_plugin::save(const CGAL::Three::Scene_item* item, QFile if (sm_item) { CGAL::write_STL(*sm_item->face_graph(), out); + items.pop_front(); return true; } return false; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp index dfac3829add..f97fed4afad 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp @@ -42,19 +42,34 @@ public: bool applicable(QAction*) const { return false;} QString name() const { return "surf_io_plugin"; } QString nameFilters() const { return "Amira files (*.surf)"; } - bool canLoad() const{ return true; } + bool canLoad(QFileInfo) const{ return true; } template CGAL::Three::Scene_item* actual_load(QFileInfo fileinfo); - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*) { return false; } - bool save(const CGAL::Three::Scene_item*, QFileInfo) { return false; } + bool save(QFileInfo fileinfo,QList& ) { return false; } }; -CGAL::Three::Scene_item* Surf_io_plugin::load(QFileInfo fileinfo) +QList +Surf_io_plugin:: +load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { - return actual_load(fileinfo); + Scene_item* item = + actual_load(fileinfo); + if(item) + { + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<(); + } } template< class FaceGraphItem> CGAL::Three::Scene_item* Surf_io_plugin::actual_load(QFileInfo fileinfo) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp index 7bed8af9e55..8ab464ed7c6 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp @@ -21,26 +21,28 @@ public: QString name() const { return "xyz_plugin"; } QString nameFilters() const { return "XYZ as Point Set (*.xyz);;Point Set with Normal (*.pwn)"; } - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + bool canLoad(QFileInfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item*, QFileInfo fileinfo); + bool save(QFileInfo fileinfo,QList&); }; -bool Polyhedron_demo_xyz_plugin::canLoad() const { +bool Polyhedron_demo_xyz_plugin::canLoad(QFileInfo) const { return true; } -CGAL::Three::Scene_item* -Polyhedron_demo_xyz_plugin::load(QFileInfo fileinfo) +QList +Polyhedron_demo_xyz_plugin:: +load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { // Open file std::ifstream in(fileinfo.filePath().toUtf8().data()); if(!in) { std::cerr << "Error! Cannot open file " << fileinfo.filePath().toStdString() << std::endl; - return NULL; + ok = false; + return QList(); } @@ -50,19 +52,26 @@ Polyhedron_demo_xyz_plugin::load(QFileInfo fileinfo) Scene_points_with_normal_item* item = new Scene_points_with_normal_item(); item->setName(fileinfo.completeBaseName()); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<setName(fileinfo.completeBaseName()); if(!point_set_item->read_xyz_point_set(in)) { delete point_set_item; - return NULL; + ok = false; + return QList(); } if(point_set_item->has_normals()) point_set_item->setRenderingMode(CGAL::Three::Three::defaultPointSetRenderingMode()); - return point_set_item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(point_set_item); + return QList()<(item); } -bool Polyhedron_demo_xyz_plugin::save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) +bool Polyhedron_demo_xyz_plugin:: +save(QFileInfo fileinfo,QList& items) { + Scene_item* item = items.front(); // Check extension (quietly) std::string extension = fileinfo.suffix().toUtf8().data(); if (extension != "xyz" && extension != "XYZ" && @@ -88,7 +99,10 @@ bool Polyhedron_demo_xyz_plugin::save(const CGAL::Three::Scene_item* item, QFile // Save point set as .xyz std::ofstream out(fileinfo.filePath().toUtf8().data()); out.precision (std::numeric_limits::digits10 + 2); - return point_set_item->write_xyz_point_set(out); + bool res = point_set_item->write_xyz_point_set(out); + if(res) + items.pop_front(); + return res; } #include "XYZ_io_plugin.moc" diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp index 9bf6a73226c..2b4d0649093 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp @@ -33,13 +33,14 @@ public: "3-map files (*.3map)"; } - bool canLoad() const { return true; } - CGAL::Three::Scene_item* load(QFileInfo fileinfo){ + bool canLoad(QFileInfo) const { return true; } + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true){ // Open file std::ifstream ifs(fileinfo.filePath().toUtf8()); if(!ifs) { std::cerr << "Error! Cannot open file " << (const char*)fileinfo.filePath().toUtf8() << std::endl; - return nullptr; + ok = false; + return QList(); } Scene_lcc_item::LCC lcc; @@ -53,17 +54,21 @@ public: } if(!res) { - return nullptr; + ok = false; + return QList(); } Scene_lcc_item* new_item = new Scene_lcc_item(lcc); new_item->setName(fileinfo.fileName()); new_item->invalidateOpenGLBuffers(); - return new_item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(new_item); + ok = true; + return QList()<& ){ return false; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 68ccf77ea8e..93af632e9e8 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -37,11 +37,11 @@ public: { return false; } - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + bool canLoad(QFileInfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item*, QFileInfo fileinfo); + bool save(QFileInfo fileinfo,QList& ); private: bool try_load_other_binary_format(std::istream& in, C3t3& c3t3); @@ -50,21 +50,23 @@ private: }; -bool Polyhedron_demo_c3t3_binary_io_plugin::canLoad() const { +bool Polyhedron_demo_c3t3_binary_io_plugin::canLoad(QFileInfo) const { return true; } - -CGAL::Three::Scene_item* -Polyhedron_demo_c3t3_binary_io_plugin::load(QFileInfo fileinfo) { +QList +Polyhedron_demo_c3t3_binary_io_plugin::load( + QFileInfo fileinfo, bool& ok, bool add_to_scene) { // Open file + ok = true; std::ifstream in(fileinfo.filePath().toUtf8(), std::ios_base::in|std::ios_base::binary); if(!in) { std::cerr << "Error! Cannot open file " << (const char*)fileinfo.filePath().toUtf8() << std::endl; - return NULL; + ok = false; + return QList(); } Scene_c3t3_item* item = new Scene_c3t3_item(); @@ -72,7 +74,9 @@ Polyhedron_demo_c3t3_binary_io_plugin::load(QFileInfo fileinfo) { { CGAL::Three::Three::warning( tr("The file you are trying to load is empty.")); item->setName(fileinfo.completeBaseName()); - return item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<< item; } if(fileinfo.suffix().toLower() == "cgal") { @@ -80,7 +84,9 @@ Polyhedron_demo_c3t3_binary_io_plugin::load(QFileInfo fileinfo) { if(item->load_binary(in)) { - return item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList() << item; } item->c3t3().clear(); @@ -89,7 +95,9 @@ Polyhedron_demo_c3t3_binary_io_plugin::load(QFileInfo fileinfo) { item->c3t3_changed(); item->changed(); item->resetCutPlane(); - return item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<< item; } item->c3t3().clear(); @@ -98,7 +106,9 @@ Polyhedron_demo_c3t3_binary_io_plugin::load(QFileInfo fileinfo) { item->c3t3_changed(); item->changed(); item->resetCutPlane(); - return item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<c3t3_changed(); item->resetCutPlane(); - return item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<c3t3().triangulation().number_of_finite_cells() == 0) { @@ -168,7 +180,8 @@ Polyhedron_demo_c3t3_binary_io_plugin::load(QFileInfo fileinfo) { // if all loading failed... delete item; - return NULL; + ok = false; + return QList(); } bool Polyhedron_demo_c3t3_binary_io_plugin::canSave(const CGAL::Three::Scene_item* item) @@ -179,51 +192,63 @@ bool Polyhedron_demo_c3t3_binary_io_plugin::canSave(const CGAL::Three::Scene_ite bool Polyhedron_demo_c3t3_binary_io_plugin:: -save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) +save(QFileInfo fileinfo, QList &items) { - const Scene_c3t3_item* c3t3_item = qobject_cast(item); - if ( NULL == c3t3_item ) - { - return false; - } + Scene_item* item = items.front(); + const Scene_c3t3_item* c3t3_item = qobject_cast(item); + if ( NULL == c3t3_item ) + { + return false; + } - QString path = fileinfo.absoluteFilePath(); + QString path = fileinfo.absoluteFilePath(); - if(path.endsWith(".cgal")) - { + if(path.endsWith(".cgal")) + { std::ofstream out(fileinfo.filePath().toUtf8(), - std::ios_base::out|std::ios_base::binary); + std::ios_base::out|std::ios_base::binary); - return out && c3t3_item->save_binary(out); - } - - else if (fileinfo.suffix() == "mesh") - { - std::ofstream medit_file (qPrintable(path)); - c3t3_item->c3t3().output_to_medit(medit_file,true,true); - return true; - } - else if (fileinfo.suffix() == "ma") - { - std::ofstream maya_file (qPrintable(path)); - c3t3_item->c3t3().output_to_maya( - maya_file,true); - return true; - } - else if (fileinfo.suffix() == "am") - { - std::ofstream avizo_file (qPrintable(path)); - CGAL::output_to_avizo(avizo_file, c3t3_item->c3t3()); - return true; - } - else if (fileinfo.suffix() == "off") - { - std::ofstream off_file(qPrintable(path)); - c3t3_item->c3t3().output_facets_in_complex_to_off(off_file); - return true; - } + bool ok = out && c3t3_item->save_binary(out); + if(!ok) + return false; else - return false; + { + items.pop_front(); + return true; + } + } + + else if (fileinfo.suffix() == "mesh") + { + std::ofstream medit_file (qPrintable(path)); + c3t3_item->c3t3().output_to_medit(medit_file,true,true); + items.pop_front(); + return true; + } + else if (fileinfo.suffix() == "ma") + { + std::ofstream maya_file (qPrintable(path)); + c3t3_item->c3t3().output_to_maya( + maya_file,true); + items.pop_front(); + return true; + } + else if (fileinfo.suffix() == "am") + { + std::ofstream avizo_file (qPrintable(path)); + CGAL::output_to_avizo(avizo_file, c3t3_item->c3t3()); + items.pop_front(); + return true; + } + else if (fileinfo.suffix() == "off") + { + std::ofstream off_file(qPrintable(path)); + c3t3_item->c3t3().output_facets_in_complex_to_off(off_file); + items.pop_front(); + return true; + } + else + return false; } struct Fake_mesh_domain { diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp index 7e646bf1029..69e31f785fa 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -282,15 +282,18 @@ public: Io_image_plugin() : planeSwitch(NULL) {} QString nameFilters() const; - bool canLoad() const; - CGAL::Three::Scene_item* load(QFileInfo fileinfo); + bool canLoad(QFileInfo) const; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*); - bool save(const CGAL::Three::Scene_item* item, QFileInfo fi) { + bool save(QFileInfo fileinfo, QList& items ) { + Scene_item* item = items.front(); const Scene_image_item* im_item = qobject_cast(item); point_image p_im = *im_item->image()->image(); - return _writeImage(&p_im, fi.filePath().toUtf8()) == 0; + bool ok = _writeImage(&p_im, fileinfo.filePath().toUtf8()) == 0; + items.pop_front(); + return ok; } QString name() const { return "segmented images"; } @@ -965,7 +968,7 @@ QString Io_image_plugin::nameFilters() const { } -bool Io_image_plugin::canLoad() const { +bool Io_image_plugin::canLoad(QFileInfo) const { return true; } @@ -987,8 +990,11 @@ void convert(Image* image) image->image()->wdim = 4; image->image()->wordKind = WK_FLOAT; } -CGAL::Three::Scene_item* -Io_image_plugin::load(QFileInfo fileinfo) { + +QList +Io_image_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) +{ + ok = true; QApplication::restoreOverrideCursor(); Image* image = new Image; if(fileinfo.suffix() != "H" && fileinfo.suffix() != "HH" && @@ -1075,8 +1081,9 @@ Io_image_plugin::load(QFileInfo fileinfo) { success = false; } if(!success){ + ok = false; delete image; - return NULL; + return QList(); } } //read a sep file @@ -1117,7 +1124,8 @@ Io_image_plugin::load(QFileInfo fileinfo) { if(return_code != QDialog::Accepted) { delete image; - return NULL; + ok = false; + return QList(); } // Get selected precision @@ -1145,7 +1153,9 @@ Io_image_plugin::load(QFileInfo fileinfo) { else image_item = new Scene_image_item(image,voxel_scale, false); image_item->setName(fileinfo.baseName()); - return image_item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(image_item); + return QList() << image_item; } bool Io_image_plugin::canSave(const CGAL::Three::Scene_item* item) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index 7534498a7af..cd8512993f0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -78,7 +78,7 @@ public: QString nameFilters() const { return "Selection files(*.selection.txt)"; } QString name() const { return "selection_sm_plugin"; } - bool canLoad() const { + bool canLoad(QFileInfo) const { Scene_item * item = CGAL::Three::Three::scene()->item( CGAL::Three::Three::scene()->mainSelectionIndex()); Scene_facegraph_item* fg_item = qobject_cast(item); @@ -91,26 +91,38 @@ public: return false; } - CGAL::Three::Scene_item* load(QFileInfo fileinfo) { - if(fileinfo.suffix().toLower() != "txt") return 0; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) { + if(fileinfo.suffix().toLower() != "txt") + { + ok = false; + return QList(); + } // There will be no actual loading at this step. Scene_polyhedron_selection_item* item = new Scene_polyhedron_selection_item(); if(!item->load(fileinfo.filePath().toStdString())) { delete item; - return NULL; + ok = false; + return QList(); } item->setName(fileinfo.baseName()); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()<(scene_item); } - bool save(const CGAL::Three::Scene_item* scene_item, QFileInfo fileinfo) { + bool save(QFileInfo fileinfo,QList& items) { + Scene_item* scene_item = items.front(); const Scene_polyhedron_selection_item* item = qobject_cast(scene_item); if(item == NULL) { return false; } - return item->save(fileinfo.filePath().toStdString()); + bool res = item->save(fileinfo.filePath().toStdString()); + if(res) + items.pop_front(); + return res; } bool applicable(QAction*) const { diff --git a/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h b/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h index 40210f4c6d9..8361b1e5384 100644 --- a/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h +++ b/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h @@ -58,17 +58,23 @@ public: //! Specifies if the io_plugin is able to load an item or not. //! This must be overriden. - virtual bool canLoad() const = 0; - //! Loads an item from a file. + virtual bool canLoad(QFileInfo fileinfo) const = 0; + //! Loads one or more item(s) from a file. `ok` is `true` if the loading + //! was successful, `false` otherwise. + //! New items will be added to the scene if `add_to_scene` is `true`. + //! You don't want that when you reload an item, for example, + //! as it will be added at some other point of the process. //! This must be overriden. - virtual Scene_item* load(QFileInfo fileinfo) = 0; + virtual QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) = 0; //!Specifies if the io_plugin can save the item or not. //!This must be overriden. virtual bool canSave(const Scene_item*) = 0; - //!Saves the item in the file corresponding to the path + //!Saves one or more items in the file corresponding to the path //!contained in fileinfo. Returns false if error. //! This must be overriden. - virtual bool save(const Scene_item*, QFileInfo fileinfo) = 0; + //! @attention When a file is successfully saved, it must be removed from the + //! list. + virtual bool save(QFileInfo fileinfo,QList& ) = 0; //! If this returns `true`, then the loader will be chosen as default in the //! list of available loaders when saving a file, which means it will be the diff --git a/Three/include/CGAL/Three/Scene_3mf_item_interface.h b/Three/include/CGAL/Three/Scene_3mf_item_interface.h new file mode 100644 index 00000000000..15b25cbfdbf --- /dev/null +++ b/Three/include/CGAL/Three/Scene_3mf_item_interface.h @@ -0,0 +1,4 @@ +#ifndef SCENE_3MF_ITEM_INTERFACE_H +#define SCENE_3MF_ITEM_INTERFACE_H + +#endif // SCENE_3MF_ITEM_INTERFACE_H From 1fba61107dc80d279c38651866522a93203ce9f9 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 14 May 2019 16:39:31 +0200 Subject: [PATCH 076/203] Add an IO plugin for the 3mf --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 51 +++- .../Polyhedron/Plugins/IO/3mf_io_plugin.cpp | 288 ++++++++++++++++++ .../demo/Polyhedron/Plugins/IO/CMakeLists.txt | 17 ++ Stream_support/include/CGAL/IO/read_3mf.h | 159 +++++++--- Stream_support/include/CGAL/IO/write_3mf.h | 187 +++++++++--- .../test/Stream_support/test_3mf_to_sm.cpp | 30 +- 6 files changed, 635 insertions(+), 97 deletions(-) create mode 100644 Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index d9b85c33c55..693b00f40e3 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -342,6 +342,41 @@ MainWindow::MainWindow(const QStringList &keywords, bool verbose, QWidget* paren this, &MainWindow::filterOperations); loadPlugins(); + //If 3mf plugin is present, add action to save scene + Polyhedron_demo_io_plugin_interface* io_3mf_plugin = nullptr; + for(Polyhedron_demo_io_plugin_interface* plugin : io_plugins) + { + if(plugin->name() == "3mf_io_plugin") + { + io_3mf_plugin = plugin; + break; + } + } + if(io_3mf_plugin ) + { + QAction* actionSaveSceneTo3mf = new QAction("Save the Scene as a 3mf File..."); + QString dir = QString("%1/scene").arg(def_save_dir); + connect(actionSaveSceneTo3mf, &QAction::triggered, this, + [this, dir, io_3mf_plugin](){ + + QString filename = + QFileDialog::getSaveFileName(this, + tr("Save Scene to File..."), + dir, + "*.3mf"); + + if(filename.isEmpty()) + return; + if(!filename.endsWith(".3mf")) + filename.append(".3mf"); + QList all_items; + for(int i = 0; i< scene->numberOfEntries(); ++i) + all_items.push_back(scene->item(i)); + io_3mf_plugin->save(filename, all_items); + }); + ui->menuFile->insertAction(ui->actionSa_ve_Scene_as_Script, actionSaveSceneTo3mf); + } + // Setup the submenu of the View menu that can toggle the dockwidgets Q_FOREACH(QDockWidget* widget, findChildren()) { ui->menuDockWindows->addAction(widget->toggleViewAction()); @@ -1899,10 +1934,12 @@ void MainWindow::on_actionLoad_triggered() continue; for(Scene_item* item : result) { - ++nb_item; - item->setColor(colors_[nb_item]); - Scene::Item_id index = scene->addItem(item); - selectSceneItem(index); + if(!item->property("already_colored").toBool()) + { + ++nb_item; + item->setColor(colors_[nb_item]); + } + selectSceneItem(scene->item_id(item)); CGAL::Three::Scene_group_item* group = qobject_cast(item); if(group) @@ -1912,8 +1949,10 @@ void MainWindow::on_actionLoad_triggered() } else { int scene_size = scene->numberOfEntries(); open(filename); - if(scene->numberOfEntries() != scene_size) - scene->item(scene->numberOfEntries()-1)->setColor(colors_[++nb_item]); + item = scene->item(scene->numberOfEntries()-1); + if(scene->numberOfEntries() != scene_size + && !item->property("already_colored").toBool()) + item->setColor(colors_[++nb_item]); } } } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp new file mode 100644 index 00000000000..879328347ce --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp @@ -0,0 +1,288 @@ +#include +#include + +#include + +#include +#include + +#include +#include + +#include "Scene_surface_mesh_item.h" +#include "Scene_points_with_normal_item.h" +#include "Scene_polylines_item.h" + +#include +#include +#include + +using namespace NMR; + +class Io_3mf_plugin: + public QObject, + public CGAL::Three::Polyhedron_demo_io_plugin_interface +{ + Q_OBJECT + Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "3mf_io_plugin.json") + + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; + typedef std::vector PointRange; + typedef std::vector Polygon; + typedef std::vector PolygonRange; + typedef std::list PolylineRange; + typedef std::vector ColorRange; + QString name() const { return "3mf_io_plugin"; } + + + QString nameFilters() const { return + "3mf files (*.3mf)"; } + + + bool canLoad(QFileInfo) const { return true; } + + + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true){ + namespace PMP = CGAL::Polygon_mesh_processing; + // Open file + ok = true; + std::vector all_points; + std::vector all_polygons; + std::vector names; + QList result; + std::vector > all_colors; + int nb_polylines = + CGAL::read_polylines_from_3mf(fileinfo.filePath().toUtf8().toStdString(), + all_points, all_colors, names); + if(nb_polylines > 0 ) + { + for(int i=0; i< nb_polylines; ++i) + { + Scene_polylines_item* pol_item = new Scene_polylines_item(); + PolylineRange& polylines = pol_item->polylines; + polylines.push_back(all_points[i]); + pol_item->setName(names[i].data()); + pol_item->invalidateOpenGLBuffers(); + CGAL::Color c = all_colors[i].front(); + pol_item->setColor(QColor(c.red(), c.green(), c.blue())); + pol_item->setProperty("already_colord", true); + result << pol_item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(pol_item); + } + } + all_points.clear(); + all_colors.clear(); + names.clear(); + int nb_point_sets = + CGAL::read_point_clouds_from_3mf(fileinfo.filePath().toUtf8().toStdString(), + all_points, all_colors, names); + for(int i=0; i< nb_point_sets; ++i) + { + Scene_points_with_normal_item* pts_item = new Scene_points_with_normal_item(); + for(std::size_t j = 0; j < all_points[i].size(); ++j) + { + pts_item->point_set()->insert(all_points[i][j]); + } + pts_item->setName(names[i].data()); + pts_item->invalidateOpenGLBuffers(); + CGAL::Color c = all_colors[i].front(); + pts_item->setColor(QColor(c.red(), c.green(), c.blue())); + pts_item->setProperty("already_colord", true); + result << pts_item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(pts_item); + } + all_points.clear(); + names.clear(); + all_colors.clear(); + int nb_meshes = + CGAL::read_soups_from_3mf(fileinfo.filePath().toUtf8().toStdString(), + all_points, all_polygons, all_colors, names); + for(std::size_t i = 0; i< nb_meshes; ++i) + { + PolygonRange triangles = all_polygons[i]; + PointRange points = all_points[i]; + ColorRange colors = all_colors[i]; + bool ok = true; + if(!PMP::is_polygon_soup_a_polygon_mesh(triangles)) + ok = PMP::orient_polygon_soup(points, triangles); + if(!ok) + { + std::cerr<<"Object is not orientable. Skipped."< fcolor = + mesh.add_property_map("f:color",first).first; + for(std::size_t pid = 0; pid < colors.size(); ++pid) + { + put(fcolor, face_descriptor(pid), colors[pid]);//should work bc mesh is just created and shouldn't have any destroyed face. Not so sure bc of orientation though. + } + } + Scene_surface_mesh_item* sm_item = new Scene_surface_mesh_item(mesh); + sm_item->setColor(QColor(first.red(), first.green(), first.blue())); + sm_item->setProperty("already_colored", true); + sm_item->setName(names[i].data()); + sm_item->invalidateOpenGLBuffers(); + result << sm_item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(sm_item); + } + } + ok = true; + return result; + } + + + bool canSave(const CGAL::Three::Scene_item*){return false;} + + + bool save(QFileInfo fi, QList& items){ + + QList to_return; + std::vector sm_items; + std::vector pts_items; + std::vector pol_items; + for(Scene_item* item : items) + { + Scene_surface_mesh_item* sm_item = + qobject_cast(item); + if(sm_item) + { + sm_items.push_back(sm_item); + continue; + } + + Scene_points_with_normal_item* pts_item = + qobject_cast(item); + if(pts_item) + { + pts_items.push_back(pts_item); + continue; + } + + Scene_polylines_item* pol_item = + qobject_cast(item); + if(pol_item) + { + pol_items.push_back(pol_item); + continue; + } + qDebug()<name()<<" will not be saved."; + to_return.push_back(item); + } + + HRESULT hResult; + NMR::PLib3MFModel * pModel; + hResult = NMR::lib3mf_createmodel(&pModel); + NMR::PLib3MFModelMeshObject* pMeshObject; + if (hResult != LIB3MF_OK) { + std::cerr << "could not create model: " << std::hex << hResult << std::endl; + return false; + } + for(Scene_surface_mesh_item* sm_item : sm_items) + { + SMesh &mesh = *sm_item->polyhedron(); + PointRange points; + PolygonRange triangles; + typedef boost::property_map::type VPMap; + VPMap vpm = get(boost::vertex_point, mesh); + std::unordered_map::vertex_descriptor, + std::size_t> vertex_id_map; + std::size_t i = 0; + for(auto v : mesh.vertices()) + { + points.push_back(get(vpm, v)); + vertex_id_map[v] = i++; + } + for(auto f : mesh.faces()) + { + Polygon triangle; + for(auto vert : CGAL::vertices_around_face(halfedge(f, mesh), mesh)) + { + triangle.push_back(vertex_id_map[vert]); + } + triangles.push_back(triangle); + } + + std::vector colors; + //if item is multicolor, fill colors with f:color + if(sm_item->isItemMulticolor()) + { + colors.reserve(triangles.size()); + SMesh::Property_map fcolors = + mesh.property_map("f:color").first; + for(auto fd : mesh.faces()) + { + colors.push_back(get(fcolors, fd)); + } + } + else if(sm_item->hasPatchIds()) + { + colors.reserve(triangles.size()); + SMesh::Property_map fpid = + mesh.property_map("f:patch_id").first; + for(auto fd : mesh.faces()) + { + int pid = get(fpid, fd); + QColor q_color = sm_item->color_vector()[pid]; + colors.push_back(CGAL::Color(q_color.red(), q_color.green(), + q_color.blue(), q_color.alpha())); + } + } + //else fill it with item->color() + else + { + colors.resize(triangles.size()); + const QColor& c = sm_item->color(); + for(auto& color : colors) + color.set_rgb(c.red(), c.green(), c.blue()); + } + + CGAL::write_mesh_to_model(points, triangles, colors, + sm_item->name().toStdString(), &pMeshObject, pModel); + } + for(Scene_points_with_normal_item* pts_item : pts_items) + { + QColor qc = pts_item->color(); + CGAL::Color color(qc.red(), qc.green(), qc.blue()); + CGAL::write_point_cloud_to_model(pts_item->point_set()->points(), color, + pts_item->name().toStdString(), + &pMeshObject, pModel); + } + for(Scene_polylines_item* pol_item : pol_items) + { + for(auto pol_it = pol_item->polylines.begin(); + pol_it != pol_item->polylines.end(); ++pol_it) + { + QColor qc = pol_item->color(); + CGAL::Color color(qc.red(), qc.green(), qc.blue()); + CGAL::write_polyline_to_model(*pol_it,color, + pol_item->name().toStdString(), + &pMeshObject, pModel); + } + } + CGAL::export_model_to_file(fi.filePath().toUtf8().toStdString(), pModel); + items = to_return; + return true; + } +}; +#include "3mf_io_plugin.moc" + diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt index 5a0289798e6..5c8bf384e39 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt @@ -72,4 +72,21 @@ else() else() message(STATUS "NOTICE : the LAS IO plugin needs LAS libraries and will not be compiled.") endif() + + find_path(3MF_INCLUDE_DIR + NAMES Common Model + DOC "Path to lib3MF headers" + ) + if(IS_DIRECTORY "${3MF_INCLUDE_DIR}/Common") + set(3MF_FOUND true) + endif() + find_library(3MF_LIBRARIES NAMES 3MF DOC "Path to the lib3MF library") + + if(3MF_FOUND) + include_directories(${3MF_INCLUDE_DIR}) + polyhedron_demo_plugin(3mf_io_plugin 3mf_io_plugin KEYWORDS IO) + target_link_libraries(3mf_io_plugin PRIVATE scene_surface_mesh_item scene_points_with_normal_item scene_polylines_item ${3MF_LIBRARIES}) + else() + message(STATUS "NOTICE: The 3mf_io_plugin requires the lib3MF library, and will not be compiled.") + endif() endif() diff --git a/Stream_support/include/CGAL/IO/read_3mf.h b/Stream_support/include/CGAL/IO/read_3mf.h index d9e477f2820..062ea68d6a0 100644 --- a/Stream_support/include/CGAL/IO/read_3mf.h +++ b/Stream_support/include/CGAL/IO/read_3mf.h @@ -25,17 +25,21 @@ #include #include #include +#include #include namespace CGAL{ template + typename PolygonRange, + typename ColorRange> bool extract_soups (NMR::PLib3MFModelMeshObject *pMeshObject, PointRange& points, PolygonRange& triangles, + ColorRange& colors, std::string& name) { typedef typename PointRange::value_type Point_3; typedef typename PolygonRange::value_type Polygon; + typedef typename ColorRange::value_type _Color; HRESULT hResult; DWORD nNeededChars; @@ -63,6 +67,19 @@ bool extract_soups (NMR::PLib3MFModelMeshObject *pMeshObject, } else name = std::string("Unknown Mesh"); + + NMR::PLib3MFPropertyHandler * pPropertyHandler; + hResult = NMR::lib3mf_meshobject_createpropertyhandler(pMeshObject, &pPropertyHandler); + if (hResult != LIB3MF_OK) { + DWORD nErrorMessage; + LPCSTR pszErrorMessage; + std::cerr << "could not create property handler: " << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(pMeshObject, &nErrorMessage, &pszErrorMessage); + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(pMeshObject); + return -1; + } + for(DWORD vid = 0; vid < points.size(); ++vid) { NMR::MODELMESHVERTEX pVertex; @@ -80,15 +97,22 @@ bool extract_soups (NMR::PLib3MFModelMeshObject *pMeshObject, for(DWORD i = 0; i< 3; ++i) triangle[i] = pTriangle.m_nIndices[i]; triangles[pid] = triangle; + NMR::MODELMESH_TRIANGLECOLOR_SRGB pColor; + NMR::lib3mf_propertyhandler_getcolor(pPropertyHandler, pid, &pColor); + NMR::MODELMESHCOLOR_SRGB mColor = pColor.m_Colors[0]; + colors[pid]=CGAL::Color(mColor.m_Red, mColor.m_Green, + mColor.m_Blue, mColor.m_Alpha); } return true; } template + typename PolygonRange, + typename ColorRange> bool extract_polylines (NMR::PLib3MFModelMeshObject *pMeshObject, PointRange& points, PolygonRange&, + ColorRange& colors, std::string& name) { typedef typename PointRange::value_type Point_3; typedef typename PolygonRange::value_type Polygon; @@ -123,8 +147,21 @@ bool extract_polylines (NMR::PLib3MFModelMeshObject *pMeshObject, points.resize(0); return false; } - points.resize(points.size()-3); - for(DWORD vid = 0; vid < points.size()-3; ++vid) //ignore dummy_vertices + + NMR::PLib3MFPropertyHandler * pPropertyHandler; + hResult = NMR::lib3mf_meshobject_createpropertyhandler(pMeshObject, &pPropertyHandler); + if (hResult != LIB3MF_OK) { + DWORD nErrorMessage; + LPCSTR pszErrorMessage; + std::cerr << "could not create property handler: " << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(pMeshObject, &nErrorMessage, &pszErrorMessage); + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(pMeshObject); + return -1; + } + + points.resize(points.size()-3);//ignore dummy_vertices + for(DWORD vid = 0; vid < points.size(); ++vid) { NMR::MODELMESHVERTEX pVertex; NMR::lib3mf_meshobject_getvertex(pMeshObject, vid+3, &pVertex); @@ -133,17 +170,24 @@ bool extract_polylines (NMR::PLib3MFModelMeshObject *pMeshObject, pVertex.m_fPosition[1], pVertex.m_fPosition[2]); } + + NMR::MODELMESH_TRIANGLECOLOR_SRGB pColor; + NMR::lib3mf_propertyhandler_getcolor(pPropertyHandler, 0, &pColor);//get color of the dummy triangle + NMR::MODELMESHCOLOR_SRGB mColor = pColor.m_Colors[0]; + colors[0]=CGAL::Color(mColor.m_Red, mColor.m_Green, + mColor.m_Blue, mColor.m_Alpha); return true; } template + typename PolygonRange, + typename ColorRange> bool extract_point_clouds (NMR::PLib3MFModelMeshObject *pMeshObject, PointRange& points, PolygonRange&, + ColorRange& colors, std::string& name) { typedef typename PointRange::value_type Point_3; - typedef typename PolygonRange::value_type Polygon; HRESULT hResult; DWORD nNeededChars; @@ -174,8 +218,21 @@ bool extract_point_clouds (NMR::PLib3MFModelMeshObject *pMeshObject, points.resize(0); return false; } - points.resize(points.size()-3); - for(DWORD vid = 0; vid < points.size()-3; ++vid) //ignore dummy_vertices + + NMR::PLib3MFPropertyHandler * pPropertyHandler; + hResult = NMR::lib3mf_meshobject_createpropertyhandler(pMeshObject, &pPropertyHandler); + if (hResult != LIB3MF_OK) { + DWORD nErrorMessage; + LPCSTR pszErrorMessage; + std::cerr << "could not create property handler: " << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(pMeshObject, &nErrorMessage, &pszErrorMessage); + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(pMeshObject); + return -1; + } + + points.resize(points.size()-3);//ignore dummy_vertices + for(DWORD vid = 0; vid < points.size(); ++vid) { NMR::MODELMESHVERTEX pVertex; NMR::lib3mf_meshobject_getvertex(pMeshObject, vid+3, &pVertex); @@ -184,16 +241,24 @@ bool extract_point_clouds (NMR::PLib3MFModelMeshObject *pMeshObject, pVertex.m_fPosition[1], pVertex.m_fPosition[2]); } - //ignore dummy_triangle. + + NMR::MODELMESH_TRIANGLECOLOR_SRGB pColor; + NMR::lib3mf_propertyhandler_getcolor(pPropertyHandler, 0, &pColor);//get color of the dummy triangle + NMR::MODELMESHCOLOR_SRGB mColor = pColor.m_Colors[0]; + colors[0]=CGAL::Color(mColor.m_Red, mColor.m_Green, + mColor.m_Blue, mColor.m_Alpha); return true; } -template +template int read_from_3mf(const std::string& file_name, PointRanges& all_points, - PolygonRanges& all_polygons, std::vector& names, + PolygonRanges& all_polygons, ColorRanges& all_colors, + std::vector& names, std::function func ) { @@ -208,21 +273,21 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, hResult = NMR::lib3mf_getinterfaceversion(&nInterfaceVersionMajor, &nInterfaceVersionMinor, &nInterfaceVersionMicro); if (hResult != LIB3MF_OK) { - std::cout << "could not get 3MF Library version: " << std::hex << hResult << std::endl; + std::cerr << "could not get 3MF Library version: " << std::hex << hResult << std::endl; return -1; } // Create Model Instance hResult = NMR::lib3mf_createmodel(&pModel); if (hResult != LIB3MF_OK) { - std::cout << "could not create model: " << std::hex << hResult << std::endl; + std::cerr << "could not create model: " << std::hex << hResult << std::endl; return -1; } // Create Model Reader hResult = NMR::lib3mf_model_queryreader(pModel, sReaderName.c_str(), &pReader); if (hResult != LIB3MF_OK) { - std::cout << "could not create model reader: " << std::hex << hResult << std::endl; + std::cerr << "could not create model reader: " << std::hex << hResult << std::endl; NMR::lib3mf_release(pModel); return -1; } @@ -230,7 +295,7 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, // Import Model from File hResult = NMR::lib3mf_reader_readfromfileutf8(pReader, file_name.c_str()); if (hResult != LIB3MF_OK) { - std::cout << "could not parse file: " << std::hex << hResult << std::endl; + std::cerr << "could not parse file: " << std::hex << hResult << std::endl; NMR::lib3mf_release(pReader); NMR::lib3mf_release(pModel); return -1; @@ -246,13 +311,13 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, hResult = NMR::lib3mf_model_getobjects(pModel, &pResourceIterator); if (hResult != LIB3MF_OK) { - std::cout << "could not get object: " << std::hex << hResult << std::endl; + std::cerr << "could not get object: " << std::hex << hResult << std::endl; NMR::lib3mf_release(pModel); return -1; } hResult = NMR::lib3mf_resourceiterator_movenext(pResourceIterator, &pbHasNext); if (hResult != LIB3MF_OK) { - std::cout << "could not get next object: " << std::hex << hResult << std::endl; + std::cerr << "could not get next object: " << std::hex << hResult << std::endl; NMR::lib3mf_release(pResourceIterator); NMR::lib3mf_release(pModel); return -1; @@ -266,7 +331,7 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, // get current resource hResult = NMR::lib3mf_resourceiterator_getcurrent(pResourceIterator, &pResource); if (hResult != LIB3MF_OK) { - std::cout << "could not get resource: " << std::hex << hResult << std::endl; + std::cerr << "could not get resource: " << std::hex << hResult << std::endl; NMR::lib3mf_release(pResourceIterator); NMR::lib3mf_release(pModel); return -1; @@ -275,7 +340,7 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, // get resource ID hResult = NMR::lib3mf_resource_getresourceid(pResource, &ResourceID); if (hResult != LIB3MF_OK) { - std::cout << "could not get resource id: " << std::hex << hResult << std::endl; + std::cerr << "could not get resource id: " << std::hex << hResult << std::endl; NMR::lib3mf_release(pResource); NMR::lib3mf_release(pResourceIterator); NMR::lib3mf_release(pModel); @@ -285,19 +350,18 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, BOOL bIsMeshObject; hResult = NMR::lib3mf_object_ismeshobject(pResource, &bIsMeshObject); if ((hResult == LIB3MF_OK) && (bIsMeshObject)) { - std::cout << "------------------------------------------------------" << std::endl; - std::cout << "mesh object #" << ResourceID << ": " << std::endl; - pMeshObject = pResource; NMR::lib3mf_meshobject_getvertexcount(pMeshObject, &nbVertices); NMR::lib3mf_meshobject_gettrianglecount(pMeshObject, &nbPolygons); PointRange points (nbVertices); PolygonRange triangles(nbPolygons); + ColorRange colors(nbPolygons); std::string name; - if(func(pMeshObject, points, triangles, name)){ + if(func(pMeshObject, points, triangles, colors, name)){ all_points.push_back(points); all_polygons.push_back(triangles); + all_colors.push_back(colors); names.push_back(name); } } @@ -305,7 +369,7 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, NMR::lib3mf_release(pResource); hResult = NMR::lib3mf_resourceiterator_movenext(pResourceIterator, &pbHasNext); if (hResult != LIB3MF_OK) { - std::cout << "could not get next object: " << std::hex << hResult << std::endl; + std::cerr << "could not get next object: " << std::hex << hResult << std::endl; return -1; } } @@ -323,6 +387,10 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, * `value_type` is a model of the concept `RandomAccessContainer` * whose `value_type` is a model of the concept `RandomAccessContainer` whose * `value_type` is std::size_t. + * \tparam ColorRanges a model of the concepts `RandomAccessContainer` and + * `BackInsertionSequence` whose `value type` is + * a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` + * whose `value type` is `CGAL::Color`. * \param file_name the name of the 3mf file to read. * \param all_points a `PointRanges` that will contain the points of the meshes * in `file_name`. @@ -331,47 +399,62 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, * meshes in `file_name`. * Each of these meshes will add a range of its triangles. A `triangle` of * all_polygons[i] contains the indices of its points in all_points[i]. + * \param all_colors will contain the color of each triangle for each soup. * \param names will contain the name of each mesh in `file_name` if any. * If the i'th mesh has no name, it will be called "Unknown Mesh" in names. * \return the number of meshes processed in `file_name`. */ -template +template int read_soups_from_3mf(const std::string& file_name, PointRanges& all_points, - PolygonRanges& all_polygons, std::vector& names + PolygonRanges& all_polygons, ColorRanges& all_colors, + std::vector& names ) { typedef typename PointRanges::value_type PointRange; typedef typename PolygonRanges::value_type PolygonRange; - return read_from_3mf - (file_name, all_points, all_polygons, names, extract_soups); + typedef typename ColorRanges::value_type ColorRange; + return read_from_3mf + (file_name, all_points, all_polygons, + all_colors, names, extract_soups); } -template -int read_polylines_from_3mf(const std::string& file_name, PointRanges& all_points, - std::vector& names +template +int read_polylines_from_3mf(const std::string& file_name, + PointRanges& all_points, + ColorRanges& all_colors, + std::vector& names ) { typedef typename PointRanges::value_type PointRange; typedef std::vector Polygon; typedef std::vector PolygonRange; + typedef std::vector ColorRange; std::vector all_polygons; - return read_from_3mf, PointRange, PolygonRange> - (file_name, all_points, all_polygons, names, extract_polylines); + return read_from_3mf, + std::vector, PointRange, PolygonRange, ColorRange> + (file_name, all_points, all_polygons, all_colors, names, + extract_polylines); } -template -int read_point_clouds_from_3mf(const std::string& file_name, PointRanges& all_points, - std::vector& names +template +int read_point_clouds_from_3mf(const std::string& file_name, + PointRanges& all_points, + ColorRanges& all_colors, + std::vector& names ) { typedef typename PointRanges::value_type PointRange; typedef std::vector Polygon; typedef std::vector PolygonRange; + typedef std::vector ColorRange; std::vector all_polygons; - return read_from_3mf, PointRange, PolygonRange> - (file_name, all_points, all_polygons, names, extract_point_clouds); + return read_from_3mf, + std::vector, PointRange, PolygonRange, ColorRange> + (file_name, all_points, all_polygons, all_colors, names, + extract_point_clouds); } }//end CGAL diff --git a/Stream_support/include/CGAL/IO/write_3mf.h b/Stream_support/include/CGAL/IO/write_3mf.h index 322d54495c3..ac4500a17b2 100644 --- a/Stream_support/include/CGAL/IO/write_3mf.h +++ b/Stream_support/include/CGAL/IO/write_3mf.h @@ -43,7 +43,18 @@ NMR::MODELMESHTRIANGLE fnCreateTriangle(int v0, int v1, int v2) result.m_nIndices[2] = v2; return result; } +NMR::MODELMESHCOLOR_SRGB fnCreateColor(unsigned char red, unsigned char green, + unsigned char blue, unsigned char alpha=255) +{ + NMR::MODELMESHCOLOR_SRGB result; + result.m_Red = red; + result.m_Green = green; + result.m_Blue = blue; + result.m_Alpha = alpha; + return result; + +} } //end internal bool add_build_item(NMR::PLib3MFModel * pModel, @@ -56,10 +67,10 @@ bool add_build_item(NMR::PLib3MFModel * pModel, NMR::PLib3MFModelBuildItem * pBuildItem; hResult = NMR::lib3mf_model_addbuilditem(pModel, pMeshObject, NULL, &pBuildItem); if (hResult != LIB3MF_OK) { - std::cout << "could not create build item: " + std::cerr << "could not create build item: " << std::hex << hResult << std::endl; NMR::lib3mf_getlasterror(pModel, &nErrorMessage, &pszErrorMessage); - std::cout << "error #" << std::hex << nErrorMessage + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(pMeshObject); NMR::lib3mf_release(pModel); @@ -82,10 +93,10 @@ bool export_model_to_file(const std::string& file_name, NMR::PLib3MFModelWriter * p3MFWriter; hResult = NMR::lib3mf_model_querywriter(pModel, "3mf", &p3MFWriter); if (hResult != LIB3MF_OK) { - std::cout << "could not create model reader: " + std::cerr << "could not create model reader: " << std::hex << hResult << std::endl; NMR::lib3mf_getlasterror(pModel, &nErrorMessage, &pszErrorMessage); - std::cout << "error #" << std::hex << nErrorMessage + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(pModel); return false; @@ -93,9 +104,9 @@ bool export_model_to_file(const std::string& file_name, // Export Model into File hResult = NMR::lib3mf_writer_writetofileutf8(p3MFWriter, file_name.c_str()); if (hResult != LIB3MF_OK) { - std::cout << "could not write file: " << std::hex << hResult << std::endl; + std::cerr << "could not write file: " << std::hex << hResult << std::endl; NMR::lib3mf_getlasterror(p3MFWriter, &nErrorMessage, &pszErrorMessage); - std::cout << "error #" << std::hex << nErrorMessage << ": " + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(pModel); NMR::lib3mf_release(p3MFWriter); @@ -107,13 +118,14 @@ bool export_model_to_file(const std::string& file_name, return true; } -template +template bool write_mesh_to_model( const PointRange& points, - const PolygonRange& polygons, + const PolygonRange& polygons, + const ColorRange& colors, const std::string& name, - NMR::PLib3MFModelMeshObject** pMeshObject, - NMR::PLib3MFModel * pModel - ) + NMR::PLib3MFModelMeshObject** pMeshObject, + NMR::PLib3MFModel * pModel + ) { DWORD nErrorMessage; LPCSTR pszErrorMessage; @@ -124,10 +136,10 @@ bool write_mesh_to_model( const PointRange& points, // Create Mesh Object hResult = NMR::lib3mf_model_addmeshobject(pModel, pMeshObject); if (hResult != LIB3MF_OK) { - std::cout << "could not add mesh object: " << std::hex + std::cerr << "could not add mesh object: " << std::hex << hResult << std::endl; NMR::lib3mf_getlasterror(pModel, &nErrorMessage, &pszErrorMessage); - std::cout << "error #" << std::hex << nErrorMessage << ": " + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(pModel); return false; @@ -135,41 +147,83 @@ bool write_mesh_to_model( const PointRange& points, for( auto point : points) { pVertices.push_back(tmf_internal::fnCreateVertex(point.x(), point.y(), point.z())); - } + } for( auto triangle : polygons) { pTriangles.push_back(tmf_internal::fnCreateTriangle(triangle[0], triangle[1], triangle[2])); - } + } hResult = NMR::lib3mf_meshobject_setgeometry(*pMeshObject, pVertices.data(), pVertices.size(), pTriangles.data(), pTriangles.size()); if (hResult != LIB3MF_OK) { - std::cout << "could not set mesh geometry: " + std::cerr << "could not set mesh geometry: " << std::hex << hResult << std::endl; NMR::lib3mf_getlasterror(*pMeshObject, &nErrorMessage, &pszErrorMessage); - std::cout << "error #" << std::hex << nErrorMessage + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(*pMeshObject); NMR::lib3mf_release(pModel); return false; } + // Create color entries + NMR::PLib3MFPropertyHandler * pPropertyHandler; + hResult = NMR::lib3mf_meshobject_createpropertyhandler(*pMeshObject, &pPropertyHandler); + if (hResult != LIB3MF_OK) { + std::cerr << "could not create property handler: " << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(*pMeshObject, &nErrorMessage, &pszErrorMessage); + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(*pMeshObject); + NMR::lib3mf_release(pModel); + return -1; + } + + // define colors + for(std::size_t pid = 0; pid +template bool write_points(const PointRange& points, + const Color& color, const std::string& name, NMR::PLib3MFModelMeshObject** pMeshObject, NMR::PLib3MFModel * pModel @@ -183,10 +237,10 @@ bool write_points(const PointRange& points, // Create Mesh Object hResult = NMR::lib3mf_model_addmeshobject(pModel, pMeshObject); if (hResult != LIB3MF_OK) { - std::cout << "could not add mesh object: " << std::hex + std::cerr << "could not add mesh object: " << std::hex << hResult << std::endl; NMR::lib3mf_getlasterror(pModel, &nErrorMessage, &pszErrorMessage); - std::cout << "error #" << std::hex << nErrorMessage << ": " + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(pModel); return false; @@ -197,34 +251,74 @@ bool write_points(const PointRange& points, for( auto point : points) { pVertices.push_back(tmf_internal::fnCreateVertex(point.x(), point.y(), point.z())); - } + } NMR::MODELMESHTRIANGLE dummy_triangle = tmf_internal::fnCreateTriangle(0,1,2); //add a triangle to avoid lib error. hResult = NMR::lib3mf_meshobject_setgeometry(*pMeshObject, pVertices.data(), pVertices.size(), &dummy_triangle, 1); if (hResult != LIB3MF_OK) { - std::cout << "could not set mesh geometry: " + std::cerr << "could not set mesh geometry: " << std::hex << hResult << std::endl; NMR::lib3mf_getlasterror(*pMeshObject, &nErrorMessage, &pszErrorMessage); - std::cout << "error #" << std::hex << nErrorMessage + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(*pMeshObject); NMR::lib3mf_release(pModel); return false; } + + // Create color entries + NMR::PLib3MFPropertyHandler * pPropertyHandler; + hResult = NMR::lib3mf_meshobject_createpropertyhandler(*pMeshObject, &pPropertyHandler); + if (hResult != LIB3MF_OK) { + std::cerr << "could not create property handler: " << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(*pMeshObject, &nErrorMessage, &pszErrorMessage); + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(*pMeshObject); + NMR::lib3mf_release(pModel); + return -1; + } + + // define colors + NMR::MODELMESHCOLOR_SRGB sColor = tmf_internal::fnCreateColor (color.red(), + color.green(), + color.blue(), + color.alpha()); + // One-colored Triangles + NMR::lib3mf_propertyhandler_setsinglecolor(pPropertyHandler, 0, &sColor); + + // make sure to define a default property + NMR::PLib3MFDefaultPropertyHandler * pDefaultPropertyHandler; + hResult = NMR::lib3mf_object_createdefaultpropertyhandler(*pMeshObject, &pDefaultPropertyHandler); + if (hResult != LIB3MF_OK) { + std::cerr<< "could not create default property handler: " << std::hex << hResult << std::endl; + NMR::lib3mf_getlasterror(*pMeshObject, &nErrorMessage, &pszErrorMessage); + std::cerr<< "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; + NMR::lib3mf_release(*pMeshObject); + NMR::lib3mf_release(pModel); + return -1; + } + NMR::MODELMESHCOLOR_SRGB default_color = tmf_internal::fnCreateColor(0,0,0,0); + NMR::lib3mf_defaultpropertyhandler_setcolor(pDefaultPropertyHandler, + &default_color); + + // release default property handler + NMR::lib3mf_release(pDefaultPropertyHandler); + // Set name hResult = NMR::lib3mf_object_setnameutf8(*pMeshObject, name.c_str()); if (hResult != LIB3MF_OK) { - std::cout << "could not set object name: " << std::hex << hResult << std::endl; + std::cerr << "could not set object name: " << std::hex << hResult << std::endl; NMR::lib3mf_getlasterror(*pMeshObject, &nErrorMessage, &pszErrorMessage); - std::cout << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; + std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(*pMeshObject); NMR::lib3mf_release(pModel); return -1; } } -template +template bool write_point_cloud_to_model(const PointRange& points, + const Color& color, const std::string& name, NMR::PLib3MFModelMeshObject** pMeshObject, NMR::PLib3MFModel * pModel @@ -232,24 +326,25 @@ bool write_point_cloud_to_model(const PointRange& points, { std::string pc_name = name; pc_name.append("_cgal_pc"); - write_points(points, pc_name, pMeshObject, pModel); + write_points(points, color, pc_name, pMeshObject, pModel); } -template +template bool write_polyline_to_model(const PointRange& points, - const std::string& name, - NMR::PLib3MFModelMeshObject** pMeshObject, - NMR::PLib3MFModel * pModel - ) + const Color& color, + const std::string& name, + NMR::PLib3MFModelMeshObject** pMeshObject, + NMR::PLib3MFModel * pModel + ) { std::string pc_name = name; pc_name.append("_cgal_pl"); - write_points(points, pc_name, pMeshObject, pModel); + write_points(points, color, pc_name, pMeshObject, pModel); } /*! - * \brief write_soups_to_3mf will write the polygon soups in all_points and - * all_polygons in `file_name`, in the 3mf format. + * \brief write_soups_to_3mf will write the polygon soups contained in all_points and + * all_polygons into the file named `file_name`, in the 3mf format. * \tparam PointRanges a model of the concepts `RandomAccessContainer` and * `BackInsertionSequence` whose `value type` is * a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` @@ -269,7 +364,7 @@ bool write_polyline_to_model(const PointRange& points, template bool write_soups_to_3mf(const std::string& file_name, const PointRanges& all_points, - const PolygonRanges& all_polygons, + const PolygonRanges& all_polygons, const std::vector& names) { DWORD nErrorMessage; @@ -280,7 +375,7 @@ bool write_soups_to_3mf(const std::string& file_name, NMR::PLib3MFModel * pModel; hResult = NMR::lib3mf_createmodel(&pModel); if (hResult != LIB3MF_OK) { - std::cout << "could not create model: " << std::hex << hResult << std::endl; + std::cerr << "could not create model: " << std::hex << hResult << std::endl; return false; } for(std::size_t id = 0; id < all_points.size(); ++id) diff --git a/Stream_support/test/Stream_support/test_3mf_to_sm.cpp b/Stream_support/test/Stream_support/test_3mf_to_sm.cpp index f776128fa9c..a2c1fe8dbab 100644 --- a/Stream_support/test/Stream_support/test_3mf_to_sm.cpp +++ b/Stream_support/test/Stream_support/test_3mf_to_sm.cpp @@ -23,6 +23,7 @@ typedef CGAL::Surface_mesh Mesh; typedef std::vector PointRange; typedef std::vector Polygon; typedef std::vector PolygonRange; +typedef std::vector ColorRange; int main(int argc, char** argv) { @@ -33,10 +34,12 @@ int main(int argc, char** argv) } std::vector all_points; std::vector all_polygons; + std::vector all_colors; std::vector names; //testing reading functions. int nb_meshes = - CGAL::read_soups_from_3mf(argv[1], all_points, all_polygons, names); + CGAL::read_soups_from_3mf(argv[1], all_points, all_polygons, + all_colors, names); if(nb_meshes <0) return 1; for(std::size_t i = 0; i< nb_meshes; ++i) @@ -64,8 +67,9 @@ int main(int argc, char** argv) } } all_points.clear(); + all_colors.clear(); int nb_polylines = - CGAL::read_polylines_from_3mf(argv[1], all_points, names); + CGAL::read_polylines_from_3mf(argv[1], all_points, all_colors, names); if(nb_polylines == 0) std::cout<<"No polyline found."<::type VPMap; VPMap vpm = get(boost::vertex_point, sphere); std::unordered_map::vertex_descriptor, @@ -119,10 +126,13 @@ int main(int argc, char** argv) triangle.push_back(vertex_id_map[vert]); } triangles.push_back(triangle); + colors.push_back(CGAL::Color(255,0,0,255)); } all_polygons.push_back(triangles); + all_colors.push_back(colors); points.clear(); triangles.clear(); + colors.clear(); vertex_id_map.clear(); i = 0; @@ -141,8 +151,11 @@ int main(int argc, char** argv) triangle.push_back(vertex_id_map[vert]); } triangles.push_back(triangle); + colors.push_back(CGAL::Color(0,0,255,255)); + } all_polygons.push_back(triangles); + all_colors.push_back(colors); names.push_back(std::string("sphere")); names.push_back(std::string("tube")); @@ -160,13 +173,16 @@ int main(int argc, char** argv) } for(int i=0; i< names.size(); ++i) { - CGAL::write_mesh_to_model(all_points[i], all_polygons[i], names[i], &pMeshObject, pModel); + CGAL::write_mesh_to_model(all_points[i], all_polygons[i], + all_colors[i], names[i], &pMeshObject, pModel); } - - CGAL::write_point_cloud_to_model(all_points.front(), names.front(), &pMeshObject, pModel); + CGAL::Color color(255,0,0); + CGAL::write_point_cloud_to_model(all_points.front(), + color, names.front(), &pMeshObject, pModel); CGAL::export_model_to_file("micro.3mf", pModel); //testing of polylines - CGAL::write_polyline_to_model(all_points.back(), names.back(), &pMeshObject, pModel); + CGAL::write_polyline_to_model(all_points.back(), + color, names.back(), &pMeshObject, pModel); CGAL::export_model_to_file("micro.3mf", pModel); std::cout<<"OK."< Date: Thu, 16 May 2019 13:20:05 +0200 Subject: [PATCH 077/203] Update interface version --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 36 +------------------ .../Camera_positions_plugin.cpp | 2 +- .../Polyhedron/Plugins/IO/3mf_io_plugin.cpp | 35 +++++++++++++++--- .../Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp | 2 +- .../Polyhedron/Plugins/IO/LAS_io_plugin.cpp | 2 +- .../Polyhedron/Plugins/IO/OFF_io_plugin.cpp | 2 +- .../Plugins/IO/OFF_to_nef_io_plugin.cpp | 2 +- .../Polyhedron/Plugins/IO/PLY_io_plugin.cpp | 2 +- .../Plugins/IO/Polylines_io_plugin.cpp | 2 +- .../Polyhedron/Plugins/IO/STL_io_plugin.cpp | 2 +- .../Polyhedron/Plugins/IO/Surf_io_plugin.cpp | 2 +- .../Polyhedron/Plugins/IO/VTK_io_plugin.cpp | 2 +- .../Polyhedron/Plugins/IO/XYZ_io_plugin.cpp | 2 +- .../Polyhedron/Plugins/IO/lcc_io_plugin.cpp | 2 +- .../Plugins/Mesh_3/Io_image_plugin.cpp | 2 +- .../Plugins/PMP/Selection_plugin.cpp | 2 +- .../Point_set/Features_detection_plugin.cpp | 2 +- .../Polyhedron_demo_io_plugin_interface.h | 11 ++++-- 18 files changed, 55 insertions(+), 57 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 693b00f40e3..bd87e92fbcf 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -342,41 +342,6 @@ MainWindow::MainWindow(const QStringList &keywords, bool verbose, QWidget* paren this, &MainWindow::filterOperations); loadPlugins(); - //If 3mf plugin is present, add action to save scene - Polyhedron_demo_io_plugin_interface* io_3mf_plugin = nullptr; - for(Polyhedron_demo_io_plugin_interface* plugin : io_plugins) - { - if(plugin->name() == "3mf_io_plugin") - { - io_3mf_plugin = plugin; - break; - } - } - if(io_3mf_plugin ) - { - QAction* actionSaveSceneTo3mf = new QAction("Save the Scene as a 3mf File..."); - QString dir = QString("%1/scene").arg(def_save_dir); - connect(actionSaveSceneTo3mf, &QAction::triggered, this, - [this, dir, io_3mf_plugin](){ - - QString filename = - QFileDialog::getSaveFileName(this, - tr("Save Scene to File..."), - dir, - "*.3mf"); - - if(filename.isEmpty()) - return; - if(!filename.endsWith(".3mf")) - filename.append(".3mf"); - QList all_items; - for(int i = 0; i< scene->numberOfEntries(); ++i) - all_items.push_back(scene->item(i)); - io_3mf_plugin->save(filename, all_items); - }); - ui->menuFile->insertAction(ui->actionSa_ve_Scene_as_Script, actionSaveSceneTo3mf); - } - // Setup the submenu of the View menu that can toggle the dockwidgets Q_FOREACH(QDockWidget* widget, findChildren()) { ui->menuDockWindows->addAction(widget->toggleViewAction()); @@ -824,6 +789,7 @@ bool MainWindow::initIOPlugin(QObject* obj) CGAL::Three::Polyhedron_demo_io_plugin_interface* plugin = qobject_cast(obj); if(plugin) { + plugin->init(); io_plugins << plugin; return true; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp index 25fd3cdc230..6cb07bd250e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp @@ -16,7 +16,7 @@ class Polyhedron_demo_camera_positions_plugin : Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: void init(QMainWindow* mainWindow, Scene_interface* scene_interface, Messages_interface* ); diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp index 879328347ce..6acf62d8768 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp @@ -25,7 +25,7 @@ class Io_3mf_plugin: { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "3mf_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "3mf_io_plugin.json") typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef std::vector PointRange; @@ -33,6 +33,31 @@ class Io_3mf_plugin: typedef std::vector PolygonRange; typedef std::list PolylineRange; typedef std::vector ColorRange; + void init() Q_DECL_OVERRIDE + { + QMenu* menuFile = CGAL::Three::Three::mainWindow()->findChild("menuFile"); + + QAction* actionSaveSceneTo3mf = new QAction("Save the Scene as a 3mf File..."); + connect(actionSaveSceneTo3mf, &QAction::triggered, this, + [this](){ + + QString filename = + QFileDialog::getSaveFileName(CGAL::Three::Three::mainWindow(), + tr("Save Scene to File..."), + QString(), + "*.3mf"); + + if(filename.isEmpty()) + return; + if(!filename.endsWith(".3mf")) + filename.append(".3mf"); + QList all_items; + for(int i = 0; i< CGAL::Three::Three::scene()->numberOfEntries(); ++i) + all_items.push_back(CGAL::Three::Three::scene()->item(i)); + save(filename, all_items); + }); + menuFile->insertAction(CGAL::Three::Three::mainWindow()->findChild("actionSa_ve_Scene_as_Script"), actionSaveSceneTo3mf); + } QString name() const { return "3mf_io_plugin"; } @@ -40,10 +65,10 @@ class Io_3mf_plugin: "3mf files (*.3mf)"; } - bool canLoad(QFileInfo) const { return true; } + bool canLoad(QFileInfo) const Q_DECL_OVERRIDE { return true; } - QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true){ + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) Q_DECL_OVERRIDE { namespace PMP = CGAL::Polygon_mesh_processing; // Open file ok = true; @@ -151,10 +176,10 @@ class Io_3mf_plugin: } - bool canSave(const CGAL::Three::Scene_item*){return false;} + bool canSave(const CGAL::Three::Scene_item*) Q_DECL_OVERRIDE {return false;} - bool save(QFileInfo fi, QList& items){ + bool save(QFileInfo fi, QList& items) Q_DECL_OVERRIDE { QList to_return; std::vector sm_items; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp index 1709c1dfa60..0f00e7eea6f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp @@ -24,7 +24,7 @@ class Polyhedron_demo_gocad_plugin : Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "gocad_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" ) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" ) public: void init(QMainWindow* mainWindow, diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp index 176824c2e16..813b29186e0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp @@ -10,7 +10,7 @@ class Polyhedron_demo_las_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "las_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "las_io_plugin.json") public: QString name() const { return "las_plugin"; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp index 58edff9b8e3..76d53b4014b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp @@ -22,7 +22,7 @@ class Polyhedron_demo_off_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "off_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "off_io_plugin.json") public: bool isDefaultLoader(const Scene_item *item) const diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp index dd765722381..3366e1dbb68 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp @@ -11,7 +11,7 @@ class Polyhedron_demo_off_to_nef_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "off_to_nef_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "off_to_nef_io_plugin.json") public: QString name() const { return "off_to_nef_plugin"; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp index d72084a7e0b..6ce2fdeb793 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp @@ -20,7 +20,7 @@ class Polyhedron_demo_ply_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "ply_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "ply_io_plugin.json") public: bool isDefaultLoader(const CGAL::Three::Scene_item *item) const diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp index 222f7362d2f..f5898b953bc 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp @@ -17,7 +17,7 @@ class Polyhedron_demo_polylines_io_plugin : Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "polylines_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp index 475fc302197..ff0ccea88ed 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp @@ -31,7 +31,7 @@ class Polyhedron_demo_stl_plugin : Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "stl_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: void init(QMainWindow* mainWindow, diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp index f97fed4afad..9e728d6efe0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp @@ -26,7 +26,7 @@ class Surf_io_plugin: Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "surf_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: void init(QMainWindow* mainWindow, diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index 485c5a0c6f8..cc235ee91a2 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -291,7 +291,7 @@ class Polyhedron_demo_vtk_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "vtk_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "vtk_io_plugin.json") public: typedef boost::graph_traits::vertex_descriptor vertex_descriptor; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp index 8ab464ed7c6..f049fed6007 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp @@ -15,7 +15,7 @@ class Polyhedron_demo_xyz_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "xyz_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "xyz_io_plugin.json") public: diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp index 2b4d0649093..71c47452676 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp @@ -14,7 +14,7 @@ class LCC_io_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "lcc_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "lcc_io_plugin.json") public: bool isDefaultLoader(const CGAL::Three::Scene_item *item) const diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp index 69e31f785fa..d1103dac9ff 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -207,7 +207,7 @@ class Io_image_plugin : Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "io_image_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "io_image_plugin.json") public: diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index cd8512993f0..22a29ef9991 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -73,7 +73,7 @@ class Polyhedron_demo_selection_plugin : Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "selection_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: QString nameFilters() const { return "Selection files(*.selection.txt)"; } QString name() const { return "selection_sm_plugin"; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.cpp index c8e045980b2..3741d73da1b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.cpp @@ -19,7 +19,7 @@ class Polyhedron_demo_features_detection_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") QAction* actionDetectFeatures; public: QList actions() const { return QList() << actionDetectFeatures; } diff --git a/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h b/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h index 8361b1e5384..039c8e9ad73 100644 --- a/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h +++ b/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h @@ -28,16 +28,23 @@ #include #include #include - +class QMainWindow; +class Messages_interface; namespace CGAL{ namespace Three { class Scene_item; +class Scene_interface; /*! * This class provides a base for creating a new IO plugin. */ class Polyhedron_demo_io_plugin_interface { public: + //! \brief Initializes the plugin + //! This function is called in the constructor of the MainWindow. + //! Whatever initialization the plugin needs can be done here. Default + //! behavior is to do nothing. + virtual void init(){} //!Returns the name of the plugin //!It is used by the loading system. virtual QString name() const = 0; @@ -89,6 +96,6 @@ public: } } Q_DECLARE_INTERFACE(CGAL::Three::Polyhedron_demo_io_plugin_interface, - "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") #endif // POLYHEDRON_DEMO_IO_PLUGIN_INTERFACE_H From dbf2a6854f7705a50e6a40d7d0bab5dc274934ac Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 16 May 2019 14:00:04 +0200 Subject: [PATCH 078/203] Clean-up io-plugins --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 6 +-- .../Camera_positions_plugin.cpp | 29 +++++--------- .../Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp | 20 ++-------- .../Polyhedron/Plugins/IO/STL_io_plugin.cpp | 21 ++-------- .../Polyhedron/Plugins/IO/Surf_io_plugin.cpp | 26 +++---------- .../Plugins/Mesh_3/C3t3_io_plugin.cpp | 38 +++++++++---------- .../CGAL/Three/Scene_3mf_item_interface.h | 4 -- 7 files changed, 45 insertions(+), 99 deletions(-) delete mode 100644 Three/include/CGAL/Three/Scene_3mf_item_interface.h diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index bd87e92fbcf..a949b58ded9 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1118,11 +1118,11 @@ void MainWindow::open(QString filename) { // collect all io_plugins and offer them to load if the file extension match one name filter // also collect all available plugin in case of a no extension match - Q_FOREACH(CGAL::Three::Polyhedron_demo_io_plugin_interface* io_plugin, io_plugins) { - if ( !io_plugin->canLoad(fileinfo) ) continue; - all_items << io_plugin->name(); + for(CGAL::Three::Polyhedron_demo_io_plugin_interface* io_plugin : io_plugins) { if ( file_matches_filter(io_plugin->loadNameFilters(), filename.toLower()) ) { + if ( !io_plugin->canLoad(fileinfo) ) continue; + all_items << io_plugin->name(); if(io_plugin->isDefaultLoader(fileinfo.completeSuffix())) selected_items.prepend(io_plugin->name()); else diff --git a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp index 6cb07bd250e..c4823cd01aa 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp @@ -1,50 +1,41 @@ #include #include "Messages_interface.h" -#include #include #include "Camera_positions_list.h" + +#include #include #include using namespace CGAL::Three; class Polyhedron_demo_camera_positions_plugin : public QObject, - public Polyhedron_demo_plugin_interface, public CGAL::Three::Polyhedron_demo_io_plugin_interface { Q_OBJECT - Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") + Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: - void init(QMainWindow* mainWindow, Scene_interface* scene_interface, Messages_interface* ); - QList actions() const; + void init(); QString name() const { return "camera_positions_plugin"; } QString nameFilters() const { return "Camera positions (*.camera.txt)"; } - bool canLoad() const { return true; } - Scene_item* load(QFileInfo fileinfo) { cpl->load(fileinfo.filePath()); return 0; } + bool canLoad(QFileInfo) const { return true; } + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) { ok = true; cpl->load(fileinfo.filePath()); return QList(); } bool canSave(const Scene_item*) { return false; } - bool save(const Scene_item*, QFileInfo ) {return false; } - bool applicable(QAction*) const {return false;} + bool save(QFileInfo,QList& ) {return false; } private: Camera_positions_list* cpl; }; -void Polyhedron_demo_camera_positions_plugin::init(QMainWindow* mainWindow, Scene_interface*, Messages_interface *) +void Polyhedron_demo_camera_positions_plugin::init() { - cpl = new Camera_positions_list(mainWindow); - mainWindow->addDockWidget(Qt::LeftDockWidgetArea, cpl); -} - -QList -Polyhedron_demo_camera_positions_plugin::actions() const -{ - return QList(); + cpl = new Camera_positions_list(CGAL::Three::Three::mainWindow()); + CGAL::Three::Three::mainWindow()->addDockWidget(Qt::LeftDockWidgetArea, cpl); } #include "Camera_positions_plugin.moc" diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp index 0f00e7eea6f..9aca2423ca0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp @@ -17,27 +17,15 @@ using namespace CGAL::Three; class Polyhedron_demo_gocad_plugin : public QObject, - public Polyhedron_demo_io_plugin_interface, - public Polyhedron_demo_plugin_helper + public Polyhedron_demo_io_plugin_interface { Q_OBJECT - Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "gocad_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" ) + Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "gocad_io_plugin.json") public: - void init(QMainWindow* mainWindow, - CGAL::Three::Scene_interface* scene_interface, - Messages_interface*) { - //get the references - this->scene = scene_interface; - this->mw = mainWindow; - } - QList actions() const { - return QList(); - } - bool applicable(QAction*) const { return false;} + QString nameFilters() const; QString name() const { return "gocad_plugin"; } bool canLoad(QFileInfo) const; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp index ff0ccea88ed..66d08020a49 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp @@ -5,8 +5,6 @@ #include "SMesh_type.h" #include -#include -#include #include #include @@ -25,26 +23,13 @@ using namespace CGAL::Three; class Polyhedron_demo_stl_plugin : public QObject, - public Polyhedron_demo_io_plugin_interface, - public Polyhedron_demo_plugin_helper + public Polyhedron_demo_io_plugin_interface { Q_OBJECT - Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "stl_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") + Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "stl_io_plugin.json") public: - void init(QMainWindow* mainWindow, - CGAL::Three::Scene_interface* scene_interface, - Messages_interface*) { - //get the references - this->scene = scene_interface; - this->mw = mainWindow; - } - QList actions() const { - return QList(); - } - bool applicable(QAction*) const { return false;} QString nameFilters() const; QString name() const { return "stl_plugin"; } bool canLoad(QFileInfo fileinfo) const; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp index 9e728d6efe0..6b0e4b8708e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp @@ -3,8 +3,6 @@ #include #include #include -#include -#include #include #include @@ -20,26 +18,14 @@ using namespace CGAL::Three; class Surf_io_plugin: public QObject, - public Polyhedron_demo_io_plugin_interface, - public Polyhedron_demo_plugin_helper + public Polyhedron_demo_io_plugin_interface { Q_OBJECT - Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "surf_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") + Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "surf_io_plugin.json") public: - void init(QMainWindow* mainWindow, - CGAL::Three::Scene_interface* scene_interface, - Messages_interface*) { - //get the references - this->scene = scene_interface; - this->mw = mainWindow; - } - QList actions() const { - return QList(); - } - bool applicable(QAction*) const { return false;} + QString name() const { return "surf_io_plugin"; } QString nameFilters() const { return "Amira files (*.surf)"; } bool canLoad(QFileInfo) const{ return true; } @@ -118,8 +104,8 @@ CGAL::Three::Scene_item* Surf_io_plugin::actual_load(QFileInfo fileinfo) FaceGraphItem *patch = new FaceGraphItem(patches[i]); patch->setName(QString("Patch #%1").arg(i)); patch->setColor(colors_[i]); - scene->addItem(patch); - scene->changeGroup(patch, group); + CGAL::Three::Three::scene()->addItem(patch); + CGAL::Three::Three::scene()->changeGroup(patch, group); } return group; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 93af632e9e8..15a93660153 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -2,7 +2,6 @@ #include "Scene_c3t3_item.h" #include #include -#include #include #include #include @@ -12,31 +11,17 @@ class Polyhedron_demo_c3t3_binary_io_plugin : public QObject, - public CGAL::Three::Polyhedron_demo_io_plugin_interface, - public CGAL::Three::Polyhedron_demo_plugin_interface + public CGAL::Three::Polyhedron_demo_io_plugin_interface { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "c3t3_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "c3t3_io_plugin.json") public: - void init(QMainWindow*, CGAL::Three::Scene_interface* sc, Messages_interface*) - { - this->scene = sc; - } QString name() const { return "C3t3_io_plugin"; } QString nameFilters() const { return "binary files (*.cgal);;ascii (*.mesh);;maya (*.ma)"; } QString saveNameFilters() const { return "binary files (*.cgal);;ascii (*.mesh);;maya (*.ma);;avizo (*.am);;OFF files (*.off)"; } QString loadNameFilters() const { return "binary files (*.cgal);;ascii (*.mesh)"; } - QList actions() const - { - return QList(); - } - bool applicable(QAction*) const - { - return false; - } bool canLoad(QFileInfo) const; QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); @@ -50,8 +35,23 @@ private: }; -bool Polyhedron_demo_c3t3_binary_io_plugin::canLoad(QFileInfo) const { - return true; +bool Polyhedron_demo_c3t3_binary_io_plugin::canLoad(QFileInfo fi) const { + std::ifstream in(fi.filePath().toUtf8(), + std::ios_base::in|std::ios_base::binary); + if(!in) { + std::cerr << "Error! Cannot open file " + << (const char*)fi.filePath().toUtf8() << std::endl; + return false; + } + std::string line; + std::istringstream iss; + std::getline (in,line); + iss.str(line); + std::string keyword; + if (iss >> keyword) + if (keyword == "binary") + return true; + return false; } QList diff --git a/Three/include/CGAL/Three/Scene_3mf_item_interface.h b/Three/include/CGAL/Three/Scene_3mf_item_interface.h deleted file mode 100644 index 15b25cbfdbf..00000000000 --- a/Three/include/CGAL/Three/Scene_3mf_item_interface.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef SCENE_3MF_ITEM_INTERFACE_H -#define SCENE_3MF_ITEM_INTERFACE_H - -#endif // SCENE_3MF_ITEM_INTERFACE_H From 90ba79493fcf014e2a0544493bfcac625a5102ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 16 May 2019 14:03:30 +0200 Subject: [PATCH 079/203] Fix Ray_2 Triangle_2 intersection when the intersection is a point --- Intersections_2/include/CGAL/Ray_2_Triangle_2_intersection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Intersections_2/include/CGAL/Ray_2_Triangle_2_intersection.h b/Intersections_2/include/CGAL/Ray_2_Triangle_2_intersection.h index 740f9c42d77..e0217e0e340 100644 --- a/Intersections_2/include/CGAL/Ray_2_Triangle_2_intersection.h +++ b/Intersections_2/include/CGAL/Ray_2_Triangle_2_intersection.h @@ -158,7 +158,7 @@ intersection(const typename K::Ray_2 &ray, default: return intersection_return(); case is_t::POINT: - return intersection_return(ispair.intersection_segment()); + return intersection_return(ispair.intersection_point()); case is_t::SEGMENT: return intersection_return(ispair.intersection_segment()); } From bf8097dd6f7eba305c69f1aa7d506648eac774b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 16 May 2019 14:06:46 +0200 Subject: [PATCH 080/203] Fix Triangle_2 Iso_rectangle_2 intersection std::unique does not handle the case where points are identical at the beginning and the end of the vector --- .../include/CGAL/Triangle_2_Iso_rectangle_2_intersection.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Intersections_2/include/CGAL/Triangle_2_Iso_rectangle_2_intersection.h b/Intersections_2/include/CGAL/Triangle_2_Iso_rectangle_2_intersection.h index 1e6a4c4e269..2bd8191b5b4 100644 --- a/Intersections_2/include/CGAL/Triangle_2_Iso_rectangle_2_intersection.h +++ b/Intersections_2/include/CGAL/Triangle_2_Iso_rectangle_2_intersection.h @@ -270,7 +270,10 @@ namespace CGAL{ namespace internal { //remove duplicated consecutive points typename std::vector::iterator last = std::unique(result.begin(),result.end()); result.erase(last,result.end()); - + + while(result.back() == result.front() && result.size() > 1) + result.pop_back(); + switch(result.size()){ case 0: return intersection_return(); From 845002d7bf3de7a7a0ba482c779e5aace65e4880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 16 May 2019 14:07:33 +0200 Subject: [PATCH 081/203] Populate existing Intersections_2 tests with missing cases --- .../Intersections_2/test_intersections_2.cpp | 284 +++++++++++++++--- 1 file changed, 244 insertions(+), 40 deletions(-) diff --git a/Intersections_2/test/Intersections_2/test_intersections_2.cpp b/Intersections_2/test/Intersections_2/test_intersections_2.cpp index 512236d8933..e382469b83c 100644 --- a/Intersections_2/test/Intersections_2/test_intersections_2.cpp +++ b/Intersections_2/test/Intersections_2/test_intersections_2.cpp @@ -1,6 +1,12 @@ // 2D intersection tests. -#include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -8,15 +14,17 @@ #include #include #include + +#include #include #include #include #include -#include +#include #include - -#include -#include +#include +#include +#include #include #include @@ -145,6 +153,11 @@ struct Test { } } + template < typename O > + void check_intersection(const O& o) + { + return check_intersection(o, o, o); + } P p(int x, int y) { @@ -155,78 +168,161 @@ struct Test { void L_L() { std::cout << "Line - Line\n"; - check_intersection (L(p(0, 0), p(10, 0)), L(p(1,7), p(1,-2)), P(1,0)); - check_intersection (L(p(0,-1), p(10, 0)), L(p(2,1), p(8,-6)), P(3.42105,-0.657895)); - check_intersection (L(p(0, 0), p(10, 0)), L(p(1,0), p(8, 0))); - -check_no_intersection (L(p(0, 0), p(10,10)), L(p(8,7), p(1, 0))); - check_intersection (L(p(0, 0), p(10, 0)), L(p(8,0), p(1, 0))); + + // no intersection + check_no_intersection (L(p(0, 0), p(10,10)), L(p(8,7), p(1, 0))); + + // point intersection + check_intersection (L(p(0, 0), p(10, 0)), L(p( 1, 7), p( 1, -2)), P(1,0)); + check_intersection (L(p(0,-1), p(10, 0)), L(p( 2, 1), p( 8, -6)), P(3.42105,-0.657895)); + check_intersection

(L(p(0, 0), p( 0, 4)), L(p(-1,-3), p(-10, -10))); + + // line intersection + check_intersection (L(p( 1, 1), p( 5, 5))); + check_intersection (L(p( 1, 1), p( 5, 5)), L(p(3, 3), p( 7, 7))); // ps0 < ps1 < pt0 < pt1 + check_intersection (L(p( 5, 5), p( 1, 1)), L(p(3, 3), p( 7, 7))); // L0 & L1 have opposite directions + check_intersection (L(p( 0, 0), p(10, 0)), L(p(0, 0), p(10, 0))); // ps0 == ps1 < pt0 == pt1 + check_intersection (L(p(10, 0), p( 0, 0)), L(p(0, 0), p(10, 0))); // ps1 == pt0 < ps0 == pt1 + check_intersection (L(p( 0, 0), p(10, 0)), L(p(1, 0), p( 8, 0))); // ps0 < ps1 < pt1 < pt0 + check_intersection (L(p( 0, 0), p(10, 0)), L(p(8, 0), p( 1, 0))); // L0 & L1 have opposite directions } void S_S() { std::cout << "Segment - Segment\n"; + + // no intersection check_no_intersection (S(p(29, 16), p( 28, 9)), S(p( 30, 12), p( 29, 6))); + check_no_intersection (S(p( 0, 0), p(103567,9826)), S(p(10000,3782), p(76250,83736))); + + // point intersection + check_intersection (S(p( 0, 0), p( 10, 0)), S(p( 1, 6), p( 1, -3)), P(1, 0)); + check_intersection (S(p( 0, -1), p( 10, 0)), S(p( 2, 1), p( 8, -6)), P(3.42105, -0.657895)); + check_intersection (S(p( 0, 0), p( 10, 0)), S(p( 0, 0), p( 4, -7)), P(0, 0)); // meeting at an extremity + + // segment intersection + check_intersection (S(p( 0, 0), p( 10, 0))); + check_intersection (S(p( 0, 0), p( 10, 0)), S(p( 1, 0), p( 8, 0)), S(P( 1, 0), P( 8, 0))); check_intersection (S(p(68, 106), p(192, 106)), S(p(150, 106), p(255, 106)), S(P(150, 106), P(192, 106))); check_intersection (S(p( 1, 10), p( 1, 2)), S(p( 1, 7), p( 1, 3)), S(P( 1, 3), P( 1, 7))); - check_no_intersection (S(p( 0, 0), p(103567,9826)), S(p(10000,3782), p(76250,83736))); - check_intersection (S(p( 0, -1), p( 10, 0)), S(p( 2, 1), p( 8, -6)), P(3.42105, -0.657895)); - check_intersection (S(p( 0, 0), p( 10, 0)), S(p( 1, 0), p( 8, 0)), S(P( 1, 0), P( 8, 0))); - check_intersection (S(p( 0, 0), p( 10, 0)), S(p( 1, 6), p( 1, -3)), P(1, 0)); } void R_R() { std::cout << "Ray - Ray\n"; + + // no intersection + check_no_intersection (R(p( 3, 4), p( 5, 7)), R(p( 2, 0), p( 2, 4))); + + // point intersection check_intersection (R(p( 2, -1), p( 2, 1)), R(p( 1, 3), p( 2, 3)), P(2, 3)); check_intersection (R(p( 0, -1), p( 10, 0)), R(p( 2, 1), p( 8, -6)), P(3.42105, -0.657895)); check_intersection (R(p( 0, 0), p( 10, 0)), R(p( 1, 6), p( 1, -3)), P(1, 0)); + check_intersection (R(p( 0, 0), p( 10, 0)), R(p( 15, 0), p( 18, 30)), P(15, 0)); // R1's source on R0's path + check_intersection (R(p( 0, 0), p( 10, 0)), R(p( 0, 0), p( -3, 4)), P(0, 0)); // same source but different directions + + // segment intersection (same supporting line, different directions) + check_intersection (R(p( 2, 4), p( 6, 1)), R(p( 14, -5), p(10, -2))); + check_intersection (R(p( 2, 4), p( 10, -2)), R(p( 6, 1), p(-2, 7))); + + // ray intersection + check_intersection (R(p( 0, 0), p( 10, 0))); + check_intersection (R(p( 0, 0), p( 10, 0)), R(p( -1, 0), p(0, 0))); // R0 'runs' into R1's source } void S_R() { std::cout << "Segment - Ray\n"; + + // no intersection check_no_intersection (S(p( 2, -1), p( 2, 1)), R(p( 1, 3), p( 2, 3))); + + // point intersection check_intersection (S(p( 0, -1), p( 10, 0)), R(p( 2, 1), p( 8, -6)), P(3.42105, -0.657895)); check_intersection (S(p( 0, 0), p( 10, 0)), R(p( 1, 6), p( 1, -3)), P(1, 0)); + check_intersection (S(p( 0, 0), p( 10, 0)), R(p( 1, 6), p( 1, -3)), P(1, 0)); + check_intersection (S(p( 0, 0), p( 10, 0)), R(p( 0, 0), p(-10, 4)), P(0, 0)); // start of ray is exactly on the segment + check_intersection (S(p( 0, 0), p( 10, 0)), R(p( 4, 0), p(-10, 4)), P(4, 0)); // start of ray is a segment extremity + + // segment intersection + check_intersection (S(p( 0, 0), p( 1, 0)), R(p( 0, 0), p( 10, 0)), S(P(0, 0), P(1,0))); + check_intersection (S(p( 3, 7), p( 2, 5)), R(p( 1, 3), p( 4, 9))); } void L_R() { std::cout << "Line - Ray\n"; + + // no intersection + check_no_intersection (L(p( 2, -1), p( 2, 1)), R(p( 1, -3), p( 1, 3))); + + // point intersection check_intersection (L(p( 2, -1), p( 2, 1)), R(p( 1, 3), p( 2, 3)), P(2, 3)); check_intersection (L(p( 0, -1), p( 10, 0)), R(p( 2, 1), p( 8, -6)), P(3.42105, -0.657895)); check_intersection (L(p( 0, 0), p( 10, 0)), R(p( 1, 6), p( 1, -3)), P(1, 0)); + check_intersection (L(p( 0, 0), p( 4, 5)), R(p( 1, 8), p( 7, 2)), P(4, 5)); // ray starts on the line + + // ray intersection + check_intersection (L(p( 2, -1), p( 2, 1)), R(p( 2, -3), p( 2, 3))); + check_intersection (L(p( 2, -1), p( 2, 1)), R(p( 2, 3), p( 2, -3))); // opposite direction } void S_L() { std::cout << "Segment - Line\n"; + + // no intersection check_no_intersection (S(p( 2, -1), p( 2, 1)), L(p( 1, 3), p( 2, 3))); + + // point intersection check_intersection (S(p( 0, -1), p( 10, 0)), L(p( 2, 1), p( 8, -6)), P(3.42105, -0.657895)); check_intersection (S(p( 0, 0), p( 10, 0)), L(p( 1, 6), p( 1, -3)), P(1, 0)); + check_intersection (S(p( 0, 0), p( 10, 0)), L(p( 1, 6), p( 2, 12)), P(0, 0)); + + // segment intersection + check_intersection (S(p(-3, 5), p( 12, 1)), L(p( 12, 1), p( 27, -3))); + check_intersection (S(p(-3, 5), p( 12, 1)), L(p(-18, 9), p( 27, -3))); + check_intersection (S(p(-3, 5), p( 12, 1)), L(p( 27, -3), p(-18, 9))); } void T_T() { std::cout << "Triangle - Triangle\n"; + + // no intersection + check_no_intersection (T(p( -10,-10), p( 0, 10), p( 20, -5)), T(p( 90, -10), p(100, 10), p(120, -5))); + + // point intersection + check_intersection (T(p( -10, 0), p( 10, 0), p(0, 3)), T(p( -12, 3), p( 12, 3), p(1, 5)), P(0, 3)); // intersection on an edge + check_intersection (T(p( -25, -4), p( 13, -18), p(0, 3)), T(p( -12, 5), p( 12, 5), p(0, 3)), P(0, 3)); // intersection at a vertex + + // segment intersection check_intersection (T(p( -10, 0), p( 10, 0), p(0, -3)), T(p( -8, 0), p( 12, 0), p(1, 5))); check_intersection (T(p( -10, 0), p( 10, 0), p(0, -3)), T(p( -8, 0), p( 8, 0), p(1, 5))); + check_intersection (T(p( -10, 0), p( 10, 0), p(0, -3)), T(p( -10, 0), p( 10, 0), p(1, 5))); + check_intersection (T(p( -10, 0), p( 10, 0), p(0, -3)), T(p( 10, 0), p(-10, 0), p(1, 5))); + check_intersection (T(p( -10, 0), p( 10, 0), p(0, -3)), T(p( -10, 0), p( 10, 0), p(1, 5))); check_intersection (T(p( -10, 0), p( 10, 0), p(0, -3)), T(p( -12, 0), p( 12, 0), p(1, 5))); - check_intersection (T(p( -10, 0), p( 10, 0), p(0, 3)), T(p( -12, 3), p( 12, 3), p(1, 5)), P(0, 3)); + + // triangle intersection + check_intersection (T(p( 0, 10), p(-10, -10), p( 20, -5)), T(p( -10, -10), p( 0, 10), p( 20, -5))); + check_intersection (T(p( -12, 1), p( 5, 3), p( -7, -15)), T(p( 29, -2), p( 0, -13), p(1, 21))); + + // polygon intersection Pol pol0; pol0.push_back(P(-6, -4)); pol0.push_back(P( -5.11111, -0.222222 )); pol0.push_back(P( 0, 10 )); pol0.push_back(P( 8, 4 )); check_intersection (T(p( 0, 10), p(-10, -10), p( 20, -5)), T(p( 2, 30), p( -6, -4), p(15, 8)), pol0, false); - check_intersection (T(p( -12, 1), p( 5, 3), p( -7, -15)), T(p( 29, -2), p( 0, -13), p(1, 21))); + Pol pol1; pol1.push_back(P( 8, 4)); pol1.push_back(P( 0, 10 )); pol1.push_back(P( -5.11111, -0.222222 )); pol1.push_back(P(-6, -4)); check_intersection (T(p( -10,-10), p( 0, 10), p( 20, -5)), T(p( 2, 30), p( -6, -4), p(15, 8)), pol1, false); + Pol pol2; pol2.push_back(P( 10.2222, 2.33333 )); pol2.push_back(P( 1.96923, 8.52308 )); @@ -235,17 +331,24 @@ check_no_intersection (L(p(0, 0), p(10,10)), L(p(8,7), p(1, 0))); pol2.push_back(P( -3.96178, -8.99363 )); pol2.push_back(P( 3.5, -7.75 )); check_intersection (T(p( -10,-10), p( 0, 10), p( 20, -5)), T(p( -9, 9), p( 14, 8), p(-2, -16)), pol2, false); - check_no_intersection (T(p( -10,-10), p( 0, 10), p( 20, -5)), T(p( 90, -10), p(100, 10), p(120, -5))); } void L_T() { std::cout << "Line - Triangle\n"; + + // no intersection + check_no_intersection (L(p(-10, 0), p( 10, 0)), T(p( -12, 3), p( 12, 3), p(1, 5))); + + // point intersection + check_intersection

(L(p( -8, 30), p( 8, 30)), T(p( 2, 30), p( 14, 2), p(-7, -2))); + check_intersection

(L(p( -8, 30), p( -7, 30)), T(p( 2, 30), p( 14, 2), p(-7, -2))); + + // segment intersection check_intersection (L(p( -1, -1), p( 0, -1)), T(p( -10, 0), p( 10, 0), p(0, -4))); check_intersection (L(p( -1, -1), p( 0, -1)), T(p( -10, 0), p( 15, 2), p(0, -4))); check_intersection (L(p(-10, 0), p( 10, 0)), T(p( -8, 0), p( 8, 0), p(1, 5))); check_intersection (L(p(-10, 0), p( 10, 0)), T(p( -12, 0), p( 12, 0), p(1, 5))); - check_no_intersection (L(p(-10, 0), p( 10, 0)), T(p( -12, 3), p( 12, 3), p(1, 5))); check_intersection (L(p( 0, 10), p(-10, -10)), T(p( 2, 30), p( -6, -4), p(15, 8))); check_intersection (L(p(-12, 1), p( 5, 3)), T(p( 29, -2), p( 0, -13), p( 1, 21))); check_intersection (L(p(-10, -10), p( 0, 10)), T(p( 2, 30), p( -6, -4), p(15, 8))); @@ -255,11 +358,21 @@ check_no_intersection (L(p(0, 0), p(10,10)), L(p(8,7), p(1, 0))); void R_T() { std::cout << "Ray - Triangle\n"; + + // no intersection + check_no_intersection (R(p(-10, 0), p( 10, 0)), T(p( -12, 3), p( 12, 3), p(1, 5))); + + // point intersection + check_intersection

(R(p(-2, -16), p( 4, -20)), T(p( -9, 9), p( 14, 8), p(-2, -16))); + check_intersection

(R(p(-8, -1), p( -8, -12)), T(p( -12, 2), p( 10, 3), p(-4, -4))); + check_intersection

(R(p(-8, 30), p( 4, 30)), T(p( 2, 30), p( 14, 2), p(-7, -2))); + check_intersection

(R(p(-8, 30), p( -7, 30)), T(p( 2, 30), p( 14, 2), p(-7, -2))); + + // segment intersection check_intersection (R(p( -1, -1), p( 0, -1)), T(p( -10, 0), p( 10, 0), p(0, -4))); check_intersection (R(p( -1, -1), p( 0, -1)), T(p( -10, 0), p( 15, 2), p(0, -4))); check_intersection (R(p(-10, 0), p( 10, 0)), T(p( -8, 0), p( 8, 0), p(1, 5))); check_intersection (R(p(-10, 0), p( 10, 0)), T(p( -12, 0), p( 12, 0), p(1, 5))); - check_no_intersection (R(p(-10, 0), p( 10, 0)), T(p( -12, 3), p( 12, 3), p(1, 5))); check_intersection (R(p( 0, 10), p(-10, -10)), T(p( 2, 30), p( -6, -4), p(15, 8))); check_intersection (R(p(-12, 1), p( 5, 3)), T(p( 29, -2), p( 0, -13), p( 1, 21))); check_intersection (R(p(-10, -10), p( 0, 10)), T(p( 2, 30), p( -6, -4), p(15, 8))); @@ -269,12 +382,22 @@ check_no_intersection (L(p(0, 0), p(10,10)), L(p(8,7), p(1, 0))); void S_T() { std::cout << "Segment - Triangle\n"; - check_intersection (S(p( -1, -1), p( 0, -1)), T(p( -10, 0), p( 10, 0), p(0, -4))); + + // no intersection check_no_intersection (S(p(-10, -10), p( 0, 10)), T(p( 90, -10), p( 100, 10), p(120, -5))); + check_no_intersection (S(p(-10, 0), p( 10, 0)), T(p( -12, 3), p( 12, 3), p(1, 5))); + + // point intersection + check_intersection

(S(p(-2, -16), p( 4, -20)), T(p( -9, 9), p( 14, 8), p(-2, -16))); + check_intersection

(S(p(-8, -1), p( -8, -12)), T(p( -12, 2), p( 10, 3), p(-4, -4))); + check_intersection

(S(p(-8, -12), p( -8, -1)), T(p( -12, 2), p( 10, 3), p(-4, -4))); + check_intersection

(S(p(-8, 30), p( 1, 30)), T(p( -2, 30), p( 14, 2), p(-7, -2))); + + // segment intersection + check_intersection (S(p( -1, -1), p( 0, -1)), T(p( -10, 0), p( 10, 0), p(0, -4))); check_intersection (S(p( -1, -1), p( 0, -1)), T(p( -10, 0), p( 15, 2), p(0, -4))); check_intersection (S(p(-10, 0), p( 10, 0)), T(p( -8, 0), p( 8, 0), p(1, 5))); check_intersection (S(p(-10, 0), p( 10, 0)), T(p( -12, 0), p( 12, 0), p(1, 5))); - check_no_intersection (S(p(-10, 0), p( 10, 0)), T(p( -12, 3), p( 12, 3), p(1, 5))); check_intersection (S(p( 0, 10), p(-10, -10)), T(p( 2, 30), p( -6, -4), p(15, 8))); check_intersection (S(p(-12, 1), p( 5, 3)), T(p( 29, -2), p( 0, -13), p( 1, 21))); check_intersection (S(p(-10, -10), p( 0, 10)), T(p( 2, 30), p( -6, -4), p(15, 8))); @@ -284,52 +407,131 @@ check_no_intersection (L(p(0, 0), p(10,10)), L(p(8,7), p(1, 0))); void P_T() { std::cout << "Point - Triangle\n"; + + // no intersection + check_no_intersection (p( 8, 6), T(p( 4, 0), p( 12, 4), p(-4, 8))); + + // point intersection check_intersection

(p( 8, 4), T(p( 4, 0), p( 12, 4), p(-4, 8))); check_intersection

(p( 8, 5), T(p( 4, 0), p( 12, 4), p(-4, 8))); - check_no_intersection (p( 8, 6), T(p( 4, 0), p( 12, 4), p(-4, 8))); + check_intersection

(p( 4, 0), T(p( 4, 0), p( 12, 4), p(-4, 8))); + check_intersection

(p( 12, 4), T(p( 4, 0), p( 12, 4), p(-4, 8))); + check_intersection

(p( -4, 8), T(p( 4, 0), p( 12, 4), p(-4, 8))); } void L_Rec() { std::cout << "Line - Iso_rectangle\n"; - check_intersection (L(p( 18, 6), p(0, 0)), Rec(p( 2, 0), p( 6, 3))); + + // no intersection + check_no_intersection (L(p( 18, 6), p( 16, 4)), Rec(p( 2, 0), p(6, 3))); + + // point intersection + check_intersection (L(p( -1, 0), p( 4, 5)), Rec(p( 0, 0), p(1, 1)), P(0, 1)); + check_intersection

(L(p( -5, 10), p(-1, -12)), Rec(p(-3, -1), p(2, 14))); + + // segment intersection + check_intersection (L(p( 18, 6), p( 0, 0)), Rec(p( 2, 0), p(6, 3))); + check_intersection (L(p( 18, 6), p( 0, 0)), Rec(p( 2, 0), p(6, 3))); + check_intersection (L(p( 2, 14), p( 2, -14)), Rec(p( 2, 0), p(6, 3))); + check_intersection (L(p( 6, 1), p( 6, 2)), Rec(p( 2, 0), p(6, 3))); + check_intersection (L(p(-1, 3), p(-2, 3)), Rec(p( 2, 0), p(6, 3))); } void R_Rec() { std::cout << "Ray - Iso_rectangle\n"; - check_intersection (R(p( 18, 6), p(0, 0)), Rec(p( 2, 0), p( 6, 3))); + + // no intersection + check_no_intersection (R(p( 18, 6), p( 16, 4)), Rec(p( 2, 0), p(6, 3))); + + // point intersection + check_intersection (R(p( -1, 0), p( 4, 5)), Rec(p( 0, 0), p(1, 1)), P(0, 1)); + check_intersection (R(p( 0, 2), p(-4, 14)), Rec(p( 0, 0), p(5, 2)), P(0, 2)); + check_intersection

(R(p( -5, 10), p(-1, -12)), Rec(p(-3, -1), p(2, 14))); + + // segment intersection + check_intersection (R(p( 18, 6), p( 0, 0)), Rec(p( 2, 0), p(6, 3))); + check_intersection (R(p( 2, 14), p( 2, -14)), Rec(p( 2, 0), p(6, 3))); + check_intersection (R(p( 2, 1), p( 2, 4)), Rec(p( 2, 0), p(6, 3))); + check_intersection (R(p(-2, 3), p(-1, 3)), Rec(p( 2, 0), p(6, 3))); } void S_Rec() { std::cout << "Segment - Iso_rectangle\n"; - check_intersection (S(p( 18, 6), p(0, 0)), Rec(p( 2, 0), p( 6, 3))); + + // no intersection + check_no_intersection (S(p( 18, 6), p( 16, 4)), Rec(p( 2, 0), p(6, 3))); + + // point intersection + check_intersection (S(p( -1, 0), p( 4, 5)), Rec(p( 0, 0), p(1, 1)), P(0, 1)); + check_intersection (S(p( 0, 2), p(-4, 14)), Rec(p( 0, 0), p(5, 2)), P(0, 2)); + check_intersection

(S(p( -5, 10), p(-1, -12)), Rec(p(-3, -1), p(2, 14))); + + // segment intersection + check_intersection (S(p( 18, 6), p( 0, 0)), Rec(p( 2, 0), p(6, 3))); + check_intersection (S(p( 2, 14), p( 2, -14)), Rec(p( 2, 0), p(6, 3))); + check_intersection (S(p( 6, 1), p( 6, 2)), Rec(p( 2, 0), p(6, 3))); + check_intersection (S(p(-2, 3), p( 6, 3)), Rec(p( 2, 0), p(6, 3))); } void Rec_Rec() { std::cout << "Iso_rectangle - Iso_rectangle\n"; + + // no intersection + check_no_intersection (Rec(p( -4, -12), p(12, 23)), Rec(p( -4, 24), p( 5, 26))); + check_no_intersection (Rec(p( -4, -12), p(12, 23)), Rec(p( 13, -24), p( 14, 15))); + + // point intersection + check_intersection (Rec(p( 10, 12), p(30, 40)), Rec(p( 30, 40), p( 31, 42))/*, p(30, 40)*/); + check_intersection (Rec(p( 10, 12), p(30, 40)), Rec(p( 30, -13), p( 33, 12))/*, p(30, 12)*/); + + // segment intersection + check_intersection (Rec(p( 3, 5), p(4, 6)), Rec(p( 2, 4), p( 6, 5))); + check_intersection (Rec(p( 3, 5), p(4, 6)), Rec(p( 1, 1), p( 3, 8))); + check_intersection (Rec(p( 3, 5), p(9, 9)), Rec(p( 1, 4), p( 3, 8))); + + // Iso rectangle intersection + check_intersection (Rec(p( 10, 12), p(30, 40))); check_intersection (Rec(p( 10, 12), p(30, 40)), Rec(p( 25, 40), p( 26, 103)), Rec(P(25, 40), P(26, 40))); } void T_Rec() { - std::cout << "Triangle Iso_rectangle\n"; + std::cout << "Triangle - Iso_rectangle\n"; + + // no intersection check_no_intersection (Rec(p( 10, 12), p(30, 40)), T(p( 4, 0), p( 12, 4), p(-4, 8))); - check_intersection(Rec(p( 0, 0), p(1, 1)), T(p( -1, 0), p( -1, 2), p(2, 2))); - check_intersection(Rec(p( 0, 0), p(1, 1)), T(p( -1, 0), p(2, 2), p( -1, 2))); - check_intersection(Rec(p( 0, 0), p(1, 1)), T(p( -1, -2), p( -1, 2), p(5, 2))); - check_intersection(Rec(p( 0, 0), p(2, 2)), T(p( 0, 0), p( 1, 0), p(0, 1))); - check_intersection(Rec(p( 0, 0), p(3, 3)), T(p( 1, 1), p( 2, 1), p(1, 2))); - check_intersection

(Rec(p( 0, 0), p(1, 1)), T(p( -1, 0), p( 0, 0), p(0, -1))); - check_intersection

(Rec(p( 0, 0), p(1, 1)), T(p( 0, 0), p( -1, 0), p(0, -1))); - check_intersection(Rec(p( 100, 100), p(200, 200)), T(p(150, 50), p(250, 170), p(50, 170))); + + // point intersection + check_intersection

(Rec(p( 0, 0), p(1, 1)), T(p( -1, 0), p( 0, 0), p( 0, -1))); // intersection at a vertex + check_intersection

(Rec(p( 0, 0), p(1, 1)), T(p( 0, 0), p( -1, 0), p( 0, -1))); // inversed triangle + check_intersection

(Rec(p( 0, 0), p(1, 1)), T(p( -1, 0), p( 2, 3), p(-4, 6))); // intersection on an edge of the triangle + check_intersection (Rec(p( 0, 0), p(3, 3)), T(p( -10, 0), p( 0, 2), p(-1, 4)), p(0, 2)); // intersection on an edge of the iso rectangle + + // segment intersection + check_intersection (Rec(p( 0, 0), p(3, 3)), T(p( -10, 0), p( 0, 0), p( 0, 3))); + check_intersection (Rec(p(-2, 2), p(3, 3)), T(p( -15, 12), p( -1, 3), p( 2, 3))); + check_intersection (Rec(p(-2, 2), p(3, 3)), T(p( -15, 12), p( -4, 3), p( 2, 3))); + check_intersection (Rec(p(-2, 2), p(3, 3)), T(p( -15, 12), p( -4, 3), p( 15, 3))); + + // triangle intersection + check_intersection (Rec(p( 0, 0), p(1, 1)), T(p( -1, 0), p( -1, 2), p( 2, 2))); + check_intersection (Rec(p( 0, 0), p(1, 1)), T(p( -1, 0), p( 2, 2), p( -1, 2))); + check_intersection (Rec(p( 0, 0), p(2, 2)), T(p( 0, 0), p( 1, 0), p( 0, 1))); + check_intersection (Rec(p( 0, 0), p(3, 3)), T(p( 1, 1), p( 2, 1), p( 1, 2))); + + // polygon intersection + check_intersection(Rec(p( 0, 0), p( 1, 1)), T(p( -1, -2), p( -1, 2), p( 5, 2))); + check_intersection(Rec(p( 100, 100), p(200, 200)), T(p(150, 50), p(250, 170), p(50, 170))); } void run() { - std::cout << "2D Intersection tests\n"; + std::cout << "2D Intersection tests with Kernel: " << typeid(K).name() << std::endl; + L_L(); S_S(); R_R(); @@ -341,18 +543,20 @@ check_no_intersection (L(p(0, 0), p(10,10)), L(p(8,7), p(1, 0))); R_T(); S_T(); P_T(); + L_Rec(); R_Rec(); S_Rec(); Rec_Rec(); T_Rec(); } - }; int main() { - Test< CGAL::Cartesian >().run(); - Test< CGAL::Homogeneous >().run(); - // TODO : test more kernels. + Test< CGAL::Simple_cartesian::Type > >().run(); + Test< CGAL::Cartesian >().run(); + Test< CGAL::Homogeneous >().run(); + Test< CGAL::Exact_predicates_inexact_constructions_kernel >().run(); + Test< CGAL::Exact_predicates_exact_constructions_kernel >().run(); } From c342a88440d7733317895fb200c82e2df109af20 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 16 May 2019 14:31:48 +0200 Subject: [PATCH 082/203] Fix c3t3 loading --- .../Plugins/AABB_tree/Cut_plugin.cpp | 28 +++++++++++-------- .../demo/Polyhedron/Scene_c3t3_item.cpp | 15 ++++++++-- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp index 4ac25e6eee9..7cdc88c9a74 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp @@ -791,12 +791,13 @@ class Polyhedron_demo_cut_plugin : Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: Polyhedron_demo_cut_plugin() : QObject(), edges_item(0) { } - virtual ~Polyhedron_demo_cut_plugin(); + ~Polyhedron_demo_cut_plugin(); bool applicable(QAction*) const { // returns true if one surface_mesh is in the entries @@ -808,29 +809,30 @@ public: return false; } - virtual QString name() const + QString name() const { return "cut-plugin"; } - virtual QString nameFilters() const + QString nameFilters() const { return "Segment soup file (*.polylines.txt *.cgal)"; } - bool canLoad() const + bool canLoad(QFileInfo) const { return false; } - virtual CGAL::Three::Scene_item* load(QFileInfo /* fileinfo */) + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) { - return 0; + ok = false; + return QList(); } - virtual bool canSave(const CGAL::Three::Scene_item* item) + bool canSave(const CGAL::Three::Scene_item* item) { // This plugin supports edges items bool b = qobject_cast(item) != 0; @@ -838,8 +840,10 @@ public: } - virtual bool save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) - { // This plugin supports edges items + bool save(QFileInfo fileinfo,QList& items) + { + Scene_item* item = items.front(); + // This plugin supports edges items const Scene_edges_item* edges_item = qobject_cast(item); @@ -848,8 +852,10 @@ public: } std::ofstream out(fileinfo.filePath().toUtf8()); - - return (out && edges_item->save(out)); + bool ok = (out && edges_item->save(out)); + if(ok) + items.pop_front(); + return ok; } void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index 8a79e3fe427..7834bca3dd6 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -1633,14 +1633,23 @@ void Scene_c3t3_item::show_intersection(bool b) d->intersection->setName("Intersection tetrahedra"); d->intersection->setRenderingMode(renderingMode()); connect(d->intersection, SIGNAL(destroyed()), this, SLOT(reset_intersection_item())); - scene->addItem(d->intersection); - scene->changeGroup(d->intersection, this); - lockChild(d->intersection); + BOOST_FOREACH(auto v, CGAL::QGLViewer::QGLViewerPool()) { CGAL::Three::Viewer_interface* viewer = static_cast(v); d->are_intersection_buffers_filled[viewer] = false; + if(!d->areInterBufFilled(viewer)) + { + //initGL + Scene_c3t3_item* ncthis = const_cast(this); + ncthis->d->computeIntersections(viewer); + d->are_intersection_buffers_filled[viewer] = true; + ncthis->show_intersection(true); + } } + scene->addItem(d->intersection); + scene->changeGroup(d->intersection, this); + lockChild(d->intersection); } else if (!b && d->intersection!=NULL) { From 621542afbd2532190e0ecacc71bc8de36e685bba Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 16 May 2019 15:10:40 +0200 Subject: [PATCH 083/203] Add Epick_without_intervals That `Epick` without the dynamic filters: only the static filters are applied before the exact computation. --- Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp | 2 +- .../test/Convex_hull_3/test_halfspace_intersections.cpp | 2 ++ .../CGAL/Exact_predicates_inexact_constructions_kernel.h | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp b/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp index 0e9f60afdbd..d217ee357d2 100644 --- a/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp +++ b/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp @@ -14,7 +14,7 @@ #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Epick_without_intervals K; typedef CGAL::Polyhedron_3 Polyhedron_3; typedef K::Point_3 Point_3; diff --git a/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp b/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp index 385236066d9..623dec0cc25 100644 --- a/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp +++ b/Convex_hull_3/test/Convex_hull_3/test_halfspace_intersections.cpp @@ -81,4 +81,6 @@ int main() test >(); test >(); test >(); + test >(); } diff --git a/Kernel_23/include/CGAL/Exact_predicates_inexact_constructions_kernel.h b/Kernel_23/include/CGAL/Exact_predicates_inexact_constructions_kernel.h index d30bcd7adca..0677d285d24 100644 --- a/Kernel_23/include/CGAL/Exact_predicates_inexact_constructions_kernel.h +++ b/Kernel_23/include/CGAL/Exact_predicates_inexact_constructions_kernel.h @@ -45,6 +45,12 @@ class Epick #endif {}; +class Epick_without_intervals + : public Static_filters_base< + Type_equality_wrapper< Simple_cartesian::Base::Type, + Epick_without_intervals > > +{}; + typedef Epick Exact_predicates_inexact_constructions_kernel; template <> From 0c7ba063a6f8d525b5d893411188de0cf30de670 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 16 May 2019 15:24:02 +0200 Subject: [PATCH 084/203] Add override in cut_plugin --- .../Plugins/AABB_tree/Cut_plugin.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp index 7cdc88c9a74..d1472428108 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp @@ -799,7 +799,7 @@ public: ~Polyhedron_demo_cut_plugin(); - bool applicable(QAction*) const { + bool applicable(QAction*) const Q_DECL_OVERRIDE{ // returns true if one surface_mesh is in the entries for (int i=0; i< scene->numberOfEntries(); ++i) { @@ -809,30 +809,31 @@ public: return false; } - QString name() const + QString name() const Q_DECL_OVERRIDE { return "cut-plugin"; } - QString nameFilters() const + QString nameFilters() const Q_DECL_OVERRIDE { return "Segment soup file (*.polylines.txt *.cgal)"; } - bool canLoad(QFileInfo) const + bool canLoad(QFileInfo) const Q_DECL_OVERRIDE { return false; } - QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) Q_DECL_OVERRIDE + { ok = false; return QList(); } - bool canSave(const CGAL::Three::Scene_item* item) + bool canSave(const CGAL::Three::Scene_item* item) Q_DECL_OVERRIDE { // This plugin supports edges items bool b = qobject_cast(item) != 0; @@ -840,7 +841,7 @@ public: } - bool save(QFileInfo fileinfo,QList& items) + bool save(QFileInfo fileinfo,QList& items) Q_DECL_OVERRIDE { Scene_item* item = items.front(); // This plugin supports edges items @@ -859,10 +860,10 @@ public: } void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, - Messages_interface* m); - QList actions() const; + Messages_interface* m) Q_DECL_OVERRIDE; + QList actions() const Q_DECL_OVERRIDE; - bool eventFilter(QObject *, QEvent *event) + bool eventFilter(QObject *, QEvent *event) Q_DECL_OVERRIDE { if(!plane_item) return false; From 162544dade187954dce6b1e0c352cb6b38d9a25b Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 16 May 2019 15:27:46 +0200 Subject: [PATCH 085/203] Add a test of Epick_without_intervals in Kernel_23 --- Kernel_23/test/Kernel_23/Simple_cartesian.cpp | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/Kernel_23/test/Kernel_23/Simple_cartesian.cpp b/Kernel_23/test/Kernel_23/Simple_cartesian.cpp index 10d2e4a2fd6..71900f364a5 100644 --- a/Kernel_23/test/Kernel_23/Simple_cartesian.cpp +++ b/Kernel_23/test/Kernel_23/Simple_cartesian.cpp @@ -22,6 +22,7 @@ #include +#include #include #include @@ -46,30 +47,26 @@ #include "CGAL/_test_mf_plane_3_to_2d.h" -int -main() -{ - typedef CGAL::Simple_cartesian Clsd; - std::cout << "Testing IO with Simple_cartesian :" << std::endl; - _test_io( Clsd() ); +#include - typedef CGAL::Simple_cartesian > Cls; - std::cout << "Testing 2d with Simple_cartesian> :"; +template +void test_kernel(std::string kernel_name, Cls) { + std::cout << "Testing 2d with "+kernel_name+" :"; std::cout << std::endl; _test_2( Cls() ); - std::cout << "Testing 3d with Simple_cartesian> :"; + std::cout << "Testing 3d with "+kernel_name+" :"; std::cout << std::endl; _test_3( Cls() ); - std::cout << "Testing new 2d with Simple_cartesian>:"; + std::cout << "Testing new 2d with "+kernel_name+" :"; std::cout << std::endl; test_new_2( Cls() ); - std::cout << "Testing new 3d with Simple_cartesian>:"; + std::cout << "Testing new 3d with "+kernel_name+" :"; std::cout << std::endl; test_new_3( Cls() ); - std::cout << "Testing new parts with Simple_cartesian> :"; + std::cout << "Testing new parts with "+kernel_name+" :"; std::cout << std::endl; _test_orientation_and_bounded_side( Cls() ); _test_fct_points_implicit_sphere( Cls() ); @@ -80,9 +77,21 @@ main() _test_cls_iso_cuboid_3( Cls() ); _test_angle( Cls() ); - std::cout << "Testing 3d-2d with Simple_cartesian>:"; + std::cout << "Testing 3d-2d with "+kernel_name+" :"; std::cout << std::endl; _test_mf_plane_3_to_2d( Cls() ); +} +int +main() +{ + typedef CGAL::Simple_cartesian Clsd; + std::cout << "Testing IO with Simple_cartesian :" << std::endl; + _test_io( Clsd() ); + + typedef CGAL::Simple_cartesian > Cls; + test_kernel("Simple_cartesian>", Cls()); + typedef CGAL::Simple_cartesian > Cls; + test_kernel("Epick_without_intervals", CGAL::Epick_without_intervals()); return 0; } From 7105406ee11a08742b19d1f98518d2ba5ed9605c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 16 May 2019 15:27:35 +0200 Subject: [PATCH 086/203] Fix warnings with CGAL_USE --- .../include/CGAL/_test_cls_aff_transformation_2.h | 4 +++- .../include/CGAL/_test_cls_aff_transformation_3.h | 4 +++- .../Kernel_23/include/CGAL/_test_cls_direction_2.h | 4 +++- .../Kernel_23/include/CGAL/_test_cls_direction_3.h | 4 +++- .../test/Kernel_23/include/CGAL/_test_cls_line_3.h | 6 ++++-- .../test/Kernel_23/include/CGAL/_test_cls_plane_3.h | 10 ++++++---- .../test/Kernel_23/include/CGAL/_test_cls_point_2.h | 3 ++- .../test/Kernel_23/include/CGAL/_test_cls_point_3.h | 3 ++- .../test/Kernel_23/include/CGAL/_test_cls_vector_2.h | 4 +++- .../test/Kernel_23/include/CGAL/_test_cls_vector_3.h | 4 +++- 10 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h index 23aff3a4c96..86c8c4d8d6d 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_AFF_TRANSFORMATION_2_H #define CGAL__TEST_CLS_AFF_TRANSFORMATION_2_H +#include + template bool _test_cls_aff_transformation_2(const R& ) @@ -56,7 +58,7 @@ _test_cls_aff_transformation_2(const R& ) CGAL::Vector_2 tvec; CGAL::Point_2 pnt( n8, n1, n10 ); // ( 6,-5) CGAL::Point_2 tpnt; - CGAL::Point_2 pvec = CGAL::ORIGIN + vec; + CGAL::Point_2 pvec = CGAL::ORIGIN + vec; CGAL_USE(pvec); CGAL::Vector_2 vpnt = pnt - CGAL::ORIGIN; CGAL::Point_2 p1(-n3, n7, n3 ); // (-1, 2) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h index a186c20d14a..6a30e82c11d 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_AFF_TRANSFORMATION_3_H #define CGAL__TEST_CLS_AFF_TRANSFORMATION_3_H +#include + template bool _test_cls_aff_transformation_3(const R& ) @@ -56,7 +58,7 @@ _test_cls_aff_transformation_3(const R& ) CGAL::Vector_3 tvec; CGAL::Point_3 pnt( n8, n1, n9, n10 ); // ( 6,-5, 3) CGAL::Point_3 tpnt; - CGAL::Point_3 pvec = CGAL::ORIGIN + vec; + CGAL::Point_3 pvec = CGAL::ORIGIN + vec; CGAL_USE(pvec); CGAL::Vector_3 vpnt = pnt - CGAL::ORIGIN; CGAL::Point_3 p1(-n3, n7, n11, n3 ); // (-1, 2,-3) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_2.h index 07106cadb25..93800057c5c 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_DIRECTION_2_H #define CGAL__TEST_CLS_DIRECTION_2_H +#include + template bool _test_cls_direction_2(const R& ) @@ -34,7 +36,7 @@ _test_cls_direction_2(const R& ) typename R::Direction_2 id; CGAL::Direction_2 d0; - CGAL::Direction_2 d1(id); + CGAL::Direction_2 d1(id); CGAL_USE(d1); std::cout << '.'; RT n0 = 10; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_3.h index d25d0ad830d..afdb4cff38a 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_direction_3.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_DIRECTION_3_H #define CGAL__TEST_CLS_DIRECTION_3_H +#include + template bool _test_cls_direction_3(const R& ) @@ -35,7 +37,7 @@ _test_cls_direction_3(const R& ) typename R::Direction_3 id; CGAL::Direction_3 d0; - CGAL::Direction_3 d1(id); + CGAL::Direction_3 d1(id); CGAL_USE(d1); std::cout << '.'; RT n0 = 10; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h index af722474195..35190bc4742 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_LINE_3_H #define CGAL__TEST_CLS_LINE_3_H +#include + template bool _test_cls_line_3(const R& ) @@ -33,8 +35,8 @@ _test_cls_line_3(const R& ) typedef typename R::RT RT; typename R::Line_3 il; - CGAL::Line_3 l0( il ); - CGAL::Line_3 l1; + CGAL::Line_3 l0( il ); CGAL_USE(l0); + CGAL::Line_3 l1; CGAL_USE(l1); RT n1 = 3; RT n2 = 53; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_plane_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_plane_3.h index a62e3a2a22d..bf423e8bf09 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_plane_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_plane_3.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_PLANE_3_H #define CGAL__TEST_CLS_PLANE_3_H +#include + template bool _test_cls_plane_3(const R& ) @@ -34,7 +36,7 @@ _test_cls_plane_3(const R& ) typedef typename R::FT FT; typename R::Plane_3 ip; - CGAL::Plane_3 pl0(ip); + CGAL::Plane_3 pl0(ip); CGAL_USE(pl0); RT x1 = -1; RT x2 = 4; @@ -45,7 +47,7 @@ _test_cls_plane_3(const R& ) py(RT(0),RT(1),RT(0)), pz(RT(0),RT(0),RT(1)); - CGAL::Point_3 p3(p1); + CGAL::Point_3 p3(p1); CGAL_USE(p3); CGAL::Direction_3 d1( RT(5), RT(-5), RT(10) ); CGAL::Vector_3 v1 = d1.vector(); @@ -121,8 +123,8 @@ _test_cls_plane_3(const R& ) assert( xy_pl.has_on( gnup ) ); CGAL::Vector_3 nov = pl1.orthogonal_vector(); - CGAL::Vector_3 vb1 = pl1.base1(); - CGAL::Vector_3 vb2 = pl1.base2(); + CGAL::Vector_3 vb1 = pl1.base1(); CGAL_USE(vb1); + CGAL::Vector_3 vb2 = pl1.base2(); CGAL_USE(vb2); assert( (nov*pl1.base1()) == FT(0)&&(nov*pl1.base2()) == FT(0) ); assert( (pl1.base2()*pl1.base1()) == FT(0) ); assert( pl1.has_on(pl1.point() + pl1.base1()) ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_2.h index 802b5482037..6a5a6d4d967 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_2.h @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -49,7 +50,7 @@ _test_cls_point_2(const R& ) typedef typename R::Point_2::Cartesian_const_iterator CCI; CGAL::Point_2 p1; - CGAL::Point_2 p2(ip); + CGAL::Point_2 p2(ip); CGAL_USE(p2); CGAL::Point_2 p0(CGAL::ORIGIN); RT n1(-35 ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_3.h index a54a062e8db..45b61412639 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_point_3.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,7 @@ _test_cls_point_3(const R& ) typedef typename R::Point_3::Cartesian_const_iterator CCI; CGAL::Point_3 p1; - CGAL::Point_3 p2(ip); + CGAL::Point_3 p2(ip); CGAL_USE(p2); CGAL::Point_3 p0(CGAL::ORIGIN); RT n1(-35 ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_2.h index 0ea7a3f621f..8b4b1b5d6af 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_VECTOR_2_H #define CGAL__TEST_CLS_VECTOR_2_H +#include + template bool _test_cls_vector_2(const R& ) @@ -37,7 +39,7 @@ _test_cls_vector_2(const R& ) typedef typename R::Vector_2::Cartesian_const_iterator CCI; CGAL::Vector_2 v1; - CGAL::Vector_2 v2(iv); + CGAL::Vector_2 v2(iv); CGAL_USE(v2); CGAL::Vector_2 v0(CGAL::NULL_VECTOR); RT n1( 12 ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_3.h index e2b35fab772..7477b855d28 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_vector_3.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_VECTOR_3_H #define CGAL__TEST_CLS_VECTOR_3_H +#include + template bool _test_cls_vector_3(const R& ) @@ -37,7 +39,7 @@ _test_cls_vector_3(const R& ) typedef typename R::Vector_3::Cartesian_const_iterator CCI; CGAL::Vector_3 v1; - CGAL::Vector_3 v2(iv); + CGAL::Vector_3 v2(iv); CGAL_USE(v2); CGAL::Vector_3 v0(CGAL::NULL_VECTOR); RT n1( 12 ); From 4012cabb11698e17630940b52b48794aacd33361 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 16 May 2019 16:20:40 +0200 Subject: [PATCH 087/203] Fix Plane_items manipulation --- Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Volume_plane.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Volume_plane.h b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Volume_plane.h index eb720862a40..53796d48b86 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Volume_plane.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Volume_plane.h @@ -560,7 +560,7 @@ void Volume_plane::draw(Viewer_interface *viewer) const { template bool Volume_plane::eventFilter(QObject *sender, QEvent *event) { - CGAL::QGLViewer* viewer = qobject_cast(sender); + CGAL::Three::Viewer_interface* viewer = qobject_cast(sender); if(!viewer) return false; if(event->type() == QEvent::MouseButtonPress) From 80d1f3f18a0723b5ed4656a175aa9d99512c5b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 17 May 2019 12:14:43 +0200 Subject: [PATCH 088/203] Clean a bit Bbox_2_Ray/Line_2 do intersect files (but the code is still wrong) --- .../CGAL/Intersections_2/Bbox_2_Line_2.h | 283 ++++++++++++++--- .../CGAL/Intersections_2/Bbox_2_Ray_2.h | 293 +++++++++++++++--- .../Bbox_2_Line_2_intersection_impl.h | 211 ------------- .../internal/Ray_2_Bbox_2_intersection_impl.h | 209 ------------- 4 files changed, 495 insertions(+), 501 deletions(-) delete mode 100644 Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Line_2_intersection_impl.h delete mode 100644 Intersections_2/include/CGAL/Intersections_2/internal/Ray_2_Bbox_2_intersection_impl.h diff --git a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Line_2.h b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Line_2.h index c5804de228c..7c9a7ff55db 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Line_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Line_2.h @@ -33,70 +33,265 @@ #include namespace CGAL { +namespace Intersections { +namespace internal { -class Bbox_2_Line_2_pair_impl; +template +class Bbox_2_Line_2_pair; + +template +class Bbox_2_Line_2_pair_impl +{ + typedef typename K::Line_2 Line_2; -class CGAL_EXPORT Bbox_2_Line_2_pair { public: - enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; - Bbox_2_Line_2_pair() ; - Bbox_2_Line_2_pair(Bbox_2_Line_2_pair const &); - Bbox_2_Line_2_pair(Bbox_2 const &bbox, - double line_a, double line_b, double line_c); - ~Bbox_2_Line_2_pair() ; - Bbox_2_Line_2_pair &operator=(Bbox_2_Line_2_pair const &o); - // set_bbox(Bbox_2 const &bbox); - // set_line(double line_a, double line_b, double line_c); - Intersection_results intersection_type() const; - bool intersection(double &x, double &y) const; - bool intersection(double &x1, double &y1, double &x2, double &y2) const; -protected: - Bbox_2_Line_2_pair_impl *pimpl; + Bbox_2_Line_2_pair_impl() {} + Bbox_2_Line_2_pair_impl(const Bbox_2& bb, const Line_2& line) + : _bbox(bb), _line(line), _known(false) + {} + + Bbox_2 _bbox; + Line_2 _line; + + mutable bool _known; + mutable typename Bbox_2_Line_2_pair::Intersection_results _result; + mutable double _min, _max; }; -template -Bbox_2_Line_2_pair intersection_computer_line_2( - Bbox_2 const &bbox, Line const &line) +template +class Bbox_2_Line_2_pair { - return Bbox_2_Line_2_pair(bbox, to_double(line->a()), - to_double(line->b()), to_double(line->c())); + typedef Bbox_2_Line_2_pair Self; + + typedef typename K::Point_2 Point_2; + typedef typename K::Vector_2 Vector_2; + typedef typename K::Line_2 Line_2; + +public: + enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; + + Bbox_2_Line_2_pair() + { + pimpl = new Bbox_2_Line_2_pair_impl; + pimpl->_known = false; + } + Bbox_2_Line_2_pair(const Self& o) { pimpl = new Bbox_2_Line_2_pair_impl(*o.pimpl); } + Bbox_2_Line_2_pair(const Bbox_2& bbox, double line_a, double line_b, double line_c) { + pimpl = new Bbox_2_Line_2_pair_impl(bbox, Line_2(line_a, line_b, line_c)); + } + + ~Bbox_2_Line_2_pair() { delete pimpl; } + + Self& operator=(const Self& o) + { + *pimpl = *o.pimpl; + return *this; + } + + Intersection_results intersection_type() const + { + if (pimpl->_known) + return pimpl->_result; + + // The non const this pointer is used to cast away const. + pimpl->_known = true; + const Point_2 &ref_point = pimpl->_line.point(); + const Vector_2 &dir = pimpl->_line.direction().to_vector(); + bool to_infinity = true; + + // first on x value + if (dir.x() == 0.0) + { + if (ref_point.x() < pimpl->_bbox.xmin()) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + + if (ref_point.x() > pimpl->_bbox.xmax()) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + } + else + { + double newmin, newmax; + if (dir.x() > 0.0) + { + newmin = (pimpl->_bbox.xmin()-ref_point.x())/dir.x(); + newmax = (pimpl->_bbox.xmax()-ref_point.x())/dir.x(); + } + else + { + newmin = (pimpl->_bbox.xmax()-ref_point.x())/dir.x(); + newmax = (pimpl->_bbox.xmin()-ref_point.x())/dir.x(); + } + + if (to_infinity) + { + pimpl->_min = newmin; + pimpl->_max = newmax; + } + else + { + if (newmin > pimpl->_min) + pimpl->_min = newmin; + if (newmax < pimpl->_max) + pimpl->_max = newmax; + if (pimpl->_max < pimpl->_min) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + } + + to_infinity = false; + } + + // now on y value + if (dir.y() == 0.0) + { + if (ref_point.y() < pimpl->_bbox.ymin()) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + + if (ref_point.y() > pimpl->_bbox.ymax()) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + } + else + { + double newmin, newmax; + if (dir.y() > 0.0) + { + newmin = (pimpl->_bbox.ymin()-ref_point.y())/dir.y(); + newmax = (pimpl->_bbox.ymax()-ref_point.y())/dir.y(); + } + else + { + newmin = (pimpl->_bbox.ymax()-ref_point.y())/dir.y(); + newmax = (pimpl->_bbox.ymin()-ref_point.y())/dir.y(); + } + + if (to_infinity) + { + pimpl->_min = newmin; + pimpl->_max = newmax; + } + else + { + if (newmin > pimpl->_min) + pimpl->_min = newmin; + if (newmax < pimpl->_max) + pimpl->_max = newmax; + if (pimpl->_max < pimpl->_min) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + } + + to_infinity = false; + } + + CGAL_kernel_assertion(!to_infinity); + if (pimpl->_max == pimpl->_min) + { + pimpl->_result = POINT; + return pimpl->_result; + } + + pimpl->_result = SEGMENT; + return pimpl->_result; + } + + bool intersection(double& x, double& y) const + { + if (!pimpl->_known) + intersection_type(); + if (pimpl->_result != POINT) + return false; + + Point_2 pt(pimpl->_line.point() + pimpl->_min*pimpl->_line.direction().to_vector()); + x = pt.x(); + y = pt.y(); + + return true; + } + + bool intersection(double& x1, double& y1, double& x2, double& y2) const + { + if (!pimpl->_known) + intersection_type(); + if (pimpl->_result != SEGMENT) + return false; + + Point_2 p1(pimpl->_line.point() + pimpl->_min*pimpl->_line.direction().to_vector()); + Point_2 p2(pimpl->_line.point() + pimpl->_max*pimpl->_line.direction().to_vector()); + x1 = p1.x(); + y1 = p1.y(); + x2 = p2.x(); + y2 = p2.y(); + + return true; + } + +protected: + Bbox_2_Line_2_pair_impl *pimpl; +}; + +template +inline bool do_intersect_line_2(const Bbox_2 &box, double line_a, double line_b, double line_c, const K& k = K()) +{ + Bbox_2_Line_2_pair pair(box, line_a, line_b, line_c); + + return pair.intersection_type() != Bbox_2_Line_2_pair::NO_INTERSECTION; } -inline bool do_intersect_line_2( - const Bbox_2 &box, double line_a, double line_b, double line_c) +template +bool do_intersect_line_2(const Bbox_2& bbox, const Line_2& line, const K& k = K()) { - Bbox_2_Line_2_pair pair(box, line_a, line_b, line_c); - return pair.intersection_type() != Bbox_2_Line_2_pair::NO_INTERSECTION; + return do_intersect_line_2(bbox, to_double(line.a()), to_double(line.b()), to_double(line.c()), k); } -template -bool do_intersect_line_2( - Bbox_2 const &bbox, Line const &line) +template +bool do_intersect_line_2(const Line_2& line, const Bbox_2& bbox, const K& k = K()) { - return do_intersect_line_2(bbox, to_double(line->a()), - to_double(line->b()), to_double(line->c())); + return do_intersect_line_2(bbox, to_double(line.a()), to_double(line.b()), to_double(line.c()), k); } -template -bool do_intersect_line_2( - Line const &line, Bbox_2 const &bbox) +template +inline bool do_intersect(const typename K::Line_2& line, const Bbox_2& bbox, const K& k = K()) { - return do_intersect_line_2(bbox, to_double(line->a()), - to_double(line->b()), to_double(line->c())); + return do_intersect_line_2(bbox, line, k); } -template -inline bool do_intersect( - const Line_2 &line, - const Bbox_2 &box) +template +inline bool do_intersect(const Bbox_2& bbox, const typename K::Line_2& line, const K& k = K()) { - return do_intersect(box, line); + return do_intersect_line_2(bbox, line, k); +} + +} // namespace internal +} // namespace Intersections + +template +inline bool do_intersect(const Line_2& line, const Bbox_2& box) +{ + return Intersections::internal::do_intersect(box, line); +} + +template +inline bool do_intersect(const Bbox_2& box, const Line_2& line) +{ + return Intersections::internal::do_intersect(box, line); } } //namespace CGAL -#ifdef CGAL_HEADER_ONLY -#include -#endif // CGAL_HEADER_ONLY - #endif diff --git a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Ray_2.h b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Ray_2.h index 512f4779b2f..1912ac8ffae 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Ray_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Ray_2.h @@ -23,7 +23,6 @@ // // Author(s) : Geert-Jan Giezeman - #ifndef CGAL_INTERSECTIONS_BBOX_2_RAY_2_H #define CGAL_INTERSECTIONS_BBOX_2_RAY_2_H @@ -33,51 +32,271 @@ #include namespace CGAL { +namespace Intersections { +namespace internal { -class Bbox_2_Ray_2_pair_impl; +template +class Bbox_2_Ray_2_pair; + +template +class Bbox_2_Ray_2_pair_impl +{ + typedef typename K::Point_2 Point_2; + typedef typename K::Vector_2 Vector_2; + typedef typename K::Ray_2 Ray_2; -class CGAL_EXPORT Bbox_2_Ray_2_pair { public: - enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; - ~Bbox_2_Ray_2_pair() ; - Bbox_2_Ray_2_pair() ; - Bbox_2_Ray_2_pair(Bbox_2_Ray_2_pair const &o) ; - Bbox_2_Ray_2_pair(Bbox_2 const &box, - double x, double y, double dx, double dy) ; - Bbox_2_Ray_2_pair& operator=(Bbox_2_Ray_2_pair const &o) ; - Intersection_results intersection_type() const; - bool intersection(double &x, double &y) const; - bool intersection(double &x1, double &y1, double &x2, double &y2) const; -protected: - Bbox_2_Ray_2_pair_impl *pimpl; + Bbox_2_Ray_2_pair_impl():_known(false) {} + Bbox_2_Ray_2_pair_impl(const Bbox_2& bbox, + const Point_2& pt, + const Vector_2& dir) + :_box(bbox), _known(false), _ref_point(pt), _dir(dir), _min(0.0) + {} + + Ray_2 _ray; + Bbox_2 _box; + bool _known; + + typename Bbox_2_Ray_2_pair::Intersection_results _result; + Point_2 _ref_point; + Vector_2 _dir; + + double _min, _max; }; -CGAL_EXPORT bool do_intersect_ray_2( - const Bbox_2 &box, double x, double y, double dx, double dy); - -template -bool do_intersect_ray_2( - const Bbox_2 &box, - const Ray &ray) +template +class Bbox_2_Ray_2_pair { - double startx = to_double(ray->start().x()); - double starty = to_double(ray->start().y()); - double dx = to_double(ray->direction().to_vector().x()); - double dy = to_double(ray->direction().to_vector().y()); - return do_intersect_ray_2(box, startx, starty, dx, dy); + typedef Bbox_2_Ray_2_pair Self; + typedef typename K::Point_2 Point_2; + typedef typename K::Vector_2 Vector_2; + +public: + enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; + + ~Bbox_2_Ray_2_pair() { delete pimpl; } + Bbox_2_Ray_2_pair() { pimpl = new Bbox_2_Ray_2_pair_impl; } + Bbox_2_Ray_2_pair(const Self& o) { pimpl = new Bbox_2_Ray_2_pair_impl(*o.pimpl); } + Bbox_2_Ray_2_pair(Bbox_2 const &bbox, double x, double y, double dx, double dy) { + pimpl = new Bbox_2_Ray_2_pair_impl(bbox, Point_2(x,y), Vector_2(dx,dy)); + } + + Self& operator=(const Self& o) + { + *pimpl = *o.pimpl; + return *this; + } + + Intersection_results intersection_type() const + { + if(pimpl->_known) + return pimpl->_result; + + pimpl->_known = true; + bool to_infinity = true; + + // first on x value + if(pimpl->_dir.x() == 0.0) + { + if(pimpl->_ref_point.x() < pimpl->_box.xmin()) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + + if(pimpl->_ref_point.x() > pimpl->_box.xmax()) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + } + else + { + double newmin, newmax; + if(pimpl->_dir.x() > 0.0) + { + newmin =(pimpl->_box.xmin()-pimpl->_ref_point.x())/pimpl->_dir.x(); + newmax =(pimpl->_box.xmax()-pimpl->_ref_point.x())/pimpl->_dir.x(); + } + else + { + newmin =(pimpl->_box.xmax()-pimpl->_ref_point.x())/pimpl->_dir.x(); + newmax =(pimpl->_box.xmin()-pimpl->_ref_point.x())/pimpl->_dir.x(); + } + + if(newmin > pimpl->_min) + pimpl->_min = newmin; + + if(to_infinity) + { + pimpl->_max = newmax; + } + else + { + if(newmax < pimpl->_max) + pimpl->_max = newmax; + } + + if(pimpl->_max < pimpl->_min) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + + to_infinity = false; + } + + // now on y value + if(pimpl->_dir.y() == 0.0) + { + if(pimpl->_ref_point.y() < pimpl->_box.ymin()) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + + if(pimpl->_ref_point.y() > pimpl->_box.ymax()) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + } + else + { + double newmin, newmax; + if(pimpl->_dir.y() > 0.0) + { + newmin =(pimpl->_box.ymin()-pimpl->_ref_point.y())/pimpl->_dir.y(); + newmax =(pimpl->_box.ymax()-pimpl->_ref_point.y())/pimpl->_dir.y(); + } + else + { + newmin =(pimpl->_box.ymax()-pimpl->_ref_point.y())/pimpl->_dir.y(); + newmax =(pimpl->_box.ymin()-pimpl->_ref_point.y())/pimpl->_dir.y(); + } + + if(newmin > pimpl->_min) + pimpl->_min = newmin; + + if(to_infinity) + { + pimpl->_max = newmax; + } + else + { + if(newmax < pimpl->_max) + pimpl->_max = newmax; + } + + if(pimpl->_max < pimpl->_min) + { + pimpl->_result = NO_INTERSECTION; + return pimpl->_result; + } + + to_infinity = false; + } + + CGAL_kernel_assertion(!to_infinity); + + if(pimpl->_max == pimpl->_min) + { + pimpl->_result = POINT; + return pimpl->_result; + } + + pimpl->_result = SEGMENT; + return pimpl->_result; + } + + bool intersection(double& x, double& y) const + { + if(!pimpl->_known) + intersection_type(); + + if(pimpl->_result != POINT) + return false; + + Point_2 pt = pimpl->_ref_point + pimpl->_min*pimpl->_dir; + x = pt.x(); + y = pt.y(); + + return true; + } + + bool intersection(double& x1, double& y1, double& x2, double& y2) const + { + if(!pimpl->_known) + intersection_type(); + + if(pimpl->_result != SEGMENT) + return false; + + Point_2 p1(pimpl->_ref_point + pimpl->_min*pimpl->_dir); + Point_2 p2(pimpl->_ref_point + pimpl->_max*pimpl->_dir); + x1 = p1.x(); + y1 = p1.y(); + x2 = p2.x(); + y2 = p2.y(); + + return true; + } + +protected: + Bbox_2_Ray_2_pair_impl* pimpl; +}; + +template +bool do_intersect_ray_2(const Bbox_2& bbox, double x, double y, double dx, double dy, const K& k) +{ + Bbox_2_Ray_2_pair pair(bbox, x, y, dx, dy); + return pair.intersection_type() != Bbox_2_Ray_2_pair::NO_INTERSECTION; } -template -inline bool do_intersect_ray_2( - const Ray &ray, - const Bbox_2 &box) +template +bool do_intersect_ray_2(const Bbox_2 &box, const Ray_2 &ray, const K& k = K()) { - return do_intersect_ray_2(box, ray); -} -} //namespace CGAL + double startx = to_double(ray.start().x()); + double starty = to_double(ray.start().y()); + double dx = to_double(ray.direction().to_vector().x()); + double dy = to_double(ray.direction().to_vector().y()); -#ifdef CGAL_HEADER_ONLY -#include -#endif // CGAL_HEADER_ONLY + return do_intersect_ray_2(box, startx, starty, dx, dy, k); +} + +template +inline bool do_intersect_ray_2(const Ray_2 &ray, const Bbox_2 &box, const K& k = K()) +{ + return do_intersect_ray_2(box, ray, k); +} + +template +inline bool do_intersect(const typename K::Ray_2& line, const Bbox_2& bbox, const K& k = K()) +{ + return do_intersect_ray_2(bbox, line, k); +} + +template +inline bool do_intersect(const Bbox_2& bbox, const typename K::Ray_2& line, const K& k = K()) +{ + return do_intersect_ray_2(bbox, line, k); +} + +} // namespace internal +} // namespace Intersections + +template +inline bool do_intersect(const Ray_2& line, const Bbox_2& box) +{ + return Intersections::internal::do_intersect(box, line); +} + +template +inline bool do_intersect(const Bbox_2& box, const Ray_2& line) +{ + return Intersections::internal::do_intersect(box, line); +} + +} // namespace CGAL #endif diff --git a/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Line_2_intersection_impl.h b/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Line_2_intersection_impl.h deleted file mode 100644 index 6ed36f37872..00000000000 --- a/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Line_2_intersection_impl.h +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright (c) 2000 -// 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 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$ -// SPDX-License-Identifier: LGPL-3.0+ -// -// -// Author(s) : Geert-Jan Giezeman - -#ifdef CGAL_HEADER_ONLY -#define CGAL_INLINE_FUNCTION inline -#else -#define CGAL_INLINE_FUNCTION -#endif - -#include -typedef CGAL::Simple_cartesian Lcart; - - -namespace CGAL { - -class Bbox_2_Line_2_pair_impl -{ -public: - Bbox_2_Line_2_pair_impl() {} - Bbox_2_Line_2_pair_impl(Bbox_2 const &bb, Lcart::Line_2 const &line) - : _bbox(bb), _line(line), _known(false) {} - Bbox_2 _bbox; - Lcart::Line_2 _line; - mutable bool _known; - mutable Bbox_2_Line_2_pair::Intersection_results _result; - mutable double _min, _max; -}; - -CGAL_INLINE_FUNCTION -Bbox_2_Line_2_pair::~Bbox_2_Line_2_pair() -{ - delete pimpl; -} - -CGAL_INLINE_FUNCTION -Bbox_2_Line_2_pair::Bbox_2_Line_2_pair() -{ - pimpl = new Bbox_2_Line_2_pair_impl; - pimpl->_known = false; -} - -CGAL_INLINE_FUNCTION -Bbox_2_Line_2_pair::Bbox_2_Line_2_pair(Bbox_2_Line_2_pair const &o) -{ - pimpl = new Bbox_2_Line_2_pair_impl(*o.pimpl); -} - -CGAL_INLINE_FUNCTION -Bbox_2_Line_2_pair::Bbox_2_Line_2_pair( - Bbox_2 const &bbox, double line_a, double line_b, double line_c) -{ - pimpl = new Bbox_2_Line_2_pair_impl(bbox, - Lcart::Line_2(line_a, line_b, line_c)); -} - -CGAL_INLINE_FUNCTION -Bbox_2_Line_2_pair & -Bbox_2_Line_2_pair::operator=(Bbox_2_Line_2_pair const &o) -{ - *pimpl = *o.pimpl; - return *this; -} - -CGAL_INLINE_FUNCTION -Bbox_2_Line_2_pair::Intersection_results -Bbox_2_Line_2_pair::intersection_type() const -{ - if (pimpl->_known) - return pimpl->_result; - // The non const this pointer is used to cast away const. - pimpl->_known = true; - const Lcart::Point_2 &ref_point = pimpl->_line.point(); - const Lcart::Vector_2 &dir = - pimpl->_line.direction().to_vector(); - bool to_infinity = true; -// first on x value - if (dir.x() == 0.0) { - if (ref_point.x() < pimpl->_bbox.xmin()) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - if (ref_point.x() > pimpl->_bbox.xmax()) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } else { - double newmin, newmax; - if (dir.x() > 0.0) { - newmin = (pimpl->_bbox.xmin()-ref_point.x())/dir.x(); - newmax = (pimpl->_bbox.xmax()-ref_point.x())/dir.x(); - } else { - newmin = (pimpl->_bbox.xmax()-ref_point.x())/dir.x(); - newmax = (pimpl->_bbox.xmin()-ref_point.x())/dir.x(); - } - if (to_infinity) { - pimpl->_min = newmin; - pimpl->_max = newmax; - } else { - if (newmin > pimpl->_min) - pimpl->_min = newmin; - if (newmax < pimpl->_max) - pimpl->_max = newmax; - if (pimpl->_max < pimpl->_min) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } - to_infinity = false; - } -// now on y value - if (dir.y() == 0.0) { - if (ref_point.y() < pimpl->_bbox.ymin()) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - if (ref_point.y() > pimpl->_bbox.ymax()) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } else { - double newmin, newmax; - if (dir.y() > 0.0) { - newmin = (pimpl->_bbox.ymin()-ref_point.y())/dir.y(); - newmax = (pimpl->_bbox.ymax()-ref_point.y())/dir.y(); - } else { - newmin = (pimpl->_bbox.ymax()-ref_point.y())/dir.y(); - newmax = (pimpl->_bbox.ymin()-ref_point.y())/dir.y(); - } - if (to_infinity) { - pimpl->_min = newmin; - pimpl->_max = newmax; - } else { - if (newmin > pimpl->_min) - pimpl->_min = newmin; - if (newmax < pimpl->_max) - pimpl->_max = newmax; - if (pimpl->_max < pimpl->_min) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } - to_infinity = false; - } - CGAL_kernel_assertion(!to_infinity); - if (pimpl->_max == pimpl->_min) { - pimpl->_result = POINT; - return pimpl->_result; - } - pimpl->_result = SEGMENT; - return pimpl->_result; -} - -CGAL_INLINE_FUNCTION -bool -Bbox_2_Line_2_pair::intersection( - double &x1, double &y1, double &x2, double &y2) const -{ - if (!pimpl->_known) - intersection_type(); - if (pimpl->_result != SEGMENT) - return false; - Lcart::Point_2 p1(pimpl->_line.point() - + pimpl->_min*pimpl->_line.direction().to_vector()); - Lcart::Point_2 p2(pimpl->_line.point() - + pimpl->_max*pimpl->_line.direction().to_vector()); - x1 = p1.x(); - y1 = p1.y(); - x2 = p2.x(); - y2 = p2.y(); - return true; -} - -CGAL_INLINE_FUNCTION -bool -Bbox_2_Line_2_pair::intersection( - double &x, double &y) const -{ - if (!pimpl->_known) - intersection_type(); - if (pimpl->_result != POINT) - return false; - Lcart::Point_2 pt(pimpl->_line.point() - + pimpl->_min*pimpl->_line.direction().to_vector()); - x = pt.x(); - y = pt.y(); - return true; -} - -} //namespace CGAL diff --git a/Intersections_2/include/CGAL/Intersections_2/internal/Ray_2_Bbox_2_intersection_impl.h b/Intersections_2/include/CGAL/Intersections_2/internal/Ray_2_Bbox_2_intersection_impl.h deleted file mode 100644 index 375fc396865..00000000000 --- a/Intersections_2/include/CGAL/Intersections_2/internal/Ray_2_Bbox_2_intersection_impl.h +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (c) 2000 -// 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 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$ -// SPDX-License-Identifier: LGPL-3.0+ -// -// -// Author(s) : Geert-Jan Giezeman - -#ifdef CGAL_HEADER_ONLY -#define CGAL_INLINE_FUNCTION inline -#else -#define CGAL_INLINE_FUNCTION -#endif - -#include -typedef CGAL::Simple_cartesian Rcart; - - -namespace CGAL { - -class Bbox_2_Ray_2_pair_impl -{ -public: - Bbox_2_Ray_2_pair_impl():_known(false) {} - Bbox_2_Ray_2_pair_impl(Bbox_2 const &bbox, Rcart::Point_2 const &pt, - Rcart::Vector_2 const &dir) - :_box(bbox), _known(false), _ref_point(pt), _dir(dir), _min(0.0) {} - Ray_2< Rcart > _ray; - Bbox_2 _box; - bool _known; - Bbox_2_Ray_2_pair::Intersection_results _result; - Rcart::Point_2 _ref_point; - Rcart::Vector_2 _dir; - double _min, _max; -}; - -CGAL_INLINE_FUNCTION -Bbox_2_Ray_2_pair::~Bbox_2_Ray_2_pair() -{ - delete pimpl; -} - -CGAL_INLINE_FUNCTION -Bbox_2_Ray_2_pair::Bbox_2_Ray_2_pair() -{ - pimpl = new Bbox_2_Ray_2_pair_impl; -} - -CGAL_INLINE_FUNCTION -Bbox_2_Ray_2_pair::Bbox_2_Ray_2_pair(Bbox_2_Ray_2_pair const &o) -{ - pimpl = new Bbox_2_Ray_2_pair_impl(*o.pimpl); -} - -CGAL_INLINE_FUNCTION -Bbox_2_Ray_2_pair::Bbox_2_Ray_2_pair( - Bbox_2 const &bbox, double x, double y, double dx, double dy) -{ - pimpl = new Bbox_2_Ray_2_pair_impl(bbox, - Rcart::Point_2(x,y), Rcart::Vector_2(dx,dy)); -} - -CGAL_INLINE_FUNCTION -Bbox_2_Ray_2_pair & -Bbox_2_Ray_2_pair::operator=(Bbox_2_Ray_2_pair const &o) -{ - *pimpl = *o.pimpl; - return *this; -} - -CGAL_INLINE_FUNCTION -Bbox_2_Ray_2_pair::Intersection_results -Bbox_2_Ray_2_pair::intersection_type() const -{ - if (pimpl->_known) - return pimpl->_result; - pimpl->_known = true; - bool to_infinity = true; -// first on x value - if (pimpl->_dir.x() == 0.0) { - if (pimpl->_ref_point.x() < pimpl->_box.xmin()) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - if (pimpl->_ref_point.x() > pimpl->_box.xmax()) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } else { - double newmin, newmax; - if (pimpl->_dir.x() > 0.0) { - newmin =(pimpl->_box.xmin()-pimpl->_ref_point.x())/pimpl->_dir.x(); - newmax =(pimpl->_box.xmax()-pimpl->_ref_point.x())/pimpl->_dir.x(); - } else { - newmin =(pimpl->_box.xmax()-pimpl->_ref_point.x())/pimpl->_dir.x(); - newmax =(pimpl->_box.xmin()-pimpl->_ref_point.x())/pimpl->_dir.x(); - } - if (newmin > pimpl->_min) - pimpl->_min = newmin; - if (to_infinity) { - pimpl->_max = newmax; - } else { - if (newmax < pimpl->_max) - pimpl->_max = newmax; - } - if (pimpl->_max < pimpl->_min){ - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - to_infinity = false; - } -// now on y value - if (pimpl->_dir.y() == 0.0) { - if (pimpl->_ref_point.y() < pimpl->_box.ymin()) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - if (pimpl->_ref_point.y() > pimpl->_box.ymax()) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } else { - double newmin, newmax; - if (pimpl->_dir.y() > 0.0) { - newmin =(pimpl->_box.ymin()-pimpl->_ref_point.y())/pimpl->_dir.y(); - newmax =(pimpl->_box.ymax()-pimpl->_ref_point.y())/pimpl->_dir.y(); - } else { - newmin =(pimpl->_box.ymax()-pimpl->_ref_point.y())/pimpl->_dir.y(); - newmax =(pimpl->_box.ymin()-pimpl->_ref_point.y())/pimpl->_dir.y(); - } - if (newmin > pimpl->_min) - pimpl->_min = newmin; - if (to_infinity) { - pimpl->_max = newmax; - } else { - if (newmax < pimpl->_max) - pimpl->_max = newmax; - } - if (pimpl->_max < pimpl->_min) { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - to_infinity = false; - } - CGAL_kernel_assertion(!to_infinity); - if (pimpl->_max == pimpl->_min) { - pimpl->_result = POINT; - return pimpl->_result; - } - pimpl->_result = SEGMENT; - return pimpl->_result; -} - -CGAL_INLINE_FUNCTION -bool Bbox_2_Ray_2_pair:: -intersection(double &x1, double &y1, double &x2, double &y2) const -{ - if (!pimpl->_known) - intersection_type(); - if (pimpl->_result != SEGMENT) - return false; - Rcart::Point_2 p1(pimpl->_ref_point + pimpl->_min*pimpl->_dir); - Rcart::Point_2 p2(pimpl->_ref_point + pimpl->_max*pimpl->_dir); - x1 = p1.x(); - y1 = p1.y(); - x2 = p2.x(); - y2 = p2.y(); - return true; -} - -CGAL_INLINE_FUNCTION -bool Bbox_2_Ray_2_pair::intersection(double &x, double &y) const -{ - if (!pimpl->_known) - intersection_type(); - if (pimpl->_result != POINT) - return false; - Rcart::Point_2 pt = pimpl->_ref_point + pimpl->_min*pimpl->_dir; - x = pt.x(); - y = pt.y(); - return true; -} - -CGAL_INLINE_FUNCTION -bool do_intersect_ray_2( - const Bbox_2 &box, double x, double y, double dx, double dy) -{ - Bbox_2_Ray_2_pair pair(box, x, y, dx, dy); - return pair.intersection_type() != Bbox_2_Ray_2_pair::NO_INTERSECTION; -} - -} //namespace CGAL From 58c894ed5e81ee5d9b11756b14458497c0870e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 17 May 2019 12:15:22 +0200 Subject: [PATCH 089/203] Add missing free function for Bbox_2 Point_2 intersection --- .../CGAL/Intersections_2/Bbox_2_Point_2.h | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Point_2.h b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Point_2.h index 5df79996e48..c047a36474c 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Point_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Point_2.h @@ -29,29 +29,29 @@ #include namespace CGAL { - -template -bool do_intersect(const CGAL::Bbox_2& a, - const Point_2& b) -{ - Point_2 bl(a.xmin(), a.ymin()), tr(a.xmax(), a.ymax()); - - Iso_rectangle_2 ic(bl,tr); - return K().do_intersect_2_object()(ic, b); -} - - -template -bool do_intersect(const Point_2& a, - const CGAL::Bbox_2& b) -{ - return do_intersect(b,a); -} - namespace Intersections { - namespace internal { +template +inline bool do_intersect(const Bbox_2 &bbox, + const Point_2 &pt, + const K& k) +{ + Point_2 bl(bbox.xmin(), bbox.ymin()), + tr(bbox.xmax(), bbox.ymax()); + Iso_rectangle_2 ic(bl,tr); + + return k.do_intersect_2_object()(ic, pt); +} + +template +inline bool do_intersect(const Point_2 &pt, + const Bbox_2& bbox, + const K& k) +{ + return do_intersect(bbox, pt, k); +} + template typename CGAL::Intersection_traits::result_type intersection(const Point_2& a, @@ -77,6 +77,20 @@ intersection(const CGAL::Bbox_2& b, } // namespace internal } // namespace Intersections +template +bool do_intersect(const CGAL::Bbox_2& a, + const Point_2& b) +{ + return Intersections::internal::do_intersect(a,b,K()); +} + +template +bool do_intersect(const Point_2& a, + const CGAL::Bbox_2& b) +{ + return Intersections::internal::do_intersect(b,a,K()); +} + template typename CGAL::Intersection_traits >::result_type intersection(const Bbox_2& b, @@ -92,6 +106,7 @@ typename CGAL::Intersection_traits >::result_type { return Intersections::internal::intersection(b,a,K()); } + } // namespace CGAL #endif // CGAL_INTERSECTIONS_2_BBOX_2_POINT_2_H From ab0ca8a7357af5d99d6c0f2a3e8a8b0671a6a38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 17 May 2019 12:15:48 +0200 Subject: [PATCH 090/203] Use the intersection traits macro to simplify code (cosmetic change) --- .../CGAL/Intersections_2/Circle_2_Circle_2.h | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/Intersections_2/include/CGAL/Intersections_2/Circle_2_Circle_2.h b/Intersections_2/include/CGAL/Intersections_2/Circle_2_Circle_2.h index 230d2e6791a..05c49b53a1a 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Circle_2_Circle_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Circle_2_Circle_2.h @@ -23,47 +23,38 @@ // // Author(s) : Geert-Jan Giezeman - #ifndef CGAL_INTERSECTIONS_2_CIRCLE_2_CIRCLE_2_H #define CGAL_INTERSECTIONS_2_CIRCLE_2_CIRCLE_2_H #include #include -namespace CGAL { - -namespace Intersections { +#include +namespace CGAL { +namespace Intersections { namespace internal { template -bool -do_intersect(const typename K::Circle_2 & circ1, - const typename K::Circle_2& circ2, - const K&) +bool do_intersect(const typename K::Circle_2 & circ1, + const typename K::Circle_2& circ2, + const K&) { - typedef typename K::FT FT; - FT sr1 = circ1.squared_radius(); - FT sr2 = circ2.squared_radius(); - FT squared_dist = squared_distance(circ1.center(), circ2.center()); - FT temp = sr1+sr2-squared_dist; - return !(FT(4)*sr1*sr2 < temp*temp); + typedef typename K::FT FT; + + FT sr1 = circ1.squared_radius(); + FT sr2 = circ2.squared_radius(); + FT squared_dist = squared_distance(circ1.center(), circ2.center()); + FT temp = sr1+sr2-squared_dist; + + return !(FT(4)*sr1*sr2 < temp*temp); } } // namespace internal } // namespace Intersections -template -inline -bool -do_intersect(const Circle_2 & circ1, - const Circle_2 & circ2) -{ - typedef typename K::Do_intersect_2 Do_intersect; - return Do_intersect()(circ1, circ2); -} +CGAL_DO_INTERSECT_FUNCTION_SELF(Circle_2, 2) - -} //namespace CGAL +} // namespace CGAL #endif From 36c6c4ca4ec23840a5ff6b6548796d7c989e6d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 17 May 2019 12:16:17 +0200 Subject: [PATCH 091/203] Move Circle_2 Iso_rectangle_2 overload to the appropriate function --- .../Circle_2_Iso_rectangle_2.h | 26 ++++++++++++++++++- .../internal/Bbox_2_Circle_2_do_intersect.h | 13 +++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Intersections_2/include/CGAL/Intersections_2/Circle_2_Iso_rectangle_2.h b/Intersections_2/include/CGAL/Intersections_2/Circle_2_Iso_rectangle_2.h index 8aae18ec2d2..a932a1c8a0d 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Circle_2_Iso_rectangle_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Circle_2_Iso_rectangle_2.h @@ -29,7 +29,31 @@ #include namespace CGAL { - CGAL_DO_INTERSECT_FUNCTION(Iso_rectangle_2, Circle_2, 2) +namespace Intersections { +namespace internal { + +template +bool do_intersect(const typename K::Iso_rectangle_2& bbox, + const typename K::Circle_2& circle, + const K&) +{ + return do_intersect_circle_box_2(circle, bbox, K()); +} + + +template +bool do_intersect(const typename K::Circle_2& circle, + const typename K::Iso_rectangle_2& bbox, + const K&) +{ + return do_intersect_circle_box_2(circle, bbox, K()); +} + +} // namespace internal +} // namespace Intersections + +CGAL_DO_INTERSECT_FUNCTION(Iso_rectangle_2, Circle_2, 2) + } #endif // CGAL_INTERSECTIONS_2_ISO_RECTANGLE_2_CIRCLE_2_H diff --git a/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h b/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h index 6306d383ef3..1822f26afdc 100644 --- a/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h +++ b/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h @@ -80,16 +80,11 @@ bool do_intersect(const CGAL::Bbox_2& bbox, } -template -bool do_intersect(const typename K::Circle_2& circle, - const CGAL::Bbox_2& bbox, - const K&) -{ - return do_intersect_circle_box_2(circle, bbox, K()); + return (distance >= circle.squared_radius()); } template -bool do_intersect(const typename K::Iso_rectangle_2& bbox, +bool do_intersect(const CGAL::Bbox_2& bbox, const typename K::Circle_2& circle, const K&) { @@ -99,7 +94,7 @@ bool do_intersect(const typename K::Iso_rectangle_2& bbox, template bool do_intersect(const typename K::Circle_2& circle, - const typename K::Iso_rectangle_2& bbox, + const CGAL::Bbox_2& bbox, const K&) { return do_intersect_circle_box_2(circle, bbox, K()); @@ -107,6 +102,6 @@ bool do_intersect(const typename K::Circle_2& circle, } // namespace internal } // namespace Intersections -} //namespace CGAL +} // namespace CGAL #endif // CGAL_INTERNAL_INTERSECTIONS_2_BBOX_2_CIRCLE_2_DO_INTERSECT_H From 325be3560bf2c2496986912d0182379c086e7243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 17 May 2019 12:18:22 +0200 Subject: [PATCH 092/203] Fix Bbox_2 Circle_2 intersection (bbox within circle is not an intersection) --- .../internal/Bbox_2_Circle_2_do_intersect.h | 61 ++++++++++++------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h b/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h index 1822f26afdc..30dc13b4580 100644 --- a/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h +++ b/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h @@ -30,55 +30,74 @@ namespace CGAL { - namespace Intersections { - namespace internal { -template +// Circle_2 is not a disk, thus if the box is contained within the circle, there is no intersection. +template bool do_intersect_circle_box_2(const typename K::Circle_2& circle, - const Box3& bbox, + const Box2& bbox, const K&) { - typedef typename K::FT FT; - typedef typename K::Point_2 Point; - FT d = FT(0); - FT distance = FT(0); + typedef typename K::FT FT; + typedef typename K::Point_2 Point; + Point center = circle.center(); + // Check that the minimum distance to the box is smaller than the radius, otherwise there is + // no intersection. + FT distance = FT(0); if(center.x() < FT(bbox.xmin())) { - d = FT(bbox.xmin()) - center.x(); + FT d = FT(bbox.xmin()) - center.x(); distance += d * d; } else if(center.x() > FT(bbox.xmax())) { - d = center.x() - FT(bbox.xmax()); + FT d = center.x() - FT(bbox.xmax()); distance += d * d; } if(center.y() < FT(bbox.ymin())) { - d = FT(bbox.ymin()) - center.y(); + FT d = FT(bbox.ymin()) - center.y(); distance += d * d; } else if(center.y() > FT(bbox.ymax())) { - d = center.y() - FT(bbox.ymax()); + FT d = center.y() - FT(bbox.ymax()); distance += d * d; } - return distance <= circle.squared_radius(); -} + // Note that with the way the distance above is computed, the distance is '0' if the box strictly + // contains the circle. But since we use '>', we don't exit + if(distance > circle.squared_radius()) + return false; -template -bool do_intersect(const CGAL::Bbox_2& bbox, - const typename K::Circle_2& circle, - const K&) -{ - return do_intersect_circle_box_2(circle, bbox, K()); -} + // Check that the maximum distance between the center of the circle and the box is not (strictly) + // smaller than the radius of the center, otherwise the box is entirely contained. + distance = FT(0); + if(center.x() <= FT(bbox.xmin() + bbox.xmax()) / FT(2)) + { + FT d = FT(bbox.xmax()) - center.x(); + distance += d * d; + } + else + { + FT d = center.x() - FT(bbox.xmin()); + distance += d * d; + } + if(center.y() < FT(bbox.ymin() + bbox.ymax()) / FT(2)) + { + FT d = FT(bbox.ymax()) - center.y(); + distance += d * d; + } + else + { + FT d = center.y() - FT(bbox.ymin()); + distance += d * d; + } return (distance >= circle.squared_radius()); } From e23d76cfab02d13bfb01c18abcb0e7108e6d9170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 17 May 2019 14:47:31 +0200 Subject: [PATCH 093/203] Cosmetic changes --- .../CGAL/Intersections_2/Circle_2_Line_2.h | 36 +++++-------------- Intersections_2/include/CGAL/intersection_2.h | 5 ++- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/Intersections_2/include/CGAL/Intersections_2/Circle_2_Line_2.h b/Intersections_2/include/CGAL/Intersections_2/Circle_2_Line_2.h index c678fa3b426..49e7e90183b 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Circle_2_Line_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Circle_2_Line_2.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace CGAL { namespace Intersections { @@ -38,45 +39,26 @@ namespace internal { template bool do_intersect(const typename K::Circle_2 & c, - const typename K::Line_2& l, - const K&) + const typename K::Line_2& l, + const K&) { - return squared_distance(c.center(), l) <= c.squared_radius(); + return squared_distance(c.center(), l) <= c.squared_radius(); } template bool do_intersect(const typename K::Line_2& l, - const typename K::Circle_2 & c, - const K&) + const typename K::Circle_2 & c, + const K&) { - return squared_distance(c.center(), l) <= c.squared_radius(); + return squared_distance(c.center(), l) <= c.squared_radius(); } } // namespace internal } // namespace Intersections - -template -inline -bool -do_intersect(const Circle_2 & c, - const Line_2 & l) -{ - typedef typename K::Do_intersect_2 Do_intersect; - return Do_intersect()(c, l); -} -template -inline -bool -do_intersect(const Line_2 & l, - const Circle_2 & c) -{ - typedef typename K::Do_intersect_2 Do_intersect; - return Do_intersect()(c, l); -} +CGAL_DO_INTERSECT_FUNCTION(Circle_2, Line_2, 2) - -} //namespace CGAL +} // namespace CGAL #endif diff --git a/Intersections_2/include/CGAL/intersection_2.h b/Intersections_2/include/CGAL/intersection_2.h index d1672662b5b..b3078e31a5b 100644 --- a/Intersections_2/include/CGAL/intersection_2.h +++ b/Intersections_2/include/CGAL/intersection_2.h @@ -31,8 +31,8 @@ #include #include -#include #include +#include #include #include @@ -49,9 +49,9 @@ #include #include +#include #include #include -#include #include #include @@ -63,5 +63,4 @@ #include - #endif // CGAL_INTERSECTION_2_H From b322f685d4ef244fb177730d8c49b63e0bd74a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 17 May 2019 14:48:04 +0200 Subject: [PATCH 094/203] Populate Intersections_2 tests --- .../Intersections_2/test_intersections_2.cpp | 464 +++++++++++++----- 1 file changed, 347 insertions(+), 117 deletions(-) diff --git a/Intersections_2/test/Intersections_2/test_intersections_2.cpp b/Intersections_2/test/Intersections_2/test_intersections_2.cpp index e8d485244b7..4b8f300b6d0 100644 --- a/Intersections_2/test/Intersections_2/test_intersections_2.cpp +++ b/Intersections_2/test/Intersections_2/test_intersections_2.cpp @@ -1,23 +1,13 @@ // 2D intersection tests. #include +#include #include #include #include -#include #include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include #include #include @@ -25,7 +15,8 @@ const double epsilon = 0.001; -struct randomint { +struct randomint +{ randomint() ; int get() const { return sequence[cur]; } int next() { cur = (cur+1)%11; return get();} @@ -57,9 +48,9 @@ inline double to_nt(int d) return double(d); } -template < typename K > -struct Test { - +template +struct Test +{ typedef typename K::Point_2 P; typedef typename K::Line_2 L; typedef typename K::Segment_2 S; @@ -67,87 +58,110 @@ struct Test { typedef typename K::Triangle_2 T; typedef typename K::Iso_rectangle_2 Rec; typedef typename K::Circle_2 C; - typedef std::vector

Pol; + typedef CGAL::Bbox_2 B; + typedef std::vector

Pol; - template < typename Type > + Test(const K& k = K()) : kernel(k) { } + + template bool approx_equal_nt(const Type &t1, const Type &t2) { - if (t1 == t2) - return true; - if (CGAL::abs(t1 - t2) / (CGAL::max)(CGAL::abs(t1), CGAL::abs(t2)) < epsilon) - return true; - std::cout << " Approximate comparison failed between : " << t1 << " and " << t2 << "\n"; - return false; + if (t1 == t2) + return true; + + if (CGAL::abs(t1 - t2) / (CGAL::max)(CGAL::abs(t1), CGAL::abs(t2)) < epsilon) + return true; + + std::cout << " Approximate comparison failed between : " << t1 << " and " << t2 << "" << std::endl; + return false; } - template < typename Type > + template bool approx_equal(const Type&t1, const Type&t2) { - return t1 == t2; - // we need approx equal to check approx kernels, but maybe we should only test with exact kernels - // (approx kernels were useful before, when the text output was checked by diff ?) - // idea : test containment with intervals ? or use some "epsilon double"? - // I need to convert the text output to exact rationals in the source... - // Well, for now the current scheme works. + return t1 == t2; + // we need approx equal to check approx kernels, but maybe we should only test with exact kernels + // (approx kernels were useful before, when the text output was checked by diff ?) + // idea : test containment with intervals ? or use some "epsilon double"? + // I need to convert the text output to exact rationals in the source... + // Well, for now the current scheme works. } bool approx_equal(const P & p, const P & q) { - return approx_equal_nt(p.x(), q.x()) && approx_equal_nt(p.y(), q.y()); + return approx_equal_nt(p.x(), q.x()) && approx_equal_nt(p.y(), q.y()); } bool approx_equal(const Pol & p, const Pol & q) { - if (p.size() != q.size()) - return false; - for(typename Pol::const_iterator itp = p.begin(), itq = q.begin(); itp != p.end(); ++itp, ++itq) - if (!approx_equal(*itp, *itq)) - return false; - return true; + if (p.size() != q.size()) + return false; + + for(typename Pol::const_iterator itp = p.begin(), itq = q.begin(); itp != p.end(); ++itp, ++itq) + if (!approx_equal(*itp, *itq)) + return false; + + return true; } - template < typename O1, typename O2> + template + void check_no_do_intersect(const O1& o1, const O2& o2) + { + assert(!CGAL::do_intersect(o1, o2)); + assert(!CGAL::do_intersect(o2, o1)); + + typename K::Do_intersect_2 do_2 = kernel.do_intersect_2_object(); + assert(!do_2(o1, o2)); + assert(!do_2(o2, o1)); + } + + template void check_no_intersection(const O1& o1, const O2& o2) { - assert(!CGAL::do_intersect(o1, o2)); - assert(!CGAL::do_intersect(o2, o1)); - assert(!CGAL::intersection(o2, o1)); - - //check with the functors - typename CGAL::Kernel_traits::Kernel::Do_intersect_2 do_2; - typename CGAL::Kernel_traits::Kernel::Intersect_2 i_2; - assert(!do_2(o1, o2)); - assert(!i_2(o1, o2)); - assert(!do_2(o2, o1)); - assert(!i_2(o2, o1)); + check_no_do_intersect(o1, o2); + + assert(!CGAL::intersection(o2, o1)); + + typename K::Intersect_2 i_2 = kernel.intersect_2_object(); + assert(!i_2(o1, o2)); + assert(!i_2(o2, o1)); } - template < typename Res, typename O1, typename O2 > + template + void check_do_intersect(const O1& o1, const O2& o2) + { + assert(CGAL::do_intersect(o1, o2)); + assert(CGAL::do_intersect(o2, o1)); + } + + template void check_intersection(const O1& o1, const O2& o2) { - Res tmp; - assert(CGAL::do_intersect(o1, o2)); - assert(CGAL::assign(tmp, CGAL::intersection(o1, o2))); - assert(CGAL::do_intersect(o2, o1)); - assert(CGAL::assign(tmp, CGAL::intersection(o2, o1))); + check_do_intersect(o1, o2); + + Res tmp; + assert(CGAL::assign(tmp, CGAL::intersection(o1, o2))); + assert(CGAL::assign(tmp, CGAL::intersection(o2, o1))); } - template < typename Res, typename O1, typename O2 > + template void check_intersection(const O1& o1, const O2& o2, const Res& result, bool do_opposite=true) { - Res tmp; - assert(CGAL::do_intersect(o1, o2)); - assert(CGAL::assign(tmp, CGAL::intersection(o1, o2))); - assert(approx_equal(tmp, result)); - if (do_opposite) { - assert(CGAL::do_intersect(o2, o1)); - assert(CGAL::assign(tmp, CGAL::intersection(o2, o1))); - assert(approx_equal(tmp, result)); - } + check_do_intersect(o1, o2); + + Res tmp; + + assert(CGAL::assign(tmp, CGAL::intersection(o1, o2))); + assert(approx_equal(tmp, result)); + if (do_opposite) + { + assert(CGAL::assign(tmp, CGAL::intersection(o2, o1))); + assert(approx_equal(tmp, result)); + } } - template < typename O > + template void check_intersection(const O& o) { return check_intersection(o, o, o); @@ -159,20 +173,155 @@ struct Test { return P(to_nt(x*w), to_nt(y*w), to_nt(w)); } + void B_C() + { + std::cout << "Bbox - Circle" << std::endl; + + // no intersection + check_no_do_intersect (p(0, 0).bbox() + p( 2, 3).bbox(), C(p( 8, 9), 3)); + check_no_do_intersect (p(8, 9).bbox() + p( 9, 10).bbox(), C(p( 9, 9), 9)); // circle containing the bbox + + // point intersection + check_do_intersect (p(0, 0).bbox() + p( 2, 3).bbox(), C(p(-1, 0), 1)); + check_do_intersect (p(0, 0).bbox() + p( 2, 3).bbox(), C(p( 1, 1), 1)); + + // generic intersection + check_do_intersect (p(0, 0).bbox() + p( 2, 3).bbox(), C(p(-1, 0), 2)); + check_do_intersect (p(0, 0).bbox() + p( 2, 0).bbox(), C(p( 1, 0), 1)); + check_do_intersect (p(0, 0).bbox() + p(10, 10).bbox(), C(p( 3, 2), 3)); + } + + // @fixme, bbox_2_line_2.h is all kind of broken + void B_L() + { + std::cout << "Bbox - Line (TODO)" << std::endl; + + // no intersection +// check_no_do_intersect (p(0,0).bbox() , L(p( 1,1), p( 0,1))); +// check_no_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p(-1,1), p(-1,5))); + + // point intersection +// check_do_intersect (p( 0, 0).bbox() , L(p(-1,1), p(1,-1))); +// check_do_intersect (p(-1,-1).bbox() + p(4,2).bbox(), L(p( 1,5), p(-3,1))); + + // segment intersection +// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p(-1, 5), p(7,5))); +// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p(-1, 5), p(2,5))); +// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p( 4,-3), p(4,1))); + } + void B_P() { - CGAL::Bbox_2 bb(0,0,10,10); - P p(1,0), bl(0,0), tr(10,10); - C c(bl,1); - Rec r(bl,tr); - check_intersection(bb,p,p,true); - check_intersection(c,p,p,true); - assert(do_intersect(r,c)); + std::cout << "Bbox - Point" << std::endl; + + // no intersection + check_no_intersection (p(1,2).bbox() + p(4,6).bbox(), p(8,9)); // point is outside the bbox + + // point intersection + check_intersection (p(1,2).bbox() , p(1,2), p(1,2)); // degenerate bbox (0d) + check_intersection (p(1,2).bbox() + p(4,2).bbox(), p(2,2), p(2,2)); // degenerate bbox (1d) + check_intersection (p(1,2).bbox() + p(4,6).bbox(), p(1,6), p(1,6)); // point is a bbox corner + check_intersection (p(1,2).bbox() + p(4,6).bbox(), p(3,6), p(3,6)); // point is on a bbox edge + check_intersection (p(1,2).bbox() + p(4,6).bbox(), p(3,3), p(3,3)); // point is within the bbox } - + + // @fixme, bbox_2_ray_2.h is all kind of broken + void B_R() + { + std::cout << "Bbox - Ray (TODO)" << std::endl; + + // no intersection +// check_no_do_intersect (p(0,0).bbox() , R(p( 1,1), p( 0,1))); +// check_no_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p(-1,1), p(-1,5))); + + // point intersection +// check_do_intersect (p( 0, 0).bbox() , R(p(-1,1), p(1,-1))); +// check_do_intersect (p(-1,-1).bbox() + p(4,2).bbox(), R(p( 1,5), p(-3,1))); + + // segment intersection +// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p(-1, 5), p(7,5))); +// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p(-1, 5), p(2,5))); +// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p( 4,-3), p(4,1))); + } + + void C_C() + { + std::cout << "Circle - Circle" << std::endl; + + // no intersection + check_no_do_intersect (C(p(13, 14), 5), C(p( 3, 2), 1)); + check_no_do_intersect (C(p( 2, 3), 9), C(p( 3, 4), 1)); // one contains the other + + // point intersection + check_do_intersect (C(p(-1, -4), 0), C(p(-1, -4), 0)); + check_do_intersect (C(p( 3, 4), 25), C(p( 6, 8), 0)); + check_do_intersect (C(p( 3, 4), 1), C(p( 3, 2), 1)); + + // more than point intersection + check_do_intersect (C(p( 2, 5), 9), C(p(-3, 2), 9)); + check_do_intersect (C(p( 1, 2), 1), C(p( 1, 2), 1)); // same cicle twice + } + + void C_Rec() + { + std::cout << "Circle - Iso_rectangle" << std::endl; + + // no intersection + check_no_do_intersect (C(p( 2, 1), 0), Rec(p( 3, 2), p( 4, 6))); + check_no_do_intersect (C(p(13, 14), 5), Rec(p( 3, 2), p( 4, 6))); + check_no_do_intersect (C(p(13, 14), 9), Rec(p(12, 13), p(14, 15))); // circle contains the box + + // point intersection + check_do_intersect (C(p(-3, -2), 0), Rec(p(-3, -2), p(14, 2))); // vertex of the rectangle + check_do_intersect (C(p( 0, 0), 4), Rec(p( 0, 2), p(12, 9))); // vertex of the rectangle + check_do_intersect (C(p(-4, 3), 0), Rec(p(-6, 2), p( 7, 3))); // point on an edge + check_do_intersect (C(p( 0, 0), 4), Rec(p(-2, 2), p(13, 4))); // point on an edge + + // more than point intersection + check_do_intersect (C(p( 5, 5), 4), Rec(p( 3, 3), p( 7, 7))); + check_do_intersect (C(p(10, 10), 2), Rec(p( 0, 0), p(10, 10))); + check_do_intersect (C(p(13, 14), 3), Rec(p( 1, 1), p(30, 32))); // rectangle contains the circle + check_do_intersect (C(p( 0, 0), 25), Rec(p(-3, -4), p( 3, 4))); // inscribed circle of the box + + // intersection with all vertices outside of the circle + check_do_intersect (C(p( 0, 0), 9), Rec(p(-10, 2), p(10, 13))); + } + + void C_L() + { + std::cout << "Circle - Line" << std::endl; + + // no intersection + check_no_do_intersect (C(p( 2, 8), 6), L(p(-3, -2), p( 2, 4))); + check_no_do_intersect (C(p( 2, 8), 6), L(p(-3, 22), p( 2, 14))); + + // point intersection + check_do_intersect (C(p( 3, 4), 0), L(p(-3, 8), p( 6, 2))); + check_do_intersect (C(p( 4, 3), 4), L(p( 6, -7), p( 6, -2))); + check_do_intersect (C(p( 4, 3), 4), L(p( 6, -7), p( 6, -9))); + + // two points intersection + check_do_intersect (C(p(-3, 1), 7), L(p(-1, -3), p(-6, 7))); + } + + void C_P() + { + std::cout << "Circle - Point" << std::endl; + + // no intersection + check_no_intersection (C(p(13, 14), 5) , p(13, 14)); + check_no_intersection (C(p( 2, 9), 4) , p(11, 12)); + + // point intersection + check_intersection (C(p( 3, 4), 16) , p( 7, 4), p(7, 4)); + check_intersection (C(p( 0, 5), p(5, 0), p(-5, 0)), p( 0, -5), p(0, -5)); +// check_intersection (C(p( 3, 4), p(2, 6), p( 1, 5)), p( 1, 5), p(1, 5)); // homogenous kernel is too imprecise + check_intersection

(C(p( 0, 0), 25) , p( 5, 0)); + } + void L_L() { - std::cout << "Line - Line\n"; + std::cout << "Line - Line" << std::endl; // no intersection check_no_intersection (L(p(0, 0), p(10,10)), L(p(8,7), p(1, 0))); @@ -192,9 +341,24 @@ struct Test { check_intersection (L(p( 0, 0), p(10, 0)), L(p(8, 0), p( 1, 0))); // L0 & L1 have opposite directions } + void L_P() + { + std::cout << "Line - Point" << std::endl; + + // no intersection + check_no_intersection (L(p(-3, 0), p( 7, 10)), p(9, 11)); + + // point intersection + check_intersection (L(p(-3, 0), p(-3, 10)), p(-3, 2), p(-3, 2)); + check_intersection (L(p(-3, 10), p(-3, 7)), p(-3, 4), p(-3, 4)); + check_intersection (L(p(-3, 4), p( 6, 4)), p( 7, 4), p( 7, 4)); + check_intersection (L(p(-3, 4), p(-6, 4)), p( 9, 4), p( 9, 4)); + check_intersection (L(p( 3, -1), p( 6, 1)), p(12, 5), p(12, 5)); + } + void S_S() { - std::cout << "Segment - Segment\n"; + std::cout << "Segment - Segment" << std::endl; // no intersection check_no_intersection (S(p(29, 16), p( 28, 9)), S(p( 30, 12), p( 29, 6))); @@ -214,7 +378,7 @@ struct Test { void R_R() { - std::cout << "Ray - Ray\n"; + std::cout << "Ray - Ray" << std::endl; // no intersection check_no_intersection (R(p( 3, 4), p( 5, 7)), R(p( 2, 0), p( 2, 4))); @@ -235,9 +399,9 @@ struct Test { check_intersection (R(p( 0, 0), p( 10, 0)), R(p( -1, 0), p(0, 0))); // R0 'runs' into R1's source } - void S_R() + void R_S() { - std::cout << "Segment - Ray\n"; + std::cout << "Ray - Segment" << std::endl; // no intersection check_no_intersection (S(p( 2, -1), p( 2, 1)), R(p( 1, 3), p( 2, 3))); @@ -256,7 +420,7 @@ struct Test { void L_R() { - std::cout << "Line - Ray\n"; + std::cout << "Line - Ray" << std::endl; // no intersection check_no_intersection (L(p( 2, -1), p( 2, 1)), R(p( 1, -3), p( 1, 3))); @@ -272,9 +436,9 @@ struct Test { check_intersection (L(p( 2, -1), p( 2, 1)), R(p( 2, 3), p( 2, -3))); // opposite direction } - void S_L() + void L_S() { - std::cout << "Segment - Line\n"; + std::cout << "Line - Segment" << std::endl; // no intersection check_no_intersection (S(p( 2, -1), p( 2, 1)), L(p( 1, 3), p( 2, 3))); @@ -292,7 +456,7 @@ struct Test { void T_T() { - std::cout << "Triangle - Triangle\n"; + std::cout << "Triangle - Triangle" << std::endl; // no intersection check_no_intersection (T(p( -10,-10), p( 0, 10), p( 20, -5)), T(p( 90, -10), p(100, 10), p(120, -5))); @@ -340,7 +504,7 @@ struct Test { void L_T() { - std::cout << "Line - Triangle\n"; + std::cout << "Line - Triangle" << std::endl; // no intersection check_no_intersection (L(p(-10, 0), p( 10, 0)), T(p( -12, 3), p( 12, 3), p(1, 5))); @@ -362,7 +526,7 @@ struct Test { void R_T() { - std::cout << "Ray - Triangle\n"; + std::cout << "Ray - Triangle" << std::endl; // no intersection check_no_intersection (R(p(-10, 0), p( 10, 0)), T(p( -12, 3), p( 12, 3), p(1, 5))); @@ -386,7 +550,7 @@ struct Test { void S_T() { - std::cout << "Segment - Triangle\n"; + std::cout << "Segment - Triangle" << std::endl; // no intersection check_no_intersection (S(p(-10, -10), p( 0, 10)), T(p( 90, -10), p( 100, 10), p(120, -5))); @@ -411,14 +575,41 @@ struct Test { void P_P() { - std::cout << "Point - Point\n"; - check_no_intersection

(p( 8, 4), p(-4, 8)); - check_intersection

(p( 8, 4), p( 8, 4)); + std::cout << "Point - Point" << std::endl; + + check_no_intersection

(p(8, 4), p(-4, 8)); + check_intersection

(p(8, 4), p( 8, 4)); + } + + void P_R() + { + std::cout << "Point - Ray" << std::endl; + + // no intersection + check_no_intersection (R(p(-1, -1), p(0, 12)), p( 9, -1)); + + // point intersection + check_intersection (R(p(-3, 0), p(7, 10)), p(-3, 0), p(-3, 0)); // origin of the ray + check_intersection (R(p(-3, 0), p(7, 10)), p( 9, 12), p( 9, 12)); + } + + void P_S() + { + std::cout << "Point - Segment" << std::endl; + + // no intersection + check_no_intersection (S(p(-1, -1), p( 0, 12)), p( 9, -1)); + check_no_intersection (S(p(-2, -3), p( 0, 4)), p( 4, 18)); + + // point intersection + check_intersection (S(p(-2, -3), p( 4, 18)), p( 0, 4), p( 0, 4)); + check_intersection (S(p(-3, 0), p( 7, 10)), p(-3, 0), p(-3, 0)); + check_intersection (S(p( 3, 2), p(-2, 11)), p(-2, 11), p(-2, 11)); } void P_T() { - std::cout << "Point - Triangle\n"; + std::cout << "Point - Triangle" << std::endl; // no intersection check_no_intersection (p( 8, 6), T(p( 4, 0), p( 12, 4), p(-4, 8))); @@ -431,9 +622,9 @@ struct Test { check_intersection

(p( -4, 8), T(p( 4, 0), p( 12, 4), p(-4, 8))); } - void L_Rec() + void Rec_L() { - std::cout << "Line - Iso_rectangle\n"; + std::cout << "Iso_rectangle - Line" << std::endl; // no intersection check_no_intersection (L(p( 18, 6), p( 16, 4)), Rec(p( 2, 0), p(6, 3))); @@ -450,9 +641,26 @@ struct Test { check_intersection (L(p(-1, 3), p(-2, 3)), Rec(p( 2, 0), p(6, 3))); } - void R_Rec() + void Rec_P() { - std::cout << "Ray - Iso_rectangle\n"; + std::cout << "Iso_rectangle - Point" << std::endl; + + // no intersection + check_no_intersection (Rec(p(-2, -6), p( 6, 3)), p( 7, 2)); + check_no_intersection (Rec(p(-2, -6), p( 6, 3)), p(-2, -7)); + + // point intersection + check_intersection (Rec(p(-1, 4), p(-1, 4)), p(-1, 4), p(-1, 4)); // degenerate rectange (0d) + check_intersection (Rec(p(-2, 4), p(-2, 7)), p(-2, 6), p(-2, 6)); // degenerate rectange (1d) + check_intersection (Rec(p(-2, 4), p(-2, 7)), p(-2, 7), p(-2, 7)); // degenerate rectange (1d) + check_intersection (Rec(p(-3, 0), p( 4, 2)), p(-3, 2), p(-3, 2)); // on vertex + check_intersection (Rec(p( 7, 8), p( 9, 9)), p( 8, 9), p( 8, 9)); // on edge + check_intersection (Rec(p(-2, 0), p( 6, 7)), p( 1, 1), p( 1, 1)); // within + } + + void Rec_R() + { + std::cout << "Iso_rectangle - Ray" << std::endl; // no intersection check_no_intersection (R(p( 18, 6), p( 16, 4)), Rec(p( 2, 0), p(6, 3))); @@ -469,9 +677,9 @@ struct Test { check_intersection (R(p(-2, 3), p(-1, 3)), Rec(p( 2, 0), p(6, 3))); } - void S_Rec() + void Rec_S() { - std::cout << "Segment - Iso_rectangle\n"; + std::cout << "Iso_rectangle - Segment" << std::endl; // no intersection check_no_intersection (S(p( 18, 6), p( 16, 4)), Rec(p( 2, 0), p(6, 3))); @@ -490,7 +698,7 @@ struct Test { void Rec_Rec() { - std::cout << "Iso_rectangle - Iso_rectangle\n"; + std::cout << "Iso_rectangle - Iso_rectangle" << std::endl; // no intersection check_no_intersection (Rec(p( -4, -12), p(12, 23)), Rec(p( -4, 24), p( 5, 26))); @@ -510,9 +718,9 @@ struct Test { check_intersection (Rec(p( 10, 12), p(30, 40)), Rec(p( 25, 40), p( 26, 103)), Rec(P(25, 40), P(26, 40))); } - void T_Rec() + void Rec_T() { - std::cout << "Triangle - Iso_rectangle\n"; + std::cout << "Iso_rectangle - Triangle" << std::endl; // no intersection check_no_intersection (Rec(p( 10, 12), p(30, 40)), T(p( 4, 0), p( 12, 4), p(-4, 8))); @@ -539,29 +747,51 @@ struct Test { check_intersection(Rec(p( 0, 0), p( 1, 1)), T(p( -1, -2), p( -1, 2), p( 5, 2))); check_intersection(Rec(p( 100, 100), p(200, 200)), T(p(150, 50), p(250, 170), p(50, 170))); } - + void run() { std::cout << "2D Intersection tests with Kernel: " << typeid(K).name() << std::endl; + + B_C(); + B_L(); B_P(); - L_L(); - S_S(); - R_R(); - S_R(); - L_R(); - S_L(); - T_T(); - L_T(); - R_T(); - S_T(); - P_T(); - P_P(); - L_Rec(); - R_Rec(); - S_Rec(); + B_R(); + + C_C(); + C_Rec(); + C_L(); + C_P(); + Rec_Rec(); - T_Rec(); + Rec_L(); + Rec_P(); + Rec_R(); + Rec_S(); + Rec_T(); + + L_L(); + L_P(); + L_R(); + L_S(); + L_T(); + + P_P(); + P_R(); + P_S(); + P_T(); + + R_R(); + R_S(); + R_T(); + + S_S(); + S_T(); + + T_T(); } + +private: + K kernel; }; int main() From 1a08685a2ff038db9bf6259e94743c59c5b3eb12 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 17 May 2019 15:39:03 +0200 Subject: [PATCH 095/203] Add build_items and components to work with real case data --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 4 +- .../Polyhedron/Plugins/IO/3mf_io_plugin.cpp | 48 +++- Stream_support/include/CGAL/IO/read_3mf.h | 268 +++++++++++++++--- Stream_support/include/CGAL/IO/write_3mf.h | 5 + 4 files changed, 274 insertions(+), 51 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index a949b58ded9..c9061238a3f 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1206,8 +1206,7 @@ QList MainWindow::loadItem(QFileInfo fileinfo, } CGAL::Three::Three::CursorScopeGuard guard(QCursor(Qt::WaitCursor)); QList result = loader->load(fileinfo, ok, add_to_scene); - selectSceneItem(scene->item_id(result.back())); - if(!ok) + if(result.empty() || !ok) { QApplication::restoreOverrideCursor(); QMessageBox::warning(this, tr("Error"), @@ -1215,6 +1214,7 @@ QList MainWindow::loadItem(QFileInfo fileinfo, .arg(fileinfo.absoluteFilePath()).arg(loader->name())); return QList(); } + selectSceneItem(scene->item_id(result.back())); for(Scene_item* item : result) { CGAL::Three::Scene_group_item* group = diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp index 6acf62d8768..484724d2a40 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp @@ -80,22 +80,26 @@ class Io_3mf_plugin: int nb_polylines = CGAL::read_polylines_from_3mf(fileinfo.filePath().toUtf8().toStdString(), all_points, all_colors, names); - if(nb_polylines > 0 ) + if(nb_polylines < 0 ) { - for(int i=0; i< nb_polylines; ++i) - { - Scene_polylines_item* pol_item = new Scene_polylines_item(); - PolylineRange& polylines = pol_item->polylines; - polylines.push_back(all_points[i]); - pol_item->setName(names[i].data()); - pol_item->invalidateOpenGLBuffers(); - CGAL::Color c = all_colors[i].front(); - pol_item->setColor(QColor(c.red(), c.green(), c.blue())); - pol_item->setProperty("already_colord", true); - result << pol_item; - if(add_to_scene) - CGAL::Three::Three::scene()->addItem(pol_item); - } + ok = false; + std::cerr << "Error in reading of meshes."<polylines; + polylines.push_back(all_points[i]); + pol_item->setName(names[i].data()); + pol_item->invalidateOpenGLBuffers(); + CGAL::Color c = all_colors[i].front(); + pol_item->setColor(QColor(c.red(), c.green(), c.blue())); + pol_item->setProperty("already_colord", true); + result << pol_item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(pol_item); } all_points.clear(); all_colors.clear(); @@ -103,6 +107,12 @@ class Io_3mf_plugin: int nb_point_sets = CGAL::read_point_clouds_from_3mf(fileinfo.filePath().toUtf8().toStdString(), all_points, all_colors, names); + if(nb_point_sets < 0 ) + { + ok = false; + std::cerr << "Error in reading of meshes."<setColor(QColor(first.red(), first.green(), first.blue())); sm_item->setProperty("already_colored", true); sm_item->setName(names[i].data()); diff --git a/Stream_support/include/CGAL/IO/read_3mf.h b/Stream_support/include/CGAL/IO/read_3mf.h index 062ea68d6a0..3448ca8b7a0 100644 --- a/Stream_support/include/CGAL/IO/read_3mf.h +++ b/Stream_support/include/CGAL/IO/read_3mf.h @@ -26,24 +26,42 @@ #include #include #include +#include #include namespace CGAL{ +namespace transform_nmr_internal{ +NMR::MODELTRANSFORM initMatrix() +{ + NMR::MODELTRANSFORM mMatrix; + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + mMatrix.m_fFields[j][i] = (i == j) ? 1.0f : 0.0f; + } + } + + return mMatrix; +} +}//end internal + template bool extract_soups (NMR::PLib3MFModelMeshObject *pMeshObject, - PointRange& points, - PolygonRange& triangles, - ColorRange& colors, - std::string& name) { + const NMR::MODELTRANSFORM& transform, + PointRange& points, + PolygonRange& triangles, + ColorRange& colors, + std::string& name) { typedef typename PointRange::value_type Point_3; typedef typename PolygonRange::value_type Polygon; typedef typename ColorRange::value_type _Color; - + typedef typename Kernel_traits::Kernel Kernel; HRESULT hResult; DWORD nNeededChars; std::vector pBuffer; + // Retrieve Mesh Name Length hResult = NMR::lib3mf_object_getnameutf8(pMeshObject, NULL, 0, &nNeededChars); if (hResult != LIB3MF_OK) @@ -68,6 +86,12 @@ bool extract_soups (NMR::PLib3MFModelMeshObject *pMeshObject, else name = std::string("Unknown Mesh"); + typename Kernel::Aff_transformation_3 t( + transform.m_fFields[0][0], transform.m_fFields[0][1], transform.m_fFields[0][2], transform.m_fFields[0][3], + transform.m_fFields[1][0], transform.m_fFields[1][1], transform.m_fFields[1][2], transform.m_fFields[1][3], + transform.m_fFields[2][0], transform.m_fFields[2][1], transform.m_fFields[2][2], transform.m_fFields[2][3] + ); + NMR::PLib3MFPropertyHandler * pPropertyHandler; hResult = NMR::lib3mf_meshobject_createpropertyhandler(pMeshObject, &pPropertyHandler); if (hResult != LIB3MF_OK) { @@ -84,10 +108,10 @@ bool extract_soups (NMR::PLib3MFModelMeshObject *pMeshObject, { NMR::MODELMESHVERTEX pVertex; NMR::lib3mf_meshobject_getvertex(pMeshObject, vid, &pVertex); - points[vid] = - Point_3(pVertex.m_fPosition[0], + Point_3 p(pVertex.m_fPosition[0], pVertex.m_fPosition[1], pVertex.m_fPosition[2]); + points[vid] = t.transform(p); } for(DWORD pid = 0; pid < triangles.size(); ++pid) { @@ -110,10 +134,11 @@ template bool extract_polylines (NMR::PLib3MFModelMeshObject *pMeshObject, - PointRange& points, - PolygonRange&, - ColorRange& colors, - std::string& name) { + const NMR::MODELTRANSFORM& transform, + PointRange& points, + PolygonRange&, + ColorRange& colors, + std::string& name) { typedef typename PointRange::value_type Point_3; typedef typename PolygonRange::value_type Polygon; @@ -175,7 +200,7 @@ bool extract_polylines (NMR::PLib3MFModelMeshObject *pMeshObject, NMR::lib3mf_propertyhandler_getcolor(pPropertyHandler, 0, &pColor);//get color of the dummy triangle NMR::MODELMESHCOLOR_SRGB mColor = pColor.m_Colors[0]; colors[0]=CGAL::Color(mColor.m_Red, mColor.m_Green, - mColor.m_Blue, mColor.m_Alpha); + mColor.m_Blue, mColor.m_Alpha); return true; } @@ -183,10 +208,11 @@ template bool extract_point_clouds (NMR::PLib3MFModelMeshObject *pMeshObject, - PointRange& points, - PolygonRange&, - ColorRange& colors, - std::string& name) { + const NMR::MODELTRANSFORM& transform, + PointRange& points, + PolygonRange&, + ColorRange& colors, + std::string& name) { typedef typename PointRange::value_type Point_3; HRESULT hResult; @@ -246,16 +272,18 @@ bool extract_point_clouds (NMR::PLib3MFModelMeshObject *pMeshObject, NMR::lib3mf_propertyhandler_getcolor(pPropertyHandler, 0, &pColor);//get color of the dummy triangle NMR::MODELMESHCOLOR_SRGB mColor = pColor.m_Colors[0]; colors[0]=CGAL::Color(mColor.m_Red, mColor.m_Green, - mColor.m_Blue, mColor.m_Alpha); + mColor.m_Blue, mColor.m_Alpha); return true; } + template int read_from_3mf(const std::string& file_name, PointRanges& all_points, - PolygonRanges& all_polygons, ColorRanges& all_colors, + PolygonRanges& all_polygons, ColorRanges& all_colors, std::vector& names, std::function int read_soups_from_3mf(const std::string& file_name, PointRanges& all_points, PolygonRanges& all_polygons, ColorRanges& all_colors, std::vector& names - ) + ) { typedef typename PointRanges::value_type PointRange; typedef typename PolygonRanges::value_type PolygonRange; @@ -425,7 +625,7 @@ int read_polylines_from_3mf(const std::string& file_name, PointRanges& all_points, ColorRanges& all_colors, std::vector& names - ) + ) { typedef typename PointRanges::value_type PointRange; typedef std::vector Polygon; @@ -444,7 +644,7 @@ int read_point_clouds_from_3mf(const std::string& file_name, PointRanges& all_points, ColorRanges& all_colors, std::vector& names - ) + ) { typedef typename PointRanges::value_type PointRange; typedef std::vector Polygon; diff --git a/Stream_support/include/CGAL/IO/write_3mf.h b/Stream_support/include/CGAL/IO/write_3mf.h index ac4500a17b2..32a6d23a3f2 100644 --- a/Stream_support/include/CGAL/IO/write_3mf.h +++ b/Stream_support/include/CGAL/IO/write_3mf.h @@ -218,6 +218,9 @@ bool write_mesh_to_model( const PointRange& points, NMR::lib3mf_release(pModel); return -1; } + + //add a builditem to finish + add_build_item(pModel, *pMeshObject); } //remember that it adds 3 demmy vertices in the beginning, and a dummy triangle to be ignored. @@ -314,6 +317,7 @@ bool write_points(const PointRange& points, NMR::lib3mf_release(pModel); return -1; } + add_build_item(pModel, *pMeshObject); } template @@ -390,6 +394,7 @@ bool write_soups_to_3mf(const std::string& file_name, else name = std::string(""); write_mesh_to_model(all_points[id], all_polygons[id], name, &pMeshObject, pModel); + add_build_item(pModel, pMeshObject); //write_mesh_object_to_model(pModel, pMeshObject); } return export_model_to_file(file_name, pModel); From 2f709a40e51515da76dc3bbb0b9e0298354acffc Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 19 May 2019 23:42:49 +0200 Subject: [PATCH 096/203] Visual Studio 2015 is broken. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 2 +- NewKernel_d/test/NewKernel_d/Epick_d.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index e631ee2c4d0..5e2faa6a59f 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -38,7 +38,7 @@ or `Dynamic_dimension_tag`. In the latter case, the dimension of the space is sp \attention Only the interfaces specific to this class are listed below. Refer to the concepts for the rest. -\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. +\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. Visual Studio 2015 is not supported. \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. diff --git a/NewKernel_d/test/NewKernel_d/Epick_d.cpp b/NewKernel_d/test/NewKernel_d/Epick_d.cpp index a86ac47685d..197e5cd85f9 100644 --- a/NewKernel_d/test/NewKernel_d/Epick_d.cpp +++ b/NewKernel_d/test/NewKernel_d/Epick_d.cpp @@ -720,9 +720,11 @@ int main(){ test2(); test2i(); test3(); test3(); +#if !defined _MSC_VER || _MSC_VER >= 1910 test2>>(); test3>>(); test3>(); +#endif } #endif From ad1fbbd2428691842d4305eb7842c01ccefce9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 20 May 2019 10:06:14 +0200 Subject: [PATCH 097/203] Fix Circle_2 -- Bbox_2/Iso_rectangle_2 intersection Bbox_2 is inherently inexact as it is double-based. Thus, Bbox_2 should use its conversion to Iso_rectangle_2 (a kernel type) and not the other way around, otherwise we are doing FT --> double --> FT and losing precision. --- .../CGAL/Intersections_2/Bbox_2_Circle_2.h | 33 ++++- .../Circle_2_Iso_rectangle_2.h | 82 +++++++++++- .../internal/Bbox_2_Circle_2_do_intersect.h | 126 ------------------ 3 files changed, 104 insertions(+), 137 deletions(-) delete mode 100644 Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h diff --git a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Circle_2.h b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Circle_2.h index aaa9f323f1c..88f342201ac 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Circle_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Circle_2.h @@ -26,21 +26,46 @@ #include #include -#include +#include namespace CGAL { +namespace Intersections { +namespace internal { + +template +bool do_intersect(const CGAL::Bbox_2& bbox, + const typename K::Circle_2& circle, + const K&) +{ + return do_intersect_circle_iso_rectangle_2(circle, bbox, K()); +} + + +template +bool do_intersect(const typename K::Circle_2& circle, + const CGAL::Bbox_2& bbox, + const K&) +{ + return do_intersect_circle_iso_rectangle_2(circle, bbox, K()); +} + +} // namespace internal +} // namespace Intersections template bool do_intersect(const CGAL::Bbox_2& a, - const Circle_2& b) { + const Circle_2& b) +{ return K().do_intersect_2_object()(a, b); } template bool do_intersect(const Circle_2& a, - const CGAL::Bbox_2& b) { + const CGAL::Bbox_2& b) +{ return K().do_intersect_2_object()(a, b); } -} +} // namespace CGAL + #endif // CGAL_INTERSECTIONS_2_BBOX_2_CIRCLE_2_H diff --git a/Intersections_2/include/CGAL/Intersections_2/Circle_2_Iso_rectangle_2.h b/Intersections_2/include/CGAL/Intersections_2/Circle_2_Iso_rectangle_2.h index a932a1c8a0d..94193a52746 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Circle_2_Iso_rectangle_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Circle_2_Iso_rectangle_2.h @@ -23,30 +23,98 @@ #ifndef CGAL_INTERSECTIONS_2_ISO_RECTANGLE_2_CIRCLE_2_H #define CGAL_INTERSECTIONS_2_ISO_RECTANGLE_2_CIRCLE_2_H -#include #include - -#include +#include +#include namespace CGAL { namespace Intersections { namespace internal { +// Circle_2 is not a disk, thus if the box is contained within the circle, there is no intersection. template -bool do_intersect(const typename K::Iso_rectangle_2& bbox, +bool do_intersect_circle_iso_rectangle_2(const typename K::Circle_2& circle, + const typename K::Iso_rectangle_2& rec, + const K&) +{ + typedef typename K::FT FT; + typedef typename K::Point_2 Point; + + Point center = circle.center(); + + // Check that the minimum distance to the box is smaller than the radius, otherwise there is + // no intersection. + FT distance = FT(0); + if(center.x() < rec.xmin()) + { + FT d = rec.xmin() - center.x(); + distance += d * d; + } + else if(center.x() > rec.xmax()) + { + FT d = center.x() - rec.xmax(); + distance += d * d; + } + + if(center.y() < rec.ymin()) + { + FT d = rec.ymin() - center.y(); + distance += d * d; + } + else if(center.y() > rec.ymax()) + { + FT d = center.y() - rec.ymax(); + distance += d * d; + } + + // Note that with the way the distance above is computed, the distance is '0' if the box strictly + // contains the circle. But since we use '>', we don't exit + if(distance > circle.squared_radius()) + return false; + + // Check that the maximum distance between the center of the circle and the box is not (strictly) + // smaller than the radius of the center, otherwise the box is entirely contained. + distance = FT(0); + if(center.x() <= (rec.xmin() + rec.xmax()) / FT(2)) + { + FT d = rec.xmax() - center.x(); + distance += d * d; + } + else + { + FT d = center.x() - rec.xmin(); + distance += d * d; + } + + if(center.y() < (rec.ymin() + rec.ymax()) / FT(2)) + { + FT d = rec.ymax() - center.y(); + distance += d * d; + } + else + { + FT d = center.y() - rec.ymin(); + distance += d * d; + } + + return (distance >= circle.squared_radius()); +} + +template +bool do_intersect(const typename K::Iso_rectangle_2& rec, const typename K::Circle_2& circle, const K&) { - return do_intersect_circle_box_2(circle, bbox, K()); + return do_intersect_circle_iso_rectangle_2(circle, rec, K()); } template bool do_intersect(const typename K::Circle_2& circle, - const typename K::Iso_rectangle_2& bbox, + const typename K::Iso_rectangle_2& rec, const K&) { - return do_intersect_circle_box_2(circle, bbox, K()); + return do_intersect_circle_iso_rectangle_2(circle, rec, K()); } } // namespace internal diff --git a/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h b/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h deleted file mode 100644 index 30dc13b4580..00000000000 --- a/Intersections_2/include/CGAL/Intersections_2/internal/Bbox_2_Circle_2_do_intersect.h +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (c) 2018 GeometryFactory (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$ -// SPDX-License-Identifier: LGPL-3.0+ -// -// -// Author(s) : Andreas Fabri - - -#ifndef CGAL_INTERNAL_INTERSECTIONS_2_BBOX_2_CIRCLE_2_DO_INTERSECT_H -#define CGAL_INTERNAL_INTERSECTIONS_2_BBOX_2_CIRCLE_2_DO_INTERSECT_H - -#include -#include - -#include - - -namespace CGAL { -namespace Intersections { -namespace internal { - -// Circle_2 is not a disk, thus if the box is contained within the circle, there is no intersection. -template -bool do_intersect_circle_box_2(const typename K::Circle_2& circle, - const Box2& bbox, - const K&) -{ - typedef typename K::FT FT; - typedef typename K::Point_2 Point; - - Point center = circle.center(); - - // Check that the minimum distance to the box is smaller than the radius, otherwise there is - // no intersection. - FT distance = FT(0); - if(center.x() < FT(bbox.xmin())) - { - FT d = FT(bbox.xmin()) - center.x(); - distance += d * d; - } - else if(center.x() > FT(bbox.xmax())) - { - FT d = center.x() - FT(bbox.xmax()); - distance += d * d; - } - - if(center.y() < FT(bbox.ymin())) - { - FT d = FT(bbox.ymin()) - center.y(); - distance += d * d; - } - else if(center.y() > FT(bbox.ymax())) - { - FT d = center.y() - FT(bbox.ymax()); - distance += d * d; - } - - // Note that with the way the distance above is computed, the distance is '0' if the box strictly - // contains the circle. But since we use '>', we don't exit - if(distance > circle.squared_radius()) - return false; - - // Check that the maximum distance between the center of the circle and the box is not (strictly) - // smaller than the radius of the center, otherwise the box is entirely contained. - distance = FT(0); - if(center.x() <= FT(bbox.xmin() + bbox.xmax()) / FT(2)) - { - FT d = FT(bbox.xmax()) - center.x(); - distance += d * d; - } - else - { - FT d = center.x() - FT(bbox.xmin()); - distance += d * d; - } - - if(center.y() < FT(bbox.ymin() + bbox.ymax()) / FT(2)) - { - FT d = FT(bbox.ymax()) - center.y(); - distance += d * d; - } - else - { - FT d = center.y() - FT(bbox.ymin()); - distance += d * d; - } - - return (distance >= circle.squared_radius()); -} - -template -bool do_intersect(const CGAL::Bbox_2& bbox, - const typename K::Circle_2& circle, - const K&) -{ - return do_intersect_circle_box_2(circle, bbox, K()); -} - - -template -bool do_intersect(const typename K::Circle_2& circle, - const CGAL::Bbox_2& bbox, - const K&) -{ - return do_intersect_circle_box_2(circle, bbox, K()); -} - -} // namespace internal -} // namespace Intersections -} // namespace CGAL - -#endif // CGAL_INTERNAL_INTERSECTIONS_2_BBOX_2_CIRCLE_2_DO_INTERSECT_H From 38afb85b61e4af7bab153460ac798bcd8ee0a84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 20 May 2019 10:42:08 +0200 Subject: [PATCH 098/203] Fix broken Bbox_2_ray/line by basing them on Iso_rectangle_2 Removes the intersection(bbox_2, ray/line), but: - it was broken - it was undocumented If it's needed, just use an Iso_rectangle instead. --- .../CGAL/Intersections_2/Bbox_2_Line_2.h | 267 ++--------------- .../CGAL/Intersections_2/Bbox_2_Ray_2.h | 280 ++---------------- Intersections_2/include/CGAL/intersection_2.h | 2 + .../src/CGAL/Bbox_2_intersections.cpp | 34 --- .../Intersections_2/test_intersections_2.cpp | 34 +-- 5 files changed, 64 insertions(+), 553 deletions(-) delete mode 100644 Intersections_2/src/CGAL/Bbox_2_intersections.cpp diff --git a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Line_2.h b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Line_2.h index 7c9a7ff55db..a68eaa2a9a0 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Line_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Line_2.h @@ -23,275 +23,50 @@ // // Author(s) : Geert-Jan Giezeman - #ifndef CGAL_INTERSECTIONS_2_BBOX_2_LINE_2_H #define CGAL_INTERSECTIONS_2_BBOX_2_LINE_2_H #include #include -#include -#include + +#include namespace CGAL { namespace Intersections { namespace internal { -template -class Bbox_2_Line_2_pair; - -template -class Bbox_2_Line_2_pair_impl +template +bool do_intersect(const typename K::Line_2& line, + const CGAL::Bbox_2& bbox, + const K& k) { - typedef typename K::Line_2 Line_2; - -public: - Bbox_2_Line_2_pair_impl() {} - Bbox_2_Line_2_pair_impl(const Bbox_2& bb, const Line_2& line) - : _bbox(bb), _line(line), _known(false) - {} - - Bbox_2 _bbox; - Line_2 _line; - - mutable bool _known; - mutable typename Bbox_2_Line_2_pair::Intersection_results _result; - mutable double _min, _max; -}; - -template -class Bbox_2_Line_2_pair -{ - typedef Bbox_2_Line_2_pair Self; - - typedef typename K::Point_2 Point_2; - typedef typename K::Vector_2 Vector_2; - typedef typename K::Line_2 Line_2; - -public: - enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; - - Bbox_2_Line_2_pair() - { - pimpl = new Bbox_2_Line_2_pair_impl; - pimpl->_known = false; - } - Bbox_2_Line_2_pair(const Self& o) { pimpl = new Bbox_2_Line_2_pair_impl(*o.pimpl); } - Bbox_2_Line_2_pair(const Bbox_2& bbox, double line_a, double line_b, double line_c) { - pimpl = new Bbox_2_Line_2_pair_impl(bbox, Line_2(line_a, line_b, line_c)); - } - - ~Bbox_2_Line_2_pair() { delete pimpl; } - - Self& operator=(const Self& o) - { - *pimpl = *o.pimpl; - return *this; - } - - Intersection_results intersection_type() const - { - if (pimpl->_known) - return pimpl->_result; - - // The non const this pointer is used to cast away const. - pimpl->_known = true; - const Point_2 &ref_point = pimpl->_line.point(); - const Vector_2 &dir = pimpl->_line.direction().to_vector(); - bool to_infinity = true; - - // first on x value - if (dir.x() == 0.0) - { - if (ref_point.x() < pimpl->_bbox.xmin()) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - - if (ref_point.x() > pimpl->_bbox.xmax()) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } - else - { - double newmin, newmax; - if (dir.x() > 0.0) - { - newmin = (pimpl->_bbox.xmin()-ref_point.x())/dir.x(); - newmax = (pimpl->_bbox.xmax()-ref_point.x())/dir.x(); - } - else - { - newmin = (pimpl->_bbox.xmax()-ref_point.x())/dir.x(); - newmax = (pimpl->_bbox.xmin()-ref_point.x())/dir.x(); - } - - if (to_infinity) - { - pimpl->_min = newmin; - pimpl->_max = newmax; - } - else - { - if (newmin > pimpl->_min) - pimpl->_min = newmin; - if (newmax < pimpl->_max) - pimpl->_max = newmax; - if (pimpl->_max < pimpl->_min) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } - - to_infinity = false; - } - - // now on y value - if (dir.y() == 0.0) - { - if (ref_point.y() < pimpl->_bbox.ymin()) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - - if (ref_point.y() > pimpl->_bbox.ymax()) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } - else - { - double newmin, newmax; - if (dir.y() > 0.0) - { - newmin = (pimpl->_bbox.ymin()-ref_point.y())/dir.y(); - newmax = (pimpl->_bbox.ymax()-ref_point.y())/dir.y(); - } - else - { - newmin = (pimpl->_bbox.ymax()-ref_point.y())/dir.y(); - newmax = (pimpl->_bbox.ymin()-ref_point.y())/dir.y(); - } - - if (to_infinity) - { - pimpl->_min = newmin; - pimpl->_max = newmax; - } - else - { - if (newmin > pimpl->_min) - pimpl->_min = newmin; - if (newmax < pimpl->_max) - pimpl->_max = newmax; - if (pimpl->_max < pimpl->_min) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } - - to_infinity = false; - } - - CGAL_kernel_assertion(!to_infinity); - if (pimpl->_max == pimpl->_min) - { - pimpl->_result = POINT; - return pimpl->_result; - } - - pimpl->_result = SEGMENT; - return pimpl->_result; - } - - bool intersection(double& x, double& y) const - { - if (!pimpl->_known) - intersection_type(); - if (pimpl->_result != POINT) - return false; - - Point_2 pt(pimpl->_line.point() + pimpl->_min*pimpl->_line.direction().to_vector()); - x = pt.x(); - y = pt.y(); - - return true; - } - - bool intersection(double& x1, double& y1, double& x2, double& y2) const - { - if (!pimpl->_known) - intersection_type(); - if (pimpl->_result != SEGMENT) - return false; - - Point_2 p1(pimpl->_line.point() + pimpl->_min*pimpl->_line.direction().to_vector()); - Point_2 p2(pimpl->_line.point() + pimpl->_max*pimpl->_line.direction().to_vector()); - x1 = p1.x(); - y1 = p1.y(); - x2 = p2.x(); - y2 = p2.y(); - - return true; - } - -protected: - Bbox_2_Line_2_pair_impl *pimpl; -}; - -template -inline bool do_intersect_line_2(const Bbox_2 &box, double line_a, double line_b, double line_c, const K& k = K()) -{ - Bbox_2_Line_2_pair pair(box, line_a, line_b, line_c); - - return pair.intersection_type() != Bbox_2_Line_2_pair::NO_INTERSECTION; + typedef typename K::Iso_rectangle_2 Iso_rectangle_2; + return Intersections::internal::do_intersect(line, Iso_rectangle_2(bbox), k); } -template -bool do_intersect_line_2(const Bbox_2& bbox, const Line_2& line, const K& k = K()) +template +bool do_intersect(const CGAL::Bbox_2& bbox, + const typename K::Line_2& line, + const K& k) { - return do_intersect_line_2(bbox, to_double(line.a()), to_double(line.b()), to_double(line.c()), k); -} - -template -bool do_intersect_line_2(const Line_2& line, const Bbox_2& bbox, const K& k = K()) -{ - return do_intersect_line_2(bbox, to_double(line.a()), to_double(line.b()), to_double(line.c()), k); -} - -template -inline bool do_intersect(const typename K::Line_2& line, const Bbox_2& bbox, const K& k = K()) -{ - return do_intersect_line_2(bbox, line, k); -} - -template -inline bool do_intersect(const Bbox_2& bbox, const typename K::Line_2& line, const K& k = K()) -{ - return do_intersect_line_2(bbox, line, k); + return Intersections::internal::do_intersect(line, bbox, k); } } // namespace internal } // namespace Intersections -template -inline bool do_intersect(const Line_2& line, const Bbox_2& box) +template +bool do_intersect(const CGAL::Bbox_2& bbox, const Line_2& line) { - return Intersections::internal::do_intersect(box, line); + return K().do_intersect_2_object()(bbox, line); } -template -inline bool do_intersect(const Bbox_2& box, const Line_2& line) +template +bool do_intersect(const Line_2& line, const CGAL::Bbox_2& bbox) { - return Intersections::internal::do_intersect(box, line); + return K().do_intersect_2_object()(line, bbox); } -} //namespace CGAL +} // namespace CGAL -#endif +#endif // CGAL_INTERSECTIONS_2_BBOX_2_LINE_2_H diff --git a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Ray_2.h b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Ray_2.h index 1912ac8ffae..589283cc222 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Ray_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Bbox_2_Ray_2.h @@ -1,9 +1,9 @@ -// Copyright (c) 2000 +// Copyright (c) 2000 // Utrecht University (The Netherlands), // ETH Zurich (Switzerland), // INRIA Sophia-Antipolis (France), // Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). All rights reserved. +// 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 Lesser General Public License as @@ -19,284 +19,54 @@ // $URL$ // $Id$ // SPDX-License-Identifier: LGPL-3.0+ -// +// // // Author(s) : Geert-Jan Giezeman -#ifndef CGAL_INTERSECTIONS_BBOX_2_RAY_2_H -#define CGAL_INTERSECTIONS_BBOX_2_RAY_2_H +#ifndef CGAL_INTERSECTIONS_2_BBOX_2_RAY_2_H +#define CGAL_INTERSECTIONS_2_BBOX_2_RAY_2_H #include #include -#include -#include + +#include namespace CGAL { namespace Intersections { namespace internal { -template -class Bbox_2_Ray_2_pair; - -template -class Bbox_2_Ray_2_pair_impl +template +bool do_intersect(const typename K::Ray_2& ray, + const CGAL::Bbox_2& bbox, + const K& k) { - typedef typename K::Point_2 Point_2; - typedef typename K::Vector_2 Vector_2; - typedef typename K::Ray_2 Ray_2; - -public: - Bbox_2_Ray_2_pair_impl():_known(false) {} - Bbox_2_Ray_2_pair_impl(const Bbox_2& bbox, - const Point_2& pt, - const Vector_2& dir) - :_box(bbox), _known(false), _ref_point(pt), _dir(dir), _min(0.0) - {} - - Ray_2 _ray; - Bbox_2 _box; - bool _known; - - typename Bbox_2_Ray_2_pair::Intersection_results _result; - Point_2 _ref_point; - Vector_2 _dir; - - double _min, _max; -}; - -template -class Bbox_2_Ray_2_pair -{ - typedef Bbox_2_Ray_2_pair Self; - typedef typename K::Point_2 Point_2; - typedef typename K::Vector_2 Vector_2; - -public: - enum Intersection_results {NO_INTERSECTION, POINT, SEGMENT}; - - ~Bbox_2_Ray_2_pair() { delete pimpl; } - Bbox_2_Ray_2_pair() { pimpl = new Bbox_2_Ray_2_pair_impl; } - Bbox_2_Ray_2_pair(const Self& o) { pimpl = new Bbox_2_Ray_2_pair_impl(*o.pimpl); } - Bbox_2_Ray_2_pair(Bbox_2 const &bbox, double x, double y, double dx, double dy) { - pimpl = new Bbox_2_Ray_2_pair_impl(bbox, Point_2(x,y), Vector_2(dx,dy)); - } - - Self& operator=(const Self& o) - { - *pimpl = *o.pimpl; - return *this; - } - - Intersection_results intersection_type() const - { - if(pimpl->_known) - return pimpl->_result; - - pimpl->_known = true; - bool to_infinity = true; - - // first on x value - if(pimpl->_dir.x() == 0.0) - { - if(pimpl->_ref_point.x() < pimpl->_box.xmin()) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - - if(pimpl->_ref_point.x() > pimpl->_box.xmax()) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } - else - { - double newmin, newmax; - if(pimpl->_dir.x() > 0.0) - { - newmin =(pimpl->_box.xmin()-pimpl->_ref_point.x())/pimpl->_dir.x(); - newmax =(pimpl->_box.xmax()-pimpl->_ref_point.x())/pimpl->_dir.x(); - } - else - { - newmin =(pimpl->_box.xmax()-pimpl->_ref_point.x())/pimpl->_dir.x(); - newmax =(pimpl->_box.xmin()-pimpl->_ref_point.x())/pimpl->_dir.x(); - } - - if(newmin > pimpl->_min) - pimpl->_min = newmin; - - if(to_infinity) - { - pimpl->_max = newmax; - } - else - { - if(newmax < pimpl->_max) - pimpl->_max = newmax; - } - - if(pimpl->_max < pimpl->_min) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - - to_infinity = false; - } - - // now on y value - if(pimpl->_dir.y() == 0.0) - { - if(pimpl->_ref_point.y() < pimpl->_box.ymin()) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - - if(pimpl->_ref_point.y() > pimpl->_box.ymax()) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - } - else - { - double newmin, newmax; - if(pimpl->_dir.y() > 0.0) - { - newmin =(pimpl->_box.ymin()-pimpl->_ref_point.y())/pimpl->_dir.y(); - newmax =(pimpl->_box.ymax()-pimpl->_ref_point.y())/pimpl->_dir.y(); - } - else - { - newmin =(pimpl->_box.ymax()-pimpl->_ref_point.y())/pimpl->_dir.y(); - newmax =(pimpl->_box.ymin()-pimpl->_ref_point.y())/pimpl->_dir.y(); - } - - if(newmin > pimpl->_min) - pimpl->_min = newmin; - - if(to_infinity) - { - pimpl->_max = newmax; - } - else - { - if(newmax < pimpl->_max) - pimpl->_max = newmax; - } - - if(pimpl->_max < pimpl->_min) - { - pimpl->_result = NO_INTERSECTION; - return pimpl->_result; - } - - to_infinity = false; - } - - CGAL_kernel_assertion(!to_infinity); - - if(pimpl->_max == pimpl->_min) - { - pimpl->_result = POINT; - return pimpl->_result; - } - - pimpl->_result = SEGMENT; - return pimpl->_result; - } - - bool intersection(double& x, double& y) const - { - if(!pimpl->_known) - intersection_type(); - - if(pimpl->_result != POINT) - return false; - - Point_2 pt = pimpl->_ref_point + pimpl->_min*pimpl->_dir; - x = pt.x(); - y = pt.y(); - - return true; - } - - bool intersection(double& x1, double& y1, double& x2, double& y2) const - { - if(!pimpl->_known) - intersection_type(); - - if(pimpl->_result != SEGMENT) - return false; - - Point_2 p1(pimpl->_ref_point + pimpl->_min*pimpl->_dir); - Point_2 p2(pimpl->_ref_point + pimpl->_max*pimpl->_dir); - x1 = p1.x(); - y1 = p1.y(); - x2 = p2.x(); - y2 = p2.y(); - - return true; - } - -protected: - Bbox_2_Ray_2_pair_impl* pimpl; -}; - -template -bool do_intersect_ray_2(const Bbox_2& bbox, double x, double y, double dx, double dy, const K& k) -{ - Bbox_2_Ray_2_pair pair(bbox, x, y, dx, dy); - return pair.intersection_type() != Bbox_2_Ray_2_pair::NO_INTERSECTION; + typedef typename K::Iso_rectangle_2 Iso_rectangle_2; + return Intersections::internal::do_intersect(ray, Iso_rectangle_2(bbox), k); } -template -bool do_intersect_ray_2(const Bbox_2 &box, const Ray_2 &ray, const K& k = K()) +template +bool do_intersect(const CGAL::Bbox_2& bbox, + const typename K::Ray_2& ray, + const K& k) { - double startx = to_double(ray.start().x()); - double starty = to_double(ray.start().y()); - double dx = to_double(ray.direction().to_vector().x()); - double dy = to_double(ray.direction().to_vector().y()); - - return do_intersect_ray_2(box, startx, starty, dx, dy, k); -} - -template -inline bool do_intersect_ray_2(const Ray_2 &ray, const Bbox_2 &box, const K& k = K()) -{ - return do_intersect_ray_2(box, ray, k); -} - -template -inline bool do_intersect(const typename K::Ray_2& line, const Bbox_2& bbox, const K& k = K()) -{ - return do_intersect_ray_2(bbox, line, k); -} - -template -inline bool do_intersect(const Bbox_2& bbox, const typename K::Ray_2& line, const K& k = K()) -{ - return do_intersect_ray_2(bbox, line, k); + return Intersections::internal::do_intersect(ray, bbox, k); } } // namespace internal } // namespace Intersections -template -inline bool do_intersect(const Ray_2& line, const Bbox_2& box) +template +bool do_intersect(const CGAL::Bbox_2& bbox, const Ray_2& ray) { - return Intersections::internal::do_intersect(box, line); + return K().do_intersect_2_object()(bbox, ray); } -template -inline bool do_intersect(const Bbox_2& box, const Ray_2& line) +template +bool do_intersect(const Ray_2& ray, const CGAL::Bbox_2& bbox) { - return Intersections::internal::do_intersect(box, line); + return K().do_intersect_2_object()(ray, bbox); } } // namespace CGAL -#endif +#endif // CGAL_INTERSECTIONS_2_BBOX_2_RAY_2_H diff --git a/Intersections_2/include/CGAL/intersection_2.h b/Intersections_2/include/CGAL/intersection_2.h index b3078e31a5b..188bdd4e553 100644 --- a/Intersections_2/include/CGAL/intersection_2.h +++ b/Intersections_2/include/CGAL/intersection_2.h @@ -29,7 +29,9 @@ #define CGAL_INTERSECTION_2_H #include +#include #include +#include #include #include diff --git a/Intersections_2/src/CGAL/Bbox_2_intersections.cpp b/Intersections_2/src/CGAL/Bbox_2_intersections.cpp deleted file mode 100644 index 3e0edcecc58..00000000000 --- a/Intersections_2/src/CGAL/Bbox_2_intersections.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2000 -// 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 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$ -// SPDX-License-Identifier: LGPL-3.0+ -// -// -// Author(s) : Geert-Jan Giezeman - -#ifndef CGAL_HEADER_ONLY - -#include -#include - -#include -#include - -#endif // CGAL_HEADER_ONLY diff --git a/Intersections_2/test/Intersections_2/test_intersections_2.cpp b/Intersections_2/test/Intersections_2/test_intersections_2.cpp index 4b8f300b6d0..1362179f713 100644 --- a/Intersections_2/test/Intersections_2/test_intersections_2.cpp +++ b/Intersections_2/test/Intersections_2/test_intersections_2.cpp @@ -191,23 +191,22 @@ struct Test check_do_intersect (p(0, 0).bbox() + p(10, 10).bbox(), C(p( 3, 2), 3)); } - // @fixme, bbox_2_line_2.h is all kind of broken void B_L() { std::cout << "Bbox - Line (TODO)" << std::endl; // no intersection -// check_no_do_intersect (p(0,0).bbox() , L(p( 1,1), p( 0,1))); -// check_no_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p(-1,1), p(-1,5))); + check_no_do_intersect (p(0,0).bbox() , L(p( 1,1), p( 0,1))); + check_no_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p(-1,1), p(-1,5))); // point intersection -// check_do_intersect (p( 0, 0).bbox() , L(p(-1,1), p(1,-1))); -// check_do_intersect (p(-1,-1).bbox() + p(4,2).bbox(), L(p( 1,5), p(-3,1))); + check_do_intersect (p( 0, 0).bbox() , L(p(-1,1), p( 1,-1))); + check_do_intersect (p(-1,-1).bbox() + p(4,2).bbox(), L(p( 1,5), p(-3,-1))); // segment intersection -// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p(-1, 5), p(7,5))); -// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p(-1, 5), p(2,5))); -// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p( 4,-3), p(4,1))); + check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p(-1, 5), p(7,5))); + check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p(-1, 5), p(2,5))); + check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), L(p( 4,-3), p(4,1))); } void B_P() @@ -225,23 +224,22 @@ struct Test check_intersection (p(1,2).bbox() + p(4,6).bbox(), p(3,3), p(3,3)); // point is within the bbox } - // @fixme, bbox_2_ray_2.h is all kind of broken void B_R() { std::cout << "Bbox - Ray (TODO)" << std::endl; // no intersection -// check_no_do_intersect (p(0,0).bbox() , R(p( 1,1), p( 0,1))); -// check_no_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p(-1,1), p(-1,5))); + check_no_do_intersect (p(0,0).bbox() , R(p( 1,1), p( 0,1))); + check_no_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p(-1,1), p(-1,5))); // point intersection -// check_do_intersect (p( 0, 0).bbox() , R(p(-1,1), p(1,-1))); -// check_do_intersect (p(-1,-1).bbox() + p(4,2).bbox(), R(p( 1,5), p(-3,1))); + check_do_intersect (p( 0, 0).bbox() , R(p(-1,1), p( 1,-1))); + check_do_intersect (p(-1,-1).bbox() + p(4,2).bbox(), R(p( 1,5), p(-3,-1))); // segment intersection -// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p(-1, 5), p(7,5))); -// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p(-1, 5), p(2,5))); -// check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p( 4,-3), p(4,1))); + check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p(-1, 5), p(7,5))); + check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p(-1, 5), p(2,5))); + check_do_intersect (p(0,0).bbox() + p(4,5).bbox(), R(p( 4,-3), p(4,1))); } void C_C() @@ -315,7 +313,7 @@ struct Test // point intersection check_intersection (C(p( 3, 4), 16) , p( 7, 4), p(7, 4)); check_intersection (C(p( 0, 5), p(5, 0), p(-5, 0)), p( 0, -5), p(0, -5)); -// check_intersection (C(p( 3, 4), p(2, 6), p( 1, 5)), p( 1, 5), p(1, 5)); // homogenous kernel is too imprecise +// check_intersection (C(p( 3, 4), p(2, 6), p( 1, 5)), p( 1, 5), p(1, 5)); check_intersection

(C(p( 0, 0), 25) , p( 5, 0)); } @@ -798,7 +796,7 @@ int main() { Test< CGAL::Simple_cartesian::Type > >().run(); Test< CGAL::Cartesian >().run(); - Test< CGAL::Homogeneous >().run(); + Test< CGAL::Homogeneous::Type > >().run(); Test< CGAL::Exact_predicates_inexact_constructions_kernel >().run(); Test< CGAL::Exact_predicates_exact_constructions_kernel >().run(); } From 4b66010b75d92402a2128648437a4dc7300ce013 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 21 May 2019 13:33:05 +0200 Subject: [PATCH 099/203] Fix znear management in orthographic mode --- GraphicsView/include/CGAL/Qt/camera.h | 11 ++++ GraphicsView/include/CGAL/Qt/camera_impl.h | 3 +- Polyhedron/demo/Polyhedron/Viewer.cpp | 60 +++++++++++++++++----- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/GraphicsView/include/CGAL/Qt/camera.h b/GraphicsView/include/CGAL/Qt/camera.h index 5d621bd5d0e..6ff78265792 100644 --- a/GraphicsView/include/CGAL/Qt/camera.h +++ b/GraphicsView/include/CGAL/Qt/camera.h @@ -299,6 +299,16 @@ public Q_SLOTS: zClippingCoef_ = coef; projectionMatrixIsUpToDate_ = false; } + /*! Sets the zNear value in orthographic mode. */ + void setOrthoZNear(qreal z) + { + m_zMin = z; + } + /*! Returns the zNear value in orthographic mode*/ + qreal orthoZNear() + { + return m_zMin; + } //@} /*! @name Scene radius and center */ @@ -463,6 +473,7 @@ private: mutable bool modelViewMatrixIsUpToDate_; mutable GLdouble projectionMatrix_[16]; // Buffered projection matrix. mutable bool projectionMatrixIsUpToDate_; + qreal m_zMin; //USed for near plane in orthographic projection. // S t e r e o p a r a m e t e r s qreal IODistance_; // inter-ocular distance, in meters diff --git a/GraphicsView/include/CGAL/Qt/camera_impl.h b/GraphicsView/include/CGAL/Qt/camera_impl.h index 2241ca9a40e..0680c4d8a29 100644 --- a/GraphicsView/include/CGAL/Qt/camera_impl.h +++ b/GraphicsView/include/CGAL/Qt/camera_impl.h @@ -46,6 +46,7 @@ CGAL_INLINE_FUNCTION Camera::Camera(QObject *parent) : frame_(NULL), fieldOfView_(CGAL_PI / 4.0), modelViewMatrixIsUpToDate_(false), projectionMatrixIsUpToDate_(false) { + m_zMin = 0; setParent(parent); // #CONNECTION# Camera copy constructor interpolationKfi_ = new KeyFrameInterpolator; @@ -228,7 +229,7 @@ qreal Camera::zNear() const { z = zMin; break; case Camera::ORTHOGRAPHIC: - z = 0.0; + z = m_zMin; break; } return z; diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index ae26fd47029..a1daacb0a76 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -621,11 +621,23 @@ void Viewer::keyPressEvent(QKeyEvent* e) } else if(e->key() == Qt::Key_M) { d->macro_mode = ! d->macro_mode; - - if(d->macro_mode) { + switch(camera()->type()){ + case CGAL::qglviewer::Camera::PERSPECTIVE: + if(d->macro_mode) { camera()->setZNearCoefficient(0.0005f); - } else { - camera()->setZNearCoefficient(0.005f); + } else { + camera()->setZNearCoefficient(0.005f); + } + break; + case CGAL::qglviewer::Camera::ORTHOGRAPHIC: + if(d->macro_mode) { + camera()->setOrthoZNear(-0.5f); + } else { + camera()->setOrthoZNear(0.0f); + } + break; + deafult: + break; } this->displayMessage(tr("Macro mode: %1"). arg(d->macro_mode ? tr("on") : tr("off"))); @@ -1351,19 +1363,39 @@ QOpenGLShaderProgram* Viewer::getShaderProgram(int name) const void Viewer::wheelEvent(QWheelEvent* e) { - if(e->modifiers().testFlag(Qt::ShiftModifier)) + if(e->modifiers().testFlag(Qt::ShiftModifier)) + { + double delta = e->delta(); + if(delta>0) { - double delta = e->delta(); - if(delta>0) - { - camera()->setZNearCoefficient(camera()->zNearCoefficient() * 1.01); - } - else - camera()->setZNearCoefficient(camera()->zNearCoefficient() / 1.01); - update(); + switch(camera()->type()) + { + case CGAL::qglviewer::Camera::ORTHOGRAPHIC: + camera()->setOrthoZNear(camera()->orthoZNear() + 0.01); + break; + case CGAL::qglviewer::Camera::PERSPECTIVE: + camera()->setZNearCoefficient(camera()->zNearCoefficient() * 1.01); + break; + default: + break; + } } else - CGAL::QGLViewer::wheelEvent(e); + switch(camera()->type()) + { + case CGAL::qglviewer::Camera::ORTHOGRAPHIC: + camera()->setOrthoZNear(camera()->orthoZNear() - 0.01); + break; + case CGAL::qglviewer::Camera::PERSPECTIVE: + camera()->setZNearCoefficient(camera()->zNearCoefficient() / 1.01); + break; + default: + break; + } + update(); + } + else + CGAL::QGLViewer::wheelEvent(e); } bool Viewer::testDisplayId(double x, double y, double z) From f08f69e745318d06815e33c1d4c60b95ae2ba294 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 21 May 2019 13:44:23 +0200 Subject: [PATCH 100/203] fix text items not displayed entirely --- Three/include/CGAL/Three/TextRenderer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Three/include/CGAL/Three/TextRenderer.h b/Three/include/CGAL/Three/TextRenderer.h index d9c3417fd21..75a7be68623 100644 --- a/Three/include/CGAL/Three/TextRenderer.h +++ b/Three/include/CGAL/Three/TextRenderer.h @@ -60,7 +60,7 @@ public : :x(p_x), y(p_y), z(p_z),_3D(p_3D), _is_always_visible(always_visible), m_text(p_text), m_font(font), m_color(p_color) { QFontMetrics fm(m_font); - _width = float(fm.width(m_text)); + _width = float(fm.horizontalAdvance(m_text)+2); _height = float(fm.height()); } //!\brief Accessor for the string From 086136716932fba420474e7608c7ced5e101a75c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 22 May 2019 12:06:40 +0200 Subject: [PATCH 101/203] Replace the planes by a vector+point The idea with those planes is a sort of pre-computation of minors of the determinant of the orientation of `(p,q,r,s)`, with `(p,q,r)` fixed. But the three minors are only the coordinates `(a,b,c)` of the plane defined by `(p,q,r)`, and the coordinate `d` is the determinant of the orientation of `(p,q,r,O)` where `O` is the origin of the Euclidean plane. We do not want to compute that `d`! So, instead of computing planes, one computes only the normal `(a,b,c)` of the plan `(p,q,r)`, and a stores it with `p`. That allows to compute the determinant of `orientation(p,q,r,s)` once `s` is known. --- Convex_hull_3/include/CGAL/convex_hull_3.h | 52 +++++++++++++++------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/Convex_hull_3/include/CGAL/convex_hull_3.h b/Convex_hull_3/include/CGAL/convex_hull_3.h index 531bfd3d943..ba0200f7164 100644 --- a/Convex_hull_3/include/CGAL/convex_hull_3.h +++ b/Convex_hull_3/include/CGAL/convex_hull_3.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -236,17 +237,23 @@ public: //and in case of failure, exact arithmetic is used. template class Is_on_positive_side_of_plane_3, boost::true_type >{ - typedef Simple_cartesian::Type> PK; - typedef Simple_cartesian CK; + typedef Simple_cartesian::Type> Exact_K; + typedef Simple_cartesian Approx_K; typedef Convex_hull_traits_3 Traits; typedef typename Traits::Point_3 Point_3; - Cartesian_converter to_CK; - Cartesian_converter to_PK; + Cartesian_converter to_AK; + Cartesian_converter to_EK; + + template + struct Vector_plus_point { + typename K::Vector_3 vector; + typename K::Point_3 point; + }; const Point_3& p,q,r; - mutable typename CK::Plane_3* ck_plane; - mutable typename PK::Plane_3* pk_plane; + mutable Vector_plus_point ak_plane; + mutable Vector_plus_point* ek_plane_ptr; double m10,m20,m21,Maxx,Maxy,Maxz; @@ -292,8 +299,13 @@ public: typedef typename Interval_nt_advanced::Protector Protector; Is_on_positive_side_of_plane_3(const Traits&,const Point_3& p_,const Point_3& q_,const Point_3& r_) - :p(p_),q(q_),r(r_),ck_plane(NULL),pk_plane(NULL) + : p(p_),q(q_),r(r_) + , ak_plane() + , ek_plane_ptr(0) { + ak_plane.vector = + typename Approx_K::Vector_3(Interval_nt_advanced(0., std::numeric_limits::infinity()), + 0., 0.); double pqx = q.x() - p.x(); double pqy = q.y() - p.y(); double pqz = q.z() - p.z(); @@ -319,8 +331,7 @@ public: } ~Is_on_positive_side_of_plane_3(){ - if (ck_plane!=NULL) delete ck_plane; - if (pk_plane!=NULL) delete pk_plane; + if (ek_plane_ptr!=NULL) delete ek_plane_ptr; } bool operator() (const Point_3& s) const @@ -334,14 +345,25 @@ public: return static_res == 1; try{ - if (ck_plane==NULL) - ck_plane=new typename CK::Plane_3(to_CK(p),to_CK(q),to_CK(r)); - return ck_plane->has_on_positive_side(to_CK(s)); + // infinity() is the sentinel for uninitialized `ak_plane` + if (ak_plane.vector.x().sup() == std::numeric_limits::infinity()) + { + const typename Approx_K::Point_3 ap = to_AK(p); + ak_plane.vector = cross_product(to_AK(q)-ap, to_AK(r)-ap); + ak_plane.point = ap; + } + return sign(scalar_product(to_AK(s) - ak_plane.point, + ak_plane.vector)) == POSITIVE; } catch (Uncertain_conversion_exception&){ - if (pk_plane==NULL) - pk_plane=new typename PK::Plane_3(to_PK(p),to_PK(q),to_PK(r)); - return pk_plane->has_on_positive_side(to_PK(s)); + if (ek_plane_ptr==NULL) { + const typename Exact_K::Point_3 ep = to_EK(p); + ek_plane_ptr = new Vector_plus_point; + ek_plane_ptr->vector = cross_product(to_EK(q)-ep, to_EK(r)-ep); + ek_plane_ptr->point = ep; + } + return sign(scalar_product(to_EK(s) - ek_plane_ptr->point, + ek_plane_ptr->vector)) == POSITIVE; } } }; From 4f8b67e115f889eed779ed733ce2320e04b403a7 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 22 May 2019 13:20:12 +0200 Subject: [PATCH 102/203] Fix nef_3 item normals --- Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp index 57b5a2fc816..362c34ee29b 100644 --- a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp @@ -286,6 +286,14 @@ void Scene_nef_polyhedron_item_priv::compute_normals_and_vertices(void) const Nef_polyhedron::Vector_3 v = f->plane().orthogonal_vector(); + if(f->plane().a() != 0) + v /= f->plane().a(); + else if(f->plane().b() != 0) + v /= f->plane().b(); + else if(f->plane().c() != 0) + v /= f->plane().c(); + else if(f->plane().d() != 0) + v /= f->plane().d(); GLfloat normal[3]; normal[0] = CGAL::to_double(v.x()); normal[1] = CGAL::to_double(v.y()); From c4d774efb87706e48f36c530886452ed71536d1d Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 22 May 2019 15:20:54 +0200 Subject: [PATCH 103/203] Fix return values of bool functions --- Stream_support/include/CGAL/IO/read_3mf.h | 4 ++-- Stream_support/include/CGAL/IO/write_3mf.h | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Stream_support/include/CGAL/IO/read_3mf.h b/Stream_support/include/CGAL/IO/read_3mf.h index 3448ca8b7a0..1e6d691512d 100644 --- a/Stream_support/include/CGAL/IO/read_3mf.h +++ b/Stream_support/include/CGAL/IO/read_3mf.h @@ -101,7 +101,7 @@ bool extract_soups (NMR::PLib3MFModelMeshObject *pMeshObject, NMR::lib3mf_getlasterror(pMeshObject, &nErrorMessage, &pszErrorMessage); std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(pMeshObject); - return -1; + return false; } for(DWORD vid = 0; vid < points.size(); ++vid) @@ -182,7 +182,7 @@ bool extract_polylines (NMR::PLib3MFModelMeshObject *pMeshObject, NMR::lib3mf_getlasterror(pMeshObject, &nErrorMessage, &pszErrorMessage); std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(pMeshObject); - return -1; + return false; } points.resize(points.size()-3);//ignore dummy_vertices diff --git a/Stream_support/include/CGAL/IO/write_3mf.h b/Stream_support/include/CGAL/IO/write_3mf.h index 32a6d23a3f2..199764f91bf 100644 --- a/Stream_support/include/CGAL/IO/write_3mf.h +++ b/Stream_support/include/CGAL/IO/write_3mf.h @@ -176,7 +176,7 @@ bool write_mesh_to_model( const PointRange& points, std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(*pMeshObject); NMR::lib3mf_release(pModel); - return -1; + return false; } // define colors @@ -199,7 +199,7 @@ bool write_mesh_to_model( const PointRange& points, std::cerr<< "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(*pMeshObject); NMR::lib3mf_release(pModel); - return -1; + return false; } NMR::MODELMESHCOLOR_SRGB default_color = tmf_internal::fnCreateColor(0,0,0,0); NMR::lib3mf_defaultpropertyhandler_setcolor(pDefaultPropertyHandler, @@ -216,11 +216,11 @@ bool write_mesh_to_model( const PointRange& points, std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(*pMeshObject); NMR::lib3mf_release(pModel); - return -1; + return false; } //add a builditem to finish - add_build_item(pModel, *pMeshObject); + return add_build_item(pModel, *pMeshObject); } //remember that it adds 3 demmy vertices in the beginning, and a dummy triangle to be ignored. @@ -278,7 +278,7 @@ bool write_points(const PointRange& points, std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(*pMeshObject); NMR::lib3mf_release(pModel); - return -1; + return false; } // define colors @@ -298,7 +298,7 @@ bool write_points(const PointRange& points, std::cerr<< "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(*pMeshObject); NMR::lib3mf_release(pModel); - return -1; + return false; } NMR::MODELMESHCOLOR_SRGB default_color = tmf_internal::fnCreateColor(0,0,0,0); NMR::lib3mf_defaultpropertyhandler_setcolor(pDefaultPropertyHandler, @@ -315,9 +315,9 @@ bool write_points(const PointRange& points, std::cerr << "error #" << std::hex << nErrorMessage << ": " << pszErrorMessage << std::endl; NMR::lib3mf_release(*pMeshObject); NMR::lib3mf_release(pModel); - return -1; + return false; } - add_build_item(pModel, *pMeshObject); + return add_build_item(pModel, *pMeshObject); } template @@ -330,7 +330,7 @@ bool write_point_cloud_to_model(const PointRange& points, { std::string pc_name = name; pc_name.append("_cgal_pc"); - write_points(points, color, pc_name, pMeshObject, pModel); + return write_points(points, color, pc_name, pMeshObject, pModel); } template @@ -343,7 +343,7 @@ bool write_polyline_to_model(const PointRange& points, { std::string pc_name = name; pc_name.append("_cgal_pl"); - write_points(points, color, pc_name, pMeshObject, pModel); + return write_points(points, color, pc_name, pMeshObject, pModel); } /*! From a126f2173e195ef8748110b28f4236b33a4e6217 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 22 May 2019 15:21:50 +0200 Subject: [PATCH 104/203] Use is_certain to avoid throwing exceptions --- Convex_hull_3/include/CGAL/convex_hull_3.h | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Convex_hull_3/include/CGAL/convex_hull_3.h b/Convex_hull_3/include/CGAL/convex_hull_3.h index ba0200f7164..18f5464f93a 100644 --- a/Convex_hull_3/include/CGAL/convex_hull_3.h +++ b/Convex_hull_3/include/CGAL/convex_hull_3.h @@ -352,19 +352,22 @@ public: ak_plane.vector = cross_product(to_AK(q)-ap, to_AK(r)-ap); ak_plane.point = ap; } - return sign(scalar_product(to_AK(s) - ak_plane.point, - ak_plane.vector)) == POSITIVE; - } - catch (Uncertain_conversion_exception&){ - if (ek_plane_ptr==NULL) { - const typename Exact_K::Point_3 ep = to_EK(p); - ek_plane_ptr = new Vector_plus_point; - ek_plane_ptr->vector = cross_product(to_EK(q)-ep, to_EK(r)-ep); - ek_plane_ptr->point = ep; + Uncertain res = + sign(scalar_product(to_AK(s) - ak_plane.point, + ak_plane.vector)); + if(is_certain(res)) { + return (get_certain(res) == POSITIVE); } - return sign(scalar_product(to_EK(s) - ek_plane_ptr->point, - ek_plane_ptr->vector)) == POSITIVE; } + catch (Uncertain_conversion_exception&){} + if (ek_plane_ptr==NULL) { + const typename Exact_K::Point_3 ep = to_EK(p); + ek_plane_ptr = new Vector_plus_point; + ek_plane_ptr->vector = cross_product(to_EK(q)-ep, to_EK(r)-ep); + ek_plane_ptr->point = ep; + } + return sign(scalar_product(to_EK(s) - ek_plane_ptr->point, + ek_plane_ptr->vector)) == POSITIVE; } }; From 47b14e656d909c13095a2b165494a3f948428ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 24 May 2019 08:14:12 +0200 Subject: [PATCH 105/203] Fix order of checks to avoid calling back() on an empty vector --- .../include/CGAL/Intersections_2/Iso_rectangle_2_Triangle_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Intersections_2/include/CGAL/Intersections_2/Iso_rectangle_2_Triangle_2.h b/Intersections_2/include/CGAL/Intersections_2/Iso_rectangle_2_Triangle_2.h index 176914e474d..77ba8ec266c 100644 --- a/Intersections_2/include/CGAL/Intersections_2/Iso_rectangle_2_Triangle_2.h +++ b/Intersections_2/include/CGAL/Intersections_2/Iso_rectangle_2_Triangle_2.h @@ -273,7 +273,7 @@ namespace internal { typename std::vector::iterator last = std::unique(result.begin(),result.end()); result.erase(last,result.end()); - while(result.back() == result.front() && result.size() > 1) + while(result.size() > 1 && result.back() == result.front()) result.pop_back(); switch(result.size()){ From 120269239420d2c0d591aa4ac7e6452f31a59642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 24 May 2019 08:14:56 +0200 Subject: [PATCH 106/203] Add a test --- Intersections_2/test/Intersections_2/test_intersections_2.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Intersections_2/test/Intersections_2/test_intersections_2.cpp b/Intersections_2/test/Intersections_2/test_intersections_2.cpp index 1362179f713..42137e92c97 100644 --- a/Intersections_2/test/Intersections_2/test_intersections_2.cpp +++ b/Intersections_2/test/Intersections_2/test_intersections_2.cpp @@ -722,6 +722,7 @@ struct Test // no intersection check_no_intersection (Rec(p( 10, 12), p(30, 40)), T(p( 4, 0), p( 12, 4), p(-4, 8))); + check_no_intersection (Rec(p( 2, 0), p( 3, 1)), T(p( 0, 3), p( 3, 3), p( 0, 0))); // point intersection check_intersection

(Rec(p( 0, 0), p(1, 1)), T(p( -1, 0), p( 0, 0), p( 0, -1))); // intersection at a vertex From 084cdc37971f3be522a0c677e4fe02cb09b6b7c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 24 May 2019 08:24:38 +0200 Subject: [PATCH 107/203] Fix order of checks to avoid calling back() on an empty vector --- .../include/CGAL/Triangle_2_Iso_rectangle_2_intersection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Intersections_2/include/CGAL/Triangle_2_Iso_rectangle_2_intersection.h b/Intersections_2/include/CGAL/Triangle_2_Iso_rectangle_2_intersection.h index 2bd8191b5b4..439705a116f 100644 --- a/Intersections_2/include/CGAL/Triangle_2_Iso_rectangle_2_intersection.h +++ b/Intersections_2/include/CGAL/Triangle_2_Iso_rectangle_2_intersection.h @@ -271,7 +271,7 @@ namespace CGAL{ namespace internal { typename std::vector::iterator last = std::unique(result.begin(),result.end()); result.erase(last,result.end()); - while(result.back() == result.front() && result.size() > 1) + while(result.size() > 1 && result.back() == result.front()) result.pop_back(); switch(result.size()){ From dcf8e6bac3b3ce43eda5a15852061fdae9408362 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 24 May 2019 09:54:47 +0200 Subject: [PATCH 108/203] Fix wheel k_ring events --- .../Polyhedron/Scene_polyhedron_selection_item.cpp | 1 + .../demo/Polyhedron/Scene_polyhedron_selection_item.h | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp index 7f5eded2882..8d244d0a38d 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp @@ -1779,6 +1779,7 @@ void Scene_polyhedron_selection_item::common_constructor() d->are_temp_buffers_filled = false; d->poly = NULL; d->ready_to_move = false; + do_process = true; setProperty("no_picking", true); setPointContainer(3, diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h index 72ccd68ffea..a2b7be5ea91 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h @@ -879,8 +879,13 @@ protected: if(gen_event->type() == QEvent::Wheel) { QWheelEvent *event = static_cast(gen_event); - int steps = event->delta() / 120; - expand_or_reduce(steps); + int steps = event->angleDelta().y()/120; + if(do_process) + { + expand_or_reduce(steps); + do_process = false; + QTimer::singleShot(0,this, [this](){do_process = true;}); + } return true; } return false; @@ -997,6 +1002,7 @@ protected: Scene_facegraph_item_k_ring_selection k_ring_selector; // action state bool is_insert; + bool do_process; public: // selection From 4ac7d2004d94dc2106bbc1c1dc5adad103d39d03 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 24 May 2019 17:32:14 +0200 Subject: [PATCH 109/203] Improve doc --- .../doc/Convex_hull_3/CGAL/convex_hull_3.h | 8 ++++---- Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt | 14 +++++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h index 6227b56d944..bc83e1d13a0 100644 --- a/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h @@ -4,7 +4,7 @@ namespace CGAL { \ingroup PkgConvexHull3Functions \brief computes the convex hull of the set of points in the range -[`first`, `last`). The polyhedron `pm` is cleared, then +[`first`, `last`). The polygon mesh `pm` is cleared, then the convex hull is stored in `pm`. Note that the convex hull will be triangulated, that is `pm` will contain only triangular facets. if the convex hull is a point or a segment, endpoints will be added in `pm` as isolated vertices. @@ -39,9 +39,9 @@ void convex_hull_3(InputIterator first, InputIterator last, PolygonMesh& pm, con \brief computes the convex hull of the set of points in the range [`first`, `last`). The result, which may be a point, a segment, -a triangle, or a polyhedron, is stored in `ch_object`. -In the case the result is a polyhedron, the convex hull will be triangulated, -that is the polyhedron will contain only triangular facets. +a triangle, or a polygon mesh, is stored in `ch_object`. +In the case the result is a polygon mesh, the convex hull will be triangulated, +that is the polygon mesh will contain only triangular facets. \tparam InputIterator must be an input iterator with a value type equivalent to `Traits::Point_3`. \tparam Traits must be model of the concept `ConvexHullTraits_3`. diff --git a/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt b/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt index 74ef744c7b3..a14a9f07703 100644 --- a/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt +++ b/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt @@ -49,11 +49,19 @@ computing the hull. The function `convex_hull_3()` is parameterized by a traits class, which specifies the types and geometric primitives to be used in the -computation. If input points from a kernel with exact predicates +computation. As the function constructs 3D planes from three input +points, we cannot simply pass a kernel with inexact constructions as +optional argument for the traits class. + +If input points from a kernel with exact predicates and non-exact constructions are used, and a certified result is expected, the traits `Convex_hull_traits_3` should be used -(`R` being the input kernel). Note that the default traits class takes this into -account. +(`R` being the input kernel). +If the constructions from a kernel are exact this kernel can be used +directly as a traits class. + +Note that the default traits class takes this into account, that is the +above considerations are only important for custom traits classes. \subsubsection Convex_hull_3Example Example From 44e606571078c72168f74bdfcc93714a6e424357 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 24 May 2019 17:47:25 +0200 Subject: [PATCH 110/203] Improve documentation --- .../doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h | 7 +++++++ Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h index 1c8b0619343..ee7e28c9b7e 100644 --- a/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h @@ -13,6 +13,13 @@ function when `R` is a kernel with exact predicates but inexact constructions \cgalModels `IsStronglyConvexTraits_3` \attention The user must include the header file of the polygon mesh type, even for the default type. + +\cgalAdvancedBegin +This class has a fourth undocumented template argument. Passing `CGAL::Tag_false` +switches off a caching of a plane with coordinates with interval arithmetic. +Instead an orientation test of four points is performed. +\cgalAdvancedEnd + */ template< typename R, typename PolygonMesh = Polyhedron_3 > class Convex_hull_traits_3 { diff --git a/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt b/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt index a14a9f07703..b7d25b6b505 100644 --- a/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt +++ b/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt @@ -55,7 +55,7 @@ optional argument for the traits class. If input points from a kernel with exact predicates and non-exact constructions are used, and a certified result is expected, -the traits `Convex_hull_traits_3` should be used +the class `Convex_hull_traits_3` should be used (`R` being the input kernel). If the constructions from a kernel are exact this kernel can be used directly as a traits class. From e3229053494182f5912b9065fd964d149dee6dc3 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 27 May 2019 16:27:24 +0200 Subject: [PATCH 111/203] Don't use horizontalAdvance as it was introduced in qt5.11 --- Three/include/CGAL/Three/TextRenderer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Three/include/CGAL/Three/TextRenderer.h b/Three/include/CGAL/Three/TextRenderer.h index 75a7be68623..962b2499964 100644 --- a/Three/include/CGAL/Three/TextRenderer.h +++ b/Three/include/CGAL/Three/TextRenderer.h @@ -60,7 +60,7 @@ public : :x(p_x), y(p_y), z(p_z),_3D(p_3D), _is_always_visible(always_visible), m_text(p_text), m_font(font), m_color(p_color) { QFontMetrics fm(m_font); - _width = float(fm.horizontalAdvance(m_text)+2); + _width = float(fm.width(m_text)+2); _height = float(fm.height()); } //!\brief Accessor for the string From 1160e396f6db9aab85355fb49c6bc6043df77b58 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 27 May 2019 16:33:33 +0200 Subject: [PATCH 112/203] Fix stuffs --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 3 ++- Polyhedron/demo/Polyhedron/Viewer.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index c9061238a3f..6e6a2248a32 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1204,7 +1204,8 @@ QList MainWindow::loadItem(QFileInfo fileinfo, QString("File %1 is not a readable file.") .arg(fileinfo.absoluteFilePath())); } - CGAL::Three::Three::CursorScopeGuard guard(QCursor(Qt::WaitCursor)); + QCursor tmp_cursor(Qt::WaitCursor); + CGAL::Three::Three::CursorScopeGuard guard(tmp_cursor); QList result = loader->load(fileinfo, ok, add_to_scene); if(result.empty() || !ok) { diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index a1daacb0a76..b8210cc0de2 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -636,7 +636,7 @@ void Viewer::keyPressEvent(QKeyEvent* e) camera()->setOrthoZNear(0.0f); } break; - deafult: + default: break; } this->displayMessage(tr("Macro mode: %1"). From a85b09051e9db60f044ddcbce7fb3e218cf5956e Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 28 May 2019 09:31:10 +0200 Subject: [PATCH 113/203] add missing includes in Color.h --- Stream_support/include/CGAL/IO/Color.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Stream_support/include/CGAL/IO/Color.h b/Stream_support/include/CGAL/IO/Color.h index a9cfdb57f25..5637d467bf3 100644 --- a/Stream_support/include/CGAL/IO/Color.h +++ b/Stream_support/include/CGAL/IO/Color.h @@ -24,6 +24,10 @@ // Author(s) : Andreas Fabri #include +#include +#include +#include + #ifndef CGAL_COLOR_H #define CGAL_COLOR_H From 30bb614ed076dc231dbd00e09f35d11ba64c06b9 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 28 May 2019 11:44:13 +0200 Subject: [PATCH 114/203] Fix plugins --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 2 - .../Plugins/AABB_tree/Cut_plugin.cpp | 2 +- .../Plugins/IO/Polylines_io_plugin.cpp | 2 +- .../Polyhedron/Plugins/IO/VTK_io_plugin.cpp | 52 ++++++++++++++----- .../Plugins/Mesh_3/Io_image_plugin.cpp | 2 +- .../Plugins/PMP/Selection_plugin.cpp | 2 +- 6 files changed, 43 insertions(+), 19 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 6e6a2248a32..9ebbe521004 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1173,7 +1173,6 @@ void MainWindow::open(QString filename) bool MainWindow::open(QString filename, QString loader_name) { QFileInfo fileinfo(filename); boost::optional item_opt; - CGAL::Three::Scene_item* item = 0; try { item_opt = wrap_a_call_to_cpp ([this, fileinfo, loader_name]() @@ -1185,7 +1184,6 @@ bool MainWindow::open(QString filename, QString loader_name) { this, __FILE__, __LINE__ ); if(!item_opt) return false; - //else item = *item_opt; } catch(std::logic_error& e) { std::cerr << e.what() << std::endl; diff --git a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp index d1472428108..8df17c89083 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp @@ -860,7 +860,7 @@ public: } void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, - Messages_interface* m) Q_DECL_OVERRIDE; + Messages_interface* m) override; QList actions() const Q_DECL_OVERRIDE; bool eventFilter(QObject *, QEvent *event) Q_DECL_OVERRIDE diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp index f5898b953bc..7c3b0c7e264 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp @@ -27,7 +27,7 @@ public: //! Configures the widget void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, - Messages_interface*) { + Messages_interface*) override{ //get the references this->scene = scene_interface; this->mw = mainWindow; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index cc235ee91a2..b21c1a21d5d 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -308,8 +308,9 @@ public: } - bool save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) + bool save(QFileInfo fileinfo,QList& items) { + Scene_item* item = items.front(); std::string extension = fileinfo.suffix().toLower().toStdString(); if ( extension != "vtk" && extension != "vtp" && extension != "vtu") return false; @@ -356,10 +357,11 @@ public: CGAL::output_to_vtu(os, c3t3); } + items.pop_front(); return true; } - bool canLoad() const { return true; } + bool canLoad(QFileInfo) const { return true; } template vtkSmartPointer @@ -374,11 +376,14 @@ public: return reader; } - CGAL::Three::Scene_item* load(QFileInfo fileinfo) + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { std::string extension=fileinfo.suffix().toLower().toStdString(); if (extension != "vtk" && extension != "vtp" && extension != "vtu") - return 0; + { + ok = false; + return QList(); + } std::string fname = fileinfo.absoluteFilePath().toStdString(); @@ -389,7 +394,10 @@ public: Scene_facegraph_item* item = new Scene_facegraph_item(); item->setName(fileinfo.completeBaseName()); - return item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(item); + return QList()< data; @@ -421,7 +429,8 @@ public: msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setIcon(QMessageBox::Critical); msgBox.exec(); - return NULL; + ok = false; + return QList(); } if (obs->GetWarning()) { @@ -442,7 +451,8 @@ public: msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setIcon(QMessageBox::Critical); msgBox.exec(); - return NULL; + ok = false; + return QList(); } if (obs->GetWarning()) { @@ -491,7 +501,10 @@ public: } else{ poly_item->setName(fileinfo.baseName()); - return poly_item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(poly_item); + return QList()<setName(fileinfo.baseName()); - return c3t3_item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(c3t3_item); + return QList()<setName(fileinfo.baseName()); - return polyline_item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(polyline_item); + return QList()<addItem(group); + return QList()<point_set()->insert(Point_3(p[0], p[1], p[2])); } point_item->setName(fileinfo.baseName()); - return point_item; + ok = true; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(point_item); + return QList()<message_interface = mi; this->scene = scene_interface; this->mw = mainWindow; diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index 22a29ef9991..f9f946cb59e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -132,7 +132,7 @@ public: void print_message(QString message) { CGAL::Three::Three::information(message); } QList actions() const { return QList() << actionSelection; } - void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface* m) { + void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface* m) override{ mw = mainWindow; scene = scene_interface; messages = m; From 736461b8f25a28331f096fc2faa8d08425032174 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 28 May 2019 13:31:46 +0200 Subject: [PATCH 115/203] Fix polylines/c3t3 reading --- .../demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp | 10 ++++++++++ .../demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp | 2 ++ 2 files changed, 12 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp index 7c3b0c7e264..16d06fb67fb 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp @@ -86,6 +86,16 @@ private: }; bool Polyhedron_demo_polylines_io_plugin::canLoad(QFileInfo fileinfo) const{ + if(!fileinfo.suffix().contains("cgal")) + return true; + std::ifstream in(fileinfo.filePath().toUtf8()); + if(!in) { + return false; + } + int first; + if(!(in >> first) + || first <= 0) + return false; return true; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 15a93660153..7e7de0d7e2c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -36,6 +36,8 @@ private: bool Polyhedron_demo_c3t3_binary_io_plugin::canLoad(QFileInfo fi) const { + if(!fi.suffix().contains("cgal")) + return true; std::ifstream in(fi.filePath().toUtf8(), std::ios_base::in|std::ios_base::binary); if(!in) { From 79008f16187f8014b9e9e6910d430f21aacc58ff Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 28 May 2019 14:03:27 +0200 Subject: [PATCH 116/203] Fix warnings --- .../demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp | 3 ++- .../Plugins/Camera_position/Camera_positions_plugin.cpp | 8 +++++++- Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp | 2 +- Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp | 2 +- .../demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp | 2 +- Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp | 2 +- Stream_support/include/CGAL/IO/read_3mf.h | 8 ++------ 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp index 8df17c89083..d32bb11e8b5 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp @@ -826,9 +826,10 @@ public: return false; } - QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) Q_DECL_OVERRIDE + QList load(QFileInfo , bool& ok, bool add_to_scene=true) Q_DECL_OVERRIDE { + CGAL_UNUSED(add_to_scene); ok = false; return QList(); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp index c4823cd01aa..0c149a40cff 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp @@ -23,7 +23,13 @@ public: QString name() const { return "camera_positions_plugin"; } QString nameFilters() const { return "Camera positions (*.camera.txt)"; } bool canLoad(QFileInfo) const { return true; } - QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) { ok = true; cpl->load(fileinfo.filePath()); return QList(); } + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) + { + Q_UNUSED(add_to_scene); + ok = true; + cpl->load(fileinfo.filePath()); + return QList(); + } bool canSave(const Scene_item*) { return false; } bool save(QFileInfo,QList& ) {return false; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp index 484724d2a40..553d560656c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp @@ -141,7 +141,7 @@ class Io_3mf_plugin: std::cerr << "Error in reading of meshes."<& ); }; -bool Polyhedron_demo_las_plugin::canLoad(QFileInfo fileinfo) const { +bool Polyhedron_demo_las_plugin::canLoad(QFileInfo ) const { return true; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp index 3366e1dbb68..0f04fcd2dbf 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp @@ -63,7 +63,7 @@ bool Polyhedron_demo_off_to_nef_plugin::canSave(const CGAL::Three::Scene_item*) } bool Polyhedron_demo_off_to_nef_plugin:: -save(QFileInfo fileinfo,QList& items) +save(QFileInfo ,QList&) { return false; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp index 6b0e4b8708e..c9ac059823d 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp @@ -34,7 +34,7 @@ public: QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); bool canSave(const CGAL::Three::Scene_item*) { return false; } - bool save(QFileInfo fileinfo,QList& ) { return false; } + bool save(QFileInfo ,QList& ) { return false; } }; diff --git a/Stream_support/include/CGAL/IO/read_3mf.h b/Stream_support/include/CGAL/IO/read_3mf.h index 1e6d691512d..f528c79de2f 100644 --- a/Stream_support/include/CGAL/IO/read_3mf.h +++ b/Stream_support/include/CGAL/IO/read_3mf.h @@ -56,7 +56,6 @@ bool extract_soups (NMR::PLib3MFModelMeshObject *pMeshObject, std::string& name) { typedef typename PointRange::value_type Point_3; typedef typename PolygonRange::value_type Polygon; - typedef typename ColorRange::value_type _Color; typedef typename Kernel_traits::Kernel Kernel; HRESULT hResult; DWORD nNeededChars; @@ -134,13 +133,12 @@ template bool extract_polylines (NMR::PLib3MFModelMeshObject *pMeshObject, - const NMR::MODELTRANSFORM& transform, + const NMR::MODELTRANSFORM& , PointRange& points, PolygonRange&, ColorRange& colors, std::string& name) { typedef typename PointRange::value_type Point_3; - typedef typename PolygonRange::value_type Polygon; HRESULT hResult; DWORD nNeededChars; @@ -208,7 +206,7 @@ template bool extract_point_clouds (NMR::PLib3MFModelMeshObject *pMeshObject, - const NMR::MODELTRANSFORM& transform, + const NMR::MODELTRANSFORM&, PointRange& points, PolygonRange&, ColorRange& colors, @@ -290,8 +288,6 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, std::string&)> func ) { - typedef typename PointRange::value_type Point_3; - typedef typename PolygonRange::value_type Polygon; DWORD nInterfaceVersionMajor, nInterfaceVersionMinor, nInterfaceVersionMicro, nbVertices, nbPolygons; HRESULT hResult; NMR::PLib3MFModel * pModel; From 6c581bac7fb06599aee626a8814302b5cf6efacf Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 29 May 2019 09:39:53 +0200 Subject: [PATCH 117/203] Don't use CGAL_UNUSED --- Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp index d32bb11e8b5..5ff4e16e3a5 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp @@ -829,7 +829,7 @@ public: QList load(QFileInfo , bool& ok, bool add_to_scene=true) Q_DECL_OVERRIDE { - CGAL_UNUSED(add_to_scene); + Q_UNUSED(add_to_scene); ok = false; return QList(); } From ef26c37b75d61081c30c033951ae52c1ef62a585 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 29 May 2019 09:45:48 +0200 Subject: [PATCH 118/203] Try to fix cmake bug on Blake --- Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt index 5c8bf384e39..d0f070f1c1c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt @@ -79,6 +79,8 @@ else() ) if(IS_DIRECTORY "${3MF_INCLUDE_DIR}/Common") set(3MF_FOUND true) + else() + set(3MF_FOUND false) endif() find_library(3MF_LIBRARIES NAMES 3MF DOC "Path to the lib3MF library") From d34ac7b14bf7b51e98cf0072077b0b7415cbede5 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 31 May 2019 10:22:21 +0200 Subject: [PATCH 119/203] Fix override and shadow warnings for clang --- .../Plugins/AABB_tree/Cut_plugin.cpp | 1 + .../Camera_positions_plugin.cpp | 2 +- .../IO/Implicit_function_io_plugin.cpp | 1 - .../Plugins/IO/Polylines_io_plugin.cpp | 17 +++++++------- .../Plugins/Mesh_3/C3t3_io_plugin.cpp | 1 - .../Plugins/Mesh_3/Io_image_plugin.cpp | 20 ++++++++--------- .../Plugins/PMP/Selection_plugin.cpp | 22 +++++++++---------- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp index 5ff4e16e3a5..4160a9b84d1 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp @@ -860,6 +860,7 @@ public: return ok; } + using Polyhedron_demo_plugin_interface::init; void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface* m) override; QList actions() const Q_DECL_OVERRIDE; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp index 0c149a40cff..29179170419 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp @@ -18,7 +18,7 @@ class Polyhedron_demo_camera_positions_plugin : Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: - void init(); + void init() override; QString name() const { return "camera_positions_plugin"; } QString nameFilters() const { return "Camera positions (*.camera.txt)"; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Implicit_function_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Implicit_function_io_plugin.cpp index 928e974cf8b..24ddcc7a818 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Implicit_function_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Implicit_function_io_plugin.cpp @@ -42,7 +42,6 @@ using namespace CGAL::Three; class Io_implicit_function_plugin : public QObject, - // public Polyhedron_demo_plugin_interface, protected Polyhedron_demo_plugin_helper { Q_OBJECT diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp index 16d06fb67fb..d86309749f8 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp @@ -24,6 +24,7 @@ public: // To silent a warning -Woverloaded-virtual // See http://stackoverflow.com/questions/9995421/gcc-woverloaded-virtual-warnings + using Polyhedron_demo_io_plugin_interface::init; //! Configures the widget void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, @@ -43,14 +44,14 @@ public: connect(actionJoin_polylines, &QAction::triggered, this, &Polyhedron_demo_polylines_io_plugin::join); } - QString name() const { return "polylines_io_plugin"; } - QString nameFilters() const { return "Polylines files (*.polylines.txt *.cgal)"; } - bool canLoad(QFileInfo fileinfo) const; - QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); + QString name() const override{ return "polylines_io_plugin"; } + QString nameFilters() const override{ return "Polylines files (*.polylines.txt *.cgal)"; } + bool canLoad(QFileInfo fileinfo) const override; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) override; - bool canSave(const CGAL::Three::Scene_item*); - bool save(QFileInfo fileinfo,QList&); - bool applicable(QAction* a) const { + bool canSave(const CGAL::Three::Scene_item*) override; + bool save(QFileInfo fileinfo,QList&) override; + bool applicable(QAction* a) const override{ bool all_polylines_selected = true; Q_FOREACH(int index, scene->selectionIndices()) { @@ -69,7 +70,7 @@ public: else return false; } - QList actions() const { + QList actions() const override{ return QList()<(scene->item(scene->mainSelectionIndex())); } - + using Polyhedron_demo_plugin_interface::init; void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface *mi) override { this->message_interface = mi; this->scene = scene_interface; @@ -270,10 +270,10 @@ public: } } } - QList actions() const { + QList actions() const override{ return QList() << planeSwitch; } - virtual void closure() + virtual void closure() override { QDockWidget* controlDockWidget = mw->findChild("volumePlanesControl"); if(controlDockWidget) @@ -281,12 +281,12 @@ public: } Io_image_plugin() : planeSwitch(NULL) {} - QString nameFilters() const; - bool canLoad(QFileInfo) const; - QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); + QString nameFilters() const override; + bool canLoad(QFileInfo) const override; + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) override; - bool canSave(const CGAL::Three::Scene_item*); - bool save(QFileInfo fileinfo, QList& items ) { + bool canSave(const CGAL::Three::Scene_item*) override; + bool save(QFileInfo fileinfo, QList& items ) override{ Scene_item* item = items.front(); const Scene_image_item* im_item = qobject_cast(item); @@ -295,7 +295,7 @@ public: items.pop_front(); return ok; } - QString name() const { return "segmented images"; } + QString name() const override{ return "segmented images"; } public Q_SLOTS: diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index f9f946cb59e..7169c7efd4f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -75,10 +75,10 @@ class Polyhedron_demo_selection_plugin : Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "selection_plugin.json") Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: - QString nameFilters() const { return "Selection files(*.selection.txt)"; } - QString name() const { return "selection_sm_plugin"; } + QString nameFilters() const override { return "Selection files(*.selection.txt)"; } + QString name() const override { return "selection_sm_plugin"; } - bool canLoad(QFileInfo) const { + bool canLoad(QFileInfo) const override { Scene_item * item = CGAL::Three::Three::scene()->item( CGAL::Three::Three::scene()->mainSelectionIndex()); Scene_facegraph_item* fg_item = qobject_cast(item); @@ -91,7 +91,7 @@ public: return false; } - QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) { + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) override { if(fileinfo.suffix().toLower() != "txt") { ok = false; @@ -111,10 +111,10 @@ public: return QList()<(scene_item); } - bool save(QFileInfo fileinfo,QList& items) { + bool save(QFileInfo fileinfo,QList& items) override { Scene_item* scene_item = items.front(); const Scene_polyhedron_selection_item* item = qobject_cast(scene_item); if(item == NULL) { return false; } @@ -125,14 +125,14 @@ public: return res; } - bool applicable(QAction*) const { + bool applicable(QAction*) const override { return qobject_cast(scene->item(scene->mainSelectionIndex())) || qobject_cast(scene->item(scene->mainSelectionIndex())); } void print_message(QString message) { CGAL::Three::Three::information(message); } - QList actions() const { return QList() << actionSelection; } - - void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface* m) override{ + QList actions() const override { return QList() << actionSelection; } + using Polyhedron_demo_io_plugin_interface::init; + virtual void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface* m) override{ mw = mainWindow; scene = scene_interface; messages = m; @@ -216,7 +216,7 @@ public: operations_map[operations_strings[8]] = 8; operations_map[operations_strings[9]] = 9; } - virtual void closure() + virtual void closure() override { dock_widget->hide(); } From 0dc66db1958df1b7042aacaa0a0a654f4f021206 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 31 May 2019 10:44:05 +0200 Subject: [PATCH 120/203] Don't use default path in 3MF find_path to avoid VTK interfering (at least on Blake, that's the reason the testsuite is red over there.) --- Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt index d0f070f1c1c..370166a697f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt @@ -73,7 +73,7 @@ else() message(STATUS "NOTICE : the LAS IO plugin needs LAS libraries and will not be compiled.") endif() - find_path(3MF_INCLUDE_DIR + find_path(3MF_INCLUDE_DIR NO_DEFAULT_PATH NAMES Common Model DOC "Path to lib3MF headers" ) From 128eb72121e2073548d6fcc2dea90e48eb20befa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 3 Jun 2019 07:57:16 +0200 Subject: [PATCH 121/203] Remove obsolete todo in std::cout in 2D intersection tests --- Intersections_2/test/Intersections_2/test_intersections_2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Intersections_2/test/Intersections_2/test_intersections_2.cpp b/Intersections_2/test/Intersections_2/test_intersections_2.cpp index 42137e92c97..b972971952b 100644 --- a/Intersections_2/test/Intersections_2/test_intersections_2.cpp +++ b/Intersections_2/test/Intersections_2/test_intersections_2.cpp @@ -193,7 +193,7 @@ struct Test void B_L() { - std::cout << "Bbox - Line (TODO)" << std::endl; + std::cout << "Bbox - Line" << std::endl; // no intersection check_no_do_intersect (p(0,0).bbox() , L(p( 1,1), p( 0,1))); @@ -226,7 +226,7 @@ struct Test void B_R() { - std::cout << "Bbox - Ray (TODO)" << std::endl; + std::cout << "Bbox - Ray" << std::endl; // no intersection check_no_do_intersect (p(0,0).bbox() , R(p( 1,1), p( 0,1))); From 87f7a68ed0cf6f7b4a3ff90a496f0d8d2600916a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 3 Jun 2019 10:10:39 +0200 Subject: [PATCH 122/203] Fix find_path and don't make blue results if 3mf not found --- .../demo/Polyhedron/Plugins/IO/CMakeLists.txt | 35 ++++++++----------- .../test/Stream_support/CMakeLists.txt | 13 +++---- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt index 370166a697f..809ff9f9ada 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt @@ -57,7 +57,7 @@ list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_rvalue_references has_cxx_rvalues) list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_variadic_templates has_cxx_variadic) if(has_cxx_rvalues LESS 0 OR has_cxx_variadic LESS 0) - message(STATUS "NOTICE: LAS/PLY IO examples require a C++11 compiler and will not be compiled.") + message(STATUS "NOTICE : LAS/PLY IO examples require a C++11 compiler and will not be compiled.") else() set(needed_cxx_features cxx_rvalue_references cxx_variadic_templates) @@ -72,23 +72,18 @@ else() else() message(STATUS "NOTICE : the LAS IO plugin needs LAS libraries and will not be compiled.") endif() - - find_path(3MF_INCLUDE_DIR NO_DEFAULT_PATH - NAMES Common Model - DOC "Path to lib3MF headers" - ) - if(IS_DIRECTORY "${3MF_INCLUDE_DIR}/Common") - set(3MF_FOUND true) - else() - set(3MF_FOUND false) - endif() - find_library(3MF_LIBRARIES NAMES 3MF DOC "Path to the lib3MF library") - - if(3MF_FOUND) - include_directories(${3MF_INCLUDE_DIR}) - polyhedron_demo_plugin(3mf_io_plugin 3mf_io_plugin KEYWORDS IO) - target_link_libraries(3mf_io_plugin PRIVATE scene_surface_mesh_item scene_points_with_normal_item scene_polylines_item ${3MF_LIBRARIES}) - else() - message(STATUS "NOTICE: The 3mf_io_plugin requires the lib3MF library, and will not be compiled.") - endif() +endif() + +find_path(3MF_INCLUDE_DIR + NAMES Model/COM/NMR_DLLInterfaces.h + DOC "Path to lib3MF headers" + ) +find_library(3MF_LIBRARIES NAMES 3MF DOC "Path to the lib3MF library") + +if(3MF_LIBRARIES AND 3MF_INCLUDE_DIR) + include_directories(${3MF_INCLUDE_DIR}) + polyhedron_demo_plugin(3mf_io_plugin 3mf_io_plugin KEYWORDS IO) + target_link_libraries(3mf_io_plugin PRIVATE scene_surface_mesh_item scene_points_with_normal_item scene_polylines_item ${3MF_LIBRARIES}) +else() + message(STATUS "NOTICE : The 3mf_io_plugin requires the lib3MF library, and will not be compiled.") endif() diff --git a/Stream_support/test/Stream_support/CMakeLists.txt b/Stream_support/test/Stream_support/CMakeLists.txt index f9905b79012..147767cad3f 100644 --- a/Stream_support/test/Stream_support/CMakeLists.txt +++ b/Stream_support/test/Stream_support/CMakeLists.txt @@ -9,24 +9,21 @@ cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) if ( CGAL_FOUND ) find_path(3MF_INCLUDE_DIR - NAMES Common Model - DOC "Path to lib3MF headers" - ) - if(IS_DIRECTORY "${3MF_INCLUDE_DIR}/Common") - set(3MF_FOUND true) - endif() + NAMES Model/COM/NMR_DLLInterfaces.h + DOC "Path to lib3MF headers" + ) find_library(3MF_LIBRARIES NAMES 3MF DOC "Path to the lib3MF library") # create a target per cppfile file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) foreach(cppfile ${cppfiles}) if ( "${cppfile}" STREQUAL "test_3mf_to_sm.cpp" ) - if(3MF_FOUND) + if(3MF_LIBRARIES AND 3MF_INCLUDE_DIR) include_directories(${3MF_INCLUDE_DIR}) create_single_source_cgal_program( "${cppfile}" ) target_link_libraries(test_3mf_to_sm PRIVATE ${3MF_LIBRARIES}) else() - message(STATUS "NOTICE: This program requires the lib3MF library, and will not be compiled.") + message(STATUS "NOTICE : This program requires the lib3MF library, and will not be compiled.") endif() else() create_single_source_cgal_program( "${cppfile}" ) From ef17e71efaf54ae0cee9d46a4d928bfebc9363e2 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 3 Jun 2019 10:14:43 +0200 Subject: [PATCH 123/203] Fix remaining warnings --- .../demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp | 2 +- .../Camera_position/Camera_positions_plugin.cpp | 12 ++++++------ .../Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp index 4160a9b84d1..2619db2aca5 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/AABB_tree/Cut_plugin.cpp @@ -860,7 +860,7 @@ public: return ok; } - using Polyhedron_demo_plugin_interface::init; + using Polyhedron_demo_io_plugin_interface::init; void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface* m) override; QList actions() const Q_DECL_OVERRIDE; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp index 29179170419..0af8d9491ca 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp @@ -20,10 +20,10 @@ class Polyhedron_demo_camera_positions_plugin : public: void init() override; - QString name() const { return "camera_positions_plugin"; } - QString nameFilters() const { return "Camera positions (*.camera.txt)"; } - bool canLoad(QFileInfo) const { return true; } - QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) + QString name() const override { return "camera_positions_plugin"; } + QString nameFilters() const override { return "Camera positions (*.camera.txt)"; } + bool canLoad(QFileInfo) const override { return true; } + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) override { Q_UNUSED(add_to_scene); ok = true; @@ -31,8 +31,8 @@ public: return QList(); } - bool canSave(const Scene_item*) { return false; } - bool save(QFileInfo,QList& ) {return false; } + bool canSave(const Scene_item*) override { return false; } + bool save(QFileInfo,QList& ) override {return false; } private: Camera_positions_list* cpl; }; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp index 1d4ab9a733b..fb15ee12af6 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -215,7 +215,7 @@ public: return qobject_cast(scene->item(scene->mainSelectionIndex())); } - using Polyhedron_demo_plugin_interface::init; + using Polyhedron_demo_io_plugin_interface::init; void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface *mi) override { this->message_interface = mi; this->scene = scene_interface; From ec48c4c3ad52bb9a620fe2ded646c00d92f07878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 3 Jun 2019 10:30:04 +0200 Subject: [PATCH 124/203] Enforce correct bit precision Necessary for some old machines whose processor violates the standard --- .../test/Intersections_2/test_intersections_2.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Intersections_2/test/Intersections_2/test_intersections_2.cpp b/Intersections_2/test/Intersections_2/test_intersections_2.cpp index b972971952b..f501bf75211 100644 --- a/Intersections_2/test/Intersections_2/test_intersections_2.cpp +++ b/Intersections_2/test/Intersections_2/test_intersections_2.cpp @@ -5,8 +5,9 @@ #include #include #include -#include +#include +#include #include #include @@ -795,6 +796,8 @@ private: int main() { + CGAL::Set_ieee_double_precision pfr; + Test< CGAL::Simple_cartesian::Type > >().run(); Test< CGAL::Cartesian >().run(); Test< CGAL::Homogeneous::Type > >().run(); From a954fbf69e8f69c8d8ed71596ea72da453d1671a Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 3 Jun 2019 14:36:32 +0200 Subject: [PATCH 125/203] Add hash function for Point_3 --- .../include/CGAL/Kernel/global_functions.h | 1 + .../include/CGAL/Kernel/hash_functions.h | 54 +++++++++++++++++++ .../test/Kernel_23/test_hash_functions.cpp | 35 ++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 Kernel_23/include/CGAL/Kernel/hash_functions.h create mode 100644 Kernel_23/test/Kernel_23/test_hash_functions.cpp diff --git a/Kernel_23/include/CGAL/Kernel/global_functions.h b/Kernel_23/include/CGAL/Kernel/global_functions.h index b2119d169f9..33e3a382d1d 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions.h @@ -31,6 +31,7 @@ #include #include +#include namespace CGAL { diff --git a/Kernel_23/include/CGAL/Kernel/hash_functions.h b/Kernel_23/include/CGAL/Kernel/hash_functions.h new file mode 100644 index 00000000000..e3a8a328bfc --- /dev/null +++ b/Kernel_23/include/CGAL/Kernel/hash_functions.h @@ -0,0 +1,54 @@ +// Copyright (c) 2019 +// GeometryFactory (France) +// +// 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$ +// SPDX-License-Identifier: LGPL-3.0+ +// +// +// Author(s) : Simon Giraudot + +#ifndef CGAL_KERNEL_HASH_FUNCTIONS_H +#define CGAL_KERNEL_HASH_FUNCTIONS_H + +namespace CGAL +{ + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Point_3& point) +{ + std::size_t result = boost::hash_value(point.x()); + boost::hash_combine(result, boost::hash_value(point.y())); + boost::hash_combine(result, boost::hash_value(point.z())); + return result; +} + +} //namespace CGAL + +// overloads of std::hash used for using std::unordered_[set/map] on CGAL Kernel objects +namespace std +{ + +template struct hash > +{ + std::size_t operator() (const CGAL::Point_3& point) const + { + return CGAL::hash_value (point); + } +}; + +} + +#endif // CGAL_KERNEL_HASH_FUNCTIONS_H diff --git a/Kernel_23/test/Kernel_23/test_hash_functions.cpp b/Kernel_23/test/Kernel_23/test_hash_functions.cpp new file mode 100644 index 00000000000..1a780d61b86 --- /dev/null +++ b/Kernel_23/test/Kernel_23/test_hash_functions.cpp @@ -0,0 +1,35 @@ +#include + +#include +#include +#include + +typedef CGAL::Simple_cartesian SC; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epick; +typedef CGAL::Exact_predicates_exact_constructions_kernel Epeck; + +int main() +{ + + std::unordered_set sc_points; + sc_points.insert (SC::Point_3 (1, 2, 3)); + sc_points.insert (SC::Point_3 (1, 2, 3)); + + std::unordered_set epick_points; + epick_points.insert (Epick::Point_3 (1, 2, 3)); + epick_points.insert (Epick::Point_3 (1, 2, 3)); + + // Epeck points not hashable + std::unordered_set epeck_points; +#if 0 // Compilation only fails if something is inserted + epeck_points.insert (Epeck::Point_3 (1, 2, 3)); + epeck_points.insert (Epeck::Point_3 (1, 2, 3)); +#endif + + assert (sc_points.size() == 1); + assert (epick_points.size() == 1); + + return 0; +} + + From b42fd4428da897260afcb29a9508ddff45400443 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 3 Jun 2019 15:36:34 +0200 Subject: [PATCH 126/203] Triangulation_{2,3): Add ranges --- .../Triangulation_3/CGAL/Triangulation_3.h | 55 +++++++++++++++++-- .../doc/Triangulation_3/Triangulation_3.txt | 17 ++++++ .../doc/Triangulation_3/examples.txt | 1 + .../examples/Triangulation_3/CMakeLists.txt | 1 + .../examples/Triangulation_3/for_loop.cpp | 45 +++++++++++++++ .../include/CGAL/Triangulation_3.h | 13 +++++ 6 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 Triangulation_3/examples/Triangulation_3/for_loop.cpp diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index 3bd0dfbe653..0b2d044da4f 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -115,6 +115,10 @@ typedef Triangulation_data_structure::Facet Facet; */ typedef Triangulation_data_structure::Edge Edge; +/*! +Concurrency tag (from the TDS). +*/ +typedef Triangulation_data_structure::Concurrency_tag Concurrency_tag; /// @} @@ -216,12 +220,28 @@ circulator over all facets incident to a given edge */ typedef Triangulation_data_structure::Facet_circulator Facet_circulator; -/*! -Concurrency tag (from the TDS). -*/ -typedef Triangulation_data_structure::Concurrency_tag Concurrency_tag; +/// @} -/// @} +/*! \name Ranges + +In order to write \cpp 11 `for`-loops we provide range typesxxx. + +*/ +/// @{ + + +/*! +range type for iterating over facets. +*/ + typedef Iterator_range All_facets; + +/*! +range type for iterating over all vertex handles, with a nested type `iterator` +that has as value type `Vertex_handle`. +*/ + typedef Iterator_range All_vertex_handles; + +/// @} /// \name Creation /// @{ @@ -1136,6 +1156,31 @@ Point_iterator points_end() const; /// @} +/*! \name Ranges + +In order to write \cpp 11 `for`-loops we provide a range type and member functions to generate ranges. +Note that vertex and cell ranges are special. + +*/ + +/// @{ +/*! + returns a range of iterators over all vertices (even the infinite one). + Returns an empty range when `t.number_of_vertices() == 0`. + \note While the value type of `All_vertices_iterator` is `Vertex`, the value type of + `All_vertex_handles::iterator` is `Vertex_handle`. + */ + All_vertex_handles all_vertex_handles() const; + + +/*! + returns a range of iterators starting at an arbitrary facet. + Returns an empty range when `t.dimension() < 2`. +*/ +All_facets all_facets() const; + +/// @} + /*!\name Cell and Facet Circulators The following circulators respectively visit all cells or all facets incident to a given edge. They are non-mutable and bidirectional. They are invalidated by any modification of one of the cells traversed. */ diff --git a/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt b/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt index 51a12ffb135..ebb0478e616 100644 --- a/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt +++ b/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt @@ -486,6 +486,23 @@ in the range. Note that this is correct because the iterator is dereferenced only once per point during the insertion. \cgalExample{Triangulation_3/info_insert_with_transform_iterator.cpp} +\subsection Triangulation3secRanges Iterators and Ranges + +The triangulation defines iterator types such as `Triangulation_3::All_vertices_iterator`. They behave like +a `Triangulation_3::Vertex_handle`, that is there is no need to dereference the iterator to obtain a handle. +Wherever the API expects a handle the iterator can be passed as well. + +In order to write a \cpp 11 `for`-loop the triangulation calls also offers the range type +`Triangulation_3::All_vertex_handles`, which has a nested type `Triangulation_3::All_vertex_handles::iterator`. +The value type of this iterator is `Triangulation_3::Vertex_handle`. Note that you only +need the iterator type if you combine the pre \cpp 11 `for`-loop with the range class. +It is similar for the various iterators for vertice and cells. + +For the range `Triangulation_3::All_facets` it holds that `Triangulation_3::All_facets::iterator` `==` +`Triangulation_3::All_facets_iterator`. It is similar for the iterators for edges and points. + +\cgalExample{Triangulation_3/for_loop.cpp} + \subsection Triangulation3secsimplex The Simplex Class The triangulation defines a `Triangulation_3::Simplex` class that represents a diff --git a/Triangulation_3/doc/Triangulation_3/examples.txt b/Triangulation_3/doc/Triangulation_3/examples.txt index 1a34261199c..0d9881f767d 100644 --- a/Triangulation_3/doc/Triangulation_3/examples.txt +++ b/Triangulation_3/doc/Triangulation_3/examples.txt @@ -1,5 +1,6 @@ /*! \example Triangulation_3/simple_triangulation_3.cpp +\example Triangulation_3/for_loop.cpp \example Triangulation_3/color.cpp \example Triangulation_3/adding_handles_3.cpp \example Triangulation_3/info_insert_with_pair_iterator.cpp diff --git a/Triangulation_3/examples/Triangulation_3/CMakeLists.txt b/Triangulation_3/examples/Triangulation_3/CMakeLists.txt index 121d27795ca..d9288dbf92f 100644 --- a/Triangulation_3/examples/Triangulation_3/CMakeLists.txt +++ b/Triangulation_3/examples/Triangulation_3/CMakeLists.txt @@ -18,6 +18,7 @@ if(CGAL_Qt5_FOUND) endif() if ( CGAL_FOUND ) + create_single_source_cgal_program( "for_loop.cpp" ) create_single_source_cgal_program( "adding_handles_3.cpp" ) create_single_source_cgal_program( "color.cpp" ) create_single_source_cgal_program( "copy_triangulation_3.cpp" ) diff --git a/Triangulation_3/examples/Triangulation_3/for_loop.cpp b/Triangulation_3/examples/Triangulation_3/for_loop.cpp new file mode 100644 index 00000000000..5b80b853028 --- /dev/null +++ b/Triangulation_3/examples/Triangulation_3/for_loop.cpp @@ -0,0 +1,45 @@ +#include +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Triangulation_3 Triangulation; +typedef Triangulation::Vertex_handle Vertex_handle; +typedef Triangulation::Point Point; +typedef Triangulation::All_vertex_handles All_vertex_handles; + +// The following types are different +// Its value type is Triangulation_3::Vertex +typedef Triangulation::All_vertices_iterator All_vertices_iterator; +// Its value type is Triangulation_3::Vertex_handle +typedef All_vertex_handles::iterator All_vertex_handles_iterator; + +int main() +{ + std::vector points = { Point(0,0,0), Point(1,0,0), Point(0,1,0), Point(0,1,1) }; + + Triangulation T(points.begin(), points.end()); + + std::cout << "Triangulation_3::All_vertices_iterator is like a Triangulation_3::Vertex_handle\n"; + for(All_vertices_iterator it = T.all_vertices_begin(); + it != T.all_vertices_end(); + ++it){ + std::cout << it->point() << std::endl; + } + + std::cout << "Triangulation_3::All_vertex_handles::iterator dereferences to Triangulation_3::Vertex_handle\n"; + All_vertex_handles::iterator b, e; + boost::tie(b,e) = T.all_vertex_handles(); + for(; b!=e; ++b){ + Vertex_handle vh = *b; // you must dereference the iterator to get a handle + std::cout << vh->point() << std::endl; + } + + std::cout << "and you can use a C++11 for loop\n"; + for(Vertex_handle vh : T.all_vertex_handles()){ + std::cout << vh->point() << std::endl; + } + + return 0; +} diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 71c1b37b443..08340be1e5d 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -431,6 +431,9 @@ public: typedef Edge_iterator All_edges_iterator; typedef Vertex_iterator All_vertices_iterator; + typedef Iterator_range > All_cells_range; + typedef Iterator_range > All_vertices_range; + typedef typename Tds::Simplex Simplex; private: @@ -1683,6 +1686,11 @@ public: All_cells_iterator all_cells_begin() const { return _tds.cells_begin(); } All_cells_iterator all_cells_end() const { return _tds.cells_end(); } + All_cells_range all_cells() const + { + return make_prevent_deref_range(all_cells_begin(), all_cells_end()); + } + Finite_vertices_iterator finite_vertices_begin() const { if(number_of_vertices() <= 0) @@ -1702,6 +1710,11 @@ public: All_vertices_iterator all_vertices_begin() const { return _tds.vertices_begin(); } All_vertices_iterator all_vertices_end() const { return _tds.vertices_end(); } + All_vertices_range all_vertices() const + { + return make_prevent_deref_range(all_vertices_begin(), all_vertices_end()); + } + Finite_edges_iterator finite_edges_begin() const { if(dimension() < 1) From 16f09a73ce9a5b7ab5940701ace48946fddd22e3 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 3 Jun 2019 15:42:15 +0200 Subject: [PATCH 127/203] typo --- Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index 0b2d044da4f..ef55e739cf7 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -224,7 +224,7 @@ typedef Triangulation_data_structure::Facet_circulator Facet_circulator; /*! \name Ranges -In order to write \cpp 11 `for`-loops we provide range typesxxx. +In order to write \cpp 11 `for`-loops we provide range types. */ /// @{ From 521a5c3c83c682416246450c1c725b49fc5a6440 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 3 Jun 2019 15:45:53 +0200 Subject: [PATCH 128/203] Use std::tie --- Triangulation_3/examples/Triangulation_3/for_loop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_3/examples/Triangulation_3/for_loop.cpp b/Triangulation_3/examples/Triangulation_3/for_loop.cpp index 5b80b853028..46547eca0a8 100644 --- a/Triangulation_3/examples/Triangulation_3/for_loop.cpp +++ b/Triangulation_3/examples/Triangulation_3/for_loop.cpp @@ -30,7 +30,7 @@ int main() std::cout << "Triangulation_3::All_vertex_handles::iterator dereferences to Triangulation_3::Vertex_handle\n"; All_vertex_handles::iterator b, e; - boost::tie(b,e) = T.all_vertex_handles(); + std::tie(b,e) = T.all_vertex_handles(); for(; b!=e; ++b){ Vertex_handle vh = *b; // you must dereference the iterator to get a handle std::cout << vh->point() << std::endl; From d88b7bab690896e85636095d1e5a7711f9310fce Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 3 Jun 2019 15:56:07 +0200 Subject: [PATCH 129/203] Hash functions for many kernel objects --- .../include/CGAL/Kernel/hash_functions.h | 286 +++++++++++++++++- .../test/Kernel_23/test_hash_functions.cpp | 80 ++++- 2 files changed, 346 insertions(+), 20 deletions(-) diff --git a/Kernel_23/include/CGAL/Kernel/hash_functions.h b/Kernel_23/include/CGAL/Kernel/hash_functions.h index e3a8a328bfc..6224bc7e3c8 100644 --- a/Kernel_23/include/CGAL/Kernel/hash_functions.h +++ b/Kernel_23/include/CGAL/Kernel/hash_functions.h @@ -25,6 +25,144 @@ namespace CGAL { +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Aff_transformation_2& transform) +{ + std::size_t result = boost::hash_value(transform.cartesian(0,0)); + for(int i=0; i < 3; ++i) + for(int j = 0; j < 3; ++j) + if (!(i == 0 && j == 0)) + boost::hash_combine(result, boost::hash_value(transform.cartesian(i,j))); + return result; +} + +std::size_t +hash_value (const Bbox_2& bbox) +{ + std::size_t result = boost::hash_value(bbox.xmin()); + boost::hash_combine(result, boost::hash_value(bbox.xmax())); + boost::hash_combine(result, boost::hash_value(bbox.ymin())); + boost::hash_combine(result, boost::hash_value(bbox.ymax())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Circle_2& circle) +{ + std::size_t result = hash_value(circle.center()); + boost::hash_combine(result, boost::hash_value(circle.squared_radius())); + boost::hash_combine(result, boost::hash_value(circle.orientation())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Direction_2& direction) +{ + std::size_t result = boost::hash_value(direction.dx()); + boost::hash_combine(result, boost::hash_value(direction.dy())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Iso_rectangle_2& iso_rectangle) +{ + std::size_t result = hash_value(iso_rectangle.min()); + boost::hash_combine(result, hash_value(iso_rectangle.max())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Point_2& point) +{ + std::size_t result = boost::hash_value(point.x()); + boost::hash_combine(result, boost::hash_value(point.y())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Ray_2& ray) +{ + std::size_t result = hash_value(ray.source()); + boost::hash_combine(result, hash_value(ray.direction())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Segment_2& segment) +{ + std::size_t result = hash_value(segment.source()); + boost::hash_combine(result, hash_value(segment.target())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Vector_2& vector) +{ + std::size_t result = boost::hash_value(vector.x()); + boost::hash_combine(result, boost::hash_value(vector.y())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Weighted_point_2& weighed_point) +{ + std::size_t result = hash_value(weighed_point.point()); + boost::hash_combine(result, boost::hash_value(weighed_point.weight())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Aff_transformation_3& transform) +{ + std::size_t result = boost::hash_value(transform.cartesian(0,0)); + for(int i = 0; i < 3; ++i) + for(int j = 0; j < 4; ++j) + if (!(i == 0 && j == 0)) + boost::hash_combine(result, boost::hash_value(transform.cartesian(i,j))); + return result; +} + +std::size_t +hash_value (const Bbox_3& bbox) +{ + std::size_t result = boost::hash_value(bbox.xmin()); + boost::hash_combine(result, boost::hash_value(bbox.xmax())); + boost::hash_combine(result, boost::hash_value(bbox.ymin())); + boost::hash_combine(result, boost::hash_value(bbox.ymax())); + boost::hash_combine(result, boost::hash_value(bbox.zmin())); + boost::hash_combine(result, boost::hash_value(bbox.zmax())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Direction_3& direction) +{ + std::size_t result = boost::hash_value(direction.dx()); + boost::hash_combine(result, boost::hash_value(direction.dy())); + boost::hash_combine(result, boost::hash_value(direction.dz())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Iso_cuboid_3& iso_cuboid) +{ + std::size_t result = hash_value(iso_cuboid.min()); + boost::hash_combine(result, hash_value(iso_cuboid.max())); + return result; +} + template inline std::enable_if_t::value, std::size_t> hash_value (const Point_3& point) @@ -35,19 +173,159 @@ hash_value (const Point_3& point) return result; } +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Ray_3& ray) +{ + std::size_t result = hash_value(ray.source()); + boost::hash_combine(result, hash_value(ray.direction())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Segment_3& segment) +{ + std::size_t result = hash_value(segment.source()); + boost::hash_combine(result, hash_value(segment.target())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Sphere_3& sphere) +{ + std::size_t result = hash_value(sphere.center()); + boost::hash_combine(result, boost::hash_value(sphere.squared_radius())); + boost::hash_combine(result, boost::hash_value(sphere.orientation())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Vector_3& vector) +{ + std::size_t result = boost::hash_value(vector.x()); + boost::hash_combine(result, boost::hash_value(vector.y())); + boost::hash_combine(result, boost::hash_value(vector.z())); + return result; +} + +template +inline std::enable_if_t::value, std::size_t> +hash_value (const Weighted_point_3& weighed_point) +{ + std::size_t result = hash_value(weighed_point.point()); + boost::hash_combine(result, boost::hash_value(weighed_point.weight())); + return result; +} + } //namespace CGAL // overloads of std::hash used for using std::unordered_[set/map] on CGAL Kernel objects namespace std { -template struct hash > -{ - std::size_t operator() (const CGAL::Point_3& point) const - { +template struct hash > { + std::size_t operator() (const CGAL::Aff_transformation_2& transform) const { + return CGAL::hash_value (transform); + } +}; +template <> struct hash { + std::size_t operator() (const CGAL::Bbox_2& bbox) const { + return CGAL::hash_value (bbox); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Circle_2& circle) const { + return CGAL::hash_value (circle); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Direction_2& direction) const { + return CGAL::hash_value (direction); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Iso_rectangle_2& iso_rectangle) const { + return CGAL::hash_value (iso_rectangle); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Point_2& point) const { return CGAL::hash_value (point); } }; +template struct hash > { + std::size_t operator() (const CGAL::Ray_2& ray) const { + return CGAL::hash_value (ray); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Segment_2& segment) const { + return CGAL::hash_value (segment); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Vector_2& vector) const { + return CGAL::hash_value (vector); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Weighted_point_2& weighted_point) const { + return CGAL::hash_value (weighted_point); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Aff_transformation_3& transform) const { + return CGAL::hash_value (transform); + } +}; +template <> struct hash { + std::size_t operator() (const CGAL::Bbox_3& bbox) const { + return CGAL::hash_value (bbox); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Direction_3& direction) const { + return CGAL::hash_value (direction); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Iso_cuboid_3& iso_cuboid) const { + return CGAL::hash_value (iso_cuboid); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Point_3& point) const { + return CGAL::hash_value (point); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Ray_3& ray) const { + return CGAL::hash_value (ray); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Segment_3& segment) const { + return CGAL::hash_value (segment); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Sphere_3& sphere) const { + return CGAL::hash_value (sphere); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Vector_3& vector) const { + return CGAL::hash_value (vector); + } +}; +template struct hash > { + std::size_t operator() (const CGAL::Weighted_point_3& weighted_point) const { + return CGAL::hash_value (weighted_point); + } +}; } diff --git a/Kernel_23/test/Kernel_23/test_hash_functions.cpp b/Kernel_23/test/Kernel_23/test_hash_functions.cpp index 1a780d61b86..d3d7194dd6a 100644 --- a/Kernel_23/test/Kernel_23/test_hash_functions.cpp +++ b/Kernel_23/test/Kernel_23/test_hash_functions.cpp @@ -2,32 +2,80 @@ #include #include -#include + +#include typedef CGAL::Simple_cartesian SC; typedef CGAL::Exact_predicates_inexact_constructions_kernel Epick; -typedef CGAL::Exact_predicates_exact_constructions_kernel Epeck; + +template +void test (const Object& obj) +{ + std::unordered_set unordered_set; + unordered_set.insert (obj); + unordered_set.insert (obj); + assert (unordered_set.size() == 1); +} int main() { + test (SC::Aff_transformation_2 (1, 2, 3, 4)); + test (Epick::Aff_transformation_2 (1, 2, 3, 4)); - std::unordered_set sc_points; - sc_points.insert (SC::Point_3 (1, 2, 3)); - sc_points.insert (SC::Point_3 (1, 2, 3)); + test (CGAL::Bbox_2 ()); + + test (SC::Circle_2 (CGAL::ORIGIN, 1)); + test (Epick::Circle_2 (CGAL::ORIGIN, 1)); - std::unordered_set epick_points; - epick_points.insert (Epick::Point_3 (1, 2, 3)); - epick_points.insert (Epick::Point_3 (1, 2, 3)); + test (SC::Direction_2 (1, 2)); + test (Epick::Direction_2 (1, 2)); + + test (SC::Iso_rectangle_2 (1, 2, 3, 4)); + test (Epick::Iso_rectangle_2 (1, 2, 3, 4)); + + test (SC::Point_2 (1, 2)); + test (Epick::Point_2 (1, 2)); + + test (SC::Ray_2 (SC::Point_2 (1, 2), SC::Vector_2 (3, 4))); + test (Epick::Ray_2 (Epick::Point_2 (1, 2), Epick::Vector_2 (3, 4))); + + test (SC::Segment_2 (SC::Point_2 (1, 2), SC::Point_2 (3, 4))); + test (Epick::Segment_2 (Epick::Point_2 (1, 2), Epick::Point_2 (3, 4))); + + test (SC::Vector_2 (1, 2)); + test (Epick::Vector_2 (1, 2)); + + test (SC::Weighted_point_2 (SC::Point_2 (1, 2), 3)); + test (Epick::Weighted_point_2 (Epick::Point_2 (1, 2), 3)); + + test (SC::Aff_transformation_3 (1, 2, 3, 4, 5, 6, 7, 8, 9)); + test (Epick::Aff_transformation_3 (1, 2, 3, 4, 5, 6, 7, 8, 9)); - // Epeck points not hashable - std::unordered_set epeck_points; -#if 0 // Compilation only fails if something is inserted - epeck_points.insert (Epeck::Point_3 (1, 2, 3)); - epeck_points.insert (Epeck::Point_3 (1, 2, 3)); -#endif + test (CGAL::Bbox_3 ()); + + test (SC::Direction_3 (1, 2, 3)); + test (Epick::Direction_3 (1, 2, 3)); + + test (SC::Iso_cuboid_3 (1, 2, 3, 4, 5, 6)); + test (Epick::Iso_cuboid_3 (1, 2, 3, 4, 5, 6)); + + test (SC::Point_3 (1, 2, 3)); + test (Epick::Point_3 (1, 2, 3)); + + test (SC::Ray_3 (SC::Point_3 (1, 2, 3), SC::Vector_3 (4, 5, 6))); + test (Epick::Ray_3 (Epick::Point_3 (1, 2, 3), Epick::Vector_3 (4, 5, 6))); + + test (SC::Segment_3 (SC::Point_3 (1, 2, 3), SC::Point_3 (4, 5, 6))); + test (Epick::Segment_3 (Epick::Point_3 (1, 2, 3), Epick::Point_3 (4, 5, 6))); + + test (SC::Sphere_3 (CGAL::ORIGIN, 1)); + test (Epick::Sphere_3 (CGAL::ORIGIN, 1)); - assert (sc_points.size() == 1); - assert (epick_points.size() == 1); + test (SC::Vector_3 (1, 2, 3)); + test (Epick::Vector_3 (1, 2, 3)); + + test (SC::Weighted_point_3 (SC::Point_3 (1, 2, 3), 4)); + test (Epick::Weighted_point_3 (Epick::Point_3 (1, 2, 3), 4)); return 0; } From 5b39428ad5f056fad862b6742cfa9fa2b7ae874c Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 3 Jun 2019 16:13:06 +0200 Subject: [PATCH 130/203] Document objects that are hashable --- Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h | 2 ++ Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h | 2 ++ Kernel_23/doc/Kernel_23/CGAL/Bbox_2.h | 2 ++ Kernel_23/doc/Kernel_23/CGAL/Bbox_3.h | 2 ++ Kernel_23/doc/Kernel_23/CGAL/Circle_2.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Direction_2.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Direction_3.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Iso_rectangle_2.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Point_2.h | 5 +---- Kernel_23/doc/Kernel_23/CGAL/Point_3.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Ray_2.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Ray_3.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Segment_2.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Segment_3.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Vector_2.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Vector_3.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Weighted_point_2.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Weighted_point_3.h | 1 + 19 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h index 274d63e33ff..ae9adff736a 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h @@ -34,6 +34,8 @@ translation vector \f$ (v_0,\,v_1,\,1)\f$ appears in the last column of the matrix. The entries \f$ m_{20}\f$ and \f$ m_{21}\f$ are always zero and therefore do not appear in the constructors. +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number + \sa `Identity_transformation` \sa `Rotation` \sa `Scaling` diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h index b95e1530c98..40803c6186c 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h @@ -29,6 +29,8 @@ In three-dimensional space we have a \f$ 4\times 4\f$ matrix \f$ m_{32}\f$ are always zero and therefore do not appear in the constructors. +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number + \sa `CGAL::Aff_transformation_2` \sa `CGAL::Identity_transformation` \sa `CGAL::Reflection` diff --git a/Kernel_23/doc/Kernel_23/CGAL/Bbox_2.h b/Kernel_23/doc/Kernel_23/CGAL/Bbox_2.h index 3f70437c5b5..e61812bef8d 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Bbox_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Bbox_2.h @@ -7,6 +7,8 @@ namespace CGAL { An object `b` of the class `Bbox_2` is a bounding box in the two-dimensional Euclidean plane \f$ \E^2\f$. This class is not templated. +\cgalModels `Hashable` + \sa `CGAL::Bbox_3` */ diff --git a/Kernel_23/doc/Kernel_23/CGAL/Bbox_3.h b/Kernel_23/doc/Kernel_23/CGAL/Bbox_3.h index 88d9f4dd426..914e4be0436 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Bbox_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Bbox_3.h @@ -7,6 +7,8 @@ namespace CGAL { An object `b` of the class `Bbox_3` is a bounding box in the three-dimensional Euclidean space \f$ \E^3\f$. +\cgalModels `Hashable` + \sa `CGAL::Bbox_2` */ diff --git a/Kernel_23/doc/Kernel_23/CGAL/Circle_2.h b/Kernel_23/doc/Kernel_23/CGAL/Circle_2.h index 9c78f79be5f..a75cd35afc2 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Circle_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Circle_2.h @@ -12,6 +12,7 @@ splits \f$ \E^2\f$ into a bounded and an unbounded side. Note that the circle can be degenerated, i.e.\ the squared radius may be zero. \cgalModels `Kernel::Circle_2` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Direction_2.h b/Kernel_23/doc/Kernel_23/CGAL/Direction_2.h index 427e2356bf5..3b419b7010f 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Direction_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Direction_2.h @@ -15,6 +15,7 @@ Further, they can be used to indicate angles. The slope of a direction is `dy()`/`dx()`. \cgalModels `Kernel::Direction_2` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Direction_3.h b/Kernel_23/doc/Kernel_23/CGAL/Direction_3.h index c7fe4ec9e7f..d64ccf8a2c5 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Direction_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Direction_3.h @@ -14,6 +14,7 @@ For example, you can ask for the direction orthogonal to an oriented plane, or the direction of an oriented line. \cgalModels `Kernel::Direction_3` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h b/Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h index 36f7014b74c..b63d2e8db02 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h @@ -17,6 +17,7 @@ whereas the coordinate type of an iso-oriented cuboid is chosen by the user. \cgalModels `Kernel::IsoCuboid_3` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Iso_rectangle_2.h b/Kernel_23/doc/Kernel_23/CGAL/Iso_rectangle_2.h index 6f2ce4070a4..c89fd390e9e 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Iso_rectangle_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Iso_rectangle_2.h @@ -18,6 +18,7 @@ whereas the coordinate type of an iso-oriented rectangle is chosen by the user. \cgalModels `Kernel::IsoRectangle_2` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Point_2.h b/Kernel_23/doc/Kernel_23/CGAL/Point_2.h index e304a259393..4c59f467f71 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Point_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Point_2.h @@ -12,10 +12,6 @@ model `Cartesian`, the two types are the same. For the kernel model `Homogeneous`, `Kernel::RT` is equal to `NT`, and `Kernel::FT` is equal to `Quotient`. -\cgalHeading{Operators} - -The following operations can be applied on points: - \cgalHeading{Example} The following declaration creates two points with @@ -35,6 +31,7 @@ std::cout << p.x() << " " << p.y() << std::endl; \endcode \cgalModels `Kernel::Point_2` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Point_3.h b/Kernel_23/doc/Kernel_23/CGAL/Point_3.h index ddd1e5f7b39..9f86642f5ec 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Point_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Point_3.h @@ -17,6 +17,7 @@ to `NT`, and `Kernel::FT` is equal to `Quotient`. The following operations can be applied on points: \cgalModels `Kernel::Point_3` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Ray_2.h b/Kernel_23/doc/Kernel_23/CGAL/Ray_2.h index 9fafa75e7c2..12dd511d6d8 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Ray_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Ray_2.h @@ -8,6 +8,7 @@ straight ray in the two-dimensional Euclidean plane \f$ \E^2\f$. It starts in a point called the source of `r` and goes to infinity. \cgalModels `Kernel::Ray_2` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Ray_3.h b/Kernel_23/doc/Kernel_23/CGAL/Ray_3.h index 0a57867a243..3c1c2779f06 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Ray_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Ray_3.h @@ -8,6 +8,7 @@ straight ray in the three-dimensional Euclidean space \f$ \E^3\f$. It starts in a point called the source of `r` and it goes to infinity. \cgalModels `Kernel::Ray_3` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Segment_2.h b/Kernel_23/doc/Kernel_23/CGAL/Segment_2.h index 30a2743380f..1d8a370d9eb 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Segment_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Segment_2.h @@ -15,6 +15,7 @@ perform a square root operation which is not defined for all number types, which is expensive, and may not be exact. \cgalModels `Kernel::Segment_2` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Segment_3.h b/Kernel_23/doc/Kernel_23/CGAL/Segment_3.h index 07b25348aa9..151c86778e2 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Segment_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Segment_3.h @@ -15,6 +15,7 @@ perform a square root operation which is not defined for all number types, which is expensive, and may not be exact. \cgalModels `Kernel::Segment_3` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Vector_2.h b/Kernel_23/doc/Kernel_23/CGAL/Vector_2.h index 8685468fbdb..0328accda34 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Vector_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Vector_2.h @@ -13,6 +13,7 @@ will explicitly state where you can pass this constant as an argument instead of a vector initialized with zeros. \cgalModels `Kernel::Vector_2` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h b/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h index 2dec956a656..9a80105c33f 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h @@ -13,6 +13,7 @@ will explicitly state where you can pass this constant as an argument instead of a vector initialized with zeros. \cgalModels `Kernel::Vector_3` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number \sa `cross_product_grp` \sa `determinant_grp` 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 620f63ae66c..74e41bacee3 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_2.h @@ -14,6 +14,7 @@ to `NT`, and `Kernel::FT` is equal to `Quotient`. \sa `Point_2` \cgalModels `Kernel::WeightedPoint_2` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_3.h b/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_3.h index 849fc10ee4a..8717bc187c8 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_3.h @@ -14,6 +14,7 @@ to `NT`, and `Kernel::FT` is equal to `Quotient`. \sa `Point_3` \cgalModels `Kernel::WeightedPoint_3` +\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > From edd84534a9480dfe6dfbecff6366d1fd80f509b4 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 3 Jun 2019 17:02:18 +0200 Subject: [PATCH 131/203] Fix code --- .../doc/Triangulation_3/CGAL/Triangulation_3.h | 2 +- Triangulation_3/include/CGAL/Triangulation_3.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index ef55e739cf7..8f1b5f97e7e 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -222,7 +222,7 @@ typedef Triangulation_data_structure::Facet_circulator Facet_circulator; /// @} -/*! \name Ranges +/*! \name In order to write \cpp 11 `for`-loops we provide range types. diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 08340be1e5d..bb1f37854d9 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -431,8 +431,8 @@ public: typedef Edge_iterator All_edges_iterator; typedef Vertex_iterator All_vertices_iterator; - typedef Iterator_range > All_cells_range; - typedef Iterator_range > All_vertices_range; + typedef Iterator_range > All_cell_handles; + typedef Iterator_range > All_vertex_handles; typedef typename Tds::Simplex Simplex; @@ -1686,7 +1686,7 @@ public: All_cells_iterator all_cells_begin() const { return _tds.cells_begin(); } All_cells_iterator all_cells_end() const { return _tds.cells_end(); } - All_cells_range all_cells() const + All_cell_handles all_cell_handles() const { return make_prevent_deref_range(all_cells_begin(), all_cells_end()); } @@ -1710,7 +1710,7 @@ public: All_vertices_iterator all_vertices_begin() const { return _tds.vertices_begin(); } All_vertices_iterator all_vertices_end() const { return _tds.vertices_end(); } - All_vertices_range all_vertices() const + All_vertex_handles all_vertex_handles() const { return make_prevent_deref_range(all_vertices_begin(), all_vertices_end()); } From 4c9bda8169b60d2becc099dee0f91ce1b2c0d032 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 3 Jun 2019 17:23:32 +0200 Subject: [PATCH 132/203] Use C++11 for loop in examples --- .../examples/Triangulation_3/color.cpp | 6 +++--- .../info_insert_with_pair_iterator.cpp | 5 ++--- .../info_insert_with_pair_iterator_regular.cpp | 5 ++--- .../info_insert_with_transform_iterator.cpp | 5 ++--- .../info_insert_with_zip_iterator.cpp | 5 ++--- Triangulation_3/include/CGAL/Triangulation_3.h | 16 ++++++++++++++++ 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Triangulation_3/examples/Triangulation_3/color.cpp b/Triangulation_3/examples/Triangulation_3/color.cpp index 1dbd7bdeb75..c61bf335689 100644 --- a/Triangulation_3/examples/Triangulation_3/color.cpp +++ b/Triangulation_3/examples/Triangulation_3/color.cpp @@ -28,9 +28,9 @@ int main() // Set the color of finite vertices of degree 6 to red. Delaunay::Finite_vertices_iterator vit; - for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if (T.degree(vit) == 6) - vit->info() = CGAL::red(); + for (Delaunay::Vertex_handle v : T.finite_vertex_handles()) + if (T.degree(v) == 6) + v->info() = CGAL::red(); return 0; } diff --git a/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator.cpp b/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator.cpp index f132ea91ccd..c99e7c24f78 100644 --- a/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator.cpp +++ b/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator.cpp @@ -29,9 +29,8 @@ int main() CGAL_assertion( T.number_of_vertices() == 6 ); // check that the info was correctly set. - Delaunay::Finite_vertices_iterator vit; - for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if( points[ vit->info() ].first != vit->point() ){ + for (Delaunay::Vertex_handle v : T.finite_vertex_handles()) + if( points[ v->info() ].first != v->point() ){ std::cerr << "Error different info" << std::endl; exit(EXIT_FAILURE); } diff --git a/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator_regular.cpp b/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator_regular.cpp index 09e223579ae..dd2d15dda99 100644 --- a/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator_regular.cpp +++ b/Triangulation_3/examples/Triangulation_3/info_insert_with_pair_iterator_regular.cpp @@ -29,9 +29,8 @@ int main() CGAL_assertion( rt.number_of_vertices() == 6 ); // check that the info was correctly set. - Regular::Finite_vertices_iterator vit; - for (vit = rt.finite_vertices_begin(); vit != rt.finite_vertices_end(); ++vit) - if( points[ vit->info() ].first != vit->point() ){ + for (Regular::Vertex_handle v : rt.finite_vertex_handles()) + if( points[ v->info() ].first != v->point() ){ std::cerr << "Error different info" << std::endl; exit(EXIT_FAILURE); } diff --git a/Triangulation_3/examples/Triangulation_3/info_insert_with_transform_iterator.cpp b/Triangulation_3/examples/Triangulation_3/info_insert_with_transform_iterator.cpp index 88fc59bcbb7..00bee0da44b 100644 --- a/Triangulation_3/examples/Triangulation_3/info_insert_with_transform_iterator.cpp +++ b/Triangulation_3/examples/Triangulation_3/info_insert_with_transform_iterator.cpp @@ -41,9 +41,8 @@ int main() CGAL_assertion( T.number_of_vertices() == 6 ); // check that the info was correctly set. - Delaunay::Finite_vertices_iterator vit; - for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if( points[ vit->info() ] != vit->point() ){ + for (Delaunay::Vertex_handle v : T.finite_vertex_handles()) + if( points[ v->info() ] != v->point() ){ std::cerr << "Error different info" << std::endl; exit(EXIT_FAILURE); } diff --git a/Triangulation_3/examples/Triangulation_3/info_insert_with_zip_iterator.cpp b/Triangulation_3/examples/Triangulation_3/info_insert_with_zip_iterator.cpp index 6282291f91a..bf3a5988f30 100644 --- a/Triangulation_3/examples/Triangulation_3/info_insert_with_zip_iterator.cpp +++ b/Triangulation_3/examples/Triangulation_3/info_insert_with_zip_iterator.cpp @@ -40,9 +40,8 @@ int main() CGAL_assertion( T.number_of_vertices() == 6 ); // check that the info was correctly set. - Delaunay::Finite_vertices_iterator vit; - for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if( points[ vit->info() ] != vit->point() ){ + for (Delaunay::Vertex_handle v : T.finite_vertex_handles() ) + if( points[ v->info() ] != v->point() ){ std::cerr << "Error different info" << std::endl; exit(EXIT_FAILURE); } diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index bb1f37854d9..a7a705d075e 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -513,6 +513,10 @@ public: operator Vertex_handle() const { return Base::base(); } }; + + typedef Iterator_range > Finite_cell_handles; + typedef Iterator_range > Finite_vertex_handles; + typedef Filter_iterator Finite_edges_iterator; typedef Filter_iterator Finite_facets_iterator; @@ -1680,6 +1684,13 @@ public: return CGAL::filter_iterator(cells_end(), Infinite_tester(this)); } + + Finite_cell_handles finite_cell_handles() const + { + return make_prevent_deref_range(finite_cells_begin(), finite_cells_end()); + } + + Cell_iterator cells_begin() const { return _tds.cells_begin(); } Cell_iterator cells_end() const { return _tds.cells_end(); } @@ -1704,6 +1715,11 @@ public: return CGAL::filter_iterator(vertices_end(), Infinite_tester(this)); } + Finite_vertex_handles finite_vertex_handles() const + { + return make_prevent_deref_range(finite_vertices_begin(), finite_vertices_end()); + } + Vertex_iterator vertices_begin() const { return _tds.vertices_begin(); } Vertex_iterator vertices_end() const { return _tds.vertices_end(); } From 285cdd5be5caeeee6b661b53269ef29b05d90555 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Jun 2019 10:40:13 +0200 Subject: [PATCH 133/203] Add more ranges and a testsuite --- .../CGAL/Triangulation_data_structure_3.h | 26 +++++ .../Triangulation_3/CGAL/Triangulation_3.h | 99 ++++++++++++++++++- .../doc/Triangulation_3/Triangulation_3.txt | 4 +- .../examples/Triangulation_3/for_loop.cpp | 20 ++-- .../include/CGAL/Triangulation_3.h | 54 ++++++++-- .../include/CGAL/_test_cls_iterator.h | 69 +++++++++++++ .../include/CGAL/_test_cls_triangulation_3.h | 2 +- 7 files changed, 248 insertions(+), 26 deletions(-) diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index 7e46fbf377e..dbc456a0138 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -166,6 +166,12 @@ public: typedef internal::Triangulation_ds_cell_circulator_3 Cell_circulator; typedef internal::Triangulation_ds_facet_circulator_3 Facet_circulator; + typedef Iterator_range > Cell_handles; + typedef Iterator_range > Vertex_handles; + + typedef Iterator_range Facets; + typedef Iterator_range Edges; + //private: // In 2D only : typedef internal::Triangulation_ds_face_circulator_3 Face_circulator; @@ -564,6 +570,11 @@ public: return cells().end(); } + Cell_handles cell_handles() const + { + return make_prevent_deref_range(cells_begin(), cells_end()); + } + Cell_iterator raw_cells_begin() const { return cells().begin(); @@ -586,6 +597,11 @@ public: return Facet_iterator(this, 1); } + Facets facets() const + { + return Facets(facets_begin(), facets_end()); + } + Edge_iterator edges_begin() const { if ( dimension() < 1 ) @@ -598,6 +614,11 @@ public: return Edge_iterator(this,1); } + Edges edges() const + { + return Edges(edges_begin(), edges_end()); + } + Vertex_iterator vertices_begin() const { return vertices().begin(); @@ -608,6 +629,11 @@ public: return vertices().end(); } + Vertex_handles vertex_handles() const + { + return make_prevent_deref_range(vertices_begin(), vertices_end()); + } + // CIRCULATOR METHODS // cells around an edge diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index 8f1b5f97e7e..5e2755e4bed 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -228,19 +228,57 @@ In order to write \cpp 11 `for`-loops we provide range types. */ /// @{ - + +/*! +range type for iterating over all cell handles, with a nested type `iterator` +that has as value type `Cell_handle`. +*/ + typedef Iterator_range All_cell_handles; + /*! range type for iterating over facets. */ - typedef Iterator_range All_facets; + typedef Iterator_range All_facets; + +/*! +range type for iterating over edges. +*/ + typedef Iterator_range All_edges; /*! range type for iterating over all vertex handles, with a nested type `iterator` that has as value type `Vertex_handle`. */ typedef Iterator_range All_vertex_handles; + + /*! +range type for iterating over finite cell handles, with a nested type `iterator` +that has as value type `Cell_handle`. +*/ + typedef Iterator_range Finite_cell_handles; + +/*! +range type for iterating over finite facets. +*/ + typedef Iterator_range Finite_facets; + +/*! +range type for iterating over finite edges. +*/ + typedef Iterator_range Finite_edges; + +/*! +range type for iterating over finite vertex handles, with a nested type `iterator` +that has as value type `Vertex_handle`. +*/ + typedef Iterator_range Finite_vertex_handles; + +/*! + range type for iterating over the points of the finite vertices. + */ + typedef Iterator_range Points; /// @} /// \name Creation @@ -1159,11 +1197,34 @@ Point_iterator points_end() const; /*! \name Ranges In order to write \cpp 11 `for`-loops we provide a range type and member functions to generate ranges. -Note that vertex and cell ranges are special. +Note that vertex and cell ranges are special. See Section \ref Triangulation3secRanges in the User Manual. */ /// @{ + +/*! + returns a range of iterators over all cells (even the infinite one). + Returns an empty range when `t.number_of_cells() == 0`. + \note While the value type of `All_cells_iterator` is `Cell`, the value type of + `All_cell_handles::iterator` is `Cell_handle`. + */ + All_cell_handles all_cell_handles() const; + + + +/*! + returns a range of iterators starting at an arbitrary facet. + Returns an empty range when `t.dimension() < 2`. +*/ +All_facets all_facets() const; + +/*! + returns a range of iterators starting at an arbitrary edge. + Returns an empty range when `t.dimension() < 2`. +*/ +All_edges all_edges() const; + /*! returns a range of iterators over all vertices (even the infinite one). Returns an empty range when `t.number_of_vertices() == 0`. @@ -1172,13 +1233,43 @@ Note that vertex and cell ranges are special. */ All_vertex_handles all_vertex_handles() const; + +/*! + returns a range of iterators over finite cells. + Returns an empty range when `t.number_of_cells() == 0`. + \note While the value type of `Finite_cells_iterator` is `Cell`, the value type of + `Finite_cell_handles::iterator` is `Cell_handle`. + */ + Finite_cell_handles finite_cell_handles() const; + + /*! returns a range of iterators starting at an arbitrary facet. Returns an empty range when `t.dimension() < 2`. */ -All_facets all_facets() const; +Finite_facets finite_facets() const; + +/*! + returns a range of iterators starting at an arbitrary edge. + Returns an empty range when `t.dimension() < 2`. +*/ +Finite_edges finite_edges() const; + +/*! + returns a range of iterators over finite vertices. + Returns an empty range when `t.number_of_vertices() == 0`. + \note While the value type of `Finite_vertices_iterator` is `Vertex`, the value type of + `Finite_vertex_handles::iterator` is `Vertex_handle`. + */ + Finite_vertex_handles finite_vertex_handles() const; + + /*! + returns a range of iterators over the points of finite vertices. + */ + Points points() const; + /// @} /*!\name Cell and Facet Circulators diff --git a/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt b/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt index ebb0478e616..d0594b5ca62 100644 --- a/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt +++ b/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt @@ -489,14 +489,14 @@ is dereferenced only once per point during the insertion. \subsection Triangulation3secRanges Iterators and Ranges The triangulation defines iterator types such as `Triangulation_3::All_vertices_iterator`. They behave like -a `Triangulation_3::Vertex_handle`, that is there is no need to dereference the iterator to obtain a handle. +a `Triangulation_3::Vertex_handle`, in the sense that there is no need to dereference the iterator to obtain a handle. Wherever the API expects a handle the iterator can be passed as well. In order to write a \cpp 11 `for`-loop the triangulation calls also offers the range type `Triangulation_3::All_vertex_handles`, which has a nested type `Triangulation_3::All_vertex_handles::iterator`. The value type of this iterator is `Triangulation_3::Vertex_handle`. Note that you only need the iterator type if you combine the pre \cpp 11 `for`-loop with the range class. -It is similar for the various iterators for vertice and cells. +It is similar for the various iterators for vertices and cells. For the range `Triangulation_3::All_facets` it holds that `Triangulation_3::All_facets::iterator` `==` `Triangulation_3::All_facets_iterator`. It is similar for the iterators for edges and points. diff --git a/Triangulation_3/examples/Triangulation_3/for_loop.cpp b/Triangulation_3/examples/Triangulation_3/for_loop.cpp index 46547eca0a8..94b3ab992f1 100644 --- a/Triangulation_3/examples/Triangulation_3/for_loop.cpp +++ b/Triangulation_3/examples/Triangulation_3/for_loop.cpp @@ -7,13 +7,13 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Triangulation_3 Triangulation; typedef Triangulation::Vertex_handle Vertex_handle; typedef Triangulation::Point Point; -typedef Triangulation::All_vertex_handles All_vertex_handles; +typedef Triangulation::Finite_vertex_handles Finite_vertex_handles; // The following types are different // Its value type is Triangulation_3::Vertex -typedef Triangulation::All_vertices_iterator All_vertices_iterator; +typedef Triangulation::Finite_vertices_iterator Finite_vertices_iterator; // Its value type is Triangulation_3::Vertex_handle -typedef All_vertex_handles::iterator All_vertex_handles_iterator; +typedef Finite_vertex_handles::iterator Finite_vertex_handles_iterator; int main() { @@ -21,23 +21,23 @@ int main() Triangulation T(points.begin(), points.end()); - std::cout << "Triangulation_3::All_vertices_iterator is like a Triangulation_3::Vertex_handle\n"; - for(All_vertices_iterator it = T.all_vertices_begin(); - it != T.all_vertices_end(); + std::cout << "Triangulation_3::Finite_vertices_iterator is like a Triangulation_3::Vertex_handle\n"; + for(Finite_vertices_iterator it = T.finite_vertices_begin(); + it != T.finite_vertices_end(); ++it){ std::cout << it->point() << std::endl; } - std::cout << "Triangulation_3::All_vertex_handles::iterator dereferences to Triangulation_3::Vertex_handle\n"; - All_vertex_handles::iterator b, e; - std::tie(b,e) = T.all_vertex_handles(); + std::cout << "Triangulation_3::Finite_vertex_handles::iterator dereferences to Triangulation_3::Vertex_handle\n"; + Finite_vertex_handles::iterator b, e; + std::tie(b,e) = T.finite_vertex_handles(); for(; b!=e; ++b){ Vertex_handle vh = *b; // you must dereference the iterator to get a handle std::cout << vh->point() << std::endl; } std::cout << "and you can use a C++11 for loop\n"; - for(Vertex_handle vh : T.all_vertex_handles()){ + for(Vertex_handle vh : T.finite_vertex_handles()){ std::cout << vh->point() << std::endl; } diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index a7a705d075e..68fb943b4bf 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -431,8 +431,10 @@ public: typedef Edge_iterator All_edges_iterator; typedef Vertex_iterator All_vertices_iterator; - typedef Iterator_range > All_cell_handles; - typedef Iterator_range > All_vertex_handles; + typedef typename Tds::Cell_handles All_cell_handles; + typedef typename Tds::Vertex_handles All_vertex_handles; + typedef typename Tds::Facets All_facets; + typedef typename Tds::Edges All_edges; typedef typename Tds::Simplex Simplex; @@ -513,13 +515,15 @@ public: operator Vertex_handle() const { return Base::base(); } }; - - typedef Iterator_range > Finite_cell_handles; + typedef Iterator_range > Finite_cell_handles; typedef Iterator_range > Finite_vertex_handles; - + typedef Filter_iterator Finite_edges_iterator; typedef Filter_iterator Finite_facets_iterator; + typedef Iterator_range Finite_edges; + typedef Iterator_range Finite_facets; + private: // Auxiliary iterators for convenience // do not use default template argument to please VC++ @@ -533,6 +537,9 @@ public: std::ptrdiff_t, std::bidirectional_iterator_tag> Point_iterator; + + typedef Iterator_range Points; + // To have a back_inserter typedef Point value_type; typedef const value_type& const_reference; @@ -1699,7 +1706,7 @@ public: All_cell_handles all_cell_handles() const { - return make_prevent_deref_range(all_cells_begin(), all_cells_end()); + return _tds.cell_handles(); } Finite_vertices_iterator finite_vertices_begin() const @@ -1728,7 +1735,7 @@ public: All_vertex_handles all_vertex_handles() const { - return make_prevent_deref_range(all_vertices_begin(), all_vertices_end()); + return _tds.vertex_handles(); } Finite_edges_iterator finite_edges_begin() const @@ -1743,12 +1750,23 @@ public: return CGAL::filter_iterator(edges_end(), Infinite_tester(this)); } + Finite_edges finite_edges() const + { + return Finite_edges(finite_edges_begin(),finite_edges_end()); + } + Edge_iterator edges_begin() const { return _tds.edges_begin(); } Edge_iterator edges_end() const { return _tds.edges_end(); } + All_edges_iterator all_edges_begin() const { return _tds.edges_begin(); } All_edges_iterator all_edges_end() const { return _tds.edges_end(); } + All_edges all_edges() const + { + return _tds.edges(); + } + Finite_facets_iterator finite_facets_begin() const { if(dimension() < 2) @@ -1761,19 +1779,37 @@ public: return CGAL::filter_iterator(facets_end(), Infinite_tester(this)); } + Finite_facets finite_facets() const + { + return Finite_facets(finite_facets_begin(),finite_facets_end()); + } + Facet_iterator facets_begin() const { return _tds.facets_begin(); } Facet_iterator facets_end() const { return _tds.facets_end(); } + All_facets_iterator all_facets_begin() const { return _tds.facets_begin(); } All_facets_iterator all_facets_end() const { return _tds.facets_end(); } - Point_iterator points_begin() const { + All_facets all_facets() const + { + return _tds.facets(); + } + + Point_iterator points_begin() const + { return Point_iterator(finite_vertices_begin()); } - Point_iterator points_end() const { + Point_iterator points_end() const + { return Point_iterator(finite_vertices_end()); } + Points points() const + { + return Points(points_begin(),points_end()); + } + // cells around an edge Cell_circulator incident_cells(const Edge& e) const { diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.h index 85d8cf29b6c..47f6099e4a9 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.h @@ -79,6 +79,7 @@ _test_vertex_iterator( const Triangulation &T ) } assert( n == T.number_of_vertices() ); + return n; } @@ -96,6 +97,18 @@ _test_triangulation_iterator( const Triangulation &T ) typedef typename Triangulation::Edge_iterator Edge_iterator; typedef typename Triangulation::Vertex_iterator Vertex_iterator; + typedef typename Triangulation::Vertex_handle Vertex_handle; + + typedef typename Triangulation::All_vertex_handles All_vertex_handles; + typedef typename Triangulation::All_cell_handles All_cell_handles; + typedef typename Triangulation::All_edges All_edges; + typedef typename Triangulation::All_facets All_facets; + typedef typename Triangulation::Finite_vertex_handles Finite_vertex_handles; + typedef typename Triangulation::Finite_cell_handles Finite_cell_handles; + typedef typename Triangulation::Finite_edges Finite_edges; + typedef typename Triangulation::Finite_facets Finite_facets; + typedef typename Triangulation::Points Points; + typedef typename Triangulation::Cell Cell; typedef typename Triangulation::Facet Facet; typedef typename Triangulation::Edge Edge; @@ -116,6 +129,62 @@ _test_triangulation_iterator( const Triangulation &T ) (void) ch; } if (T.dimension()==3) { + { + All_vertex_handles range = T.all_vertex_handles(); + Vertex_handle vh = *(range.first); + assert(vh == T.all_vertices_begin()); + vh = *(range.second); + assert(vh == T.all_vertices_end()); + } + { + All_cell_handles range = T.all_cell_handles(); + Cell_handle vh = *(range.first); + assert(vh == T.all_cells_begin()); + vh = *(range.second); + assert(vh == T.all_cells_end()); + } + { + All_edges range = T.all_edges(); + assert(range.first == T.all_edges_begin()); + assert(range.second == T.all_edges_end()); + } + { + All_facets range = T.all_facets(); + assert(range.first == T.all_facets_begin()); + assert(range.second == T.all_facets_end()); + } + { + Finite_vertex_handles range = T.finite_vertex_handles(); + Vertex_handle vh = *(range.first); + assert(vh == Vertex_handle(T.finite_vertices_begin())); + vh = *(range.second); + + assert(vh == Vertex_handle(T.finite_vertices_end())); + } + { + Finite_cell_handles range = T.finite_cell_handles(); + Cell_handle ch = *(range.first); + assert(ch == Cell_handle(T.finite_cells_begin())); + ch = *(range.second); + assert(ch == Cell_handle(T.finite_cells_end())); + } + { + Finite_edges range = T.finite_edges(); + assert(range.first == T.finite_edges_begin()); + assert(range.second == T.finite_edges_end()); + } + { + Finite_facets range = T.finite_facets(); + assert(range.first == T.finite_facets_begin()); + assert(range.second == T.finite_facets_end()); + } + { + Points range = T.points(); + assert(range.first == T.points_begin()); + assert(range.second == T.points_end()); + } + + for (FCit = T.finite_cells_begin(); FCit != T.finite_cells_end(); ++FCit) { Cell_handle ch = FCit; // Test the conversion. diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h index 66b9b86e787..e5f850f8fdc 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h @@ -116,7 +116,7 @@ _test_cls_triangulation_3(const Triangulation &) typedef typename Cls::Finite_edges_iterator Finite_edges_iterator; typedef typename Cls::Finite_facets_iterator Finite_facets_iterator; typedef typename Cls::Finite_cells_iterator Finite_cells_iterator; - + CGAL_USE_TYPE(Vertex); CGAL_USE_TYPE(Cell); CGAL_USE_TYPE(difference_type); From 44907c83266a78e6c97acf26456493de9c060a88 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 4 Jun 2019 10:13:41 +0200 Subject: [PATCH 134/203] Update CHANGES.md --- Installation/CHANGES.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index a445365fc91..dad64711549 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -45,6 +45,16 @@ Release date: September 2019 the approximate dihedral angle between 2 vectors. Corresponding functors in the model (`Compute_approximate_angle_3`) and free function (`approximate_angle`) are also added. + - The following objects are now hashable and thus trivially usable + with `std::unordered_set` and `std::unordered_map`: + `CGAL::Aff_transformation_2`, `CGAL::Aff_transformation_3`, + `CGAL::Bbox_2`, `CGAL::Bbox_3`, `CGAL::Circle_2`, + `CGAL::Direction_2`, `CGAL::Direction_3`, + `CGAL::Iso_cuboid_3`, `CGAL::Iso_rectangle_2`, + `CGAL::Point_2`, `CGAL::Point_3`, `CGAL::Ray_2`, + `CGAL::Ray_3`, `CGAL::Segment_2`, `CGAL::Segment_3`, + `CGAL::Vector_2`, `CGAL::Vector_3`, `CGAL::Weighted_point_2` + and `CGAL::Weighted_point_3`. ### IO Streams From 785ae04e0ba8fd05652d55eab0ff2e2e777c5544 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Jun 2019 12:45:42 +0200 Subject: [PATCH 135/203] Add ranges to Regular_triangulation_2 --- .../CGAL/Triangulation_data_structure_2.h | 21 +++++ .../CGAL/Triangulation_data_structure_3.h | 2 +- .../include/CGAL/Regular_triangulation_2.h | 43 +++++++++- .../include/CGAL/Triangulation_2.h | 80 ++++++++++++++++++- .../CGAL/_test_triangulation_iterators.h | 17 +++- 5 files changed, 155 insertions(+), 8 deletions(-) diff --git a/TDS_2/include/CGAL/Triangulation_data_structure_2.h b/TDS_2/include/CGAL/Triangulation_data_structure_2.h index ef05a3bb57e..08bbf3e6793 100644 --- a/TDS_2/include/CGAL/Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/Triangulation_data_structure_2.h @@ -98,6 +98,11 @@ public: typedef Triangulation_ds_vertex_circulator_2 Vertex_circulator; typedef Triangulation_ds_edge_circulator_2 Edge_circulator; + typedef Iterator_range > Vertex_handles; + typedef Iterator_range > Face_handles; + typedef Iterator_range Edges; + typedef Iterator_range Halfedges; + typedef Vertex_iterator Vertex_handle; typedef Face_iterator Face_handle; @@ -172,6 +177,10 @@ public: return faces().end(); } + Face_handles face_handles() const { + return make_prevent_deref_range(faces_begin(),faces_end()); + } + Vertex_iterator vertices_begin() const { return vertices().begin(); } @@ -179,6 +188,10 @@ public: Vertex_iterator vertices_end() const { return vertices().end(); } + + Vertex_handles vertex_handles() const { + return make_prevent_deref_range(vertices_begin(),vertices_end()); + } Edge_iterator edges_begin() const { return Edge_iterator(this); @@ -187,6 +200,10 @@ public: Edge_iterator edges_end() const { return Edge_iterator(this,1); } + + Edges edges() const { + return Edges(edges_begin(),edges_end()); + } Halfedge_iterator halfedges_begin() const { return Halfedge_iterator(this); @@ -196,6 +213,10 @@ public: return Halfedge_iterator(this,1); } + Halfedges halfedges() const { + return Halfedges(halfedges_begin(),halfedges_end()); + } + Face_circulator incident_faces(Vertex_handle v, Face_handle f = Face_handle()) const{ return Face_circulator(v,f); diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index dbc456a0138..686e12e361d 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -170,7 +170,7 @@ public: typedef Iterator_range > Vertex_handles; typedef Iterator_range Facets; - typedef Iterator_range Edges; + typedef Iterator_range Edges; //private: // In 2D only : typedef internal::Triangulation_ds_face_circulator_3 Face_circulator; diff --git a/Triangulation_2/include/CGAL/Regular_triangulation_2.h b/Triangulation_2/include/CGAL/Regular_triangulation_2.h index 0f2a30c720e..b8da37214da 100644 --- a/Triangulation_2/include/CGAL/Regular_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Regular_triangulation_2.h @@ -175,6 +175,8 @@ public: operator Vertex_handle() const { return Base::base(); } }; + typedef Iterator_range > All_vertex_handles; + class Finite_vertices_iterator : public Filter_iterator { @@ -190,6 +192,8 @@ public: operator Vertex_handle() const { return Base::base(); } }; + typedef Iterator_range > Finite_vertex_handles; + class Hidden_vertices_iterator : public Filter_iterator { @@ -205,6 +209,8 @@ public: operator Vertex_handle() const { return Base::base(); } }; + typedef Iterator_range > Hidden_vertex_handles; + //for backward compatibility typedef Finite_faces_iterator Face_iterator; typedef Finite_edges_iterator Edge_iterator; @@ -341,14 +347,18 @@ public: All_vertices_iterator all_vertices_begin() const; All_vertices_iterator all_vertices_end() const; - + All_vertex_handles all_vertex_handles() const; + Finite_vertices_iterator finite_vertices_begin() const; Finite_vertices_iterator finite_vertices_end() const; + Finite_vertex_handles finite_vertex_handles() const; + Vertex_handle finite_vertex() const; Hidden_vertices_iterator hidden_vertices_begin() const; Hidden_vertices_iterator hidden_vertices_end() const; - + Hidden_vertex_handles hidden_vertex_handles() const; + // Vertex_handle file_input(std::istream& is); // void file_output(std::ostream& os) const; @@ -2191,7 +2201,15 @@ all_vertices_end() const return CGAL::filter_iterator(Base::all_vertices_end(), Hidden_tester()); } - + +template < class Gt, class Tds > +typename Regular_triangulation_2::All_vertex_handles +Regular_triangulation_2:: +all_vertex_handles() const +{ + return make_prevent_deref_range(all_vertices_begin(),all_vertices_end()); +} + template < class Gt, class Tds > typename Regular_triangulation_2::Finite_vertices_iterator Regular_triangulation_2:: @@ -2202,6 +2220,7 @@ finite_vertices_begin() const Base::finite_vertices_begin()); } + template < class Gt, class Tds > typename Regular_triangulation_2::Vertex_handle Regular_triangulation_2:: @@ -2221,6 +2240,14 @@ finite_vertices_end() const Hidden_tester()); } +template < class Gt, class Tds > +typename Regular_triangulation_2::Finite_vertex_handles +Regular_triangulation_2:: +finite_vertex_handles() const +{ + return make_prevent_deref_range(finite_vertices_begin(),finite_vertices_end()); +} + template < class Gt, class Tds > typename Regular_triangulation_2::Hidden_vertices_iterator Regular_triangulation_2:: @@ -2239,7 +2266,15 @@ hidden_vertices_end() const return CGAL::filter_iterator(Base::finite_vertices_end(), Unhidden_tester()); } - + +template < class Gt, class Tds > +typename Regular_triangulation_2::Hidden_vertex_handles +Regular_triangulation_2:: +hidden_vertex_handles() const +{ + return make_prevent_deref_range(hidden_vertices_begin(),hidden_vertices_end()); +} + template < class Gt, class Tds > typename Regular_triangulation_2::Vertex_handle Regular_triangulation_2:: diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index 4004b700c60..275e9e9c865 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -207,6 +207,20 @@ public: typedef Project_point Proj_point; typedef boost::transform_iterator Point_iterator; + + + // Range types + + + typedef typename Tds::Face_handles All_face_handles; + typedef typename Tds::Vertex_handles All_vertex_handles; + typedef typename Tds::Edges All_edges; + + typedef Iterator_range > Finite_face_handles; + typedef Iterator_range > Finite_vertex_handles; + typedef Iterator_range Finite_edges; + typedef Iterator_range Points; + typedef Point value_type; // to have a back_inserter typedef const value_type& const_reference; typedef value_type& reference; @@ -437,19 +451,32 @@ public: //TRAVERSING : ITERATORS AND CIRCULATORS Finite_faces_iterator finite_faces_begin() const; Finite_faces_iterator finite_faces_end() const; + Finite_face_handles finite_face_handles() const; + Finite_vertices_iterator finite_vertices_begin() const; Finite_vertices_iterator finite_vertices_end() const; + Finite_vertex_handles finite_vertex_handles() const; + Finite_edges_iterator finite_edges_begin() const; Finite_edges_iterator finite_edges_end() const; + Finite_edges finite_edges() const; + Point_iterator points_begin() const; Point_iterator points_end() const; + Points points() const; All_faces_iterator all_faces_begin() const; All_faces_iterator all_faces_end() const; + All_face_handles all_face_handles() const; + All_vertices_iterator all_vertices_begin() const; All_vertices_iterator all_vertices_end() const; + All_vertex_handles all_vertex_handles() const; + All_edges_iterator all_edges_begin() const; All_edges_iterator all_edges_end() const; + All_edges all_edges() const; + All_halfedges_iterator all_halfedges_begin() const; All_halfedges_iterator all_halfedges_end() const; @@ -3077,6 +3104,14 @@ finite_faces_end() const Infinite_tester(this) ); } +template +typename Triangulation_2::Finite_face_handles +Triangulation_2:: +finite_face_handles() const +{ + return make_prevent_deref_range(finite_faces_begin(),finite_faces_end()); +} + template typename Triangulation_2::Finite_vertices_iterator Triangulation_2:: @@ -3098,6 +3133,14 @@ finite_vertices_end() const Infinite_tester(this)); } +template +typename Triangulation_2::Finite_vertex_handles +Triangulation_2:: +finite_vertex_handles() const +{ + return make_prevent_deref_range(finite_vertices_begin(),finite_vertices_end()); +} + template typename Triangulation_2::Finite_edges_iterator Triangulation_2:: @@ -3119,6 +3162,15 @@ finite_edges_end() const infinite_tester() ); } + +template +typename Triangulation_2::Finite_edges +Triangulation_2:: +finite_edges() const +{ + return Finite_edges(finite_edges_begin(), finite_edges_end()); +} + template typename Triangulation_2::Point_iterator Triangulation_2:: @@ -3135,6 +3187,14 @@ points_end() const return Point_iterator(finite_vertices_end()); } +template +typename Triangulation_2::Points +Triangulation_2:: +points() const +{ + return Points(points_begin(), points_end()); +} + template typename Triangulation_2::All_faces_iterator Triangulation_2:: @@ -3142,13 +3202,21 @@ all_faces_begin() const { return _tds.faces_begin(); } - + template typename Triangulation_2::All_faces_iterator Triangulation_2:: all_faces_end() const { - return _tds.faces_end();; + return _tds.faces_end(); +} + +template +typename Triangulation_2::All_face_handles +Triangulation_2:: +all_face_handles() const +{ + return _tds.face_handles(); } template @@ -3166,6 +3234,14 @@ all_vertices_end() const { return _tds.vertices_end(); } + +template +typename Triangulation_2::All_vertex_handles +Triangulation_2:: +all_vertex_handles() const +{ + return _tds.vertex_handles(); +} template typename Triangulation_2::All_edges_iterator diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h index 265f6139bf3..5e3e8684ef0 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h @@ -80,6 +80,8 @@ _test_cls_face_iterator( const Triangulation &T ) typedef typename Triangulation::Face_handle Face_handle; typedef typename Triangulation::size_type size_type; + typedef typename Triangulation::Finite_face_handles Finite_face_handles; + Face f; Face_handle fh; Vertex_handle vh; @@ -104,6 +106,9 @@ _test_cls_face_iterator( const Triangulation &T ) n--; assert(n==0); + Finite_face_handles range = T.finite_face_handles(); + fh = *(range.first); + return n_finite; } @@ -119,6 +124,8 @@ _test_cls_vertex_iterator( const Triangulation &T ) typedef typename Triangulation::Face_handle Face_handle; typedef typename Triangulation::size_type size_type; + typedef typename Triangulation::Finite_vertex_handles Finite_vertex_handles; + Vertex v; Face_handle fh; Vertex_handle vh; @@ -143,6 +150,8 @@ _test_cls_vertex_iterator( const Triangulation &T ) n--; assert( n == 0 ); + Finite_vertex_handles range = T.finite_vertex_handles(); + vh = *(range.first); return nv; } @@ -153,7 +162,7 @@ _test_cls_point_iterator( Triangulation &T ) typedef typename Triangulation::Point_iterator Point_iterator; typedef typename Triangulation::Point Point; typedef typename Triangulation::size_type size_type; - + typedef typename Triangulation::Points Points; size_type np = 0; Point_iterator pit; Point p; @@ -172,6 +181,8 @@ _test_cls_point_iterator( Triangulation &T ) n--; assert( n == 0 ); + Points range = T.points(); + p = *(range.first); return np; } @@ -185,6 +196,8 @@ _test_cls_edge_iterator( const Triangulation &T ) typedef typename Triangulation::Face_handle Face_handle; typedef typename Triangulation::size_type size_type; + typedef typename Triangulation::Finite_edges Finite_edges; + Edge e; Face_handle fh; @@ -205,6 +218,8 @@ _test_cls_edge_iterator( const Triangulation &T ) n--; assert( n == 0 ); + Finite_edges range = T.finite_edges(); + e = *(range.first); return ne; } From 9ee478139b9165ef564b8bcdccaab95e6f4e2a5c Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 4 Jun 2019 13:26:05 +0200 Subject: [PATCH 136/203] Remove hash for Direction_23/Ray_23 as equality is more complicated --- Installation/CHANGES.md | 10 ++-- Kernel_23/doc/Kernel_23/CGAL/Direction_2.h | 1 - Kernel_23/doc/Kernel_23/CGAL/Direction_3.h | 1 - Kernel_23/doc/Kernel_23/CGAL/Ray_2.h | 1 - Kernel_23/doc/Kernel_23/CGAL/Ray_3.h | 1 - .../include/CGAL/Kernel/hash_functions.h | 57 ------------------- .../test/Kernel_23/test_hash_functions.cpp | 12 ---- 7 files changed, 4 insertions(+), 79 deletions(-) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index dad64711549..a3fddc11741 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -49,12 +49,10 @@ Release date: September 2019 with `std::unordered_set` and `std::unordered_map`: `CGAL::Aff_transformation_2`, `CGAL::Aff_transformation_3`, `CGAL::Bbox_2`, `CGAL::Bbox_3`, `CGAL::Circle_2`, - `CGAL::Direction_2`, `CGAL::Direction_3`, - `CGAL::Iso_cuboid_3`, `CGAL::Iso_rectangle_2`, - `CGAL::Point_2`, `CGAL::Point_3`, `CGAL::Ray_2`, - `CGAL::Ray_3`, `CGAL::Segment_2`, `CGAL::Segment_3`, - `CGAL::Vector_2`, `CGAL::Vector_3`, `CGAL::Weighted_point_2` - and `CGAL::Weighted_point_3`. + `CGAL::Iso_cuboid_3`, `CGAL::Iso_rectangle_2`, `CGAL::Point_2`, + `CGAL::Point_3`, `CGAL::Segment_2`, `CGAL::Segment_3`, + `CGAL::Vector_2`, `CGAL::Vector_3`, `CGAL::Weighted_point_2` and + `CGAL::Weighted_point_3`. ### IO Streams diff --git a/Kernel_23/doc/Kernel_23/CGAL/Direction_2.h b/Kernel_23/doc/Kernel_23/CGAL/Direction_2.h index 3b419b7010f..427e2356bf5 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Direction_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Direction_2.h @@ -15,7 +15,6 @@ Further, they can be used to indicate angles. The slope of a direction is `dy()`/`dx()`. \cgalModels `Kernel::Direction_2` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Direction_3.h b/Kernel_23/doc/Kernel_23/CGAL/Direction_3.h index d64ccf8a2c5..c7fe4ec9e7f 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Direction_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Direction_3.h @@ -14,7 +14,6 @@ For example, you can ask for the direction orthogonal to an oriented plane, or the direction of an oriented line. \cgalModels `Kernel::Direction_3` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Ray_2.h b/Kernel_23/doc/Kernel_23/CGAL/Ray_2.h index 12dd511d6d8..9fafa75e7c2 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Ray_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Ray_2.h @@ -8,7 +8,6 @@ straight ray in the two-dimensional Euclidean plane \f$ \E^2\f$. It starts in a point called the source of `r` and goes to infinity. \cgalModels `Kernel::Ray_2` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Ray_3.h b/Kernel_23/doc/Kernel_23/CGAL/Ray_3.h index 3c1c2779f06..0a57867a243 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Ray_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Ray_3.h @@ -8,7 +8,6 @@ straight ray in the three-dimensional Euclidean space \f$ \E^3\f$. It starts in a point called the source of `r` and it goes to infinity. \cgalModels `Kernel::Ray_3` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number */ template< typename Kernel > diff --git a/Kernel_23/include/CGAL/Kernel/hash_functions.h b/Kernel_23/include/CGAL/Kernel/hash_functions.h index 6224bc7e3c8..82417b78f48 100644 --- a/Kernel_23/include/CGAL/Kernel/hash_functions.h +++ b/Kernel_23/include/CGAL/Kernel/hash_functions.h @@ -57,15 +57,6 @@ hash_value (const Circle_2& circle) return result; } -template -inline std::enable_if_t::value, std::size_t> -hash_value (const Direction_2& direction) -{ - std::size_t result = boost::hash_value(direction.dx()); - boost::hash_combine(result, boost::hash_value(direction.dy())); - return result; -} - template inline std::enable_if_t::value, std::size_t> hash_value (const Iso_rectangle_2& iso_rectangle) @@ -84,15 +75,6 @@ hash_value (const Point_2& point) return result; } -template -inline std::enable_if_t::value, std::size_t> -hash_value (const Ray_2& ray) -{ - std::size_t result = hash_value(ray.source()); - boost::hash_combine(result, hash_value(ray.direction())); - return result; -} - template inline std::enable_if_t::value, std::size_t> hash_value (const Segment_2& segment) @@ -144,16 +126,6 @@ hash_value (const Bbox_3& bbox) return result; } -template -inline std::enable_if_t::value, std::size_t> -hash_value (const Direction_3& direction) -{ - std::size_t result = boost::hash_value(direction.dx()); - boost::hash_combine(result, boost::hash_value(direction.dy())); - boost::hash_combine(result, boost::hash_value(direction.dz())); - return result; -} - template inline std::enable_if_t::value, std::size_t> hash_value (const Iso_cuboid_3& iso_cuboid) @@ -173,15 +145,6 @@ hash_value (const Point_3& point) return result; } -template -inline std::enable_if_t::value, std::size_t> -hash_value (const Ray_3& ray) -{ - std::size_t result = hash_value(ray.source()); - boost::hash_combine(result, hash_value(ray.direction())); - return result; -} - template inline std::enable_if_t::value, std::size_t> hash_value (const Segment_3& segment) @@ -241,11 +204,6 @@ template struct hash > { return CGAL::hash_value (circle); } }; -template struct hash > { - std::size_t operator() (const CGAL::Direction_2& direction) const { - return CGAL::hash_value (direction); - } -}; template struct hash > { std::size_t operator() (const CGAL::Iso_rectangle_2& iso_rectangle) const { return CGAL::hash_value (iso_rectangle); @@ -256,11 +214,6 @@ template struct hash > { return CGAL::hash_value (point); } }; -template struct hash > { - std::size_t operator() (const CGAL::Ray_2& ray) const { - return CGAL::hash_value (ray); - } -}; template struct hash > { std::size_t operator() (const CGAL::Segment_2& segment) const { return CGAL::hash_value (segment); @@ -286,11 +239,6 @@ template <> struct hash { return CGAL::hash_value (bbox); } }; -template struct hash > { - std::size_t operator() (const CGAL::Direction_3& direction) const { - return CGAL::hash_value (direction); - } -}; template struct hash > { std::size_t operator() (const CGAL::Iso_cuboid_3& iso_cuboid) const { return CGAL::hash_value (iso_cuboid); @@ -301,11 +249,6 @@ template struct hash > { return CGAL::hash_value (point); } }; -template struct hash > { - std::size_t operator() (const CGAL::Ray_3& ray) const { - return CGAL::hash_value (ray); - } -}; template struct hash > { std::size_t operator() (const CGAL::Segment_3& segment) const { return CGAL::hash_value (segment); diff --git a/Kernel_23/test/Kernel_23/test_hash_functions.cpp b/Kernel_23/test/Kernel_23/test_hash_functions.cpp index d3d7194dd6a..393ae364add 100644 --- a/Kernel_23/test/Kernel_23/test_hash_functions.cpp +++ b/Kernel_23/test/Kernel_23/test_hash_functions.cpp @@ -27,18 +27,12 @@ int main() test (SC::Circle_2 (CGAL::ORIGIN, 1)); test (Epick::Circle_2 (CGAL::ORIGIN, 1)); - test (SC::Direction_2 (1, 2)); - test (Epick::Direction_2 (1, 2)); - test (SC::Iso_rectangle_2 (1, 2, 3, 4)); test (Epick::Iso_rectangle_2 (1, 2, 3, 4)); test (SC::Point_2 (1, 2)); test (Epick::Point_2 (1, 2)); - test (SC::Ray_2 (SC::Point_2 (1, 2), SC::Vector_2 (3, 4))); - test (Epick::Ray_2 (Epick::Point_2 (1, 2), Epick::Vector_2 (3, 4))); - test (SC::Segment_2 (SC::Point_2 (1, 2), SC::Point_2 (3, 4))); test (Epick::Segment_2 (Epick::Point_2 (1, 2), Epick::Point_2 (3, 4))); @@ -53,18 +47,12 @@ int main() test (CGAL::Bbox_3 ()); - test (SC::Direction_3 (1, 2, 3)); - test (Epick::Direction_3 (1, 2, 3)); - test (SC::Iso_cuboid_3 (1, 2, 3, 4, 5, 6)); test (Epick::Iso_cuboid_3 (1, 2, 3, 4, 5, 6)); test (SC::Point_3 (1, 2, 3)); test (Epick::Point_3 (1, 2, 3)); - test (SC::Ray_3 (SC::Point_3 (1, 2, 3), SC::Vector_3 (4, 5, 6))); - test (Epick::Ray_3 (Epick::Point_3 (1, 2, 3), Epick::Vector_3 (4, 5, 6))); - test (SC::Segment_3 (SC::Point_3 (1, 2, 3), SC::Point_3 (4, 5, 6))); test (Epick::Segment_3 (Epick::Point_3 (1, 2, 3), Epick::Point_3 (4, 5, 6))); From 45efa5a6c0335fddf3c54e2de5dfc67b1f29508c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 4 Jun 2019 16:30:12 +0200 Subject: [PATCH 137/203] Tame a warning from MSVC 2015 ``` ...\include\CGAL/NewKernel_d/utils.h(85): warning C4552: '*': operator has no effect; expected operator with side-effect ...\include\CGAL/transforming_iterator.h(65): note: see reference to function template instantiation 'decltype(auto) CGAL::Scale::operator ()(FT) const' being compiled with [ FT=const double & ] ``` --- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index b3ebf0e10af..725a3c86697 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -82,7 +82,7 @@ struct Has_type_different_from template decltype(auto) operator()(FT&& x)const { - return scale*std::forward(x); + return (scale*std::forward(x)); } }; template struct Divide { From 70720e224febf188d12dea346ba64e23fa3c3045 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Jun 2019 16:32:30 +0200 Subject: [PATCH 138/203] Add documentation for T2 --- .../CGAL/Constrained_triangulation_plus_2.h | 20 ++++- .../Triangulation_2/CGAL/Triangulation_2.h | 90 +++++++++++++++++++ .../doc/Triangulation_2/Triangulation_2.txt | 16 ++++ .../doc/Triangulation_2/examples.txt | 1 + .../examples/Triangulation_2/colored_face.cpp | 5 +- .../examples/Triangulation_2/constrained.cpp | 11 ++- .../examples/Triangulation_2/for_loop_2.cpp | 47 ++++++++++ .../info_insert_with_pair_iterator_2.cpp | 5 +- ...fo_insert_with_pair_iterator_regular_2.cpp | 6 +- .../info_insert_with_transform_iterator_2.cpp | 5 +- .../info_insert_with_zip_iterator_2.cpp | 7 +- .../Triangulation_2/polygon_triangulation.cpp | 20 ++--- .../polylines_triangulation.cpp | 18 +--- .../CGAL/Constrained_triangulation_plus_2.h | 40 +++++++-- 14 files changed, 238 insertions(+), 53 deletions(-) create mode 100644 Triangulation_2/examples/Triangulation_2/for_loop_2.cpp diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h index 42cb053bf86..3596bc4640b 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h @@ -78,7 +78,6 @@ typedef unspecified_type Constraint_iterator; /*! A subconstraint is a pair of vertices that correspond to an `Edge`. -\todo The documentation does not match the code */ typedef std::pair Subconstraint; @@ -92,6 +91,11 @@ subconstraint. */ typedef unspecified_type Subconstraint_iterator; +/*! +A range type for iterating over all subconstraints. +*/ +typedef Iterator_range Subconstraints; + /*! An iterator on the vertices of the chain of subconstraints representing a @@ -137,6 +141,10 @@ is `Context`. */ typedef unspecified_type Context_iterator; +/*! +range type for iterating over contexts. +*/ +typedef Iterator_range Contexts; /// @} /// \name Creation @@ -333,7 +341,7 @@ corresponding to the constraints enclosing the subconstraint `(va,vb)`. \pre `va` and `vb` refer to the vertices of a constrained edge of the triangulation. */ Context_iterator contexts_begin(Vertex_handle va, -Vertex_handle vb) const; + Vertex_handle vb) const; /*! Returns an iterator past the end `Context` @@ -342,8 +350,14 @@ corresponding to the constraints enclosing the subconstraint `(va,vb)`. \pre `va` and `vb` refer to the vertices of a constrained edge of the triangulation. */ Context_iterator contexts_end(Vertex_handle va, -Vertex_handle vb) const; + Vertex_handle vb) const; +/*! +Returns a range of contexts. +*/ +Contexts contexts((Vertex_handle va, + Vertex_handle vb) const; + /*! Returns an iterator on the first vertex on the constraint `cid`. */ diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Triangulation_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Triangulation_2.h index 769ad789783..d7abf32abae 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Triangulation_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Triangulation_2.h @@ -252,6 +252,8 @@ typedef Tds::difference_type difference_type; /// finite ones. The triangulation class also defines the following /// enum type to specify which case occurs when locating a point in /// the triangulation. +/// +/// In order to write \cpp 11 `for`-loops we provide range types. /*! handle to a vertex. @@ -300,6 +302,50 @@ finite vertices of the triangulation. */ typedef unspecified_type Point_iterator; + +/*! +range type for iterating over all faces, with a nested +type `iterator` that has as value type `Face_handle` +*/ +typedef Iterator_range All_face_handles; + + +/*! +range type for iterating over edges. +*/ +typedef Iterator_range All_edges; + +/*! +range type for iterating over all vertices, with a nested +type `iterator` that has as value type `Vertex_handle` +*/ +typedef Iterator_range All_vertex_handles; + + +/*! +range type for iterating over finite faces, with a nested +type `iterator` that has as value type `Face_handle` +*/ +typedef Iterator_range Finite_face_handles; + + +/*! +range type for iterating over edges. +*/ +typedef Iterator_range Finite_edges; + +/*! +range type for iterating over finite vertices, with a nested +type `iterator` that has as value type `Vertex_handle` +*/ +typedef Iterator_range Finite_vertex_handles; + +/*! +range type for iterating over the points of the finite vertices. +*/ +typedef Iterator_range Points; + + /*! circulator over all faces intersected by a line. */ @@ -858,6 +904,30 @@ Past-the-end iterator */ Point_iterator points_end() const; +/*! +returns a range of iterators over finite vertices. +\note While the value type of `Finite_vertices_iterator` is `Vertex`, the value type of + `Finite_vertex_handles::iterator` is `Vertex_handle` +*/ +Finite_vertex_handles finite_vertex_handles() const; + +/*! +returns a range of iterators over finite edges. +*/ +Finite_edges finite_edges() const; + +/*! +returns a range of iterators over finite faces. +\note While the value type of `Finite_faces_iterator` is `Face`, the value type of + `Finite_face_handles::iterator` is `Face_handle` +*/ +Finite_face_handles finite_face_handles() const; + +/*! +returns a range of iterators over the points of finite vertices. +*/ +Points points() const; + /// @} /// \name All Face, Edge and Vertex Iterators @@ -899,6 +969,26 @@ Past-the-end iterator */ All_faces_iterator all_faces_end() const; + +/*! +returns a range of iterators over all vertices. +\note While the value type of `All_vertices_iterator` is `Vertex`, the value type of + `All_vertex_handles::iterator` is `Vertex_handle` +*/ +All_vertex_handles all_vertex_handles() const; + +/*! +returns a range of iterators over all edges. +*/ +All_edges all_edges() const; + +/*! +returns a range of iterators over all faces. +\note While the value type of `All_faces_iterator` is `Face`, the value type of + `All_face_handles::iterator` is `Face_handle` +*/ +All_face_handles all_face_handles() const; + /// @} /*! diff --git a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt index b6c1dfa5eea..9fc0999236d 100644 --- a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt +++ b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt @@ -377,6 +377,22 @@ forms a convex quadrilateral (see \cgalFigureRef{Triangulation_2D_fig_flip_bis}) Flip. \cgalFigureEnd +The triangulation defines iterator types such as `Triangulation_3::All_vertices_iterator`. They behave like +a `Triangulation_3::Vertex_handle`, in the sense that there is no need to dereference the iterator to obtain a handle. +Wherever the API expects a handle the iterator can be passed as well. + +In order to write a \cpp 11 `for`-loop the triangulation calls also offers the range type +`Triangulation_3::All_vertex_handles`, which has a nested type `Triangulation_3::All_vertex_handles::iterator`. +The value type of this iterator is `Triangulation_3::Vertex_handle`. Note that you only +need the iterator type if you combine the pre \cpp 11 `for`-loop with the range class. +It is similar for the various iterators for vertices and cells. + +For the range `Triangulation_3::All_facets` it holds that `Triangulation_3::All_facets::iterator` `==` +`Triangulation_3::All_facets_iterator`. It is similar for the iterators for edges and points. + +\cgalExample{Triangulation_3/for_loop_2.cpp} + + \subsection Triangulation_2Implementation Implementation Locate is implemented by a stochastic walk \cgalCite{cgal:dpt-wt-02}. diff --git a/Triangulation_2/doc/Triangulation_2/examples.txt b/Triangulation_2/doc/Triangulation_2/examples.txt index 9bff70297db..45128d71309 100644 --- a/Triangulation_2/doc/Triangulation_2/examples.txt +++ b/Triangulation_2/doc/Triangulation_2/examples.txt @@ -1,4 +1,5 @@ /*! +\example Triangulation_2/for_loop_2.cpp \example Triangulation_2/adding_handles.cpp \example Triangulation_2/colored_face.cpp \example Triangulation_2/constrained.cpp diff --git a/Triangulation_2/examples/Triangulation_2/colored_face.cpp b/Triangulation_2/examples/Triangulation_2/colored_face.cpp index 84392cd820b..820daa4cfe5 100644 --- a/Triangulation_2/examples/Triangulation_2/colored_face.cpp +++ b/Triangulation_2/examples/Triangulation_2/colored_face.cpp @@ -11,7 +11,6 @@ typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Triangulation_2 Triangulation; typedef Triangulation::Face_handle Face_handle; -typedef Triangulation::Finite_faces_iterator Finite_faces_iterator; typedef Triangulation::Point Point; int main() { @@ -21,8 +20,8 @@ int main() { t.insert(Point(2,0)); t.insert(Point(2,2)); - Finite_faces_iterator fc = t.finite_faces_begin(); - for( ; fc != t.finite_faces_end(); ++fc) fc->info() = CGAL::blue(); + for(Face_handle f : t.finite_face_handles()) + f->info() = CGAL::blue(); Point p(0.5,0.5); Face_handle fh = t.locate(p); diff --git a/Triangulation_2/examples/Triangulation_2/constrained.cpp b/Triangulation_2/examples/Triangulation_2/constrained.cpp index a4cc7925a3f..84ff46a8155 100644 --- a/Triangulation_2/examples/Triangulation_2/constrained.cpp +++ b/Triangulation_2/examples/Triangulation_2/constrained.cpp @@ -8,8 +8,8 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_tag Itag; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; -typedef CDT::Point Point; - +typedef CDT::Point Point; +typedef CDT::Edge Edge; int main( ) { @@ -22,10 +22,9 @@ main( ) assert(cdt.is_valid()); int count = 0; - for (CDT::Finite_edges_iterator eit = cdt.finite_edges_begin(); - eit != cdt.finite_edges_end(); - ++eit) - if (cdt.is_constrained(*eit)) ++count; + for (Edge e : cdt.finite_edges()) + if (cdt.is_constrained(e)) + ++count; std::cout << "The number of resulting constrained edges is "; std::cout << count << std::endl; return 0; diff --git a/Triangulation_2/examples/Triangulation_2/for_loop_2.cpp b/Triangulation_2/examples/Triangulation_2/for_loop_2.cpp new file mode 100644 index 00000000000..4c884845667 --- /dev/null +++ b/Triangulation_2/examples/Triangulation_2/for_loop_2.cpp @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Triangulation_2 Triangulation; +typedef Triangulation::Vertex_handle Vertex_handle; +typedef Triangulation::Point Point; +typedef Triangulation::Finite_vertex_handles Finite_vertex_handles; + +// The following types are different +// Its value type is Triangulation_2::Vertex +typedef Triangulation::Finite_vertices_iterator Finite_vertices_iterator; +// Its value type is Triangulation_2::Vertex_handle +typedef Finite_vertex_handles::iterator Finite_vertex_handles_iterator; + +int main() +{ + std::vector points = { Point(0,0), Point(1,0), Point(0,1) }; + + Triangulation T; + + T.insert(points.begin(), points.end()); + + std::cout << "Triangulation_2::Finite_vertices_iterator is like a Triangulation_2::Vertex_handle\n"; + for(Finite_vertices_iterator it = T.finite_vertices_begin(); + it != T.finite_vertices_end(); + ++it){ + std::cout << it->point() << std::endl; + } + + std::cout << "Triangulation_2::Finite_vertex_handles::iterator dereferences to Triangulation_2::Vertex_handle\n"; + Finite_vertex_handles::iterator b, e; + std::tie(b,e) = T.finite_vertex_handles(); + for(; b!=e; ++b){ + Vertex_handle vh = *b; // you must dereference the iterator to get a handle + std::cout << vh->point() << std::endl; + } + + std::cout << "and you can use a C++11 for loop\n"; + for(Vertex_handle vh : T.finite_vertex_handles()){ + std::cout << vh->point() << std::endl; + } + + return 0; +} diff --git a/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_2.cpp b/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_2.cpp index b420ef58868..7cf822fe1f4 100644 --- a/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_2.cpp +++ b/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_2.cpp @@ -8,6 +8,7 @@ typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Delaunay_triangulation_2 Delaunay; typedef Delaunay::Point Point; +typedef Delaunay::Vertex_handle Vertex_handle; int main() { @@ -27,8 +28,8 @@ int main() // check that the info was correctly set. Delaunay::Finite_vertices_iterator vit; - for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if( points[ vit->info() ].first != vit->point() ){ + for (Vertex_handle v : T.finite_vertex_handles()) + if( points[ v->info() ].first != v->point() ){ std::cerr << "Error different info" << std::endl; exit(EXIT_FAILURE); } diff --git a/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_regular_2.cpp b/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_regular_2.cpp index fd334e50071..27b51dba0db 100644 --- a/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_regular_2.cpp +++ b/Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_regular_2.cpp @@ -13,6 +13,7 @@ typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Regular_triangulation_2 Regular; typedef K::Point_2 Point; typedef K::Weighted_point_2 Wpoint; +typedef Regular::Vertex_handle Vertex_handle; int main() { @@ -30,9 +31,8 @@ int main() CGAL_assertion( rt.number_of_vertices() == 6 ); // check that the info was correctly set. - Regular::Finite_vertices_iterator vit; - for (vit = rt.finite_vertices_begin(); vit != rt.finite_vertices_end(); ++vit) - if( points[ vit->info() ].first != vit->point() ){ + for (Vertex_handle v : rt.finite_vertex_handles()) + if( points[ v->info() ].first != v->point() ){ std::cerr << "Error different info" << std::endl; exit(EXIT_FAILURE); } diff --git a/Triangulation_2/examples/Triangulation_2/info_insert_with_transform_iterator_2.cpp b/Triangulation_2/examples/Triangulation_2/info_insert_with_transform_iterator_2.cpp index 54c73013d0b..ebc9a8418e0 100644 --- a/Triangulation_2/examples/Triangulation_2/info_insert_with_transform_iterator_2.cpp +++ b/Triangulation_2/examples/Triangulation_2/info_insert_with_transform_iterator_2.cpp @@ -9,6 +9,7 @@ typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Delaunay_triangulation_2 Delaunay; typedef Delaunay::Point Point; +typedef Delaunay::Vertex_handle Vertex_handle; //a functor that returns a std::pair. //the unsigned integer is incremented at each call to @@ -40,8 +41,8 @@ int main() // check that the info was correctly set. Delaunay::Finite_vertices_iterator vit; - for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if( points[ vit->info() ] != vit->point() ){ + for (Vertex_handle v : T.finite_vertex_handles()) + if( points[ v->info() ] != v->point() ){ std::cerr << "Error different info" << std::endl; exit(EXIT_FAILURE); } diff --git a/Triangulation_2/examples/Triangulation_2/info_insert_with_zip_iterator_2.cpp b/Triangulation_2/examples/Triangulation_2/info_insert_with_zip_iterator_2.cpp index de92cb6478e..884f4d9d23c 100644 --- a/Triangulation_2/examples/Triangulation_2/info_insert_with_zip_iterator_2.cpp +++ b/Triangulation_2/examples/Triangulation_2/info_insert_with_zip_iterator_2.cpp @@ -9,6 +9,7 @@ typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Delaunay_triangulation_2 Delaunay; typedef Delaunay::Point Point; +typedef Delaunay::Vertex_handle Vertex_handle; int main() { @@ -39,9 +40,9 @@ int main() // check that the info was correctly set. - Delaunay::Finite_vertices_iterator vit; - for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if( points[ vit->info() ] != vit->point() ){ + + for (Vertex_handle v : T.finite_vertex_handles()) + if( points[ v->info() ] != v->point() ){ std::cerr << "Error different info" << std::endl; exit(EXIT_FAILURE); } diff --git a/Triangulation_2/examples/Triangulation_2/polygon_triangulation.cpp b/Triangulation_2/examples/Triangulation_2/polygon_triangulation.cpp index cb0beece9fe..a876c7a6747 100644 --- a/Triangulation_2/examples/Triangulation_2/polygon_triangulation.cpp +++ b/Triangulation_2/examples/Triangulation_2/polygon_triangulation.cpp @@ -24,27 +24,28 @@ typedef CGAL::Exact_predicates_tag Itag; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; typedef CDT::Point Point; typedef CGAL::Polygon_2 Polygon_2; +typedef CDT::Face_handle Face_handle; void mark_domains(CDT& ct, - CDT::Face_handle start, + Face_handle start, int index, std::list& border ) { if(start->info().nesting_level != -1){ return; } - std::list queue; + std::list queue; queue.push_back(start); while(! queue.empty()){ - CDT::Face_handle fh = queue.front(); + Face_handle fh = queue.front(); queue.pop_front(); if(fh->info().nesting_level == -1){ fh->info().nesting_level = index; for(int i = 0; i < 3; i++){ CDT::Edge e(fh,i); - CDT::Face_handle n = fh->neighbor(i); + Face_handle n = fh->neighbor(i); if(n->info().nesting_level == -1){ if(ct.is_constrained(e)) border.push_back(e); else queue.push_back(n); @@ -63,8 +64,8 @@ mark_domains(CDT& ct, void mark_domains(CDT& cdt) { - for(CDT::All_faces_iterator it = cdt.all_faces_begin(); it != cdt.all_faces_end(); ++it){ - it->info().nesting_level = -1; + for(CDT::Face_handle f : cdt.all_face_handles()){ + f->info().nesting_level = -1; } std::list border; @@ -72,7 +73,7 @@ mark_domains(CDT& cdt) while(! border.empty()){ CDT::Edge e = border.front(); border.pop_front(); - CDT::Face_handle n = e.first->neighbor(e.second); + Face_handle n = e.first->neighbor(e.second); if(n->info().nesting_level == -1){ mark_domains(cdt, n, e.first->info().nesting_level+1, border); } @@ -104,10 +105,9 @@ int main( ) mark_domains(cdt); int count=0; - for (CDT::Finite_faces_iterator fit=cdt.finite_faces_begin(); - fit!=cdt.finite_faces_end();++fit) + for (Face_handle f : cdt.finite_face_handles()) { - if ( fit->info().in_domain() ) ++count; + if ( f->info().in_domain() ) ++count; } std::cout << "There are " << count << " facets in the domain." << std::endl; diff --git a/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp b/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp index 46d2d638db9..a13ee365034 100644 --- a/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp +++ b/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp @@ -21,10 +21,7 @@ print(const CDTP& cdtp, Cid cid) typedef CDTP::Vertices_in_constraint Vertices_in_constraint; std::cout << "Polyline constraint:" << std::endl; - for(Vertices_in_constraint it = cdtp.vertices_in_constraint_begin(cid); - it !=cdtp.vertices_in_constraint_end(cid); - it++){ - Vertex_handle vh = *it; + for(Vertex_handle vh : cdtp.vertices_in_constraint(cid)){ std::cout << vh->point() << std::endl; } } @@ -33,20 +30,13 @@ print(const CDTP& cdtp, Cid cid) void contexts(const CDTP& cdtp) { - CDTP::Subconstraint_iterator - beg = cdtp.subconstraints_begin(), - end = cdtp.subconstraints_end(); - - for(; beg!=end; ++beg){ - Vertex_handle vp = beg->first.first, vq = beg->first.second; + for(auto sc : cdtp.subconstraints()){ + Vertex_handle vp = sc.first.first, vq = sc.first.second; if(cdtp.number_of_enclosing_constraints(vp, vq) == 2){ - CDTP::Context_iterator cbeg = cdtp.contexts_begin(vp,vq), - cend = cdtp.contexts_end(vp,vq); std::cout << "subconstraint " << vp->point() << " " << vq->point() << " is on constraints starting at:\n"; - for(; cbeg != cend; ++cbeg){ - CDTP::Context c = *cbeg; + for(CDTP::Context c : cdtp.contexts(vp,vq)){ std::cout << (*(c.vertices_begin()))->point() << std::endl; } } diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index 7f19c173511..8d5a27c26a3 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -179,21 +179,26 @@ public: // for user interface with the constraint hierarchy typedef typename Constraint_hierarchy::Vertex_it Vertices_in_constraint_iterator; + + typedef Iterator_range Vertices_in_constraint; typedef typename Constraint_hierarchy::Point_it Points_in_constraint_iterator; - - typedef typename Constraint_hierarchy::Context Context; - typedef typename Constraint_hierarchy::Context_iterator Context_iterator; + typedef Iterator_range Points_in_constraint; + + typedef typename Constraint_hierarchy::Context Context; + typedef typename Constraint_hierarchy::Context_iterator Context_iterator; + typedef Iterator_range Contexts; + typedef typename Constraint_hierarchy::C_iterator Constraint_iterator; + typedef typename Constraint_hierarchy::Subconstraint_iterator Subconstraint_iterator; + typedef Iterator_range Subconstraints; + typedef typename Constraint_hierarchy::Constraint_id Constraint_id; typedef std::pair Subconstraint; - //for backward compatibility - typedef Vertices_in_constraint_iterator Vertices_in_constraint; - using Triangulation::geom_traits; using Triangulation::cw; using Triangulation::ccw; @@ -769,6 +774,12 @@ public: Constraint_iterator constraints_end() const; Subconstraint_iterator subconstraints_begin() const; Subconstraint_iterator subconstraints_end() const; + + Subconstraints subconstraints() const + { + return Subconstraints(subconstraints_begin(),subconstraints_end()); + } + Context context(Vertex_handle va, Vertex_handle vb); //AF: const; bool is_subconstraint(Vertex_handle va, @@ -780,11 +791,26 @@ public: Context_iterator contexts_end(Vertex_handle va, Vertex_handle vb) const; + Contexts contexts(Vertex_handle va, Vertex_handle vb) const + { + return Contexts(contexts_begin(va,vb),contexts_end(va,vb)); + } + Vertices_in_constraint_iterator vertices_in_constraint_begin(Constraint_id cid) const; - Vertices_in_constraint_iterator vertices_in_constraint_end(Constraint_id cid) const ; + Vertices_in_constraint_iterator vertices_in_constraint_end(Constraint_id cid) const; + + Vertices_in_constraint vertices_in_constraint(Constraint_id cid) const + { + return Vertices_in_constraint(vertices_in_constraint_begin(cid), vertices_in_constraint_end(cid)); + } + Points_in_constraint_iterator points_in_constraint_begin(Constraint_id cid) const; Points_in_constraint_iterator points_in_constraint_end(Constraint_id cid) const ; + Points_in_constraint points_in_constraint(Constraint_id cid) const + { + return Points_in_constraint(points_in_constraint_begin(cid), points_in_constraint_end(cid)); + } size_type number_of_constraints() { return static_cast (hierarchy.number_of_constraints());} From 1cfa22481b682b49576bb10a53f665c5a6ddf523 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Jun 2019 16:34:47 +0200 Subject: [PATCH 139/203] indentation --- .../Triangulation_3/CGAL/Triangulation_3.h | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index 5e2755e4bed..7a4845d13d4 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -1208,8 +1208,8 @@ Note that vertex and cell ranges are special. See Section \ref Triangulation3sec Returns an empty range when `t.number_of_cells() == 0`. \note While the value type of `All_cells_iterator` is `Cell`, the value type of `All_cell_handles::iterator` is `Cell_handle`. - */ - All_cell_handles all_cell_handles() const; +*/ +All_cell_handles all_cell_handles() const; @@ -1230,8 +1230,8 @@ All_edges all_edges() const; Returns an empty range when `t.number_of_vertices() == 0`. \note While the value type of `All_vertices_iterator` is `Vertex`, the value type of `All_vertex_handles::iterator` is `Vertex_handle`. - */ - All_vertex_handles all_vertex_handles() const; +*/ +All_vertex_handles all_vertex_handles() const; /*! @@ -1239,8 +1239,8 @@ All_edges all_edges() const; Returns an empty range when `t.number_of_cells() == 0`. \note While the value type of `Finite_cells_iterator` is `Cell`, the value type of `Finite_cell_handles::iterator` is `Cell_handle`. - */ - Finite_cell_handles finite_cell_handles() const; +*/ +Finite_cell_handles finite_cell_handles() const; @@ -1261,13 +1261,13 @@ Finite_edges finite_edges() const; Returns an empty range when `t.number_of_vertices() == 0`. \note While the value type of `Finite_vertices_iterator` is `Vertex`, the value type of `Finite_vertex_handles::iterator` is `Vertex_handle`. - */ - Finite_vertex_handles finite_vertex_handles() const; +*/ +Finite_vertex_handles finite_vertex_handles() const; - /*! - returns a range of iterators over the points of finite vertices. - */ - Points points() const; +/*! + returns a range of iterators over the points of finite vertices. +*/ +Points points() const; /// @} From 22a8edd7507f2d0d985133b48aa502a28c438db2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Jun 2019 16:52:33 +0200 Subject: [PATCH 140/203] doc --- .../CGAL/Constrained_triangulation_2.h | 37 +++++++----- .../CGAL/Constrained_triangulation_plus_2.h | 60 +++++++++++++------ .../CGAL/Constrained_triangulation_2.h | 6 ++ .../CGAL/Constrained_triangulation_plus_2.h | 8 ++- 4 files changed, 77 insertions(+), 34 deletions(-) diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h index 9722d8b0fa7..d4b15333855 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h @@ -165,6 +165,10 @@ The value type of this iterator is `Edge`. */ typedef unspecified_type Constrained_edges_iterator; +/*! +A range type to iterate over the constrained edges. +*/ +typedef Iterator_range Constrained_edges; /*! The intersection tag which decides how @@ -197,18 +201,18 @@ Constrained_triangulation_2& ct1); /// @{ /*! -Returns `true` if edge `e` is a constrained edge. +returns `true` if edge `e` is a constrained edge. */ bool is_constrained(Edge e) const; /*! -Returns `true` if at least one of the edges incident to vertex `v` +returns `true` if at least one of the edges incident to vertex `v` is constrained. */ bool are_there_incident_constraints(Vertex_handle v) const; /*! -Outputs the constrained edges incident to `v` +outputs the constrained edges incident to `v` into the output iterator `out` and returns the resulting output iterator. \tparam OutputItEdges is an `OutputIterator` with `Edge` as value @@ -229,6 +233,11 @@ returns the past-the-end iterator. */ Constrained_edges_iterator constrained_edges_end() const; +/*! +returns a range of constrained edges. +*/ +Constrained_edges constrained_edges() const; + /// @} /// \name Insertion and Removal @@ -236,14 +245,14 @@ Constrained_edges_iterator constrained_edges_end() const; /// @{ /*! -Inserts point `p` and restores the status (constrained or not) of all +inserts point `p` and restores the status (constrained or not) of all the touched edges. If present, `f` is used as an hint for the location of `p`. */ Vertex_handle insert(Point p, Face_handle f = Face_handle() ); /*! -Inserts point `p` in the triangulation at the location given by `(lt,loc,i)`. +inserts point `p` in the triangulation at the location given by `(lt,loc,i)`. \sa `Triangulation_2::locate()` */ Vertex_handle @@ -258,7 +267,7 @@ Vertex_handle push_back(const Point& p); /*! -Inserts points `a` and `b` in this order, and inserts the line segment `ab` as a +inserts points `a` and `b` in this order, and inserts the line segment `ab` as a constraint. Removes the faces crossed by segment `ab` and creates new faces instead. If a vertex `c` lies on segment `ab`, constraint `ab` is replaced by the two constraints `ac` and `cb`. Apart from the insertion of @@ -273,7 +282,7 @@ Equivalent to `insert(c.first, c.second)`. void push_back(const std::pair& c); /*! -Inserts the line segment `s` whose endpoints are the vertices +inserts the line segment `s` whose endpoints are the vertices `va` and `vb` as a constraint. The triangles intersected by `s` are removed and new ones are created. @@ -281,7 +290,7 @@ are removed and new ones are created. void insert_constraint(const Vertex_handle & va, const Vertex_handle & vb); /*! -Inserts a polyline defined by the points in the range `[first,last)`. +inserts a polyline defined by the points in the range `[first,last)`. The polyline is considered as a polygon if the first and last point are equal or if `close = true`. This enables for example passing the vertex range of a `Polygon_2`. \tparam PointIterator must be an `InputIterator` with the value type `Point`. */ @@ -291,23 +300,23 @@ void insert_constraint(PointIterator first, PointIterator last, bool close=false /*! -Removes a vertex `v`. +removes a vertex `v`. \pre Vertex `v` is not incident to a constrained edge. */ void remove(Vertex_handle v); /*! -Make the edges incident to vertex `v` unconstrained edges. +makes the edges incident to vertex `v` unconstrained edges. */ void remove_incident_constraints(Vertex_handle v); /*! -Make edge `(f,i)` unconstrained. +makes edge `(f,i)` unconstrained. */ void remove_constrained_edge(Face_handle f, int i); /*! -Checks the validity of the triangulation and the consistency +checks the validity of the triangulation and the consistency of the constrained marks in edges. */ bool @@ -318,7 +327,7 @@ is_valid(bool verbose = false, int level = 0) const; }; /* end Constrained_triangulation_2 */ /*! -Writes the triangulation as for `Triangulation_2` and, for each face `f`, and integers `i=0,1,2`, +writes the triangulation as for `Triangulation_2` and, for each face `f`, and integers `i=0,1,2`, writes "C" or "N" depending whether edge `(f,i)` is constrained or not. \relates Constrained_triangulation_2 @@ -327,7 +336,7 @@ template std::ostream & operator<<(std::ostream& os, const Constrained_triangulation_2 &ct); /*! -Reads a triangulation from stream `is` and assigns it to c`t`. Data in the stream must have the same format `operator<<` uses. +eeads a triangulation from stream `is` and assigns it to c`t`. Data in the stream must have the same format `operator<<` uses. Note that `ct` is first cleared. \relates Constrained_triangulation_2 */ diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h index 3596bc4640b..235aa29e544 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h @@ -76,6 +76,12 @@ The value type of this iterator is `Constraint_id`. */ typedef unspecified_type Constraint_iterator; +/*! +A range type for iterating over all constraints. +*/ +typedef Iterator_range Constraints; + + /*! A subconstraint is a pair of vertices that correspond to an `Edge`. */ @@ -201,13 +207,13 @@ void swap(Constrained_triangulation_plus_2 tr); /// @{ /*! -Inserts point `p` as a vertex of the triangulation. +inserts point `p` as a vertex of the triangulation. */ Vertex_handle insert(const Point& p, Face_handle start = Face_handle() ); /*! -Inserts point `p` in the triangulation at the location given by `(lt,loc,i)`. +inserts point `p` in the triangulation at the location given by `(lt,loc,i)`. \sa `Triangulation_2::locate()` */ Vertex_handle insert(const Point& p, @@ -220,7 +226,7 @@ Equivalent to `insert(p)`. Vertex_handle push_back(const Point& p); /*! -Inserts the points in the range `[first,last)`. +inserts the points in the range `[first,last)`. Returns the number of inserted points. \tparam PointIterator must be an `InputIterator` with the value type `Point`. */ @@ -229,19 +235,19 @@ size_type insert(PointIterator first, PointIterator last); /*! -Inserts the constraint segment `ab` in the triangulation. +inserts the constraint segment `ab` in the triangulation. If the two points are equal the point is inserted but no constraint, and the default constructed `Constraint_id` is returned. */ Constraint_id insert_constraint(Point a, Point b); /*! -Inserts the constraint `c`. +inserts the constraint `c`. */ void push_back(const std::pair& c); /*! -Inserts a constraint whose endpoints are the vertices +inserts a constraint whose endpoints are the vertices pointed by `va` and `vb` in the triangulation. If the two vertex handles are equal no constraint is inserted, and the default constructed `Constraint_id` is returned. @@ -249,7 +255,7 @@ and the default constructed `Constraint_id` is returned. Constraint_id insert_constraint(Vertex_handle va, Vertex_handle vb); /*! -Inserts a polyline defined by the points in the range `[first,last)` +inserts a polyline defined by the points in the range `[first,last)` and returns the constraint id. The polyline is considered as a closed curve if the first and last point are equal or if `close == true`. This enables for example passing the vertex range of a `Polygon_2`. When traversing the vertices of a closed polyline constraint with a `Vertices_in_constraint_iterator` the first and last vertex are the same. @@ -288,7 +294,7 @@ std::size_t insert_constraints(PointIterator points_first, PointIterator points_ /*! -Removes the constraint `cid`, without removing the points from the triangulation. +removes the constraint `cid`, without removing the points from the triangulation. */ void remove_constraint(Constraint_id cid); @@ -298,29 +304,39 @@ void remove_constraint(Constraint_id cid); /// @{ /*! -Returns a `Constraint_iterator` that points at the first +returns a `Constraint_iterator` that points at the first constraint of the triangulation. */ Constraint_iterator constraints_begin() const; /*! -Returns the past-the-end iterator of the constraints of the triangulation. +returns the past-the-end iterator of the constraints of the triangulation. */ Constraint_iterator constraints_end() const; +/*! +returns a range of constraints. +*/ +Subconstraints constraints() const; + /*! -Returns a `Subconstraint_iterator` pointing at the first +returns a `Subconstraint_iterator` pointing at the first subconstraint of the triangulation. */ Subconstraint_iterator subconstraints_begin() const; /*! -Returns the past-the-end iterator of the subconstraints of the triangulation. +returns the past-the-end iterator of the subconstraints of the triangulation. */ Subconstraint_iterator subconstraints_end() const; +/*! +returns a range of subconstraints. +*/ +Subconstraints subconstraints() const; + /*! -Returns the number of constraints enclosing the subconstraint +returns the number of constraints enclosing the subconstraint `(va,vb)`. \pre `va` and `vb` refer to the vertices of a constrained edge of the triangulation. */ @@ -328,14 +344,14 @@ int number_of_enclosing_constraints(Vertex_handle va, Vertex_handle vb) const; /*! -Returns the `Context` relative to one of the constraints +returns the `Context` relative to one of the constraints enclosing the subconstraint `(va,vb)`. \pre `va` and `vb` refer to the vertices of a constrained edge of the triangulation. */ Context context(Vertex_handle va, Vertex_handle vb) const; /*! -Returns an iterator pointing at the first `Context` +returns an iterator pointing at the first `Context` of the sequence of contexts corresponding to the constraints enclosing the subconstraint `(va,vb)`. \pre `va` and `vb` refer to the vertices of a constrained edge of the triangulation. @@ -344,7 +360,7 @@ Context_iterator contexts_begin(Vertex_handle va, Vertex_handle vb) const; /*! -Returns an iterator past the end `Context` +returns an iterator past the end `Context` of the sequence of contexts corresponding to the constraints enclosing the subconstraint `(va,vb)`. \pre `va` and `vb` refer to the vertices of a constrained edge of the triangulation. @@ -353,23 +369,29 @@ Context_iterator contexts_end(Vertex_handle va, Vertex_handle vb) const; /*! -Returns a range of contexts. +returns a range of contexts. */ Contexts contexts((Vertex_handle va, Vertex_handle vb) const; /*! -Returns an iterator on the first vertex on the constraint `cid`. +returns an iterator on the first vertex on the constraint `cid`. */ Vertices_in_constraint_iterator vertices_in_constraint_begin(Constraint_id cid) const; /*! -Returns an iterator past the last vertex on the constraint `cid`. +returns an iterator past the last vertex on the constraint `cid`. */ Vertices_in_constraint_iterator vertices_in_constraint_end(Constraint_id cid) const; +/*! +returns an range of vertices on the constraint `cid`. +*/ +Vertices_in_constraint +vertices_in_constraint(Constraint_id cid) const; + /// @} diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h index e3b80ccc4ee..1b200e8d8d9 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h @@ -120,6 +120,7 @@ public: typename Triangulation::All_edges_iterator> Constrained_edges_iterator; + typedef Iterator_range Constrained_edges; #ifndef CGAL_CFG_USING_BASE_MEMBER_BUG_2 using Triangulation::number_of_vertices; @@ -218,6 +219,11 @@ public: all_edges_end()); } + Constrained_edges constrained_edges() const + { + return Constrained_edges(constrained_edges_begin(),constrained_edges_end()); + } + // INSERTION Vertex_handle insert(const Point& p, Face_handle start = Face_handle() ); diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index 8d5a27c26a3..df6493cc529 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -191,7 +191,8 @@ public: typedef Iterator_range Contexts; typedef typename Constraint_hierarchy::C_iterator Constraint_iterator; - + typedef Iterator_range Cconstraints; + typedef typename Constraint_hierarchy::Subconstraint_iterator Subconstraint_iterator; typedef Iterator_range Subconstraints; @@ -772,6 +773,11 @@ public: // Query of the constraint hierarchy Constraint_iterator constraints_begin() const; Constraint_iterator constraints_end() const; + Constraints constraints() const + { + return Constraints(constraints_begin(),constraints_end()); + } + Subconstraint_iterator subconstraints_begin() const; Subconstraint_iterator subconstraints_end() const; From 9db0366789dd67ed30431f7173d8ad0ef6a247f8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Jun 2019 17:25:25 +0200 Subject: [PATCH 141/203] whitespace --- Triangulation_2/doc/Triangulation_2/Triangulation_2.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt index 9fc0999236d..4d51fed170d 100644 --- a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt +++ b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt @@ -1056,7 +1056,7 @@ The class `Constrained_triangulation_plus_2` additionally provides the means to - traverse all the constraints of the triangulation using an iterator of type `Constraint_iterator` the value type of which is `Constraint_id`, - obtain all constraints that induce a constrained edge or a subconstraint, - traverse the sequence of vertices of a constraint using an iterator of type `Vertices_in_constraint_iterator`, the value type of which is `Vertex_handle` -- traverse the subconstraints in the triangulation using an iterator of type `Subconstraint_iterator`,the value type of which is `Subconstraint`. +- traverse the subconstraints in the triangulation using an iterator of type `Subconstraint_iterator`, the value type of which is `Subconstraint`. Note that the `Constrained_edges_iterator` and the `Subconstraint_iterator` are quite similar. The `Constrained_edges_iterator` traverses all edges and skips those that are \em not constrained, From 7111518cb05ac86a457fa29b22d60859ee4ad29b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Jun 2019 08:02:19 +0200 Subject: [PATCH 142/203] Fix usage of Vertices_in_constraint --- .../polylines_triangulation.cpp | 2 -- .../CGAL/Constrained_triangulation_plus_2.h | 7 ++-- .../CGAL/_test_cls_const_triang_plus_2.h | 34 +++++++++---------- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp b/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp index a13ee365034..623194cbf8e 100644 --- a/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp +++ b/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp @@ -18,8 +18,6 @@ typedef CDTP::Vertex_handle Vertex void print(const CDTP& cdtp, Cid cid) { - typedef CDTP::Vertices_in_constraint Vertices_in_constraint; - std::cout << "Polyline constraint:" << std::endl; for(Vertex_handle vh : cdtp.vertices_in_constraint(cid)){ std::cout << vh->point() << std::endl; diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index df6493cc529..e6ae11cea77 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -191,7 +191,7 @@ public: typedef Iterator_range Contexts; typedef typename Constraint_hierarchy::C_iterator Constraint_iterator; - typedef Iterator_range Cconstraints; + typedef Iterator_range Constraints; typedef typename Constraint_hierarchy::Subconstraint_iterator Subconstraint_iterator; typedef Iterator_range Subconstraints; @@ -629,10 +629,7 @@ public: for(Constraint_iterator cit = constraints_begin(); cit != constraints_end(); ++cit){ os << (*cit).second->all_size(); - for(Vertices_in_constraint it = vertices_in_constraint_begin(*cit); - it != vertices_in_constraint_end(*cit); - it++){ - Vertex_handle vh = *it; + for(Vertex_handle vh : vertices_in_constraint(*cit)){ os << " " << V[vh]; } os << std::endl; diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_triang_plus_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_triang_plus_2.h index 72b84a1916b..bc93551235c 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_triang_plus_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_const_triang_plus_2.h @@ -5,17 +5,17 @@ void _test_cls_const_triang_plus_2( const TrP & ) { //typedef TriangPlus TrP; - typedef typename TrP::Geom_traits Gt; - typedef typename Gt::Point_2 Point; + typedef typename TrP::Geom_traits Gt; + typedef typename Gt::Point_2 Point; - typedef typename TrP::Vertex_handle Vertex_handle; - typedef typename TrP::Constraint Constraint; - typedef typename TrP::Constraint_iterator Constraint_iterator; - typedef typename TrP::Constraint_hierarchy Hierarchy; - typedef typename TrP::Context Context; - typedef typename TrP::Context_iterator Context_iterator; - typedef typename TrP::Vertices_in_constraint Vertices_in_constraint; - typedef typename TrP::Constraint_id Constraint_id; + typedef typename TrP::Vertex_handle Vertex_handle; + typedef typename TrP::Constraint Constraint; + typedef typename TrP::Constraint_iterator Constraint_iterator; + typedef typename TrP::Constraint_hierarchy Hierarchy; + typedef typename TrP::Context Context; + typedef typename TrP::Context_iterator Context_iterator; + typedef typename TrP::Vertices_in_constraint_iterator Vertices_in_constraint_iterator; + typedef typename TrP::Constraint_id Constraint_id; CGAL_USE_TYPE(Hierarchy); CGAL_USE_TYPE(Context); @@ -47,7 +47,7 @@ _test_cls_const_triang_plus_2( const TrP & ) // test access to the hierarchy std::cout << " test acces to the constraint hierarchy" << std::endl; - Vertices_in_constraint vit = trp.vertices_in_constraint_begin(cid); + Vertices_in_constraint_iterator vit = trp.vertices_in_constraint_begin(cid); assert (*vit == vh[10] || *vit == vh[11] ); Vertex_handle va = *++vit; Vertex_handle vb = *++vit; @@ -58,12 +58,12 @@ _test_cls_const_triang_plus_2( const TrP & ) Context_iterator cit2 = cit1++; //trp.print_hierarchy(); assert( cit1->number_of_vertices() == 4 || cit1->number_of_vertices() == 7); - Vertices_in_constraint firstin1 = cit1->vertices_begin(); - Vertices_in_constraint lastin1 = --(cit1->vertices_end()); - Vertices_in_constraint currentin1 = cit1->current(); - Vertices_in_constraint firstin2 = cit2->vertices_begin(); - Vertices_in_constraint lastin2 = --(cit2->vertices_end()); - Vertices_in_constraint currentin2 = cit2->current(); + Vertices_in_constraint_iterator firstin1 = cit1->vertices_begin(); + Vertices_in_constraint_iterator lastin1 = --(cit1->vertices_end()); + Vertices_in_constraint_iterator currentin1 = cit1->current(); + Vertices_in_constraint_iterator firstin2 = cit2->vertices_begin(); + Vertices_in_constraint_iterator lastin2 = --(cit2->vertices_end()); + Vertices_in_constraint_iterator currentin2 = cit2->current(); if ( cit1->number_of_vertices() == 4) { assert( (*firstin1 == vh[10] && *lastin1 == vh[11]) || (*firstin1 == vh[11] && *lastin1 == vh[10])); From de45c8341b3cdb1c9a413fedbdd4a47658c2d7c1 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 5 Jun 2019 09:13:11 +0200 Subject: [PATCH 143/203] Protect std::max from macro substitution (the min/max macros...) --- Filtered_kernel/include/CGAL/Lazy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 4369e9b28c1..68dd199809c 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -339,7 +339,7 @@ class Lazy_rep_n : Lazy_rep_n(const AC& ac, const EC& ec, LL&&...ll) : Lazy_rep(ac(CGAL::approx(ll)...)), EC(ec), l(std::forward(ll)...) { - this->set_depth(std::max({ -1, (int)CGAL::depth(ll)...}) + 1); + this->set_depth((std::max)({ -1, (int)CGAL::depth(ll)...}) + 1); } #ifdef CGAL_LAZY_KERNEL_DEBUG private: From 070a26a5b72569b48c4580cda71e6e2e0ba7973e Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 5 Jun 2019 10:43:28 +0200 Subject: [PATCH 144/203] Fix missing inclusions + ADL for hash_value --- .../include/CGAL/Kernel/hash_functions.h | 65 ++++++++++--------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/Kernel_23/include/CGAL/Kernel/hash_functions.h b/Kernel_23/include/CGAL/Kernel/hash_functions.h index 82417b78f48..3559828cce2 100644 --- a/Kernel_23/include/CGAL/Kernel/hash_functions.h +++ b/Kernel_23/include/CGAL/Kernel/hash_functions.h @@ -22,28 +22,33 @@ #ifndef CGAL_KERNEL_HASH_FUNCTIONS_H #define CGAL_KERNEL_HASH_FUNCTIONS_H +#include +#include + namespace CGAL { +using boost::hash_value; + template inline std::enable_if_t::value, std::size_t> hash_value (const Aff_transformation_2& transform) { - std::size_t result = boost::hash_value(transform.cartesian(0,0)); + std::size_t result = hash_value(transform.cartesian(0,0)); for(int i=0; i < 3; ++i) for(int j = 0; j < 3; ++j) if (!(i == 0 && j == 0)) - boost::hash_combine(result, boost::hash_value(transform.cartesian(i,j))); + boost::hash_combine(result, hash_value(transform.cartesian(i,j))); return result; } std::size_t hash_value (const Bbox_2& bbox) { - std::size_t result = boost::hash_value(bbox.xmin()); - boost::hash_combine(result, boost::hash_value(bbox.xmax())); - boost::hash_combine(result, boost::hash_value(bbox.ymin())); - boost::hash_combine(result, boost::hash_value(bbox.ymax())); + std::size_t result = hash_value(bbox.xmin()); + boost::hash_combine(result, hash_value(bbox.xmax())); + boost::hash_combine(result, hash_value(bbox.ymin())); + boost::hash_combine(result, hash_value(bbox.ymax())); return result; } @@ -52,8 +57,8 @@ inline std::enable_if_t::value, std::size hash_value (const Circle_2& circle) { std::size_t result = hash_value(circle.center()); - boost::hash_combine(result, boost::hash_value(circle.squared_radius())); - boost::hash_combine(result, boost::hash_value(circle.orientation())); + boost::hash_combine(result, hash_value(circle.squared_radius())); + boost::hash_combine(result, hash_value(circle.orientation())); return result; } @@ -70,8 +75,8 @@ template inline std::enable_if_t::value, std::size_t> hash_value (const Point_2& point) { - std::size_t result = boost::hash_value(point.x()); - boost::hash_combine(result, boost::hash_value(point.y())); + std::size_t result = hash_value(point.x()); + boost::hash_combine(result, hash_value(point.y())); return result; } @@ -88,8 +93,8 @@ template inline std::enable_if_t::value, std::size_t> hash_value (const Vector_2& vector) { - std::size_t result = boost::hash_value(vector.x()); - boost::hash_combine(result, boost::hash_value(vector.y())); + std::size_t result = hash_value(vector.x()); + boost::hash_combine(result, hash_value(vector.y())); return result; } @@ -98,7 +103,7 @@ inline std::enable_if_t::value, std::size hash_value (const Weighted_point_2& weighed_point) { std::size_t result = hash_value(weighed_point.point()); - boost::hash_combine(result, boost::hash_value(weighed_point.weight())); + boost::hash_combine(result, hash_value(weighed_point.weight())); return result; } @@ -106,23 +111,23 @@ template inline std::enable_if_t::value, std::size_t> hash_value (const Aff_transformation_3& transform) { - std::size_t result = boost::hash_value(transform.cartesian(0,0)); + std::size_t result = hash_value(transform.cartesian(0,0)); for(int i = 0; i < 3; ++i) for(int j = 0; j < 4; ++j) if (!(i == 0 && j == 0)) - boost::hash_combine(result, boost::hash_value(transform.cartesian(i,j))); + boost::hash_combine(result, hash_value(transform.cartesian(i,j))); return result; } std::size_t hash_value (const Bbox_3& bbox) { - std::size_t result = boost::hash_value(bbox.xmin()); - boost::hash_combine(result, boost::hash_value(bbox.xmax())); - boost::hash_combine(result, boost::hash_value(bbox.ymin())); - boost::hash_combine(result, boost::hash_value(bbox.ymax())); - boost::hash_combine(result, boost::hash_value(bbox.zmin())); - boost::hash_combine(result, boost::hash_value(bbox.zmax())); + std::size_t result = hash_value(bbox.xmin()); + boost::hash_combine(result, hash_value(bbox.xmax())); + boost::hash_combine(result, hash_value(bbox.ymin())); + boost::hash_combine(result, hash_value(bbox.ymax())); + boost::hash_combine(result, hash_value(bbox.zmin())); + boost::hash_combine(result, hash_value(bbox.zmax())); return result; } @@ -139,9 +144,9 @@ template inline std::enable_if_t::value, std::size_t> hash_value (const Point_3& point) { - std::size_t result = boost::hash_value(point.x()); - boost::hash_combine(result, boost::hash_value(point.y())); - boost::hash_combine(result, boost::hash_value(point.z())); + std::size_t result = hash_value(point.x()); + boost::hash_combine(result, hash_value(point.y())); + boost::hash_combine(result, hash_value(point.z())); return result; } @@ -159,8 +164,8 @@ inline std::enable_if_t::value, std::size hash_value (const Sphere_3& sphere) { std::size_t result = hash_value(sphere.center()); - boost::hash_combine(result, boost::hash_value(sphere.squared_radius())); - boost::hash_combine(result, boost::hash_value(sphere.orientation())); + boost::hash_combine(result, hash_value(sphere.squared_radius())); + boost::hash_combine(result, hash_value(sphere.orientation())); return result; } @@ -168,9 +173,9 @@ template inline std::enable_if_t::value, std::size_t> hash_value (const Vector_3& vector) { - std::size_t result = boost::hash_value(vector.x()); - boost::hash_combine(result, boost::hash_value(vector.y())); - boost::hash_combine(result, boost::hash_value(vector.z())); + std::size_t result = hash_value(vector.x()); + boost::hash_combine(result, hash_value(vector.y())); + boost::hash_combine(result, hash_value(vector.z())); return result; } @@ -179,7 +184,7 @@ inline std::enable_if_t::value, std::size hash_value (const Weighted_point_3& weighed_point) { std::size_t result = hash_value(weighed_point.point()); - boost::hash_combine(result, boost::hash_value(weighed_point.weight())); + boost::hash_combine(result, hash_value(weighed_point.weight())); return result; } From 72ea50ae7795f3c305653b8c9934790ac3070d3c Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 5 Jun 2019 10:50:08 +0200 Subject: [PATCH 145/203] Change condition on FT/Kernel for hash functions --- .../doc/Kernel_23/CGAL/Aff_transformation_2.h | 2 +- .../doc/Kernel_23/CGAL/Aff_transformation_3.h | 2 +- Kernel_23/doc/Kernel_23/CGAL/Circle_2.h | 2 +- Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h | 2 +- .../doc/Kernel_23/CGAL/Iso_rectangle_2.h | 2 +- Kernel_23/doc/Kernel_23/CGAL/Point_2.h | 2 +- Kernel_23/doc/Kernel_23/CGAL/Point_3.h | 2 +- Kernel_23/doc/Kernel_23/CGAL/Segment_2.h | 2 +- Kernel_23/doc/Kernel_23/CGAL/Segment_3.h | 2 +- Kernel_23/doc/Kernel_23/CGAL/Sphere_3.h | 1 + Kernel_23/doc/Kernel_23/CGAL/Vector_2.h | 2 +- Kernel_23/doc/Kernel_23/CGAL/Vector_3.h | 2 +- .../doc/Kernel_23/CGAL/Weighted_point_2.h | 2 +- .../doc/Kernel_23/CGAL/Weighted_point_3.h | 2 +- .../include/CGAL/Kernel/hash_functions.h | 28 +++++++++---------- 15 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h index ae9adff736a..a8d6d43f269 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h @@ -34,7 +34,7 @@ translation vector \f$ (v_0,\,v_1,\,1)\f$ appears in the last column of the matrix. The entries \f$ m_{20}\f$ and \f$ m_{21}\f$ are always zero and therefore do not appear in the constructors. -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` \sa `Identity_transformation` \sa `Rotation` diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h index 40803c6186c..e23674bbc6b 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h @@ -29,7 +29,7 @@ In three-dimensional space we have a \f$ 4\times 4\f$ matrix \f$ m_{32}\f$ are always zero and therefore do not appear in the constructors. -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` \sa `CGAL::Aff_transformation_2` \sa `CGAL::Identity_transformation` diff --git a/Kernel_23/doc/Kernel_23/CGAL/Circle_2.h b/Kernel_23/doc/Kernel_23/CGAL/Circle_2.h index a75cd35afc2..be4a2b7424f 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Circle_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Circle_2.h @@ -12,7 +12,7 @@ splits \f$ \E^2\f$ into a bounded and an unbounded side. Note that the circle can be degenerated, i.e.\ the squared radius may be zero. \cgalModels `Kernel::Circle_2` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h b/Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h index b63d2e8db02..72471b06f6e 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Iso_cuboid_3.h @@ -17,7 +17,7 @@ whereas the coordinate type of an iso-oriented cuboid is chosen by the user. \cgalModels `Kernel::IsoCuboid_3` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Iso_rectangle_2.h b/Kernel_23/doc/Kernel_23/CGAL/Iso_rectangle_2.h index c89fd390e9e..7a725ce421b 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Iso_rectangle_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Iso_rectangle_2.h @@ -18,7 +18,7 @@ whereas the coordinate type of an iso-oriented rectangle is chosen by the user. \cgalModels `Kernel::IsoRectangle_2` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Point_2.h b/Kernel_23/doc/Kernel_23/CGAL/Point_2.h index 4c59f467f71..8ac3eff82d6 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Point_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Point_2.h @@ -31,7 +31,7 @@ std::cout << p.x() << " " << p.y() << std::endl; \endcode \cgalModels `Kernel::Point_2` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Point_3.h b/Kernel_23/doc/Kernel_23/CGAL/Point_3.h index 9f86642f5ec..deed3e522d7 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Point_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Point_3.h @@ -17,7 +17,7 @@ to `NT`, and `Kernel::FT` is equal to `Quotient`. The following operations can be applied on points: \cgalModels `Kernel::Point_3` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Segment_2.h b/Kernel_23/doc/Kernel_23/CGAL/Segment_2.h index 1d8a370d9eb..391e3aa80a2 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Segment_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Segment_2.h @@ -15,7 +15,7 @@ perform a square root operation which is not defined for all number types, which is expensive, and may not be exact. \cgalModels `Kernel::Segment_2` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Segment_3.h b/Kernel_23/doc/Kernel_23/CGAL/Segment_3.h index 151c86778e2..454e31cc848 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Segment_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Segment_3.h @@ -15,7 +15,7 @@ perform a square root operation which is not defined for all number types, which is expensive, and may not be exact. \cgalModels `Kernel::Segment_3` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Sphere_3.h b/Kernel_23/doc/Kernel_23/CGAL/Sphere_3.h index 93b97a78ac3..94947d291f4 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Sphere_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Sphere_3.h @@ -12,6 +12,7 @@ splits \f$ \E^3\f$ into a bounded and an unbounded side. Note that the sphere can be degenerated, i.e.\ the squared radius may be zero. \cgalModels `Kernel::Sphere_3` +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Vector_2.h b/Kernel_23/doc/Kernel_23/CGAL/Vector_2.h index 0328accda34..6fb8d5b0ea9 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Vector_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Vector_2.h @@ -13,7 +13,7 @@ will explicitly state where you can pass this constant as an argument instead of a vector initialized with zeros. \cgalModels `Kernel::Vector_2` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h b/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h index 9a80105c33f..924b35f04d1 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Vector_3.h @@ -13,7 +13,7 @@ will explicitly state where you can pass this constant as an argument instead of a vector initialized with zeros. \cgalModels `Kernel::Vector_3` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` \sa `cross_product_grp` \sa `determinant_grp` 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 74e41bacee3..4c2d0a15cbc 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_2.h @@ -14,7 +14,7 @@ to `NT`, and `Kernel::FT` is equal to `Quotient`. \sa `Point_2` \cgalModels `Kernel::WeightedPoint_2` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_3.h b/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_3.h index 8717bc187c8..e652a47049d 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Weighted_point_3.h @@ -14,7 +14,7 @@ to `NT`, and `Kernel::FT` is equal to `Quotient`. \sa `Point_3` \cgalModels `Kernel::WeightedPoint_3` -\cgalModels `Hashable` if `Kernel::FT` is a floating-point number +\cgalModels `Hashable` if `Kernel` is a cartesian kernel and if `Kernel::FT` is `Hashable` */ template< typename Kernel > diff --git a/Kernel_23/include/CGAL/Kernel/hash_functions.h b/Kernel_23/include/CGAL/Kernel/hash_functions.h index 3559828cce2..c1c1631516d 100644 --- a/Kernel_23/include/CGAL/Kernel/hash_functions.h +++ b/Kernel_23/include/CGAL/Kernel/hash_functions.h @@ -31,7 +31,7 @@ namespace CGAL using boost::hash_value; template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Aff_transformation_2& transform) { std::size_t result = hash_value(transform.cartesian(0,0)); @@ -53,7 +53,7 @@ hash_value (const Bbox_2& bbox) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Circle_2& circle) { std::size_t result = hash_value(circle.center()); @@ -63,7 +63,7 @@ hash_value (const Circle_2& circle) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Iso_rectangle_2& iso_rectangle) { std::size_t result = hash_value(iso_rectangle.min()); @@ -72,7 +72,7 @@ hash_value (const Iso_rectangle_2& iso_rectangle) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Point_2& point) { std::size_t result = hash_value(point.x()); @@ -81,7 +81,7 @@ hash_value (const Point_2& point) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Segment_2& segment) { std::size_t result = hash_value(segment.source()); @@ -90,7 +90,7 @@ hash_value (const Segment_2& segment) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Vector_2& vector) { std::size_t result = hash_value(vector.x()); @@ -99,7 +99,7 @@ hash_value (const Vector_2& vector) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Weighted_point_2& weighed_point) { std::size_t result = hash_value(weighed_point.point()); @@ -108,7 +108,7 @@ hash_value (const Weighted_point_2& weighed_point) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Aff_transformation_3& transform) { std::size_t result = hash_value(transform.cartesian(0,0)); @@ -132,7 +132,7 @@ hash_value (const Bbox_3& bbox) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Iso_cuboid_3& iso_cuboid) { std::size_t result = hash_value(iso_cuboid.min()); @@ -141,7 +141,7 @@ hash_value (const Iso_cuboid_3& iso_cuboid) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Point_3& point) { std::size_t result = hash_value(point.x()); @@ -151,7 +151,7 @@ hash_value (const Point_3& point) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Segment_3& segment) { std::size_t result = hash_value(segment.source()); @@ -160,7 +160,7 @@ hash_value (const Segment_3& segment) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Sphere_3& sphere) { std::size_t result = hash_value(sphere.center()); @@ -170,7 +170,7 @@ hash_value (const Sphere_3& sphere) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Vector_3& vector) { std::size_t result = hash_value(vector.x()); @@ -180,7 +180,7 @@ hash_value (const Vector_3& vector) } template -inline std::enable_if_t::value, std::size_t> +inline std::enable_if_t::value, std::size_t> hash_value (const Weighted_point_3& weighed_point) { std::size_t result = hash_value(weighed_point.point()); From 0a87e078b94df95f3d612f595e741cb7af70d42c Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 5 Jun 2019 10:51:25 +0200 Subject: [PATCH 146/203] Add Sphere_3 to changes --- Installation/CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index a3fddc11741..65275deb989 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -51,8 +51,8 @@ Release date: September 2019 `CGAL::Bbox_2`, `CGAL::Bbox_3`, `CGAL::Circle_2`, `CGAL::Iso_cuboid_3`, `CGAL::Iso_rectangle_2`, `CGAL::Point_2`, `CGAL::Point_3`, `CGAL::Segment_2`, `CGAL::Segment_3`, - `CGAL::Vector_2`, `CGAL::Vector_3`, `CGAL::Weighted_point_2` and - `CGAL::Weighted_point_3`. + `CGAL::Sphere_3`, `CGAL::Vector_2`, `CGAL::Vector_3`, + `CGAL::Weighted_point_2` and `CGAL::Weighted_point_3`. ### IO Streams From 2a044cff996ee96f21a28ae076d010115f808614 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Jun 2019 11:05:50 +0200 Subject: [PATCH 147/203] Fix and polish doc --- .../CGAL/Constrained_triangulation_plus_2.h | 4 ++-- .../doc/Triangulation_2/Triangulation_2.txt | 14 ++++++++------ .../doc/Triangulation_3/Triangulation_3.txt | 8 +++++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h index 235aa29e544..4f69f5d89c2 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h @@ -371,8 +371,8 @@ Context_iterator contexts_end(Vertex_handle va, /*! returns a range of contexts. */ -Contexts contexts((Vertex_handle va, - Vertex_handle vb) const; +Contexts contexts(Vertex_handle va, + Vertex_handle vb) const; /*! returns an iterator on the first vertex on the constraint `cid`. diff --git a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt index 4d51fed170d..ed2dcfc10f7 100644 --- a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt +++ b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt @@ -382,15 +382,17 @@ a `Triangulation_3::Vertex_handle`, in the sense that there is no need to derefe Wherever the API expects a handle the iterator can be passed as well. In order to write a \cpp 11 `for`-loop the triangulation calls also offers the range type -`Triangulation_3::All_vertex_handles`, which has a nested type `Triangulation_3::All_vertex_handles::iterator`. -The value type of this iterator is `Triangulation_3::Vertex_handle`. Note that you only -need the iterator type if you combine the pre \cpp 11 `for`-loop with the range class. +`Triangulation_2::All_vertex_handles`, which has a nested type `Triangulation_2::All_vertex_handles::iterator`. +The value type of this iterator is `Triangulation_2::Vertex_handle`. It is similar for the various iterators for vertices and cells. -For the range `Triangulation_3::All_facets` it holds that `Triangulation_3::All_facets::iterator` `==` -`Triangulation_3::All_facets_iterator`. It is similar for the iterators for edges and points. +For the range `Triangulation_2::All_edges` it holds that `Triangulation_2::All_edges::iterator` `==` +`Triangulation_2::All_facets_iterator`. It is similar for the various iterators for edges and points. -\cgalExample{Triangulation_3/for_loop_2.cpp} +Note that you only need the iterator type if you combine the pre \cpp 11 `for`-loop with the range class. + + +\cgalExample{Triangulation_2/for_loop_2.cpp} \subsection Triangulation_2Implementation Implementation diff --git a/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt b/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt index d0594b5ca62..4284b30705b 100644 --- a/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt +++ b/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt @@ -494,12 +494,14 @@ Wherever the API expects a handle the iterator can be passed as well. In order to write a \cpp 11 `for`-loop the triangulation calls also offers the range type `Triangulation_3::All_vertex_handles`, which has a nested type `Triangulation_3::All_vertex_handles::iterator`. -The value type of this iterator is `Triangulation_3::Vertex_handle`. Note that you only -need the iterator type if you combine the pre \cpp 11 `for`-loop with the range class. +The value type of this iterator is `Triangulation_3::Vertex_handle`. It is similar for the various iterators for vertices and cells. For the range `Triangulation_3::All_facets` it holds that `Triangulation_3::All_facets::iterator` `==` -`Triangulation_3::All_facets_iterator`. It is similar for the iterators for edges and points. +`Triangulation_3::All_facets_iterator`. It is similar for the iterators for facets, edges and points. + + +Note that you only need the iterator type if you combine the pre \cpp 11 `for`-loop with the range class. \cgalExample{Triangulation_3/for_loop.cpp} From bb97332e726a0db3004fe0c9b2ffc75246cf4d0d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Jun 2019 16:40:05 +0200 Subject: [PATCH 148/203] Update Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h Co-Authored-By: Mael --- .../Triangulation_3/include/CGAL/_test_cls_triangulation_3.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h index e5f850f8fdc..d533bcfe945 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h @@ -116,7 +116,6 @@ _test_cls_triangulation_3(const Triangulation &) typedef typename Cls::Finite_edges_iterator Finite_edges_iterator; typedef typename Cls::Finite_facets_iterator Finite_facets_iterator; typedef typename Cls::Finite_cells_iterator Finite_cells_iterator; - CGAL_USE_TYPE(Vertex); CGAL_USE_TYPE(Cell); CGAL_USE_TYPE(difference_type); From c34536be24501ce5ab850b07dbffb0639b3f9692 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Jun 2019 17:26:37 +0200 Subject: [PATCH 149/203] Apply suggestions from code review Co-Authored-By: Mael --- .../Triangulation_2/CGAL/Constrained_triangulation_2.h | 2 +- .../CGAL/Constrained_triangulation_plus_2.h | 2 +- .../doc/Triangulation_2/CGAL/Triangulation_2.h | 8 ++++---- Triangulation_2/doc/Triangulation_2/Triangulation_2.txt | 6 +++--- Triangulation_2/include/CGAL/Triangulation_2.h | 1 - .../doc/Triangulation_3/CGAL/Triangulation_3.h | 6 +++--- .../Triangulation_3/include/CGAL/_test_cls_iterator.h | 1 - 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h index d4b15333855..181dc976ff6 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h @@ -336,7 +336,7 @@ template std::ostream & operator<<(std::ostream& os, const Constrained_triangulation_2 &ct); /*! -eeads a triangulation from stream `is` and assigns it to c`t`. Data in the stream must have the same format `operator<<` uses. +reads a triangulation from stream `is` and assigns it to c`t`. Data in the stream must have the same format `operator<<` uses. Note that `ct` is first cleared. \relates Constrained_triangulation_2 */ diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h index 4f69f5d89c2..1a6f843b53b 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h @@ -387,7 +387,7 @@ Vertices_in_constraint_iterator vertices_in_constraint_end(Constraint_id cid) const; /*! -returns an range of vertices on the constraint `cid`. +returns a range of the vertices on the constraint `cid`. */ Vertices_in_constraint vertices_in_constraint(Constraint_id cid) const; diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Triangulation_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Triangulation_2.h index d7abf32abae..ed65934ff74 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Triangulation_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Triangulation_2.h @@ -304,19 +304,19 @@ typedef unspecified_type Point_iterator; /*! -range type for iterating over all faces, with a nested +range type for iterating over all faces (including infinite faces), with a nested type `iterator` that has as value type `Face_handle` */ typedef Iterator_range All_face_handles; /*! -range type for iterating over edges. +range type for iterating over all edges (including infinite ones). */ typedef Iterator_range All_edges; /*! -range type for iterating over all vertices, with a nested +range type for iterating over all vertices (including the infinite vertex), with a nested type `iterator` that has as value type `Vertex_handle` */ typedef Iterator_range All_vertex_handles; @@ -330,7 +330,7 @@ typedef Iterator_range Finite_face_handles; /*! -range type for iterating over edges. +range type for iterating over finite edges. */ typedef Iterator_range Finite_edges; diff --git a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt index ed2dcfc10f7..6bee3b8a77f 100644 --- a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt +++ b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt @@ -378,7 +378,7 @@ Flip. \cgalFigureEnd The triangulation defines iterator types such as `Triangulation_3::All_vertices_iterator`. They behave like -a `Triangulation_3::Vertex_handle`, in the sense that there is no need to dereference the iterator to obtain a handle. +a handle, in the sense that there is no need to dereference the iterator to obtain a handle. Wherever the API expects a handle the iterator can be passed as well. In order to write a \cpp 11 `for`-loop the triangulation calls also offers the range type @@ -387,9 +387,9 @@ The value type of this iterator is `Triangulation_2::Vertex_handle`. It is similar for the various iterators for vertices and cells. For the range `Triangulation_2::All_edges` it holds that `Triangulation_2::All_edges::iterator` `==` -`Triangulation_2::All_facets_iterator`. It is similar for the various iterators for edges and points. +`Triangulation_2::All_edges_iterator`. It is similar for the various iterators for edges and points. -Note that you only need the iterator type if you combine the pre \cpp 11 `for`-loop with the range class. +Note that you only need the iterator type if you wish to combine pre \cpp 11 `for`-loops with the range class. \cgalExample{Triangulation_2/for_loop_2.cpp} diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index 275e9e9c865..74a54f19f4f 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -3202,7 +3202,6 @@ all_faces_begin() const { return _tds.faces_begin(); } - template typename Triangulation_2::All_faces_iterator Triangulation_2:: diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index 7a4845d13d4..a16bec60427 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -224,13 +224,13 @@ typedef Triangulation_data_structure::Facet_circulator Facet_circulator; /*! \name -In order to write \cpp 11 `for`-loops we provide range types. +In order to write \cpp 11 `for`-loops we provide the following range types. */ /// @{ /*! -range type for iterating over all cell handles, with a nested type `iterator` +range type for iterating over all cell handles (including infinite cells), with a nested type `iterator` that has as value type `Cell_handle`. */ typedef Iterator_range All_cell_handles; @@ -1204,7 +1204,7 @@ Note that vertex and cell ranges are special. See Section \ref Triangulation3sec /// @{ /*! - returns a range of iterators over all cells (even the infinite one). + returns a range of iterators over all cells (even the infinite cells). Returns an empty range when `t.number_of_cells() == 0`. \note While the value type of `All_cells_iterator` is `Cell`, the value type of `All_cell_handles::iterator` is `Cell_handle`. diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.h index 47f6099e4a9..d252dfff8ec 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.h @@ -79,7 +79,6 @@ _test_vertex_iterator( const Triangulation &T ) } assert( n == T.number_of_vertices() ); - return n; } From 2c5433fbd70c7f4aeb54820d224cae6b9d4b9b2f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Jun 2019 17:31:27 +0200 Subject: [PATCH 150/203] Remove a sentence as suggested by Mael --- .../doc/Triangulation_3/CGAL/Triangulation_3.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index a16bec60427..f540b6682dd 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -1089,8 +1089,7 @@ The following iterators allow the user to visit cells, facets, edges and vertice /*! Starts at an arbitrary finite vertex. Then `++` and `--` will -iterate over finite vertices. Returns `finite_vertices_end()` when -`t.number_of_vertices() == 0`. +iterate over finite vertices. */ Finite_vertices_iterator finite_vertices_begin() const; @@ -1101,8 +1100,7 @@ Finite_vertices_iterator finite_vertices_end() const; /*! Starts at an arbitrary finite edge. Then `++` and `--` will -iterate over finite edges. Returns `finite_edges_end()` when -`t.dimension() < 1`. +iterate over finite edges. */ Finite_edges_iterator finite_edges_begin() const; @@ -1136,9 +1134,7 @@ Past-the-end iterator Finite_cells_iterator finite_cells_end() const; /*! -Starts at an arbitrary vertex. Iterates over all vertices (even the infinite -one). Returns `vertices_end()` when -`t.number_of_vertices() == 0`. +Starts at an arbitrary vertex. Iterates over all vertices (even the infinite one). */ All_vertices_iterator all_vertices_begin() const; @@ -1227,7 +1223,6 @@ All_edges all_edges() const; /*! returns a range of iterators over all vertices (even the infinite one). - Returns an empty range when `t.number_of_vertices() == 0`. \note While the value type of `All_vertices_iterator` is `Vertex`, the value type of `All_vertex_handles::iterator` is `Vertex_handle`. */ @@ -1258,7 +1253,6 @@ Finite_edges finite_edges() const; /*! returns a range of iterators over finite vertices. - Returns an empty range when `t.number_of_vertices() == 0`. \note While the value type of `Finite_vertices_iterator` is `Vertex`, the value type of `Finite_vertex_handles::iterator` is `Vertex_handle`. */ From c3c825519c70b8d6c23b27305cb2ad2be3f80465 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Thu, 6 Jun 2019 09:51:10 +0200 Subject: [PATCH 151/203] Add missing inlines --- Kernel_23/include/CGAL/Kernel/hash_functions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel_23/include/CGAL/Kernel/hash_functions.h b/Kernel_23/include/CGAL/Kernel/hash_functions.h index c1c1631516d..c2364394b02 100644 --- a/Kernel_23/include/CGAL/Kernel/hash_functions.h +++ b/Kernel_23/include/CGAL/Kernel/hash_functions.h @@ -42,7 +42,7 @@ hash_value (const Aff_transformation_2& transform) return result; } -std::size_t +inline std::size_t hash_value (const Bbox_2& bbox) { std::size_t result = hash_value(bbox.xmin()); @@ -119,7 +119,7 @@ hash_value (const Aff_transformation_3& transform) return result; } -std::size_t +inline std::size_t hash_value (const Bbox_3& bbox) { std::size_t result = hash_value(bbox.xmin()); From 5c6f20e1ec7c5d0c1454c04133d61171b957f902 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 6 Jun 2019 13:04:47 +0200 Subject: [PATCH 152/203] add a writing function for meshes --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 4 - .../Polyhedron/Plugins/IO/3mf_io_plugin.cpp | 1 - Stream_support/include/CGAL/IO/write_3mf.h | 77 +++++++++++++++++-- .../test/Stream_support/test_3mf_to_sm.cpp | 5 ++ 4 files changed, 76 insertions(+), 11 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 9ebbe521004..879294d57db 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1004,8 +1004,6 @@ void MainWindow::reloadItem() { if(!ok) return; QVariant varian = item->property("load_mates"); - if (!varian.canConvert()) - qDebug()<<"Well, that's gonna be a problem !"; QSequentialIterable iterable = varian.value(); // Can use foreach: int mate_id = 0; @@ -1013,8 +1011,6 @@ void MainWindow::reloadItem() { { Scene_item* mate = v.value(); Scene_item* new_item = new_items[mate_id]; - if(!new_item) - qDebug()<<"That too, is gonna be a problem..."; new_item->setName(mate->name()); new_item->setColor(mate->color()); new_item->setRenderingMode(mate->renderingMode()); diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp index 553d560656c..b72e3cb1971 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp @@ -169,7 +169,6 @@ class Io_3mf_plugin: } if(need_pmap) { - //todo: check if possibility to store pid as property or not SMesh::Property_map fcolor = mesh.add_property_map("f:color",first).first; for(std::size_t pid = 0; pid < colors.size(); ++pid) diff --git a/Stream_support/include/CGAL/IO/write_3mf.h b/Stream_support/include/CGAL/IO/write_3mf.h index 199764f91bf..de335110f3c 100644 --- a/Stream_support/include/CGAL/IO/write_3mf.h +++ b/Stream_support/include/CGAL/IO/write_3mf.h @@ -23,7 +23,11 @@ #include #include #include + +#include + #include "Model/COM/NMR_DLLInterfaces.h" + namespace CGAL{ namespace tmf_internal{ // Utility functions to create vertices and triangles @@ -347,8 +351,8 @@ bool write_polyline_to_model(const PointRange& points, } /*! - * \brief write_soups_to_3mf will write the polygon soups contained in all_points and - * all_polygons into the file named `file_name`, in the 3mf format. + * \brief writes the triangle soups contained in `all_points` and + * `all_polygons` into the 3mf file `file_name`. * \tparam PointRanges a model of the concepts `RandomAccessContainer` and * `BackInsertionSequence` whose `value type` is * a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` @@ -366,7 +370,7 @@ bool write_polyline_to_model(const PointRange& points, * \return `true` if the writing is successful, `false` otherwise. */ template -bool write_soups_to_3mf(const std::string& file_name, +bool write_triangle_soups_to_3mf(const std::string& file_name, const PointRanges& all_points, const PolygonRanges& all_polygons, const std::vector& names) @@ -393,11 +397,72 @@ bool write_soups_to_3mf(const std::string& file_name, } else name = std::string(""); - write_mesh_to_model(all_points[id], all_polygons[id], name, &pMeshObject, pModel); - add_build_item(pModel, pMeshObject); - //write_mesh_object_to_model(pModel, pMeshObject); + std::vector colors(all_polygons[id].size()); + write_mesh_to_model(all_points[id], all_polygons[id], colors, name, &pMeshObject, pModel); } return export_model_to_file(file_name, pModel); } + + +/*! + * \brief writes the triangle meshes contained in `tms` + * into the 3mf file `file_name`. + * \tparam TriangleMeshRange a model of the concepts `RandomAccessContainer` + * and `BackInsertionSequence` whose `value type` is + * a model of the concepts `FaceListGraph` and `HalfedgeListGraph` + * that has only triangle faces. + * \param file_name the name of the 3mf file to write. + * \param tms a `TriangleMeshRange` that contains the meshes + * to write. An internal property map for `CGAL::vertex_point_t` + * must be available for each mesh. + * \param names will contains the name of each mesh in `file_name`. + * \return `true` if the writing is successful, `false` otherwise. + */ +template +bool write_triangle_meshes_to_3mf(const std::string& file_name, + const TriangleMeshRange& tms, + const std::vector& names) +{ + typedef typename TriangleMeshRange::value_type Mesh; + typedef typename boost::property_map::type VPMap; + typedef typename boost::property_traits::value_type Point_3; + + typedef std::vector Polygon; + typedef std::vector PolygonRange; + + typedef std::vector PointRange; + + std::vector all_points; + std::vector all_polygons; + + + for(auto tm : tms) + { + PointRange points; + PolygonRange triangles; + VPMap vpm = get(boost::vertex_point, tm); + std::unordered_map::vertex_descriptor, + std::size_t> vertex_id_map; + std::size_t i = 0; + for(auto v : vertices(tm)) + { + points.push_back(get(vpm, v)); + vertex_id_map[v] = i++; + } + all_points.push_back(points); + for(auto f : faces(tm)) + { + Polygon triangle; + for(auto vert : CGAL::vertices_around_face(halfedge(f, tm), tm)) + { + triangle.push_back(vertex_id_map[vert]); + } + triangles.push_back(triangle); + } + all_polygons.push_back(triangles); + } + + return write_triangle_soups_to_3mf(file_name, all_points, all_polygons, names); +} }//end CGAL #endif // WRITE_3MF_H diff --git a/Stream_support/test/Stream_support/test_3mf_to_sm.cpp b/Stream_support/test/Stream_support/test_3mf_to_sm.cpp index a2c1fe8dbab..31578a5bca5 100644 --- a/Stream_support/test/Stream_support/test_3mf_to_sm.cpp +++ b/Stream_support/test/Stream_support/test_3mf_to_sm.cpp @@ -159,6 +159,11 @@ int main(int argc, char** argv) names.push_back(std::string("sphere")); names.push_back(std::string("tube")); + std::vector meshes(2); + meshes[0] = sphere; + meshes[1] = tube; + CGAL::write_triangle_meshes_to_3mf("meshes.3mf", meshes, names); + //testing of point clouds DWORD nErrorMessage; From addad6c95378346334f42d1bae1143bb2b8b6607 Mon Sep 17 00:00:00 2001 From: Mael Date: Fri, 7 Jun 2019 09:00:02 +0200 Subject: [PATCH 153/203] Do not define a halfedge range for TDS_2 Halfedges have no place in the TDS, and the only reason they exist is because of the 2D triangulation graph traits. The latter are reworked in another PR (https://github.com/CGAL/cgal/pull/3885) such that there is no need to have halfedges defined in TDS_2/T2 --- TDS_2/include/CGAL/Triangulation_data_structure_2.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/TDS_2/include/CGAL/Triangulation_data_structure_2.h b/TDS_2/include/CGAL/Triangulation_data_structure_2.h index 08bbf3e6793..9c670b9a0a1 100644 --- a/TDS_2/include/CGAL/Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/Triangulation_data_structure_2.h @@ -101,7 +101,6 @@ public: typedef Iterator_range > Vertex_handles; typedef Iterator_range > Face_handles; typedef Iterator_range Edges; - typedef Iterator_range Halfedges; typedef Vertex_iterator Vertex_handle; typedef Face_iterator Face_handle; @@ -213,10 +212,6 @@ public: return Halfedge_iterator(this,1); } - Halfedges halfedges() const { - return Halfedges(halfedges_begin(),halfedges_end()); - } - Face_circulator incident_faces(Vertex_handle v, Face_handle f = Face_handle()) const{ return Face_circulator(v,f); From dfb37e2378f262212033176a7c5aa828c9b60e17 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 7 Jun 2019 12:06:44 +0200 Subject: [PATCH 154/203] Fix when called with Surface_mesh instead of Polyhedron_3 --- Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h index bbfbb9b5a89..aea123f781d 100644 --- a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h @@ -217,7 +217,7 @@ public: stored_polyhedra.push_back(bounding_polyhedron); get(face_patch_id_t(), stored_polyhedra.back()); this->add_primitives(stored_polyhedra.back()); - if(bounding_polyhedron.empty()) { + if(CGAL::is_empty(bounding_polyhedron)) { this->set_surface_only(); } else { this->add_primitives_to_bounding_tree(stored_polyhedra.back()); From 2ad4bf8c6f1616fb1721339ef1840de7ca699f4b Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 7 Jun 2019 12:07:20 +0200 Subject: [PATCH 155/203] Mesh_3_plugin: clean `applicable()` and allow to mesh multiple surfaces --- .../Plugins/Mesh_3/Mesh_3_plugin.cpp | 200 +++++++++--------- .../Mesh_3/Mesh_3_plugin_cgal_code.cpp | 83 ++------ .../Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h | 3 +- 3 files changed, 120 insertions(+), 166 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp index c63c36d17e9..77d08116016 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp @@ -89,33 +89,27 @@ public: bool applicable(QAction* a) const { if(a == actionSplitPolylines) { return qobject_cast - (scene->item(scene->mainSelectionIndex())) != 0; + (scene->item(scene->mainSelectionIndex())) != nullptr; } #ifdef CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS - if(qobject_cast(scene->item(scene->mainSelectionIndex())) != NULL - && a == actionMesh_3) + if(qobject_cast + (scene->item(scene->mainSelectionIndex())) != nullptr) { return true; + } #endif #ifdef CGAL_MESH_3_DEMO_ACTIVATE_SEGMENTED_IMAGES - Q_FOREACH(int ind, scene->selectionIndices()){ - if( qobject_cast(scene->item(ind))) - return true; + if( qobject_cast + (scene->item(scene->mainSelectionIndex())) != nullptr ) { + return true; } -#endif - Q_FOREACH(int ind, scene->selectionIndices()){ +#endif + for(int ind: scene->selectionIndices()){ Scene_surface_mesh_item* sm_item = qobject_cast(scene->item(ind)); - if(NULL == sm_item) - continue; - if (a == actionMesh_3) - { - if(sm_item) - return is_closed(*sm_item->polyhedron()); - } - else - return true; + if(nullptr == sm_item) + return false; } - return false; + return true; } public Q_SLOTS: @@ -182,66 +176,76 @@ void Mesh_3_plugin::mesh_3_volume() void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) { - Scene_surface_mesh_item* sm_item = NULL; - Scene_surface_mesh_item* bounding_sm_item = NULL; - Scene_implicit_function_item* function_item = NULL; - Scene_image_item* image_item = NULL; - Scene_polylines_item* polylines_item = NULL; + QList sm_items; + Scene_surface_mesh_item* bounding_sm_item = nullptr; + Scene_implicit_function_item* function_item = nullptr; + Scene_image_item* image_item = nullptr; + Scene_polylines_item* polylines_item = nullptr; - Q_FOREACH(int ind, scene->selectionIndices()) { - if(sm_item == NULL) - { - sm_item = qobject_cast(scene->item(ind)); - if (sm_item != NULL - && scene->selectionIndices().size() == 2 - && bounding_sm_item == NULL) - { - bounding_sm_item = qobject_cast( - scene->item(scene->selectionIndices().back())); - if (bounding_sm_item != NULL) - { - if (is_closed(*sm_item->polyhedron()) - && !is_closed(*bounding_sm_item->polyhedron())) - { - //todo : check sm_item is inside bounding_sm_item - std::swap(sm_item, bounding_sm_item); - //now bounding_sm_item is the bounding one - } - } + for(int ind: scene->selectionIndices()) { + Scene_surface_mesh_item* sm_item = + qobject_cast(scene->item(ind)); + if(sm_item) { + sm_items.push_back(sm_item); + if(is_closed(*sm_item->polyhedron())) { + bounding_sm_item = sm_item; } } #ifdef CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS - if(function_item == NULL){ - function_item = qobject_cast(scene->item(ind)); - } + else if(function_item == nullptr && + nullptr != + (function_item = qobject_cast(scene->item(ind)))) + {} #endif #ifdef CGAL_MESH_3_DEMO_ACTIVATE_SEGMENTED_IMAGES - if(image_item == NULL){ - image_item = qobject_cast(scene->item(ind)); - } + else if(image_item == nullptr && + nullptr != (image_item = qobject_cast(scene->item(ind)))) + {} #endif - if(polylines_item == NULL){ - polylines_item = qobject_cast(scene->item(ind)); - } - } - Scene_item* item = NULL; - bool features_protection_available = false; - if(NULL != sm_item) - { - if (!is_triangle_mesh(*sm_item->polyhedron())) - { - QMessageBox::warning(mw, tr(""), - tr("Selected Scene_surface_mesh__item is not triangulated.")); + else if(polylines_item == nullptr && + nullptr != (polylines_item = qobject_cast(scene->item(ind)))) + {} + else { + QMessageBox::warning(mw, tr("Mesh_3 plugin"), + tr("Wrong selection of items")); return; } - item = sm_item; + } + Scene_item* item = nullptr; + bool more_than_one_item = false; + bool features_protection_available = false; + if(!sm_items.empty()) + { + for(auto sm_item : sm_items) { + if(nullptr == sm_item->polyhedron()) { + QApplication::restoreOverrideCursor(); + QMessageBox::critical(mw, tr("Mesh_3 plugin"), + tr("ERROR: no data in selected item %1").arg(sm_item->name())); + return; + } + if (!is_triangle_mesh(*sm_item->polyhedron())) + { + QApplication::restoreOverrideCursor(); + QMessageBox::warning(mw, tr("Mesh_3 plugin"), + tr("Selected Scene_surface_mesh_item %1 is not triangulated.") + .arg(sm_item->name())); + return; + } + if(sm_item->getNbIsolatedvertices() != 0) + { + QApplication::restoreOverrideCursor(); + QMessageBox::critical(mw, tr(""), tr("ERROR: there are isolated vertices in this mesh.")); + return; + } + } + item = sm_items.front(); features_protection_available = true; } #ifdef CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS - else if (NULL != function_item) { item = function_item; } + else if (nullptr != function_item) { item = function_item; } #endif #ifdef CGAL_MESH_3_DEMO_ACTIVATE_SEGMENTED_IMAGES - else if (NULL != image_item) + else if (nullptr != image_item) { item = image_item; features_protection_available = true; @@ -275,7 +279,7 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) } #endif - if (NULL == item) + if (nullptr == item) { QMessageBox::warning(mw, tr(""), tr("Selected object can't be meshed")); @@ -372,13 +376,13 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) ui.protectEdges->setEnabled(features_protection_available); ui.facegraphCheckBox->setVisible(surface_only); - ui.initializationGroup->setVisible(image_item != NULL && !image_item->isGray()); - ui.grayImgGroup->setVisible(image_item != NULL && image_item->isGray()); - if (sm_item != NULL) - ui.volumeGroup->setVisible(!surface_only && is_closed(*sm_item->polyhedron())); + ui.initializationGroup->setVisible(image_item != nullptr && !image_item->isGray()); + ui.grayImgGroup->setVisible(image_item != nullptr && image_item->isGray()); + if (!sm_items.empty()) + ui.volumeGroup->setVisible(!surface_only && nullptr != bounding_sm_item); else ui.volumeGroup->setVisible(!surface_only); - if ((sm_item == NULL)|| polylines_item != NULL) { + if ((!sm_items.empty())|| polylines_item != nullptr) { ui.sharpEdgesAngleLabel->setVisible(false); ui.sharpEdgesAngle->setVisible(false); @@ -394,7 +398,7 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) if (features_protection_available) { - if (NULL != sm_item) + if (!sm_items.empty()) { if (surface_only) { @@ -404,9 +408,9 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) else ui.protectEdges->addItem(QString("Sharp edges")); } - else if(NULL != image_item) + else if(nullptr != image_item) { - if(polylines_item != NULL) + if(polylines_item != nullptr) ui.protectEdges->addItem(QString("Input polylines")); else { @@ -444,29 +448,23 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) const float inside_is_less = float(ui.inside_is_less_checkBox->isChecked()); as_facegraph = surface_only ? ui.facegraphCheckBox->isChecked() : false; - Meshing_thread* thread = NULL; - if ( NULL != sm_item ) + Meshing_thread* thread = nullptr; + if (!sm_items.empty()) { - SMesh* pMesh = sm_item->polyhedron(); - if (NULL == pMesh) - { - QApplication::restoreOverrideCursor(); - QMessageBox::critical(mw, tr(""), tr("ERROR: no data in selected item")); - return; - } - if(sm_item->getNbIsolatedvertices() != 0) - { - QApplication::restoreOverrideCursor(); - QMessageBox::critical(mw, tr(""), tr("ERROR: there are isolated vertices in this mesh.")); - return; - } + QList polyhedrons; + sm_items.removeAll(bounding_sm_item); + std::transform(sm_items.begin(), sm_items.end(), + std::back_inserter(polyhedrons), + [](Scene_surface_mesh_item* item) { + return item->polyhedron(); + }); Scene_polylines_item::Polylines_container plc; - SMesh *pBMesh = (bounding_sm_item == NULL) ? NULL - : bounding_sm_item->polyhedron(); + SMesh *bounding_polyhedron = + (bounding_sm_item == nullptr) ? nullptr : bounding_sm_item->polyhedron(); - thread = cgal_code_mesh_3(pMesh, - (polylines_item == NULL)?plc:polylines_item->polylines, - pBMesh, + thread = cgal_code_mesh_3(polyhedrons, + (polylines_item == nullptr)?plc:polylines_item->polylines, + bounding_polyhedron, item->name(), angle, facet_sizing, @@ -483,10 +481,10 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) } // Image #ifdef CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS - else if (NULL != function_item) + else if (nullptr != function_item) { const Implicit_function_interface* pFunction = function_item->function(); - if (NULL == pFunction) + if (nullptr == pFunction) { QMessageBox::critical(mw, tr(""), tr("ERROR: no data in selected item")); return; @@ -505,10 +503,10 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) } #endif #ifdef CGAL_MESH_3_DEMO_ACTIVATE_SEGMENTED_IMAGES - else if (NULL != image_item) + else if (nullptr != image_item) { const Image* pImage = image_item->image(); - if (NULL == pImage) + if (nullptr == pImage) { QMessageBox::critical(mw, tr(""), tr("ERROR: no data in selected item")); return; @@ -517,7 +515,7 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) Scene_polylines_item::Polylines_container plc; thread = cgal_code_mesh_3(pImage, - (polylines_item == NULL)?plc:polylines_item->polylines, + (polylines_item == nullptr)?plc:polylines_item->polylines, angle, facet_sizing, approx, @@ -536,7 +534,7 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) } #endif - if ( NULL == thread ) + if ( nullptr == thread ) { QMessageBox::critical(mw,tr(""),tr("ERROR: no thread created")); return; @@ -595,7 +593,7 @@ void Mesh_3_plugin:: status_report(QString str) { - if ( NULL == message_box_ ) { return; } + if ( nullptr == message_box_ ) { return; } message_box_->setInformativeText(str); } @@ -632,7 +630,7 @@ meshing_done(Meshing_thread* thread) // close message box message_box_->done(0); - message_box_ = NULL; + message_box_ = nullptr; // free memory // TODO: maybe there is another way to do that diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp index 211c98f1bd4..59547587a70 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp @@ -1,3 +1,4 @@ +#define CGAL_MESH_3_VERBOSE 1 #include "config_mesh_3.h" #include "Mesh_3_plugin_cgal_code.h" @@ -31,15 +32,9 @@ struct Compare_to_isovalue { } }; -template -struct Polyhedral_mesh_domain_selector -{ - typedef Polyhedral_mesh_domain type; -}; -template -Meshing_thread* cgal_code_mesh_3_templated(const Mesh* pMesh, +Meshing_thread* cgal_code_mesh_3(QList pMeshes, const Polylines_container& polylines, - const Mesh* pBoundingMesh, + const SMesh* pBoundingMesh, QString filename, const double facet_angle, const double facet_sizing, @@ -54,43 +49,39 @@ Meshing_thread* cgal_code_mesh_3_templated(const Mesh* pMesh, const bool surface_only, CGAL::Three::Scene_interface* scene) { - if(!pMesh) return 0; + if(pMeshes.empty() && nullptr == pBoundingMesh) return 0; std::cerr << "Meshing file \"" << qPrintable(filename) << "\"\n"; std::cerr << " angle: " << facet_angle << std::endl << " edge size bound: " << edge_size << std::endl << " facets size bound: " << facet_sizing << std::endl << " approximation bound: " << facet_approx << std::endl; - if (is_closed(*pMesh)) + if (!surface_only) std::cerr << " tetrahedra size bound: " << tet_sizing << std::endl; std::cerr << "Build AABB tree..."; CGAL::Real_timer timer; timer.start(); - typedef typename Polyhedral_mesh_domain_selector::type Polyhedral_mesh_domain; // Create domain Polyhedral_mesh_domain* p_domain = NULL; - if (!surface_only && is_closed(*pMesh)) - p_domain = new Polyhedral_mesh_domain(*pMesh); - else if (!surface_only && pBoundingMesh != NULL && is_closed(*pBoundingMesh)) - p_domain = new Polyhedral_mesh_domain(*pMesh, *pBoundingMesh); + if (surface_only || nullptr == pBoundingMesh) + p_domain = new Polyhedral_mesh_domain(pMeshes.begin(), pMeshes.end()); + else if(pMeshes.empty()) + p_domain = new Polyhedral_mesh_domain(*pBoundingMesh); else - { - std::vector poly_ptrs_vector(1, pMesh); - p_domain = new Polyhedral_mesh_domain(poly_ptrs_vector.begin(), poly_ptrs_vector.end()); - } - + p_domain = new Polyhedral_mesh_domain(pMeshes.begin(), pMeshes.end(), + *pBoundingMesh); // Features - if(polylines.empty() && protect_features) { + if(polylines.empty()) { + if(protect_features) { //includes detection of borders in the surface case p_domain->detect_features(sharp_edges_angle); - } - else if (polylines.empty() && protect_borders) - { - p_domain->detect_borders(); - } - if(! polylines.empty()){ + } + else if (protect_borders) { + p_domain->detect_borders(); + } + } else { p_domain->add_features(polylines.begin(), polylines.end()); protect_features = true; // so that it will be passed in make_mesh_3 } @@ -111,7 +102,7 @@ Meshing_thread* cgal_code_mesh_3_templated(const Mesh* pMesh, .arg(edge_size) .arg(facet_sizing) .arg(facet_approx); - if (is_closed(*pMesh)) + if (!surface_only) tooltip += QString("
  • Tetrahedra size bound: %1
  • " ) .arg(tet_sizing); tooltip += ""; @@ -135,42 +126,6 @@ Meshing_thread* cgal_code_mesh_3_templated(const Mesh* pMesh, return new Meshing_thread(p_mesh_function, p_new_item); } - - -Meshing_thread* cgal_code_mesh_3(const SMesh* pMesh, - const Polylines_container& polylines, - const SMesh* pBoundingMesh, - QString filename, - const double facet_angle, - const double facet_sizing, - const double facet_approx, - const double tet_sizing, - const double edge_size, - const double tet_shape, - bool protect_features, - bool protect_borders, - const double sharp_edges_angle, - const int manifold, - const bool surface_only, - CGAL::Three::Scene_interface* scene) -{ - return cgal_code_mesh_3_templated(pMesh, - polylines, - pBoundingMesh, - filename, - facet_angle, - facet_sizing, - facet_approx, - tet_sizing, - edge_size, - tet_shape, - protect_features, - protect_borders, - sharp_edges_angle, - manifold, - surface_only, - scene); -} #ifdef CGAL_MESH_3_DEMO_ACTIVATE_IMPLICIT_FUNCTIONS Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction, diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h index 20b01d11e6d..454c27e5cae 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h @@ -8,6 +8,7 @@ #include "Meshing_thread.h" #include "Scene_surface_mesh_item.h" #include +#include class Scene_surface_mesh_item; @@ -19,7 +20,7 @@ namespace CGAL { namespace Three { typedef std::list > Polylines_container; -Meshing_thread* cgal_code_mesh_3(const SMesh* pMesh, +Meshing_thread* cgal_code_mesh_3(QList pMeshes, const Polylines_container& polylines, const SMesh* pBoundingMesh, QString filename, From 39bceb093c91e919436360ff37cf66789b4c54f6 Mon Sep 17 00:00:00 2001 From: bryantcurto Date: Fri, 7 Jun 2019 11:57:19 -0400 Subject: [PATCH 156/203] Fixed do_intersect() ambiguity. Occurs when compiling with clang --- .../CGAL/Intersections_3/internal/intersection_3_1_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/intersection_3_1_impl.h b/Intersections_3/include/CGAL/Intersections_3/internal/intersection_3_1_impl.h index 2112802e019..d0dac100942 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/intersection_3_1_impl.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/intersection_3_1_impl.h @@ -430,7 +430,7 @@ do_intersect(const typename K::Segment_3 &s1, const K & k) { CGAL_precondition(! s1.is_degenerate () && ! s2.is_degenerate () ); - bool b=do_intersect(s1.supporting_line(),s2.supporting_line(),k); + bool b=internal::do_intersect(s1.supporting_line(),s2.supporting_line(),k); if (b) { //supporting_line intersects: points are coplanar From cc76597a3ebcc9f024d8b8e3f69ffff28c7b64cf Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 11 Jun 2019 12:02:27 +0200 Subject: [PATCH 157/203] Fix in the testcase. Forgot to test if the range is empty, before dereferencing the iterator --- .../include/CGAL/_test_triangulation_iterators.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h index 5e3e8684ef0..b23b97ba286 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h @@ -182,7 +182,9 @@ _test_cls_point_iterator( Triangulation &T ) assert( n == 0 ); Points range = T.points(); - p = *(range.first); + if(! range.empty()){ + p = *(range.first); + } return np; } From 8a272dd0b963e3697b6aa8644f1e1441d2dc579c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 12 Jun 2019 08:17:51 +0200 Subject: [PATCH 158/203] Fix warning --- .../CGAL/Polygon_mesh_processing/connected_components.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 4065cca8c26..2baf098aac3 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -441,10 +441,12 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh, for(face_descriptor f : faces(pmesh)) component_size[face_cc[f]] += get(face_size_pmap, f); + const Face_size thresh = threshold_value; + std::vector cc_to_keep; for(std::size_t i=0; i= threshold_value) + if(component_size[i] >= thresh) cc_to_keep.push_back(i); } From 7a49b4801901e49b21cf167760f10ac8b3705d7d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 12 Jun 2019 09:23:57 +0200 Subject: [PATCH 159/203] Add code and test for all_edges() --- Triangulation_2/include/CGAL/Triangulation_2.h | 8 ++++++++ .../include/CGAL/_test_triangulation_iterators.h | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index 74a54f19f4f..9a26986117d 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -3258,6 +3258,14 @@ all_edges_end() const return _tds.edges_end(); } +template +typename Triangulation_2::All_edges +Triangulation_2:: +all_edges() const +{ + return _tds.edges(); +} + template typename Triangulation_2::All_halfedges_iterator Triangulation_2:: diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h index b23b97ba286..e5a1201b5c8 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_triangulation_iterators.h @@ -199,6 +199,7 @@ _test_cls_edge_iterator( const Triangulation &T ) typedef typename Triangulation::size_type size_type; typedef typename Triangulation::Finite_edges Finite_edges; + typedef typename Triangulation::All_edges All_edges; Edge e; Face_handle fh; @@ -221,7 +222,14 @@ _test_cls_edge_iterator( const Triangulation &T ) assert( n == 0 ); Finite_edges range = T.finite_edges(); - e = *(range.first); + if(! range.empty()){ + e = *(range.first); + } + + All_edges aerange = T.all_edges(); + if(! aerange.empty()){ + e = *(aerange.first); + } return ne; } From f94122b31b0b96d69ed7ed6c44bcadf17822aed0 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 13 Jun 2019 09:11:02 +0200 Subject: [PATCH 160/203] Add a testsuite for Epick --- .../test/Kernel_23/Filtered_cartesian.cpp | 13 +++++- .../Kernel_23/include/CGAL/_approx_equal.h | 44 +++++++++++++++++++ .../include/CGAL/_test_fct_weighted_point_2.h | 7 ++- .../include/CGAL/_test_further_fct_point_2.h | 6 ++- 4 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h diff --git a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp index 841aeb1fcd3..19d96c02f2b 100644 --- a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp +++ b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp @@ -27,6 +27,7 @@ #include #include +#include #include @@ -52,9 +53,12 @@ #include "CGAL/_test_mf_plane_3_to_2d.h" +template +void test(); int main() { + CGAL::force_ieee_double_precision(); typedef CGAL::Cartesian Clsdb; typedef CGAL::Filtered_kernel Clsd; @@ -71,6 +75,13 @@ main() std::cout << "Testing IO with F_k>:" << std::endl; _test_io( Clsd() ); + std::cout << "Testing with Epick:\n"; + test(); + return 0; +} + +template +void test() { std::cout << "Testing 2d :"; std::cout << std::endl; _test_2( Cls() ); @@ -101,6 +112,4 @@ main() std::cout << "Testing 3d-2d :"; std::cout << std::endl; _test_mf_plane_3_to_2d( Cls() ); - - return 0; } diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h b/Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h new file mode 100644 index 00000000000..361d0800554 --- /dev/null +++ b/Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h @@ -0,0 +1,44 @@ +#ifndef CGAL_TESTSUITE_APPROX_EQUAL_H +#define CGAL_TESTSUITE_APPROX_EQUAL_H +#include + +namespace CGAL { +namespace testsuite { + +template +bool approx_equal(FT a, FT b) { return a == b; } + +bool approx_equal(double a, double b) { + return std::abs(boost::math::float_distance(a, b)) <= 1; +} + +struct Xyz_tag {}; +struct Xy_tag {}; + +template +bool approx_equal(Object a, Object b, CGAL::testsuite::Xyz_tag) +{ + return approx_equal(a.x(), b.x()) && + approx_equal(a.y(), b.y()) && + approx_equal(a.z(), b.z()); +} + +template +bool approx_equal(Object a, Object b, CGAL::testsuite::Xy_tag) +{ + return approx_equal(a.x(), b.x()) && approx_equal(a.y(), b.y()); +} + +struct Direction_2_tag {}; +template +bool approx_equal(Object a, Object b, CGAL::testsuite::Direction_2_tag) +{ + return CGAL_NTS sign(a.dx()) == CGAL_NTS sign(a.dx()) + && CGAL_NTS sign(a.dy()) == CGAL_NTS sign(b.dy()) + && approx_equal(a.dx() * b.dy(), a.dy() * b.dx()); +} + +} // end namespace testsuite +} // end namespace CGAL + +#endif // CGAL_TESTSUITE_APPROX_EQUAL_H diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h index dbe58ed1121..a0ffb40e8be 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h @@ -31,6 +31,8 @@ #include #include +#include "_approx_equal.h" + template bool _test_fct_weighted_point_2(const R& ) @@ -158,8 +160,9 @@ _test_fct_weighted_point_2(const R& ) std::cout << CGAL::weighted_circumcenter(wp_00, wp_10, wp_01) << std::endl; - assert( CGAL::squared_radius_smallest_orthogonal_circle(wp1, wp3, wp5) - == CGAL::squared_radius(p1, p3, p5)); + using CGAL::testsuite::approx_equal; + assert( approx_equal(CGAL::squared_radius_smallest_orthogonal_circle(wp1, wp3, wp5), + CGAL::squared_radius(p1, p3, p5)) ); assert( CGAL::squared_radius_smallest_orthogonal_circle(wp_00, wp_10, wp_01) == RT(0)); std::cout << "done" << std::endl; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h index f17c9028deb..cf498947577 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_FURTHER_FCT_POINT_2_H #define CGAL__TEST_FURTHER_FCT_POINT_2_H +#include "_approx_equal.h" + template bool _test_further_fct_point_2(const R& ) @@ -95,8 +97,10 @@ _test_further_fct_point_2(const R& ) p4 = p0.transform(rotate4); p5 = p0.transform(rotate5); + using CGAL::testsuite::approx_equal; + using CGAL::testsuite::Direction_2_tag; - assert( (p5 - CGAL::ORIGIN).direction() == dir5 ); + assert( approx_equal((p5 - CGAL::ORIGIN).direction(), dir5, Direction_2_tag()) ); assert( CGAL::side_of_bounded_circle(p1, p2, p3, CGAL::Point_2(CGAL::ORIGIN))\ == CGAL::ON_BOUNDED_SIDE ); From 3b2b6bb468e05ec91dda4e0b909e39e02257e034 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 13 Jun 2019 09:11:12 +0200 Subject: [PATCH 161/203] Fix that incorrect testsuite of Epick_without_intervals --- Kernel_23/test/Kernel_23/Simple_cartesian.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Kernel_23/test/Kernel_23/Simple_cartesian.cpp b/Kernel_23/test/Kernel_23/Simple_cartesian.cpp index 71900f364a5..4058ddaa5b3 100644 --- a/Kernel_23/test/Kernel_23/Simple_cartesian.cpp +++ b/Kernel_23/test/Kernel_23/Simple_cartesian.cpp @@ -22,7 +22,6 @@ #include -#include #include #include @@ -91,7 +90,5 @@ main() typedef CGAL::Simple_cartesian > Cls; test_kernel("Simple_cartesian>", Cls()); - typedef CGAL::Simple_cartesian > Cls; - test_kernel("Epick_without_intervals", CGAL::Epick_without_intervals()); return 0; } From 7d543d5bf80ae5fe3d0075d52b9750e3a0115fbc Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 13 Jun 2019 15:06:19 +0200 Subject: [PATCH 162/203] Add a testsuite for Epick and Epick_without_intervals --- .../test/Kernel_23/Filtered_cartesian.cpp | 6 ++- .../CGAL/_test_cls_aff_transformation_2.h | 19 ++++---- .../CGAL/_test_cls_aff_transformation_3.h | 34 +++++++------- .../include/CGAL/_test_cls_circle_2.h | 14 ++++-- .../Kernel_23/include/CGAL/_test_cls_line_3.h | 12 +++-- .../include/CGAL/_test_cls_sphere_3.h | 26 ++++++----- .../CGAL/_test_fct_points_implicit_sphere.h | 28 ++++++----- .../include/CGAL/_test_fct_weighted_point_3.h | 8 ++-- .../include/CGAL/_test_further_fct_point_2.h | 19 ++++---- .../include/CGAL/_test_mf_plane_3_to_2d.h | 46 ++++++++++--------- 10 files changed, 121 insertions(+), 91 deletions(-) diff --git a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp index 19d96c02f2b..25a57e1965e 100644 --- a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp +++ b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp @@ -75,8 +75,12 @@ main() std::cout << "Testing IO with F_k>:" << std::endl; _test_io( Clsd() ); - std::cout << "Testing with Epick:\n"; + std::cout << "Testing with Epeck:\n"; test(); + std::cout << "Testing with Epick:\n"; + test(); + std::cout << "Testing with Epick_without_intervals:\n"; + test(); return 0; } diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h index 86c8c4d8d6d..fe63c96b789 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h @@ -25,6 +25,7 @@ #define CGAL__TEST_CLS_AFF_TRANSFORMATION_2_H #include +#include template bool @@ -35,6 +36,8 @@ _test_cls_aff_transformation_2(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; + const bool nonexact = boost::is_same::value; + typename R::Aff_transformation_2 ia; CGAL::Aff_transformation_2 a1(ia); @@ -170,7 +173,7 @@ _test_cls_aff_transformation_2(const R& ) tisor= isor.transform( a[i]); assert( tseg == CGAL::Segment_2(tp1, tp2) ); assert( tray == CGAL::Ray_2(tp3, tp2) ); - assert( tlin == CGAL::Line_2(tp2, tp4) ); + assert( tlin == CGAL::Line_2(tp2, tp4) || nonexact); assert( ttri == CGAL::Triangle_2(tp2, tp3, tp4) ); assert( tisor== CGAL::Iso_rectangle_2( tp3, tp4 ) ); @@ -180,11 +183,11 @@ _test_cls_aff_transformation_2(const R& ) tray = tray.transform( inv ); tlin = tlin.transform( inv ); ttri = ttri.transform( inv ); - assert( tp4 == p4 ); - assert( tseg == seg ); - assert( tray == ray ); - assert( tlin == lin ); - assert( ttri == tri ); + assert( tp4 == p4 || nonexact ); + assert( tseg == seg || nonexact ); + assert( tray == ray || nonexact ); + assert( tlin == lin || nonexact ); + assert( ttri == tri || nonexact ); }; std::cout << '.'; @@ -293,7 +296,7 @@ _test_cls_aff_transformation_2(const R& ) // rotation assert( d0.transform( rot90 ) == d1 ); assert( d1.transform( rot90.inverse() ) == d0 ); - assert( d0.transform( rot3 ) == CGAL::Direction_2( RT(4), RT(3)) ); + assert( d0.transform( rot3 ) == CGAL::Direction_2( RT(4), RT(3)) || nonexact); co1 = rot3 * rot90; assert( d1.transform( rot3) == d0.transform( co1 ) ); co1 = rot2 * rot90; @@ -326,7 +329,7 @@ _test_cls_aff_transformation_2(const R& ) tp3 = p3.transform( rot3 ); tp4 = p4.transform( rot3 ); tcirc = circ.orthogonal_transform( rot3 ); - assert( tcirc == CGAL::Circle_2( tp2, tp3, tp4 ) ); + assert( tcirc == CGAL::Circle_2( tp2, tp3, tp4 ) || nonexact ); // copy diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h index 6a30e82c11d..2d52d61a01b 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h @@ -25,6 +25,7 @@ #define CGAL__TEST_CLS_AFF_TRANSFORMATION_3_H #include +#include template bool @@ -34,6 +35,7 @@ _test_cls_aff_transformation_3(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; + const bool nonexact = boost::is_same::value; typename R::Aff_transformation_3 ia; CGAL::Aff_transformation_3 a1(ia); @@ -184,7 +186,7 @@ _test_cls_aff_transformation_3(const R& ) tlin = lin.transform( a[i] ); ttri = tri.transform( a[i] ); ttet = tet.transform( a[i] ); - assert( tpla == CGAL::Plane_3( tp1, tp2, tp3) ); + assert( tpla == CGAL::Plane_3( tp1, tp2, tp3) || nonexact ); assert( tseg == CGAL::Segment_3(tp1, tp2) ); assert( tray == CGAL::Ray_3(tp3, tp2) ); assert( tlin == CGAL::Line_3(tp2, tp4) ); @@ -198,13 +200,13 @@ _test_cls_aff_transformation_3(const R& ) tlin = tlin.transform( inv ); ttri = ttri.transform( inv ); ttet = ttet.transform( inv ); - assert( tp4 == p4 ); - assert( tpla == pla ); - assert( tseg == seg ); - assert( tray == ray ); - assert( tlin == lin ); - assert( ttri == tri ); - assert( ttet == tet ); + assert( tp4 == p4 || nonexact ); + assert( tpla == pla || nonexact ); + assert( tseg == seg || nonexact ); + assert( tray == ray || nonexact ); + assert( tlin == lin || nonexact ); + assert( ttri == tri || nonexact ); + assert( ttet == tet || nonexact ); }; std::cout << '.'; @@ -213,7 +215,7 @@ _test_cls_aff_transformation_3(const R& ) assert( vec.transform(ident) == vec ); assert( dir.transform(ident) == dir ); assert( pnt.transform(ident) == pnt ); - assert( pla.transform(ident) == pla ); + assert( pla.transform(ident) == pla || nonexact ); // scale11 and gscale tpnt = pnt.transform(scale11); @@ -236,7 +238,7 @@ _test_cls_aff_transformation_3(const R& ) assert( vec.transform(scale11) == vec.transform(gscale) ); assert( dir.transform(scale11) == dir.transform(gscale) ); assert( pnt.transform(scale11) == pnt.transform(gscale) ); - assert( pla.transform(scale11) == pla.transform(gscale) ); + assert( pla.transform(scale11) == pla.transform(gscale) || nonexact ); // translate and gtrans tvec = vec.transform(translate); @@ -274,7 +276,7 @@ _test_cls_aff_transformation_3(const R& ) assert( pnt.transform(xrefl).transform(xrefl) == pnt ); assert( dir.transform(xrefl).transform(xrefl) == dir ); assert( vec.transform(xrefl).transform(xrefl) == vec ); - assert( pla.transform(xrefl).transform(xrefl) == pla ); + assert( pla.transform(xrefl).transform(xrefl) == pla || nonexact ); CGAL::Aff_transformation_3 co1 = xrefl * xrefl; assert( pnt.transform(xrefl).transform(xrefl) == pnt.transform(co1) ); assert( dir.transform(xrefl).transform(xrefl) == dir.transform(co1) ); @@ -284,7 +286,7 @@ _test_cls_aff_transformation_3(const R& ) assert( pnt.transform(gat3).transform(gat2) == pnt.transform(co1) ); assert( dir.transform(gat3).transform(gat2) == dir.transform(co1) ); assert( vec.transform(gat3).transform(gat2) == vec.transform(co1) ); - assert( pla.transform(gat3).transform(gat2) == pla.transform(co1) ); + assert( pla.transform(gat3).transform(gat2) == pla.transform(co1) || nonexact ); co1 = ident * gat1; assert( vec.transform(gat1) == vec.transform(co1) ); assert( dir.transform(gat1) == dir.transform(co1) ); @@ -296,10 +298,10 @@ _test_cls_aff_transformation_3(const R& ) assert( pnt.transform(gat1) == pnt.transform(co1) ); assert( pla.transform(gat1) == pla.transform(co1) ); co1 = gat1 * gat1.inverse() ; - assert( vec == vec.transform(co1) ); - assert( dir == dir.transform(co1) ); - assert( pnt == pnt.transform(co1) ); - assert( pla == pla.transform(co1) ); + assert( vec == vec.transform(co1) || nonexact ); + assert( dir == dir.transform(co1) || nonexact ); + assert( pnt == pnt.transform(co1) || nonexact ); + assert( pla == pla.transform(co1) || nonexact ); assert( vec.transform( gat5 ) == vec.transform( gat2 ) ); assert( dir.transform( gat5 ) == dir.transform( gat2 ) ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h index c93726b81ed..6933bec5a4d 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h @@ -27,6 +27,8 @@ #include #include +#include + template void _test_construct_radical_line(const K &k) { typedef typename K::FT FT; @@ -83,6 +85,8 @@ _test_cls_circle_2(const R& ) typename R::Circle_2 ic; CGAL::Circle_2 c0; + const bool nonexact = boost::is_same::value; + RT n0 = 0; RT n1 = 16; RT n2 = -4; @@ -194,9 +198,9 @@ _test_cls_circle_2(const R& ) == CGAL::ON_POSITIVE_SIDE ); assert( c10.oriented_side(CGAL::ORIGIN + v1 + vx*n2 ) \ == CGAL::ON_NEGATIVE_SIDE ); - assert( c10.oriented_side(p9 ) == CGAL::ON_ORIENTED_BOUNDARY ); - assert( c10.has_on_boundary(p9) ); - assert( c10.has_on_boundary(p4 + v1) ); + assert( c10.oriented_side(p9 ) == CGAL::ON_ORIENTED_BOUNDARY || nonexact); + assert( c10.has_on_boundary(p9) || nonexact); + assert( c10.has_on_boundary(p4 + v1) || nonexact ); CGAL::Point_2 p11( n4, n4, n3) ; // (2.5, 2.5) CGAL::Point_2 p12( n5, n5, n3) ; // ( 5 , 5 ) assert( c10.has_on_bounded_side( p11 ) ); @@ -206,8 +210,8 @@ _test_cls_circle_2(const R& ) assert( c10.has_on_negative_side( p12 ) ); assert( c10.opposite().has_on_negative_side( p11 ) ); assert( c10.opposite().has_on_positive_side( p12 ) ); - assert( c10.has_on_boundary( p6 ) ); - assert( c10.has_on_boundary( p8 ) ); + assert( c10.has_on_boundary( p6 ) || nonexact); + assert( c10.has_on_boundary( p8 ) || nonexact); std::cout << '.'; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h index 35190bc4742..9c0509b17ab 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_3.h @@ -25,6 +25,7 @@ #define CGAL__TEST_CLS_LINE_3_H #include +#include template bool @@ -33,6 +34,7 @@ _test_cls_line_3(const R& ) std::cout << "Testing class Line_3" ; typedef typename R::RT RT; + const bool nonexact = boost::is_same::value; typename R::Line_3 il; CGAL::Line_3 l0( il ); CGAL_USE(l0); @@ -101,20 +103,20 @@ _test_cls_line_3(const R& ) assert( l4.point(2) - l4.point(1) == l4.point(1) - l4.point(0) ); CGAL::Point_3 p1l4proj = l4.projection(p1); - assert( l4.has_on( p1l4proj ) ); - assert( l4.perpendicular_plane( p1l4proj ).has_on( p1l4proj ) ); - assert( l4.perpendicular_plane( p1l4proj ).has_on( p1 ) ); + assert( l4.has_on( p1l4proj ) || nonexact ); + assert( l4.perpendicular_plane( p1l4proj ).has_on( p1l4proj ) || nonexact ); + assert( l4.perpendicular_plane( p1l4proj ).has_on( p1 ) || nonexact ); CGAL::Point_3 p4 = l4.projection(p2); CGAL::Point_3 p5 = l4.projection(p3); assert( ( l4.direction() == ( p5 - p4 ).direction() )\ - ||( l4.direction() == ( p4 - p5 ).direction() ) ); + ||( l4.direction() == ( p4 - p5 ).direction() ) || nonexact ); assert( l5.direction() == - l6.direction() ); std::cout <<'.'; assert( l2.has_on(p1) ); assert( l2.has_on(p2) ); - assert( l4.has_on(p4) ); + assert( l4.has_on(p4) || nonexact ); assert( l4.has_on(p5) ); assert( CGAL::Line_3(p1,p1).is_degenerate() ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_sphere_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_sphere_3.h index 69bac242dae..f3428f32226 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_sphere_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_sphere_3.h @@ -26,6 +26,7 @@ #include #include +#include template bool @@ -38,6 +39,7 @@ _test_cls_sphere_3(const R& ) typename R::Sphere_3 ic; CGAL::Sphere_3 c0; + const bool nonexact = boost::is_same::value; RT n0 = 0; RT n1 = 16; RT n2 = -4; @@ -104,8 +106,8 @@ _test_cls_sphere_3(const R& ) assert( cn3 == cp3.opposite() ); assert( c7.opposite() == c8 ); assert( c8.opposite() == c7 ); - assert( c1.opposite() == c3 ); - assert( c3.opposite() == c1 ); + assert( c1.opposite() == c3 || nonexact ); + assert( c3.opposite() == c1 || nonexact ); assert( c7.orientation() == CGAL::POSITIVE ); assert( c8.orientation() == CGAL::NEGATIVE ); assert( c5.orientation() == CGAL::POSITIVE ); @@ -181,22 +183,22 @@ _test_cls_sphere_3(const R& ) CGAL::Point_3 ori = CGAL::Point_3( RT(0), RT(0), RT(0)); CGAL::Point_3 p6 = p2.transform( rotate1 ); - assert( CGAL::compare_distance_to_point( ori, p2, p6) == CGAL::EQUAL ); + assert( CGAL::compare_distance_to_point( ori, p2, p6) == CGAL::EQUAL || nonexact ); CGAL::Point_3 p7 = p2.transform( rotate2 ); - assert( CGAL::compare_distance_to_point( ori, p2, p7) == CGAL::EQUAL ); + assert( CGAL::compare_distance_to_point( ori, p2, p7) == CGAL::EQUAL || nonexact ); CGAL::Point_3 p8 = p2.transform( rotate3 ); - assert( CGAL::compare_distance_to_point( ori, p2, p8) == CGAL::EQUAL ); + assert( CGAL::compare_distance_to_point( ori, p2, p8) == CGAL::EQUAL || nonexact ); CGAL::Point_3 p9 = p2.transform( rotate4 ); assert( CGAL::compare_distance_to_point( ori, p2, p9) == CGAL::EQUAL ); CGAL::Point_3 p10 = p2.transform( rotate5 ); - assert( CGAL::compare_distance_to_point( ori, p2, p10) == CGAL::EQUAL ); + assert( CGAL::compare_distance_to_point( ori, p2, p10) == CGAL::EQUAL || nonexact ); p6 = p6 + v1; p7 = p7 + v1; p8 = p8 + v1; p9 = p9 + v1; p10 = p10 + v1; CGAL::Sphere_3 c10 (p6, p8, p7, p9); - assert( c10.center() == ori + v1 ); + assert( c10.center() == ori + v1 || nonexact ); assert( c10.orientation() == CGAL::POSITIVE ); assert( c10.opposite().orientation() == CGAL::NEGATIVE ); @@ -205,9 +207,9 @@ _test_cls_sphere_3(const R& ) == CGAL::ON_POSITIVE_SIDE ); assert( c10.oriented_side(CGAL::ORIGIN + v1 + vx*n2 ) \ == CGAL::ON_NEGATIVE_SIDE ); - assert( c10.oriented_side(p9 ) == CGAL::ON_ORIENTED_BOUNDARY ); - assert( c10.has_on_boundary(p9) ); - assert( c10.has_on_boundary(p4 + v1) ); + assert( c10.oriented_side(p9 ) == CGAL::ON_ORIENTED_BOUNDARY || nonexact ); + assert( c10.has_on_boundary(p9) || nonexact ); + assert( c10.has_on_boundary(p4 + v1) || nonexact ); CGAL::Point_3 p11( n4, n4, n4, n3) ; // (2.5, 2.5, 2.5) CGAL::Point_3 p12( n5, n5, n5, n3) ; // ( 5 , 5, 5 ) assert( c10.has_on_bounded_side( p11 ) ); @@ -217,8 +219,8 @@ _test_cls_sphere_3(const R& ) assert( c10.has_on_negative_side( p12 ) ); assert( c10.opposite().has_on_negative_side( p11 ) ); assert( c10.opposite().has_on_positive_side( p12 ) ); - assert( c10.has_on_boundary( p6 ) ); - assert( c10.has_on_boundary( p8 ) ); + assert( c10.has_on_boundary( p6 ) || nonexact ); + assert( c10.has_on_boundary( p8 ) || nonexact ); std::cout << '.'; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_points_implicit_sphere.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_points_implicit_sphere.h index abf69f2fe5b..97cf0c43e41 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_points_implicit_sphere.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_points_implicit_sphere.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_FCT_POINTS_IMPLICIT_SPHERE_H #define CGAL__TEST_FCT_POINTS_IMPLICIT_SPHERE_H +#include + template bool _test_fct_points_implicit_sphere(const R&) @@ -32,6 +34,8 @@ _test_fct_points_implicit_sphere(const R&) typedef typename R::FT FT; typedef CGAL::Tetrahedron_3 Tetrahedron; + const bool nonexact = boost::is_same::value; + const RT RT0(0); const RT RT4(4); const FT FT1(1); @@ -70,7 +74,7 @@ _test_fct_points_implicit_sphere(const R&) CGAL::Point_3 tpt = p.transform(rot_z); assert( CGAL::squared_distance( tpt, org ) == FT1 ); p = tpt.transform(rot_z); - assert( CGAL::squared_distance( p, org ) == FT1 ); + assert( CGAL::squared_distance( p, org ) == FT1 || nonexact ); CGAL::rational_rotation_approximation( RT(35), RT(-8), sin, cos, den, @@ -82,9 +86,9 @@ _test_fct_points_implicit_sphere(const R&) assert( CGAL::squared_distance( q, org ) == FT1 ); tpt = q.transform(rot_x); - assert( CGAL::squared_distance( tpt, org ) == FT1 ); + assert( CGAL::squared_distance( tpt, org ) == FT1 || nonexact ); q = tpt.transform(rot_y); - assert( CGAL::squared_distance( q, org ) == FT1 ); + assert( CGAL::squared_distance( q, org ) == FT1 || nonexact ); CGAL::rational_rotation_approximation( RT(9), RT(-8), sin, cos, den, @@ -98,7 +102,7 @@ _test_fct_points_implicit_sphere(const R&) tpt = r.transform(rot_z); assert( CGAL::squared_distance( tpt, org ) == FT1 ); r = tpt.transform(rot_y); - assert( CGAL::squared_distance( r, org ) == FT1 ); + assert( CGAL::squared_distance( r, org ) == FT1 || nonexact ); CGAL::rational_rotation_approximation( RT(-19), RT(-1), sin, cos, den, @@ -137,11 +141,11 @@ _test_fct_points_implicit_sphere(const R&) CGAL::Point_3 ez( RT0, RT0, RT1); CGAL::Point_3 oz( RT0, RT0, -RT1); assert( CGAL::circumcenter(ex, ey, ez, oz) == org ); - assert( CGAL::circumcenter(p,q,r,s) == org ); - assert( CGAL::circumcenter(p,r,q,s) == org ); + assert( CGAL::circumcenter(p,q,r,s) == org || nonexact ); + assert( CGAL::circumcenter(p,r,q,s) == org || nonexact ); assert( CGAL::circumcenter(Tetrahedron(ex, ey, ez, oz)) == org ); - assert( CGAL::circumcenter(Tetrahedron(p,q,r,s)) == org ); - assert( CGAL::circumcenter(Tetrahedron(p,r,q,s)) == org ); + assert( CGAL::circumcenter(Tetrahedron(p,q,r,s)) == org || nonexact ); + assert( CGAL::circumcenter(Tetrahedron(p,r,q,s)) == org || nonexact ); CGAL::Vector_3 v( RT(12), RT(4), RT(-4), RT(2) ); CGAL::Point_3 pt = p + v; @@ -169,10 +173,10 @@ _test_fct_points_implicit_sphere(const R&) assert( CGAL::side_of_bounded_sphere(pt,rt,qt,st,ot) \ == CGAL::ON_UNBOUNDED_SIDE); - assert( CGAL::circumcenter(pt,qt,rt,st) == c ); - assert( CGAL::circumcenter(pt,rt,qt,st) == c ); - assert( CGAL::circumcenter(Tetrahedron(pt,qt,rt,st)) == c ); - assert( CGAL::circumcenter(Tetrahedron(pt,rt,qt,st)) == c ); + assert( CGAL::circumcenter(pt,qt,rt,st) == c || nonexact ); + assert( CGAL::circumcenter(pt,rt,qt,st) == c || nonexact ); + assert( CGAL::circumcenter(Tetrahedron(pt,qt,rt,st)) == c || nonexact ); + assert( CGAL::circumcenter(Tetrahedron(pt,rt,qt,st)) == c || nonexact ); // Now test side_of_bounded_sphere(p, q, t). diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_3.h index 11d455778db..b860bc86c3d 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_3.h @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -37,6 +38,7 @@ _test_fct_weighted_point_3(const R& ) std::cout << "Testing functions Weighted_point_3" ; typedef typename R::RT RT; + const bool nonexact = boost::is_same::value; CGAL::Point_3 p1(RT(18), RT(15), RT(-21), RT(3) ); // 6, 5, -7 CGAL::Point_3 p2(RT(18), RT(15), RT( 12), RT(3) ); // 6, 5, 4 @@ -138,7 +140,7 @@ _test_fct_weighted_point_3(const R& ) assert( CGAL::power_side_of_bounded_power_sphere(wp3_b, wp1_b, wp6b_b) == CGAL::ON_BOUNDED_SIDE ); assert( CGAL::power_side_of_bounded_power_sphere(wp1_b, wp3_b, wp6b_b) == CGAL::ON_BOUNDED_SIDE ); - assert( CGAL::coplanar(p4, p5, p6, p7) ); + assert( CGAL::coplanar(p4, p5, p6, p7) || nonexact ); assert( CGAL::power_side_of_bounded_power_sphere(wp4, wp5, wp6, wp7) == CGAL::side_of_bounded_sphere(p4, p5, p6, p7) ); assert( CGAL::power_side_of_bounded_power_sphere(wp4, wp5, wp6, wp5) @@ -171,11 +173,11 @@ _test_fct_weighted_point_3(const R& ) assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1_b, wp3_b) == RT(164)); assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1, wp3, wp5) - == CGAL::squared_radius(p1, p3, p5)); + == CGAL::squared_radius(p1, p3, p5) || nonexact); assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp000, wp100, wp010) == RT(0)); assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp1, wp3, wp4, wp5) - == CGAL::squared_radius(p1, p3, p4, p5)); + == CGAL::squared_radius(p1, p3, p4, p5) || nonexact); assert( CGAL::squared_radius_smallest_orthogonal_sphere(wp000, wp100, wp010, wp001) == RT(0)); std::cout << "."; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h index cf498947577..828b0493d0e 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h @@ -25,6 +25,7 @@ #define CGAL__TEST_FURTHER_FCT_POINT_2_H #include "_approx_equal.h" +#include template bool @@ -100,6 +101,8 @@ _test_further_fct_point_2(const R& ) using CGAL::testsuite::approx_equal; using CGAL::testsuite::Direction_2_tag; + const bool nonexact = boost::is_same::value; + assert( approx_equal((p5 - CGAL::ORIGIN).direction(), dir5, Direction_2_tag()) ); assert( CGAL::side_of_bounded_circle(p1, p2, p3, CGAL::Point_2(CGAL::ORIGIN))\ @@ -107,15 +110,15 @@ _test_further_fct_point_2(const R& ) assert( CGAL::side_of_bounded_circle(p1+v, p2+v, p3+v, CGAL::ORIGIN + v) \ == CGAL::ON_BOUNDED_SIDE ); assert( CGAL::side_of_bounded_circle(p1+v, p2+v, p3+v, CGAL::ORIGIN - v) \ - == CGAL::ON_UNBOUNDED_SIDE ); + == CGAL::ON_UNBOUNDED_SIDE || nonexact); assert( CGAL::side_of_bounded_circle(p1, p2, p3, p4) \ - == CGAL::ON_BOUNDARY ); + == CGAL::ON_BOUNDARY || nonexact); assert( CGAL::side_of_bounded_circle(p1+v, p2+v, p3+v, p4+v) \ - == CGAL::ON_BOUNDARY ); + == CGAL::ON_BOUNDARY || nonexact); assert( CGAL::side_of_bounded_circle(p1+v, p3+v, p4+v, p2+v) \ - == CGAL::ON_BOUNDARY ); + == CGAL::ON_BOUNDARY || nonexact); assert( CGAL::side_of_bounded_circle(p2+v, p4+v, p1+v, p3+v) \ - == CGAL::ON_BOUNDARY ); + == CGAL::ON_BOUNDARY || nonexact); assert( CGAL::orientation( p1, p2, p3 ) == CGAL::POSITIVE ); @@ -130,11 +133,11 @@ _test_further_fct_point_2(const R& ) assert( CGAL::side_of_oriented_circle(p2+v, p1+v, p3+v, CGAL::ORIGIN - v) \ == CGAL::ON_POSITIVE_SIDE ); assert( CGAL::side_of_oriented_circle(p1, p2, p3, p4) \ - == CGAL::ON_ORIENTED_BOUNDARY ); + == CGAL::ON_ORIENTED_BOUNDARY || nonexact); assert( CGAL::side_of_oriented_circle(p1+v, p2+v, p3+v, p4+v) \ - == CGAL::ON_ORIENTED_BOUNDARY ); + == CGAL::ON_ORIENTED_BOUNDARY || nonexact); assert( CGAL::side_of_oriented_circle(p1+v, p3+v, p4+v, p2+v) \ - == CGAL::ON_ORIENTED_BOUNDARY ); + == CGAL::ON_ORIENTED_BOUNDARY || nonexact); CGAL::Point_2 p10( RT(100), RT(100), RT(10) ); CGAL::Point_2 p11( RT(-100), RT(-100), RT(10) ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_mf_plane_3_to_2d.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_mf_plane_3_to_2d.h index 48348c0e2c6..d86c33d2e2f 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_mf_plane_3_to_2d.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_mf_plane_3_to_2d.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_MF_PLANE_3_TO_2D_H #define CGAL__TEST_MF_PLANE_3_TO_2D_H +#include + template bool _test_mf_plane_3_to_2d(const R& ) @@ -35,6 +37,8 @@ _test_mf_plane_3_to_2d(const R& ) typedef CGAL::Point_3< R> Point_3; typedef CGAL::Point_2< R> Point_2; + const bool nonexact = boost::is_same::value; + RT n0 = 0; RT n1 = 7; RT n2 = 21; @@ -51,33 +55,33 @@ _test_mf_plane_3_to_2d(const R& ) Point_3 p4 = p3 + (p2 - p1); Plane_3 pl1( p1, p2, p3); - assert( pl1.has_on( pl1.to_3d( pl1.to_2d( pl1.point() ))) ); - assert( pl1.has_on( pl1.to_3d( pl1.to_2d( p4 ))) ); - assert( p1 == pl1.to_3d( pl1.to_2d( p1)) ); - assert( p2 == pl1.to_3d( pl1.to_2d( p2)) ); - assert( p3 == pl1.to_3d( pl1.to_2d( p3)) ); - assert( p4 == pl1.to_3d( pl1.to_2d( p4)) ); + assert( pl1.has_on( pl1.to_3d( pl1.to_2d( pl1.point() ))) || nonexact ); + assert( pl1.has_on( pl1.to_3d( pl1.to_2d( p4 ))) || nonexact ); + assert( p1 == pl1.to_3d( pl1.to_2d( p1)) || nonexact ); + assert( p2 == pl1.to_3d( pl1.to_2d( p2)) || nonexact ); + assert( p3 == pl1.to_3d( pl1.to_2d( p3)) || nonexact ); + assert( p4 == pl1.to_3d( pl1.to_2d( p4)) || nonexact ); std::cout << '.'; Plane_3 pl2( p2, p1, p3); - assert( pl2.has_on( pl2.to_3d( pl2.to_2d( pl2.point() ))) ); - assert( pl2.has_on( pl2.to_3d( pl2.to_2d( p4 ))) ); - assert( p1 == pl2.to_3d( pl2.to_2d( p1)) ); - assert( p2 == pl2.to_3d( pl2.to_2d( p2)) ); - assert( p3 == pl2.to_3d( pl2.to_2d( p3)) ); - assert( p4 == pl2.to_3d( pl2.to_2d( p4)) ); + assert( pl2.has_on( pl2.to_3d( pl2.to_2d( pl2.point() ))) || nonexact ); + assert( pl2.has_on( pl2.to_3d( pl2.to_2d( p4 ))) || nonexact ); + assert( p1 == pl2.to_3d( pl2.to_2d( p1)) || nonexact ); + assert( p2 == pl2.to_3d( pl2.to_2d( p2)) || nonexact ); + assert( p3 == pl2.to_3d( pl2.to_2d( p3)) || nonexact ); + assert( p4 == pl2.to_3d( pl2.to_2d( p4)) || nonexact ); Point_3 p5( n2, n8, n0, n7); Point_3 p6( n4, n5, n0, n8); Plane_3 pl3( p4, p5, p6); - assert( p4 == pl3.to_3d( pl3.to_2d( p4)) ); + assert( p4 == pl3.to_3d( pl3.to_2d( p4)) || nonexact ); assert( p5 == pl3.to_3d( pl3.to_2d( p5)) ); - assert( p6 == pl3.to_3d( pl3.to_2d( p6)) ); + assert( p6 == pl3.to_3d( pl3.to_2d( p6)) || nonexact ); Plane_3 pl4( p4, p6, p5); - assert( p4 == pl4.to_3d( pl4.to_2d( p4)) ); + assert( p4 == pl4.to_3d( pl4.to_2d( p4)) || nonexact ); assert( p5 == pl4.to_3d( pl4.to_2d( p5)) ); - assert( p6 == pl4.to_3d( pl4.to_2d( p6)) ); + assert( p6 == pl4.to_3d( pl4.to_2d( p6)) || nonexact ); Point_3 p7 = CGAL::midpoint( p1, p2); Point_3 p8 = CGAL::midpoint( p3, p3 + (p2-p1) ); @@ -98,14 +102,14 @@ _test_mf_plane_3_to_2d(const R& ) CGAL::Segment_2 sp2( pp9, pp10); Point_2 pp; assert( CGAL::assign( pp, CGAL::intersection( sp1, sp2)) ); - assert( sp1.has_on( pp) ); - assert( sp2.has_on( pp) ); + assert( sp1.has_on( pp) || nonexact ); + assert( sp2.has_on( pp) || nonexact ); Point_3 p = pl1.to_3d( pp); - assert( pl1.has_on( p )); + assert( pl1.has_on( p ) || nonexact ); CGAL::Segment_3 s1( p7, p8); CGAL::Segment_3 s2( p9, p10); - assert( s1.has_on( p) ); - assert( s2.has_on( p) ); + assert( s1.has_on( p) || nonexact ); + assert( s2.has_on( p) || nonexact ); std::cout << '.' << std::endl; return true; From 30b25a4d58684681e04d21fffa3143dc383d9763 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 14 Jun 2019 11:09:40 +0200 Subject: [PATCH 163/203] Fix warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was a unused assigned variable: ``` test/Kernel_23/include/CGAL/_test_new_2.h:375:6: warning: variable ‘tmp22d’ set but not used [-Wunused-but-set-variable] 375 | FT tmp22d = Compute_squared_distance(p1, p2); | ^~~~~~ ``` and also use of uninitialized variable. That pattern was used a lot: ``` typename R::Iso_cuboid_3 ir; CGAL::Iso_cuboid_3 r0(ir); ``` that is: - create a default-initialized object, - then copy it. Default-initialized object cannot be copied without a warning. --- .../test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h | 8 +++++--- .../Kernel_23/include/CGAL/_test_cls_iso_rectangle_2.h | 8 +++++--- Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_2.h | 5 ++++- .../test/Kernel_23/include/CGAL/_test_cls_triangle_2.h | 8 +++++--- Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h | 9 +++++---- Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h | 6 +++--- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h index 0307fe1f38f..b4fa97c2f29 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h @@ -26,6 +26,7 @@ #include #include +#include template bool @@ -36,9 +37,6 @@ _test_cls_iso_cuboid_3(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; - typename R::Iso_cuboid_3 ir; - CGAL::Iso_cuboid_3 r0(ir); - RT n1 = 1; RT n2 = 2; RT n3 = 3; @@ -65,6 +63,10 @@ _test_cls_iso_cuboid_3(const R& ) CGAL::Point_3 p12(n1, n1, n3 ); // ( 1, 1, 3) CGAL::Point_3 p13(n4, n1, n3 ); // ( 4, 1, 3) + typename R::Iso_cuboid_3 ir0; CGAL_USE(ir0); // test default-construction + typename R::Iso_cuboid_3 ir( p1, p3); + CGAL::Iso_cuboid_3 r0(ir); + const CGAL::Iso_cuboid_3 r1( p1, p3); CGAL::Iso_cuboid_3 r1_( p1, p3, 0); CGAL::Iso_cuboid_3 r2( p3, p1); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_rectangle_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_rectangle_2.h index c2411734ff9..1f488e830af 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_rectangle_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_rectangle_2.h @@ -26,6 +26,7 @@ #include #include +#include template bool @@ -36,9 +37,6 @@ _test_cls_iso_rectangle_2(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; - typename R::Iso_rectangle_2 ir; - CGAL::Iso_rectangle_2 r0(ir); - RT n1 = 1; RT n2 = 2; RT n3 = 3; @@ -59,6 +57,10 @@ _test_cls_iso_rectangle_2(const R& ) CGAL::Point_2 p8( n4, n6, n2); // ( 2, 3) CGAL::Point_2 p9(-n3, n7); // (-3, 7) + typename R::Iso_rectangle_2 ir0; CGAL_USE(ir0); // test default-construction + typename R::Iso_rectangle_2 ir(p1, p3); + CGAL::Iso_rectangle_2 r0(ir); + const CGAL::Iso_rectangle_2 r1( p1, p3); CGAL::Iso_rectangle_2 r1_( p1, p3, 0); CGAL::Iso_rectangle_2 r2( p3, p1); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_2.h index 7c16868a588..f9895fb0270 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_line_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_CLS_LINE_2_H #define CGAL__TEST_CLS_LINE_2_H +#include + template bool _test_cls_line_2(const R& ) @@ -47,7 +49,8 @@ _test_cls_line_2(const R& ) CGAL::Point_2 p3(-n6, n6, n3 ); // (-2, 2 ) CGAL::Point_2 p4( n8, n4, n2 ); // ( 4, 2 ) - typename R::Line_2 il; + typename R::Line_2 il0; CGAL_USE(il0); // test default-construction + typename R::Line_2 il(p1, p2); CGAL::Line_2 l0(il); CGAL::Line_2 l12( p1, p2 ); CGAL::Line_2 l21( p2, p1 ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_2.h index 4c1a4c28655..06f9afd582a 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_2.h @@ -26,6 +26,7 @@ #include #include +#include template bool @@ -36,9 +37,6 @@ _test_cls_triangle_2(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; - typename R::Triangle_2 it; - CGAL::Triangle_2 t0(it); - RT n0 = 0; RT n1 = 1; RT n2 = 2; @@ -62,6 +60,10 @@ _test_cls_triangle_2(const R& ) CGAL::Point_2 p8(-n12,-n8,-n2); // ( 6, 4) CGAL::Point_2 p9( n9, n9, n3); // ( 3, 3) + typename R::Triangle_2 it0; CGAL_USE(it0); // test default-construction + typename R::Triangle_2 it(p1, p2, p3); + CGAL::Triangle_2 t0(it); + CGAL::Triangle_2 t1( p1, p3, p5); CGAL::Triangle_2 t2( p3, p1, p5); CGAL::Triangle_2 t3( p7, p8, p9); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h index ae3ae7fbbe8..59f0a94a19a 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h @@ -35,7 +35,7 @@ #include "_test_cls_iso_rectangle_new_2.h" #include "_test_cls_circle_new_2.h" -#include +#include using CGAL::internal::use; @@ -175,8 +175,8 @@ test_new_2(const R& rep) typename R::Construct_triangle_2 construct_triangle = rep.construct_triangle_2_object(); - Triangle_2 t1; - Triangle_2 t2 = construct_triangle(p2,p3,p4); + Triangle_2 t0; CGAL_USE(t0); // test default-construction + Triangle_2 t2 = construct_triangle(p2,p3,p4), t1 = t2; typename R::Construct_iso_rectangle_2 construct_iso_rectangle = rep.construct_iso_rectangle_2_object(); @@ -379,6 +379,7 @@ test_new_2(const R& rep) typename R::Compute_power_product_2 compute_power_product = rep.compute_power_product_2_object(); tmp22d = compute_power_product(wp6, wp7); + CGAL_USE(tmp22d); typename R::Compute_squared_length_2 Compute_squared_length = rep.compute_squared_length_2_object(); @@ -672,7 +673,7 @@ test_new_2(const R& rep) use(tmp9); use(tmp10); use(tmp11); use(tmp12); use(tmp12a); use(tmp14); use(tmp14a); use(tmp15); use(tmp16); use(tmp16); use(tmp17); use(tmp19); use(tmp19a); use(tmp22a); - use(tmp22b); use(tmp22c); use(tmp23); + use(tmp22b); use(tmp22c); use(tmp22d); use(tmp23); use(tmp58); use(tmp57); use(tmp56); use(tmp55); use(tmp54); use(tmp53b); use(tmp53a); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h index c9493e57108..f78c879628f 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h @@ -29,7 +29,7 @@ #include #include -#include +#include using CGAL::internal::use; @@ -157,8 +157,8 @@ test_new_3(const R& rep) typename R::Construct_segment_3 construct_segment = rep.construct_segment_3_object(); - Segment_3 s1; - Segment_3 s2 = construct_segment(p2,p3); + Segment_3 s0; CGAL_USE(s0); // test default-construction + Segment_3 s2 = construct_segment(p2,p3), s1 = s2; typename R::Construct_ray_3 construct_ray = rep.construct_ray_3_object(); From 3f76dfb056365bdbfefcf604f0de23d466df9582 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 14 Jun 2019 12:59:02 +0200 Subject: [PATCH 164/203] take the offset into account in the test is_clipped() of the Selection functor. --- .../Plugins/Point_set/Point_set_selection_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp index 8b6f4f59a26..063bc14da48 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp @@ -143,9 +143,9 @@ public: if(!static_cast(CGAL::QGLViewer::QGLViewerPool().first())->isClipping()) return true; - double x = p.x(), y = p.y(), z = p.z(); + double x = p.x()+offset.x, y = p.y()+offset.y, z = p.z()+offset.z; - return !(clipbox[0][0]*x+clipbox[0][1]*y+clipbox[0][2]*z+clipbox[0][3]>0 || + return !(clipbox[0][0]*x+clipbox[0][1]*y+clipbox[0][2]*z+clipbox[0][3] >0 || clipbox[1][0]*x+clipbox[1][1]*y+clipbox[1][2]*z+clipbox[1][3]>0 || clipbox[2][0]*x+clipbox[2][1]*y+clipbox[2][2]*z+clipbox[2][3]>0 || clipbox[3][0]*x+clipbox[3][1]*y+clipbox[3][2]*z+clipbox[3][3]>0 || From e15dbd02aa4a41e658b5de6e3c782802f4c89be2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 14 Jun 2019 15:47:43 +0200 Subject: [PATCH 165/203] Use const& --- Triangulation_2/examples/Triangulation_2/constrained.cpp | 2 +- .../examples/Triangulation_2/polylines_triangulation.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Triangulation_2/examples/Triangulation_2/constrained.cpp b/Triangulation_2/examples/Triangulation_2/constrained.cpp index 84ff46a8155..9901ec05fd3 100644 --- a/Triangulation_2/examples/Triangulation_2/constrained.cpp +++ b/Triangulation_2/examples/Triangulation_2/constrained.cpp @@ -22,7 +22,7 @@ main( ) assert(cdt.is_valid()); int count = 0; - for (Edge e : cdt.finite_edges()) + for (const Edge& e : cdt.finite_edges()) if (cdt.is_constrained(e)) ++count; std::cout << "The number of resulting constrained edges is "; diff --git a/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp b/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp index 623194cbf8e..60ab20dd663 100644 --- a/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp +++ b/Triangulation_2/examples/Triangulation_2/polylines_triangulation.cpp @@ -34,7 +34,7 @@ contexts(const CDTP& cdtp) if(cdtp.number_of_enclosing_constraints(vp, vq) == 2){ std::cout << "subconstraint " << vp->point() << " " << vq->point() << " is on constraints starting at:\n"; - for(CDTP::Context c : cdtp.contexts(vp,vq)){ + for(const CDTP::Context& c : cdtp.contexts(vp,vq)){ std::cout << (*(c.vertices_begin()))->point() << std::endl; } } From 1e1bfa1675bb5accdf53ae0531f4d6d264725c8e Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Sat, 15 Jun 2019 22:30:47 +0200 Subject: [PATCH 166/203] constness --- .../internal/Polyline_constraint_hierarchy_2.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h index e40da6fa737..7b6f3bb38b5 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h @@ -170,9 +170,9 @@ public: : enclosing(hc.enclosing), pos(hc.pos) {} - Vertex_it vertices_begin() { return enclosing->skip_begin();} - Vertex_it current() {return pos;} - Vertex_it vertices_end() {return enclosing->skip_end();} + Vertex_it vertices_begin()const { return enclosing->skip_begin();} + Vertex_it current()const {return pos;} + Vertex_it vertices_end()const {return enclosing->skip_end();} Constraint_id id() { return enclosing; } std::size_t number_of_vertices() const {return enclosing->skip_size(); } }; From 07a88a6b0b6c19660889058db379b7f8cebccf41 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 17 Jun 2019 08:59:42 +0200 Subject: [PATCH 167/203] Reset .travis.yml --- .travis.yml | 22 +++++++++++----------- .travis/generate_travis.sh | 15 ++++++++++----- .travis/packages.txt | 8 ++++---- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index abb5bbfd54b..da8787d8579 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,10 @@ env: - PACKAGE='AABB_tree Advancing_front_surface_reconstruction Algebraic_foundations ' - PACKAGE='Algebraic_kernel_d Algebraic_kernel_for_circles Algebraic_kernel_for_spheres ' - PACKAGE='Alpha_shapes_2 Alpha_shapes_3 Apollonius_graph_2 ' - - PACKAGE='Arithmetic_kernel Arrangement_on_surface_2 Barycentric_coordinates_2 ' - - PACKAGE='BGL Boolean_set_operations_2 Bounding_volumes ' - - PACKAGE='Box_intersection_d Cartesian_kernel CGAL_Core ' - - PACKAGE='CGAL_ImageIO CGAL_ipelets Circular_kernel_2 ' + - PACKAGE='Arithmetic_kernel Arrangement_on_surface_2 BGL ' + - PACKAGE='Barycentric_coordinates_2 Boolean_set_operations_2 Bounding_volumes ' + - PACKAGE='Box_intersection_d CGAL_Core CGAL_ImageIO ' + - PACKAGE='CGAL_ipelets Cartesian_kernel Circular_kernel_2 ' - PACKAGE='Circular_kernel_3 Circulator Classification ' - PACKAGE='Combinatorial_map Cone_spanners_2 Convex_decomposition_3 ' - PACKAGE='Convex_hull_2 Convex_hull_3 Convex_hull_d ' @@ -39,15 +39,15 @@ env: - PACKAGE='Polynomial Polytope_distance_d Principal_component_analysis ' - PACKAGE='Principal_component_analysis_LGPL Profiling_tools Property_map ' - PACKAGE='QP_solver Random_numbers Ridges_3 ' - - PACKAGE='Scale_space_reconstruction_3 Scripts SearchStructures ' - - PACKAGE='Segment_Delaunay_graph_2 Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 ' - - PACKAGE='Skin_surface_3 Snap_rounding_2 Solver_interface ' - - PACKAGE='Spatial_searching Spatial_sorting STL_Extension ' + - PACKAGE='STL_Extension Scale_space_reconstruction_3 Scripts ' + - PACKAGE='SearchStructures Segment_Delaunay_graph_2 Segment_Delaunay_graph_Linf_2 ' + - PACKAGE='Set_movable_separability_2 Skin_surface_3 Snap_rounding_2 ' + - PACKAGE='Solver_interface Spatial_searching Spatial_sorting ' - PACKAGE='Straight_skeleton_2 Stream_lines_2 Stream_support ' - PACKAGE='Subdivision_method_3 Surface_mesh Surface_mesh_approximation ' - - PACKAGE='Surface_mesh_deformation Surface_mesher Surface_mesh_parameterization ' - - PACKAGE='Surface_mesh_segmentation Surface_mesh_shortest_path Surface_mesh_simplification ' - - PACKAGE='Surface_mesh_skeletonization Surface_sweep_2 TDS_2 ' + - PACKAGE='Surface_mesh_deformation Surface_mesh_parameterization Surface_mesh_segmentation ' + - PACKAGE='Surface_mesh_shortest_path Surface_mesh_simplification Surface_mesh_skeletonization ' + - PACKAGE='Surface_mesher Surface_sweep_2 TDS_2 ' - PACKAGE='TDS_3 Testsuite Three ' - PACKAGE='Triangulation Triangulation_2 Triangulation_3 ' - PACKAGE='Union_find Visibility_2 Voronoi_diagram_2 ' diff --git a/.travis/generate_travis.sh b/.travis/generate_travis.sh index 6f70a2d0eb6..c770c9600f0 100755 --- a/.travis/generate_travis.sh +++ b/.travis/generate_travis.sh @@ -21,16 +21,20 @@ for f in * do if [ -d "$f/package_info/$f" ] then - PACKAGES[$INDEX]+="$f " + echo "$f " >> ./tmp.txt + fi +done + LC_ALL=C sort ./tmp.txt > ./.travis/packages.txt + rm ./tmp.txt + while read p; do + PACKAGES[$INDEX]+="$p " i=$[i+1] if [ $i = 3 ] then i=0 INDEX=$[INDEX+1] fi - echo "$f " >> ./.travis/packages.txt - fi -done +done <./.travis/packages.txt if [ -f ".travis.yml" ] then #copy the current .travis.yml for later check @@ -73,7 +77,8 @@ IFS=$' ' #check if there are differences between the files if ! cmp -s ./.travis.yml ./.travis.old; then - echo ".travis.yml has changed" + echo ".travis.yml has changed : " + diff ./.travis.yml ./.travis.old if [ -n "$CHECK" ]; then echo "You should modify the file .travis/template.txt" exit 1 diff --git a/.travis/packages.txt b/.travis/packages.txt index fa151634628..717ce2050e2 100644 --- a/.travis/packages.txt +++ b/.travis/packages.txt @@ -9,15 +9,15 @@ Alpha_shapes_3 Apollonius_graph_2 Arithmetic_kernel Arrangement_on_surface_2 -Barycentric_coordinates_2 BGL +Barycentric_coordinates_2 Boolean_set_operations_2 Bounding_volumes Box_intersection_d -Cartesian_kernel CGAL_Core CGAL_ImageIO CGAL_ipelets +Cartesian_kernel Circular_kernel_2 Circular_kernel_3 Circulator @@ -97,6 +97,7 @@ Property_map QP_solver Random_numbers Ridges_3 +STL_Extension Scale_space_reconstruction_3 Scripts SearchStructures @@ -108,7 +109,6 @@ Snap_rounding_2 Solver_interface Spatial_searching Spatial_sorting -STL_Extension Straight_skeleton_2 Stream_lines_2 Stream_support @@ -116,12 +116,12 @@ Subdivision_method_3 Surface_mesh Surface_mesh_approximation Surface_mesh_deformation -Surface_mesher Surface_mesh_parameterization Surface_mesh_segmentation Surface_mesh_shortest_path Surface_mesh_simplification Surface_mesh_skeletonization +Surface_mesher Surface_sweep_2 TDS_2 TDS_3 From d5320f661737735695b604f2ba44d679d54e653c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 17 Jun 2019 09:01:46 +0200 Subject: [PATCH 168/203] Reset travis.yml from 4.14 --- .travis.yml | 22 +++++++++++----------- .travis/generate_travis.sh | 15 +++++---------- .travis/packages.txt | 8 ++++---- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index da8787d8579..abb5bbfd54b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,10 @@ env: - PACKAGE='AABB_tree Advancing_front_surface_reconstruction Algebraic_foundations ' - PACKAGE='Algebraic_kernel_d Algebraic_kernel_for_circles Algebraic_kernel_for_spheres ' - PACKAGE='Alpha_shapes_2 Alpha_shapes_3 Apollonius_graph_2 ' - - PACKAGE='Arithmetic_kernel Arrangement_on_surface_2 BGL ' - - PACKAGE='Barycentric_coordinates_2 Boolean_set_operations_2 Bounding_volumes ' - - PACKAGE='Box_intersection_d CGAL_Core CGAL_ImageIO ' - - PACKAGE='CGAL_ipelets Cartesian_kernel Circular_kernel_2 ' + - PACKAGE='Arithmetic_kernel Arrangement_on_surface_2 Barycentric_coordinates_2 ' + - PACKAGE='BGL Boolean_set_operations_2 Bounding_volumes ' + - PACKAGE='Box_intersection_d Cartesian_kernel CGAL_Core ' + - PACKAGE='CGAL_ImageIO CGAL_ipelets Circular_kernel_2 ' - PACKAGE='Circular_kernel_3 Circulator Classification ' - PACKAGE='Combinatorial_map Cone_spanners_2 Convex_decomposition_3 ' - PACKAGE='Convex_hull_2 Convex_hull_3 Convex_hull_d ' @@ -39,15 +39,15 @@ env: - PACKAGE='Polynomial Polytope_distance_d Principal_component_analysis ' - PACKAGE='Principal_component_analysis_LGPL Profiling_tools Property_map ' - PACKAGE='QP_solver Random_numbers Ridges_3 ' - - PACKAGE='STL_Extension Scale_space_reconstruction_3 Scripts ' - - PACKAGE='SearchStructures Segment_Delaunay_graph_2 Segment_Delaunay_graph_Linf_2 ' - - PACKAGE='Set_movable_separability_2 Skin_surface_3 Snap_rounding_2 ' - - PACKAGE='Solver_interface Spatial_searching Spatial_sorting ' + - PACKAGE='Scale_space_reconstruction_3 Scripts SearchStructures ' + - PACKAGE='Segment_Delaunay_graph_2 Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 ' + - PACKAGE='Skin_surface_3 Snap_rounding_2 Solver_interface ' + - PACKAGE='Spatial_searching Spatial_sorting STL_Extension ' - PACKAGE='Straight_skeleton_2 Stream_lines_2 Stream_support ' - PACKAGE='Subdivision_method_3 Surface_mesh Surface_mesh_approximation ' - - PACKAGE='Surface_mesh_deformation Surface_mesh_parameterization Surface_mesh_segmentation ' - - PACKAGE='Surface_mesh_shortest_path Surface_mesh_simplification Surface_mesh_skeletonization ' - - PACKAGE='Surface_mesher Surface_sweep_2 TDS_2 ' + - PACKAGE='Surface_mesh_deformation Surface_mesher Surface_mesh_parameterization ' + - PACKAGE='Surface_mesh_segmentation Surface_mesh_shortest_path Surface_mesh_simplification ' + - PACKAGE='Surface_mesh_skeletonization Surface_sweep_2 TDS_2 ' - PACKAGE='TDS_3 Testsuite Three ' - PACKAGE='Triangulation Triangulation_2 Triangulation_3 ' - PACKAGE='Union_find Visibility_2 Voronoi_diagram_2 ' diff --git a/.travis/generate_travis.sh b/.travis/generate_travis.sh index c770c9600f0..6f70a2d0eb6 100755 --- a/.travis/generate_travis.sh +++ b/.travis/generate_travis.sh @@ -21,20 +21,16 @@ for f in * do if [ -d "$f/package_info/$f" ] then - echo "$f " >> ./tmp.txt - fi -done - LC_ALL=C sort ./tmp.txt > ./.travis/packages.txt - rm ./tmp.txt - while read p; do - PACKAGES[$INDEX]+="$p " + PACKAGES[$INDEX]+="$f " i=$[i+1] if [ $i = 3 ] then i=0 INDEX=$[INDEX+1] fi -done <./.travis/packages.txt + echo "$f " >> ./.travis/packages.txt + fi +done if [ -f ".travis.yml" ] then #copy the current .travis.yml for later check @@ -77,8 +73,7 @@ IFS=$' ' #check if there are differences between the files if ! cmp -s ./.travis.yml ./.travis.old; then - echo ".travis.yml has changed : " - diff ./.travis.yml ./.travis.old + echo ".travis.yml has changed" if [ -n "$CHECK" ]; then echo "You should modify the file .travis/template.txt" exit 1 diff --git a/.travis/packages.txt b/.travis/packages.txt index 717ce2050e2..fa151634628 100644 --- a/.travis/packages.txt +++ b/.travis/packages.txt @@ -9,15 +9,15 @@ Alpha_shapes_3 Apollonius_graph_2 Arithmetic_kernel Arrangement_on_surface_2 -BGL Barycentric_coordinates_2 +BGL Boolean_set_operations_2 Bounding_volumes Box_intersection_d +Cartesian_kernel CGAL_Core CGAL_ImageIO CGAL_ipelets -Cartesian_kernel Circular_kernel_2 Circular_kernel_3 Circulator @@ -97,7 +97,6 @@ Property_map QP_solver Random_numbers Ridges_3 -STL_Extension Scale_space_reconstruction_3 Scripts SearchStructures @@ -109,6 +108,7 @@ Snap_rounding_2 Solver_interface Spatial_searching Spatial_sorting +STL_Extension Straight_skeleton_2 Stream_lines_2 Stream_support @@ -116,12 +116,12 @@ Subdivision_method_3 Surface_mesh Surface_mesh_approximation Surface_mesh_deformation +Surface_mesher Surface_mesh_parameterization Surface_mesh_segmentation Surface_mesh_shortest_path Surface_mesh_simplification Surface_mesh_skeletonization -Surface_mesher Surface_sweep_2 TDS_2 TDS_3 From 34a9b24698934acb382fa54b228764878a8937ce Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 17 Jun 2019 10:03:56 +0200 Subject: [PATCH 169/203] Fix a remaining warning about t1 not being initialized There are a lot of uninitialized variables, in that testsuite, that are used anyway (like copied). Strangely the compilers do not seem to catch them all at the same time. That probably depends on inlinings. --- Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h index f78c879628f..6b5939a9afa 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h @@ -214,11 +214,10 @@ test_new_3(const R& rep) Sphere_3 sp8 = construct_sphere(p3); Sphere_3 sp9 = construct_sphere(p3,CLOCKWISE); - + Triangle_3 t0; CGAL_USE(t0); // test the default-construction typename R::Construct_triangle_3 construct_triangle = rep.construct_triangle_3_object(); - Triangle_3 t1; - Triangle_3 t2 = construct_triangle(p2,p3,p4); + Triangle_3 t1 = construct_triangle(p2,p3,p4), t2 = t1; typename R::Construct_tetrahedron_3 construct_tetrahedron = rep.construct_tetrahedron_3_object(); From 22fb28d57e09bbe0d8f30f9056f806d13c21c6db Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 17 Jun 2019 13:47:05 +0200 Subject: [PATCH 170/203] Modify the name when multiple source items --- .../Plugins/Mesh_3/Mesh_3_plugin.cpp | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp index 77d08116016..0b173ec59d6 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Mesh_3_plugin.cpp @@ -132,6 +132,7 @@ private: Messages_interface* msg; QMessageBox* message_box_; Scene_item* source_item_; + QString source_item_name_; CGAL::Three::Scene_interface* scene; QMainWindow* mw; bool as_facegraph; @@ -212,7 +213,7 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) } } Scene_item* item = nullptr; - bool more_than_one_item = false; + const bool more_than_one_item = sm_items.size() > 1; bool features_protection_available = false; if(!sm_items.empty()) { @@ -340,9 +341,18 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) connect(ui.protect, SIGNAL(toggled(bool)), ui.protectEdges, SLOT(setEnabled(bool))); + QString item_name = more_than_one_item ? + QString("%1...").arg(item->name()) : + item->name(); + // Set default parameters CGAL::Three::Scene_interface::Bbox bbox = item->bbox(); - ui.objectName->setText(item->name()); + if(more_than_one_item) { + for(auto it: sm_items) { + bbox = bbox + it->bbox(); + } + } + ui.objectName->setText(item_name); ui.objectNameSize->setText(tr("Object bbox size (w,h,d): %1, %2, %3") .arg(bbox.xmax() - bbox.xmin(),0,'g',3) .arg(bbox.ymax() - bbox.ymin(),0,'g',3) @@ -465,7 +475,7 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) thread = cgal_code_mesh_3(polyhedrons, (polylines_item == nullptr)?plc:polylines_item->polylines, bounding_polyhedron, - item->name(), + item_name, angle, facet_sizing, approx, @@ -542,6 +552,7 @@ void Mesh_3_plugin::mesh_3(const bool surface_only, const bool use_defaults) // Launch thread source_item_ = item; + source_item_name_ = item_name; launch_thread(thread); QApplication::restoreOverrideCursor(); @@ -605,7 +616,7 @@ meshing_done(Meshing_thread* thread) { // Print message in console QString str = QString("Meshing of \"%1\" done in %2s
    ") - .arg(source_item_->name()) + .arg(source_item_name_) .arg(thread->time()); Q_FOREACH( QString param, thread->parameters_log() ) @@ -645,7 +656,7 @@ treat_result(Scene_item& source_item, { if(!as_facegraph) { - result_item->setName(tr("%1 [3D Mesh]").arg(source_item.name())); + result_item->setName(tr("%1 [3D Mesh]").arg(source_item_name_)); result_item->c3t3_changed(); @@ -671,7 +682,7 @@ treat_result(Scene_item& source_item, { Scene_surface_mesh_item* new_item = new Scene_surface_mesh_item; CGAL::facets_in_complex_3_to_triangle_mesh(result_item->c3t3(), *new_item->face_graph()); - new_item->setName(tr("%1 [Remeshed]").arg(source_item.name())); + new_item->setName(tr("%1 [Remeshed]").arg(source_item_name_)); Q_FOREACH(int ind, scene->selectionIndices()) { scene->item(ind)->setVisible(false); } From 1970d94c5329397be8babadf5f5f4e63571bb813 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 17 Jun 2019 14:03:55 +0200 Subject: [PATCH 171/203] Add a function to Surface_mesh that reads a range of surface_meshes from a 3mf file. --- Stream_support/include/CGAL/IO/read_3mf.h | 15 +-- .../test/Stream_support/test_3mf_to_sm.cpp | 49 +++---- .../include/CGAL/Surface_mesh/IO/3mf.h | 125 ++++++++++++++++++ 3 files changed, 148 insertions(+), 41 deletions(-) create mode 100644 Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h diff --git a/Stream_support/include/CGAL/IO/read_3mf.h b/Stream_support/include/CGAL/IO/read_3mf.h index f528c79de2f..1d6ee3cd3d4 100644 --- a/Stream_support/include/CGAL/IO/read_3mf.h +++ b/Stream_support/include/CGAL/IO/read_3mf.h @@ -18,8 +18,8 @@ // // Author(s) : Maxime Gimeno -#ifndef READ_3MF_H -#define READ_3MF_H +#ifndef CGAL_IO_READ_3MF_H +#define CGAL_IO_READ_3MF_H #include #include #include @@ -43,7 +43,7 @@ NMR::MODELTRANSFORM initMatrix() return mMatrix; } -}//end internal +}//end transform_nmr_internal template int read_soups_from_3mf(const std::string& file_name, PointRanges& all_points, @@ -654,5 +653,5 @@ int read_point_clouds_from_3mf(const std::string& file_name, } }//end CGAL -#endif // READ_3MF_H +#endif // CGAL_IO_READ_3MF_H diff --git a/Stream_support/test/Stream_support/test_3mf_to_sm.cpp b/Stream_support/test/Stream_support/test_3mf_to_sm.cpp index 31578a5bca5..5c96e769ed9 100644 --- a/Stream_support/test/Stream_support/test_3mf_to_sm.cpp +++ b/Stream_support/test/Stream_support/test_3mf_to_sm.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -27,49 +28,31 @@ typedef std::vector ColorRange; int main(int argc, char** argv) { - if( argc != 2) - { - std::cerr<<"please give an input 3mf file."; - return 1; - } + const char* file_name=(argc == 2) ? argv[1] : "data/test.3mf"; + std::vector all_points; std::vector all_polygons; std::vector all_colors; std::vector names; + std::vector meshes; //testing reading functions. int nb_meshes = - CGAL::read_soups_from_3mf(argv[1], all_points, all_polygons, - all_colors, names); + CGAL::read_3mf(file_name, meshes); if(nb_meshes <0) return 1; for(std::size_t i = 0; i< nb_meshes; ++i) { - PolygonRange triangles = all_polygons[i]; - PointRange points = all_points[i]; - bool ok = true; - if(!PMP::is_polygon_soup_a_polygon_mesh(triangles)) - ok = PMP::orient_polygon_soup(points, triangles); - if(!ok) - { - std::cerr<<"Object is not orientable. Skipped."< meshes(2); + meshes.resize(2); meshes[0] = sphere; meshes[1] = tube; CGAL::write_triangle_meshes_to_3mf("meshes.3mf", meshes, names); diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h new file mode 100644 index 00000000000..36acfa11e37 --- /dev/null +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h @@ -0,0 +1,125 @@ +// Copyright (c) 2019 Geometry Factory +// 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$ +// SPDX-License-Identifier: LGPL-3.0+ +// +// Author(s) : Maxime Gimeno + + +#ifndef CGAL_SURFACE_MESH_IO_3MF_H +#define CGAL_SURFACE_MESH_IO_3MF_H + +#include +#include +#include + +namespace CGAL{ +/*! + * Extracts the surface meshes from an input 3mf file and appends it to `output`. + *\tparam SurfaceMeshRange a model of the concepts `RandomAccessContainer` and + * `BackInsertionSequence` whose `value type` is `CGAL::Surface_mesh`. + * \param file_name the path to the 3mf file. + * \param output the `SurfaceMeshRange` that will be filled by this function. + * \return the number of extracted surface meshes. + */ + +template +int read_3mf(const std::string& file_name, + std::vector >& output) +{ + typedef std::vector PointRange; + typedef std::vector Polygon; + typedef std::vector PolygonRange; + typedef CGAL::Surface_mesh SMesh; + typedef typename SMesh::Vertex_index Vertex_index; + typedef typename SMesh::Face_index Face_index; + + std::vector all_points; + std::vector all_polygons; + std::vector names; + std::vector > all_colors; + int result = 0; + int nb_meshes = + CGAL::read_soups_from_3mf(file_name, + all_points, all_polygons, all_colors, names); + if(nb_meshes < 0 ) + { + std::cerr << "Error in reading meshes."< colors = all_colors[i]; + //Create the surface mesh from scratch + std::size_t n(points.size()); + sm.reserve(n,0, triangles.size()); + for(const Point& p : points) + { + sm.add_vertex(p); + } + + for(Polygon& triangle : triangles) + { + std::vector face; + face.reserve(triangle.size()); + for(auto index : triangle) + { + face.push_back(Vertex_index(index)); + } + Face_index fi = sm.add_face(face); + if(fi == sm.null_face()) + { + skip = true; + sm.clear(); + break; + } + } + if(skip) + continue; + //end constructin the surface mesh from scratch + + CGAL::Color first = colors.front(); + bool need_pmap = false; + for(auto color : colors) + { + if (color != first) + { + need_pmap = true; + break; + } + } + if(need_pmap) + { + typename SMesh::template Property_map fcolor = + sm.template add_property_map("f:color",first).first; + for(std::size_t pid = 0; pid < colors.size(); ++pid) + { + put(fcolor, Face_index(pid), colors[pid]);//should work bc mesh is just created and shouldn't have any destroyed face. + } + } + output.push_back(sm); + ++result; + } + return result; +} + +}//end CGAL +#endif // CGAL_SURFACE_MESH_3MF_H From 7de29bdd9373f68ca288aea1ca4f436ade1356c4 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 17 Jun 2019 14:06:12 +0200 Subject: [PATCH 172/203] update doc --- Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h index 36acfa11e37..1fd956c8e76 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h @@ -29,11 +29,10 @@ namespace CGAL{ /*! * Extracts the surface meshes from an input 3mf file and appends it to `output`. - *\tparam SurfaceMeshRange a model of the concepts `RandomAccessContainer` and - * `BackInsertionSequence` whose `value type` is `CGAL::Surface_mesh`. + *\tparam Point the Point type of the output meshes. * \param file_name the path to the 3mf file. - * \param output the `SurfaceMeshRange` that will be filled by this function. - * \return the number of extracted surface meshes. + * \param output a `std::vector` containing the `CGAL::Surface_mesh`s that will be filled by this function. + * \return the number of extracted meshes. */ template From c5174f693c89bcdd0b00835968c5e50d1b4be66f Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 17 Jun 2019 14:07:27 +0200 Subject: [PATCH 173/203] Rename soup function --- Stream_support/include/CGAL/IO/read_3mf.h | 2 +- Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Stream_support/include/CGAL/IO/read_3mf.h b/Stream_support/include/CGAL/IO/read_3mf.h index 1d6ee3cd3d4..cbd1dbd6c40 100644 --- a/Stream_support/include/CGAL/IO/read_3mf.h +++ b/Stream_support/include/CGAL/IO/read_3mf.h @@ -600,7 +600,7 @@ int read_from_3mf(const std::string& file_name, PointRanges& all_points, * \return the number of soups read. */ template -int read_soups_from_3mf(const std::string& file_name, PointRanges& all_points, +int read_triangle_soups_from_3mf(const std::string& file_name, PointRanges& all_points, PolygonRanges& all_polygons, ColorRanges& all_colors, std::vector& names ) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h index 1fd956c8e76..4ca44a0e890 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/3mf.h @@ -52,7 +52,7 @@ int read_3mf(const std::string& file_name, std::vector > all_colors; int result = 0; int nb_meshes = - CGAL::read_soups_from_3mf(file_name, + CGAL::read_triangle_soups_from_3mf(file_name, all_points, all_polygons, all_colors, names); if(nb_meshes < 0 ) { From 86ca13a388767e036f63b88e0cb6f85aae8d974f Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 17 Jun 2019 14:11:32 +0200 Subject: [PATCH 174/203] change behavior when soup is not orientable in the demo. --- .../Polyhedron/Plugins/IO/3mf_io_plugin.cpp | 61 +++++++++---------- Stream_support/include/CGAL/IO/write_3mf.h | 8 +-- 2 files changed, 33 insertions(+), 36 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp index b72e3cb1971..4b3c921dce5 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp @@ -133,7 +133,7 @@ class Io_3mf_plugin: names.clear(); all_colors.clear(); int nb_meshes = - CGAL::read_soups_from_3mf(fileinfo.filePath().toUtf8().toStdString(), + CGAL::read_triangle_soups_from_3mf(fileinfo.filePath().toUtf8().toStdString(), all_points, all_polygons, all_colors, names); if(nb_meshes <0 ) { @@ -151,42 +151,39 @@ class Io_3mf_plugin: ok = PMP::orient_polygon_soup(points, triangles); if(!ok) { - std::cerr<<"Object is not orientable. Skipped."< fcolor = - mesh.add_property_map("f:color",first).first; - for(std::size_t pid = 0; pid < colors.size(); ++pid) - { - put(fcolor, face_descriptor(pid), colors[pid]);//should work bc mesh is just created and shouldn't have any destroyed face. Not so sure bc of orientation though. - } - } - Scene_surface_mesh_item* sm_item = new Scene_surface_mesh_item(mesh); - if(first == CGAL::Color(0,0,0,0)) - first = CGAL::Color(50,80,120,255); - sm_item->setColor(QColor(first.red(), first.green(), first.blue())); - sm_item->setProperty("already_colored", true); - sm_item->setName(names[i].data()); - sm_item->invalidateOpenGLBuffers(); - result << sm_item; - if(add_to_scene) - CGAL::Three::Three::scene()->addItem(sm_item); } + if(need_pmap) + { + SMesh::Property_map fcolor = + mesh.add_property_map("f:color",first).first; + for(std::size_t pid = 0; pid < colors.size(); ++pid) + { + put(fcolor, face_descriptor(pid), colors[pid]);//should work bc mesh is just created and shouldn't have any destroyed face. Not so sure bc of orientation though. + } + } + Scene_surface_mesh_item* sm_item = new Scene_surface_mesh_item(mesh); + if(first == CGAL::Color(0,0,0,0)) + first = CGAL::Color(50,80,120,255); + sm_item->setColor(QColor(first.red(), first.green(), first.blue())); + sm_item->setProperty("already_colored", true); + sm_item->setName(names[i].data()); + sm_item->invalidateOpenGLBuffers(); + result << sm_item; + if(add_to_scene) + CGAL::Three::Three::scene()->addItem(sm_item); } ok = true; return result; diff --git a/Stream_support/include/CGAL/IO/write_3mf.h b/Stream_support/include/CGAL/IO/write_3mf.h index de335110f3c..8f66e342767 100644 --- a/Stream_support/include/CGAL/IO/write_3mf.h +++ b/Stream_support/include/CGAL/IO/write_3mf.h @@ -18,15 +18,15 @@ // // Author(s) : Maxime Gimeno -#ifndef WRITE_3MF_H -#define WRITE_3MF_H +#ifndef CGAL_IO_WRITE_3MF_H +#define CGAL_IO_WRITE_3MF_H #include #include #include #include -#include "Model/COM/NMR_DLLInterfaces.h" +#include namespace CGAL{ namespace tmf_internal{ @@ -465,4 +465,4 @@ bool write_triangle_meshes_to_3mf(const std::string& file_name, return write_triangle_soups_to_3mf(file_name, all_points, all_polygons, names); } }//end CGAL -#endif // WRITE_3MF_H +#endif // CGAL_IO_WRITE_3MF_H From b1a37a0f1e835aa106bd3466276dcc74ec861d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 17 Jun 2019 15:16:39 +0200 Subject: [PATCH 175/203] Update CHANGES.md --- Installation/CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 6af7f7aa97d..292a5bc594d 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -45,6 +45,11 @@ Release date: September 2019 `CGAL::Polygon_mesh_processing::stitch_boundary_cycles()`, which can be used to try and merge together geometrically compatible but combinatorially different halfedges that belong to the same boundary cycle. +- It is now possible to pass a face-size property map to `CGAL::Polygon_mesh_processing::keep_large_connected_components()` + and `CGAL::Polygon_mesh_processing::keep_largest_connected_components()`, enabling users to define + how the size of a face is computed (the size of the connected component is the sum of the sizes of its faces). + If no property map is passed, the behavior is unchanged to previous versions: the size + of a connected component is the number of faces it contains. ### IO Streams - **Breaking change:** The API of `CGAL::Color` has been cleaned up. From 4e15225e982bcb288ef831990d7bcba290d71417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Jun 2019 11:04:09 +0200 Subject: [PATCH 176/203] Derecursify 'expand_conflict_region' --- .../include/CGAL/Segment_Delaunay_graph_2.h | 25 +- .../Segment_Delaunay_graph_2_impl.h | 296 ++++++++++-------- .../Segment_Delaunay_graph_hierarchy_2_impl.h | 3 +- ...ent_Delaunay_graph_Linf_hierarchy_2_impl.h | 3 +- 4 files changed, 185 insertions(+), 142 deletions(-) diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h index 24aa1ed5478..1d78f845f6a 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1448,16 +1449,22 @@ protected: std::pair find_faces_to_split(const Vertex_handle& v, const Site_2& t) const; - void expand_conflict_region(const Face_handle& f, const Site_2& t, - const Storage_site_2& ss, -#ifdef CGAL_SDG_NO_FACE_MAP - List& l, -#else - List& l, Face_map& fm, - std::map& sign_map, + bool check_unregistered_face(const Face_handle& n, + const Site_2& t, + List& l, +#ifndef CGAL_SDG_NO_FACE_MAP + Face_map& fm, #endif - Triple& vcross); + Triple& vcross); + + void expand_conflict_region(const Face_handle& in_f, + const Site_2& t, + List& l, +#ifndef CGAL_SDG_NO_FACE_MAP + Face_map& fm, + std::map& sign_map, +#endif + Triple& vcross); Vertex_handle add_bogus_vertex(Edge e, List& l); Vertex_list add_bogus_vertices(List& l); diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h index bdd4d43e1a7..83c47c96006 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h @@ -465,9 +465,9 @@ insert_point2(const Storage_site_2& ss, const Site_2& t, // REGION AND EXPANDS THE CONFLICT REGION. initialize_conflict_region(start_f, l); #ifdef CGAL_SDG_NO_FACE_MAP - expand_conflict_region(start_f, t, ss, l, vcross); + expand_conflict_region(start_f, t, l, vcross); #else - expand_conflict_region(start_f, t, ss, l, fm, sign_map, vcross); + expand_conflict_region(start_f, t, l, fm, sign_map, vcross); #endif CGAL_assertion( !vcross.first ); @@ -846,9 +846,9 @@ insert_segment_interior(const Site_2& t, const Storage_site_2& ss, // REGION AND EXPANDS THE CONFLICT REGION. initialize_conflict_region(start_f, l); #ifdef CGAL_SDG_NO_FACE_MAP - expand_conflict_region(start_f, t, ss, l, vcross); + expand_conflict_region(start_f, t, l, vcross); #else - expand_conflict_region(start_f, t, ss, l, fm, sign_map, vcross); + expand_conflict_region(start_f, t, l, fm, sign_map, vcross); #endif CGAL_assertion( vcross.third == AT2::DISJOINT || @@ -958,152 +958,190 @@ initialize_conflict_region(const Face_handle& f, List& l) template -void +bool Segment_Delaunay_graph_2:: -expand_conflict_region(const Face_handle& f, const Site_2& t, - const Storage_site_2& ss, -#ifdef CGAL_SDG_NO_FACE_MAP - List& l, -#else - List& l, Face_map& fm, - std::map& sign_map, +check_unregistered_face(const Face_handle& n, + const Site_2& t, + List& l, +#ifndef CGAL_SDG_NO_FACE_MAP + Face_map& fm, #endif - Triple& vcross) + Triple& vcross) { + for (int j = 0; j < 3; ++j) + { + Vertex_handle vf = n->vertex(j); + + if ( is_infinite(vf) ) + continue; + + Arrangement_type at_res = arrangement_type(t, vf); + + CGAL_assertion( vcross.third == AT2::DISJOINT || + vcross.third == AT2::CROSSING || + vcross.third == AT2::INTERIOR ); + + if ( vf->is_segment() ) + { + CGAL_assertion( at_res != AT2::IDENTICAL ); + CGAL_assertion( at_res != AT2::TOUCH_11_INTERIOR_1 ); + CGAL_assertion( at_res != AT2::TOUCH_12_INTERIOR_1 ); + + if ( at_res == AT2::CROSSING ) + { + vcross.first = true; + vcross.second = vf; + vcross.third = AT2::CROSSING; + l.clear(); #ifdef CGAL_SDG_NO_FACE_MAP - if ( f->tds_data().is_in_conflict() ) { return; } + fhc_.clear(); #else - if ( fm.find(f) != fm.end() ) { return; } + fm.clear(); #endif - - // this is done to stop the recursion when intersecting segments - // are found - if ( vcross.first ) { return; } - - // setting fm[f] to true means that the face has been reached and - // that the face is available for recycling. If we do not want the - // face to be available for recycling we must set this flag to - // false. -#ifdef CGAL_SDG_NO_FACE_MAP - f->tds_data().mark_in_conflict(); - fhc_.push_back(f); -#else - fm[f] = true; -#endif - - // CGAL_assertion( fm.find(f) != fm.end() ); - - for (int i = 0; i < 3; i++) { - Face_handle n = f->neighbor(i); - -#ifdef CGAL_SDG_NO_FACE_MAP - bool face_registered = n->tds_data().is_in_conflict(); -#else - bool face_registered = (fm.find(n) != fm.end()); -#endif - - if ( !face_registered ) { - for (int j = 0; j < 3; j++) { - Vertex_handle vf = n->vertex(j); - - if ( is_infinite(vf) ) { continue; } - - Arrangement_type at_res = arrangement_type(t, vf); - - CGAL_assertion( vcross.third == AT2::DISJOINT || - vcross.third == AT2::CROSSING || - vcross.third == AT2::INTERIOR ); - - if ( vf->is_segment() ) { - CGAL_assertion( at_res != AT2::IDENTICAL ); - CGAL_assertion( at_res != AT2::TOUCH_11_INTERIOR_1 ); - CGAL_assertion( at_res != AT2::TOUCH_12_INTERIOR_1 ); - - if ( at_res == AT2::CROSSING ) { - vcross.first = true; - vcross.second = vf; - vcross.third = AT2::CROSSING; - l.clear(); -#ifdef CGAL_SDG_NO_FACE_MAP - fhc_.clear(); -#else - fm.clear(); -#endif - return; - } else { - CGAL_assertion ( at_res == AT2::DISJOINT || - at_res == AT2::TOUCH_1 || - at_res == AT2::TOUCH_2 || - at_res == AT2::TOUCH_11 || - at_res == AT2::TOUCH_12 || - at_res == AT2::TOUCH_21 || - at_res == AT2::TOUCH_22 ); - // we do nothing in these cases - } - } else { - CGAL_assertion( vf->is_point() ); - if ( at_res == AT2::INTERIOR ) { - vcross.first = true; - vcross.second = vf; - vcross.third = AT2::INTERIOR; - l.clear(); -#ifdef CGAL_SDG_NO_FACE_MAP - fhc_.clear(); -#else - fm.clear(); -#endif - return; - } - } + return true; + } + else // at_res != AT2::CROSSING + { + CGAL_assertion ( at_res == AT2::DISJOINT || + at_res == AT2::TOUCH_1 || + at_res == AT2::TOUCH_2 || + at_res == AT2::TOUCH_11 || + at_res == AT2::TOUCH_12 || + at_res == AT2::TOUCH_21 || + at_res == AT2::TOUCH_22 ); + // we do nothing in these cases } } + else // ! vf->is_segment() + { + CGAL_assertion( vf->is_point() ); + if ( at_res == AT2::INTERIOR ) + { + vcross.first = true; + vcross.second = vf; + vcross.third = AT2::INTERIOR; + l.clear(); +#ifdef CGAL_SDG_NO_FACE_MAP + fhc_.clear(); +#else + fm.clear(); +#endif + return true; + } + } + } - Sign s = incircle(n, t); + return false; +} + +template +void +Segment_Delaunay_graph_2:: +expand_conflict_region(const Face_handle& in_f, + const Site_2& t, + List& l, +#ifndef CGAL_SDG_NO_FACE_MAP + Face_map& fm, + std::map& sign_map, +#endif + Triple& vcross) +{ + std::stack face_stack; + face_stack.push(in_f); + + while(!face_stack.empty()) + { + // Stop as soon as intersecting segments are found + if ( vcross.first ) + break; + + const Face_handle curr_f = face_stack.top(); + face_stack.pop(); #ifdef CGAL_SDG_NO_FACE_MAP - n->tds_data().set_incircle_sign(s); - - Sign s_f = f->tds_data().incircle_sign(); + if ( curr_f->tds_data().is_in_conflict() ) + continue; #else - sign_map[n] = s; - - Sign s_f = sign_map[f]; + if ( fm.find(curr_f) != fm.end() ) + continue; #endif - if ( s == POSITIVE ) { continue; } - if ( s != s_f ) { continue; } + // setting fm[f] to true means that the face has been reached and + // that the face is available for recycling. If we do not want the + // face to be available for recycling we must set this flag to false. +#ifdef CGAL_SDG_NO_FACE_MAP + curr_f->tds_data().mark_in_conflict(); + fhc_.push_back(curr_f); +#else + fm[curr_f] = true; +#endif - bool interior_in_conflict = edge_interior(f, i, t, s); +// CGAL_assertion( fm.find(curr_f) != fm.end() ); - if ( !interior_in_conflict ) { continue; } - - if ( face_registered ) { continue; } - - Edge e = sym_edge(f, i); - - CGAL_assertion( l.is_in_list(e) ); - int j = this->_tds.mirror_index(f, i); - Edge e_before = sym_edge(n, ccw(j)); - Edge e_after = sym_edge(n, cw(j)); - if ( !l.is_in_list(e_before) ) { - l.insert_before(e, e_before); - } - if ( !l.is_in_list(e_after) ) { - l.insert_after(e, e_after); - } - l.remove(e); + for (int i = 0; i < 3; ++i) + { + Face_handle n = curr_f->neighbor(i); #ifdef CGAL_SDG_NO_FACE_MAP - expand_conflict_region(n, t, ss, l, vcross); + bool face_registered = n->tds_data().is_in_conflict(); #else - expand_conflict_region(n, t, ss, l, fm, sign_map, vcross); + bool face_registered = (fm.find(n) != fm.end()); #endif - // this is done to stop the recursion when intersecting segments - // are found - // if ( fm.size() == 0 && l.size() == 0 ) { return; } - if ( vcross.first ) { return; } - } // for-loop + if ( !face_registered ) + { +#ifdef CGAL_SDG_NO_FACE_MAP + if(check_unregistered_face(n, t, l, vcross)) +#else + if(check_unregistered_face(n, t, l, fm, vcross)) +#endif + { + CGAL_assertion(vcross.first); + break; // intersecting segments were found + } + } + + Sign s = incircle(n, t); + +#ifdef CGAL_SDG_NO_FACE_MAP + n->tds_data().set_incircle_sign(s); + + Sign s_f = curr_f->tds_data().incircle_sign(); +#else + sign_map[n] = s; + + Sign s_f = sign_map[curr_f]; +#endif + + if ( s == POSITIVE ) + continue; + if ( s != s_f ) + continue; + if ( face_registered ) + continue; + + bool interior_in_conflict = edge_interior(curr_f, i, t, s); + if ( !interior_in_conflict ) + continue; + + Edge e = sym_edge(curr_f, i); + CGAL_assertion( l.is_in_list(e) ); + + int j = this->_tds.mirror_index(curr_f, i); + Edge e_before = sym_edge(n, ccw(j)); + Edge e_after = sym_edge(n, cw(j)); + + if ( !l.is_in_list(e_before) ) + l.insert_before(e, e_before); + + if ( !l.is_in_list(e_after) ) + l.insert_after(e, e_after); + + l.remove(e); + + face_stack.push(n); + } // neighbor for-loop + } } diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h index a5f635f1a37..1ddcca8dd44 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h @@ -478,8 +478,7 @@ insert_segment_interior(const Site_2& t, const Storage_site_2& ss, vcross(false, Vertex_handle(), AT2::DISJOINT); hierarchy[0]->initialize_conflict_region(start_f, l); - hierarchy[0]->expand_conflict_region(start_f, t, ss, l, fm, - sign_map, vcross); + hierarchy[0]->expand_conflict_region(start_f, t, l, fm, sign_map, vcross); CGAL_assertion( vcross.third == AT2::DISJOINT || vcross.third == AT2::CROSSING || diff --git a/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_hierarchy_2_impl.h b/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_hierarchy_2_impl.h index 218909e0213..b27bfb83685 100644 --- a/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_hierarchy_2_impl.h +++ b/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_hierarchy_2_impl.h @@ -520,8 +520,7 @@ insert_segment_interior(const Site_2& t, const Storage_site_2& ss, vcross(false, Vertex_handle(), AT2::DISJOINT); hierarchy[0]->initialize_conflict_region(start_f, l); - hierarchy[0]->expand_conflict_region(start_f, t, ss, l, fm, - sign_map, vcross); + hierarchy[0]->expand_conflict_region(start_f, t, l, fm, sign_map, vcross); CGAL_assertion( vcross.third == AT2::DISJOINT || vcross.third == AT2::CROSSING || From a6c528cd8f2873d0e90622eddbc46fd64c46c242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Jun 2019 13:18:25 +0200 Subject: [PATCH 177/203] Derecursify Apollonius_graph_2::expand_conflict_region() --- .../include/CGAL/Apollonius_graph_2.h | 3 +- .../Apollonius_graph_2_impl.h | 112 ++++++++++-------- 2 files changed, 66 insertions(+), 49 deletions(-) diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h index ae3fc8f8ef3..20c27711e82 100644 --- a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h @@ -32,8 +32,9 @@ #include -#include #include +#include +#include #include diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Apollonius_graph_2_impl.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Apollonius_graph_2_impl.h index a1be16f6372..c22ff29c1e3 100644 --- a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Apollonius_graph_2_impl.h +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Apollonius_graph_2_impl.h @@ -817,69 +817,85 @@ check_edge_for_hidden_sites(const Face_handle& f, int i, template void Apollonius_graph_2:: -expand_conflict_region(const Face_handle& f, const Site_2& p, - List& l, Face_map& fm, Vertex_map& vm, - std::vector* fe) +expand_conflict_region(const Face_handle& in_f, + const Site_2& p, + List& l, + Face_map& fm, + Vertex_map& vm, + std::vector* fe) { - // setting fm[f] to true means that the face has been reached and - // that the face is available for recycling. If we do not want the - // face to be available for recycling we must set this flag to - // false. - fm[f] = true; + std::stack face_stack; + face_stack.push(in_f); - // CGAL_assertion( fm.find(f) != fm.end() ); - for (int i = 0; i < 3; i++) { - bool hidden_found = - check_edge_for_hidden_sites(f, i, p, vm); + while(!face_stack.empty()) + { + const Face_handle curr_f = face_stack.top(); + face_stack.pop(); - Face_handle n = f->neighbor(i); + // setting fm[curr_f] to true means that the face has been reached and + // that the face is available for recycling. If we do not want the + // face to be available for recycling we must set this flag to false. + fm[curr_f] = true; - if ( !hidden_found ) { - Sign s = incircle(n, p); - if ( s != NEGATIVE ) { continue; } + // CGAL_assertion( fm.find(curr_f) != fm.end() ); + for (int i = 0; i < 3; ++i) + { + bool hidden_found = check_edge_for_hidden_sites(curr_f, i, p, vm); - bool interior_in_conflict = edge_interior(f, i, p, true); + Face_handle n = curr_f->neighbor(i); - if ( !interior_in_conflict ) { continue; } - } + if ( !hidden_found ) + { + Sign s = incircle(n, p); + if ( s != NEGATIVE ) + continue; - if ( fm.find(n) != fm.end() ) { - Edge e = sym_edge(f, i); - if ( l.is_in_list(e) || - l.is_in_list(sym_edge(e)) ) { - l.remove(e); - l.remove(sym_edge(e)); + bool interior_in_conflict = edge_interior(curr_f, i, p, true); + if ( !interior_in_conflict ) + continue; } - continue; - } - Edge e = sym_edge(f, i); + if ( fm.find(n) != fm.end() ) + { + Edge e = sym_edge(curr_f, i); + if ( l.is_in_list(e) ) + l.remove(e); - CGAL_assertion( l.is_in_list(e) ); - int j = tds().mirror_index(f, i); - Edge e_before = sym_edge(n, ccw(j)); - Edge e_after = sym_edge(n, cw(j)); - if ( !l.is_in_list(e_before) ) { - l.insert_before(e, e_before); - } - if ( !l.is_in_list(e_after) ) { - l.insert_after(e, e_after); - } - l.remove(e); + if( l.is_in_list(sym_edge(e)) ) + l.remove(sym_edge(e)); - if ( fe != NULL ) { - Vh_triple* vhq = new Vh_triple[1]; + continue; + } - (*vhq)[0] = Vertex_handle(); - (*vhq)[1] = n->vertex( j ); - (*vhq)[2] = n->vertex( ccw(j) ); + Edge e = sym_edge(curr_f, i); + CGAL_assertion( l.is_in_list(e) ); - fe->push_back(vhq); - } + int j = tds().mirror_index(curr_f, i); + Edge e_before = sym_edge(n, ccw(j)); + Edge e_after = sym_edge(n, cw(j)); + if ( !l.is_in_list(e_before) ) + l.insert_before(e, e_before); - expand_conflict_region(n, p, l, fm, vm, fe); - } // for-loop + if ( !l.is_in_list(e_after) ) + l.insert_after(e, e_after); + + l.remove(e); + + if ( fe != NULL ) + { + Vh_triple* vhq = new Vh_triple[1]; + + (*vhq)[0] = Vertex_handle(); + (*vhq)[1] = n->vertex( j ); + (*vhq)[2] = n->vertex( ccw(j) ); + + fe->push_back(vhq); + } + + face_stack.push(n); + } // neighbor for-loop + } } From 51333214c0748f20ba0c26311e8224d3c0d20769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Jun 2019 13:18:51 +0200 Subject: [PATCH 178/203] Derecursify SDG_2::expand_conflict_region_remove() --- .../include/CGAL/Segment_Delaunay_graph_2.h | 10 +-- .../Segment_Delaunay_graph_2_impl.h | 88 +++++++++++-------- 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h index 1d78f845f6a..501ec5e4c7f 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h @@ -969,11 +969,11 @@ protected: std::map& vmap, List& l) const; - void expand_conflict_region_remove(const Face_handle& f, - const Site_2& t, - const Storage_site_2& ss, - List& l, Face_map& fm, - Sign_map& sign_map); + void expand_conflict_region_remove(const Face_handle& in_f, + const Site_2& t, + List& l, + Face_map& fm, + Sign_map& sign_map); void find_conflict_region_remove(const Vertex_handle& v, const Vertex_handle& vnearest, diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h index 83c47c96006..145c1a4b464 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h @@ -1601,56 +1601,72 @@ equalize_degrees(const Vertex_handle& v, Self& small_d, template void Segment_Delaunay_graph_2:: -expand_conflict_region_remove(const Face_handle& f, const Site_2& t, - const Storage_site_2& ss, - List& l, Face_map& fm, Sign_map& sign_map) +expand_conflict_region_remove(const Face_handle& in_f, + const Site_2& t, + List& l, + Face_map& fm, + Sign_map& sign_map) { - if ( fm.find(f) != fm.end() ) { return; } + std::stack face_stack; + face_stack.push(in_f); - // setting fm[f] to true means that the face has been reached and - // that the face is available for recycling. If we do not want the - // face to be available for recycling we must set this flag to - // false. - fm[f] = true; + while(!face_stack.empty()) + { + const Face_handle curr_f = face_stack.top(); + face_stack.pop(); - // CGAL_assertion( fm.find(f) != fm.end() ); + if ( fm.find(curr_f) != fm.end() ) + continue; - for (int i = 0; i < 3; i++) { - Face_handle n = f->neighbor(i); + // setting fm[curr_f] to true means that the face has been reached and + // that the face is available for recycling. If we do not want the + // face to be available for recycling we must set this flag to + // false. + fm[curr_f] = true; - bool face_registered = (fm.find(n) != fm.end()); + // CGAL_assertion( fm.find(f) != fm.end() ); - Sign s = incircle(n, t); + for (int i = 0; i < 3; ++i) + { + Face_handle n = curr_f->neighbor(i); - sign_map[n] = s; + bool face_registered = (fm.find(n) != fm.end()); - Sign s_f = sign_map[f]; + Sign s = incircle(n, t); - if ( s == POSITIVE ) { continue; } - if ( s != s_f ) { continue; } + sign_map[n] = s; - bool interior_in_conflict = edge_interior(f, i, t, s); + Sign s_f = sign_map[curr_f]; - if ( !interior_in_conflict ) { continue; } + if ( s == POSITIVE ) + continue; + if ( s != s_f ) + continue; + if ( face_registered ) + continue; - if ( face_registered ) { continue; } + bool interior_in_conflict = edge_interior(curr_f, i, t, s); + if ( !interior_in_conflict ) + continue; - Edge e = sym_edge(f, i); + Edge e = sym_edge(curr_f, i); + CGAL_assertion( l.is_in_list(e) ); - CGAL_assertion( l.is_in_list(e) ); - int j = this->_tds.mirror_index(f, i); - Edge e_before = sym_edge(n, ccw(j)); - Edge e_after = sym_edge(n, cw(j)); - if ( !l.is_in_list(e_before) ) { - l.insert_before(e, e_before); - } - if ( !l.is_in_list(e_after) ) { - l.insert_after(e, e_after); - } - l.remove(e); + int j = this->_tds.mirror_index(curr_f, i); + Edge e_before = sym_edge(n, ccw(j)); + Edge e_after = sym_edge(n, cw(j)); - expand_conflict_region_remove(n, t, ss, l, fm, sign_map); - } // for-loop + if ( !l.is_in_list(e_before) ) + l.insert_before(e, e_before); + + if ( !l.is_in_list(e_after) ) + l.insert_after(e, e_after); + + l.remove(e); + + face_stack.push(n); + } // neighbor for-loop + } } @@ -1728,7 +1744,7 @@ find_conflict_region_remove(const Vertex_handle& v, } initialize_conflict_region(start_f, l); - expand_conflict_region_remove(start_f, t, ss, l, fm, sign_map); + expand_conflict_region_remove(start_f, t, l, fm, sign_map); } From e4aaf2447caf6336d3872b399598e716128bcf5c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 18 Jun 2019 15:50:15 +0200 Subject: [PATCH 179/203] Fix the use of offset in Labeled_mesh_domain_3 --- CGAL_ImageIO/include/CGAL/Image_3.h | 4 ++++ Mesh_3/include/CGAL/Labeled_image_mesh_domain_3.h | 12 ++++++------ Mesh_3/include/CGAL/Labeled_mesh_domain_3.h | 8 ++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CGAL_ImageIO/include/CGAL/Image_3.h b/CGAL_ImageIO/include/CGAL/Image_3.h index 9b6e9bbd32c..3ae77477dd6 100644 --- a/CGAL_ImageIO/include/CGAL/Image_3.h +++ b/CGAL_ImageIO/include/CGAL/Image_3.h @@ -146,6 +146,10 @@ public: double vy() const { return image_ptr->vy; } double vz() const { return image_ptr->vz; } + double tx() const { return image_ptr->tx; } + double ty() const { return image_ptr->ty; } + double tz() const { return image_ptr->tz; } + float value(const std::size_t i, const std::size_t j, const std::size_t k) const diff --git a/Mesh_3/include/CGAL/Labeled_image_mesh_domain_3.h b/Mesh_3/include/CGAL/Labeled_image_mesh_domain_3.h index 275a4b312d8..e934e0a4187 100644 --- a/Mesh_3/include/CGAL/Labeled_image_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Labeled_image_mesh_domain_3.h @@ -109,12 +109,12 @@ private: /// Returns a box enclosing image \c im Bbox_3 compute_bounding_box(const Image& im) const { - return Bbox_3(-im.vx(), - -im.vy(), - -im.vz(), - double(im.xdim()+1)*im.vx(), - double(im.ydim()+1)*im.vy(), - double(im.zdim()+1)*im.vz()); + return Bbox_3(-im.vx()+im.tx(), + -im.vy()+im.ty(), + -im.vz()+im.tz(), + double(im.xdim()+1)*im.vx()+im.tx(), + double(im.ydim()+1)*im.vy()+im.ty(), + double(im.zdim()+1)*im.vz()+im.tz()); } }; // end class Labeled_image_mesh_domain_3 diff --git a/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h b/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h index 6a7acf56999..f5bd84ebd33 100644 --- a/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h @@ -88,10 +88,10 @@ namespace internal { /// Returns a box enclosing image \c im inline Bbox_3 compute_bounding_box(const Image_3& im) { - return Bbox_3(-1,-1,-1, - double(im.xdim())*im.vx()+1, - double(im.ydim())*im.vy()+1, - double(im.zdim())*im.vz()+1); + return Bbox_3(-1+im.tx(),-1+im.ty(),-1+im.tz(), + double(im.xdim())*im.vx()+im.tx()+1, + double(im.ydim())*im.vy()+im.ty()+1, + double(im.zdim())*im.vz()+im.tz()+1); } template From 4fbf00fb8a458a4b4466c221f24819366de4e74a Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 19 Jun 2019 14:34:59 +0200 Subject: [PATCH 180/203] CMake>=3.13: opt for for new policies up to 3.15 --- AABB_tree/benchmark/AABB_tree/CMakeLists.txt | 12 +----------- AABB_tree/demo/AABB_tree/CMakeLists.txt | 2 +- AABB_tree/examples/AABB_tree/CMakeLists.txt | 2 +- AABB_tree/test/AABB_tree/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../examples/Algebraic_foundations/CMakeLists.txt | 2 +- .../test/Algebraic_foundations/CMakeLists.txt | 2 +- .../examples/Algebraic_kernel_d/CMakeLists.txt | 2 +- .../test/Algebraic_kernel_d/CMakeLists.txt | 2 +- .../Algebraic_kernel_for_circles/CMakeLists.txt | 2 +- .../Algebraic_kernel_for_spheres/CMakeLists.txt | 2 +- .../examples/Alpha_shapes_2/CMakeLists.txt | 2 +- Alpha_shapes_2/test/Alpha_shapes_2/CMakeLists.txt | 2 +- Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt | 2 +- .../examples/Alpha_shapes_3/CMakeLists.txt | 2 +- Alpha_shapes_3/test/Alpha_shapes_3/CMakeLists.txt | 2 +- .../examples/Apollonius_graph_2/CMakeLists.txt | 2 +- .../test/Apollonius_graph_2/CMakeLists.txt | 2 +- .../test/Arithmetic_kernel/CMakeLists.txt | 2 +- .../demo/Arrangement_on_surface_2/CMakeLists.txt | 2 +- .../Arrangement_on_surface_2/CMakeLists.txt | 2 +- .../test/Arrangement_on_surface_2/CMakeLists.txt | 2 +- BGL/examples/BGL_LCC/CMakeLists.txt | 2 +- BGL/examples/BGL_OpenMesh/CMakeLists.txt | 2 +- BGL/examples/BGL_arrangement_2/CMakeLists.txt | 2 +- BGL/examples/BGL_polyhedron_3/CMakeLists.txt | 2 +- BGL/examples/BGL_surface_mesh/CMakeLists.txt | 2 +- BGL/examples/BGL_triangulation_2/CMakeLists.txt | 2 +- BGL/test/BGL/CMakeLists.txt | 2 +- .../Barycentric_coordinates_2/CMakeLists.txt | 2 +- .../test/Barycentric_coordinates_2/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../Boolean_set_operations_2/CMakeLists.txt | 2 +- .../test/Boolean_set_operations_2/CMakeLists.txt | 2 +- .../Approximate_min_ellipsoid_d/CMakeLists.txt | 2 +- .../examples/Min_annulus_d/CMakeLists.txt | 2 +- .../examples/Min_circle_2/CMakeLists.txt | 2 +- .../examples/Min_ellipse_2/CMakeLists.txt | 2 +- .../examples/Min_quadrilateral_2/CMakeLists.txt | 2 +- .../examples/Min_sphere_d/CMakeLists.txt | 2 +- .../Min_sphere_of_spheres_d/CMakeLists.txt | 2 +- .../examples/Rectangular_p_center_2/CMakeLists.txt | 2 +- .../test/Bounding_volumes/CMakeLists.txt | 2 +- .../examples/Box_intersection_d/CMakeLists.txt | 2 +- .../test/Box_intersection_d/CMakeLists.txt | 2 +- CGAL_Core/examples/Core/CMakeLists.txt | 2 +- .../archive/demo/CGALimageIO/CMakeLists.txt | 2 +- CGAL_ImageIO/examples/CGALimageIO/CMakeLists.txt | 2 +- CGAL_ImageIO/test/CGAL_ImageIO/CMakeLists.txt | 2 +- CGAL_ipelets/demo/CGAL_ipelets/CMakeLists.txt | 2 +- CGAL_ipelets/examples/CGAL_ipelets/CMakeLists.txt | 2 +- CMakeLists.txt | 2 +- .../examples/Circular_kernel_2/CMakeLists.txt | 2 +- .../test/Circular_kernel_2/CMakeLists.txt | 3 +-- .../demo/Circular_kernel_3/CMakeLists.txt | 2 +- .../examples/Circular_kernel_3/CMakeLists.txt | 2 +- .../test/Circular_kernel_3/CMakeLists.txt | 3 +-- Circulator/examples/Circulator/CMakeLists.txt | 2 +- Circulator/test/Circulator/CMakeLists.txt | 2 +- .../examples/Classification/CMakeLists.txt | 2 +- Classification/test/Classification/CMakeLists.txt | 2 +- .../examples/Combinatorial_map/CMakeLists.txt | 2 +- .../test/Combinatorial_map/CMakeLists.txt | 2 +- .../examples/Cone_spanners_2/CMakeLists.txt | 2 +- .../test/Cone_spanners_2/CMakeLists.txt | 2 +- .../examples/Convex_decomposition_3/CMakeLists.txt | 2 +- .../test/Convex_decomposition_3/CMakeLists.txt | 2 +- .../examples/Convex_hull_2/CMakeLists.txt | 2 +- Convex_hull_2/test/Convex_hull_2/CMakeLists.txt | 2 +- Convex_hull_3/demo/Convex_hull_3/CMakeLists.txt | 2 +- .../examples/Convex_hull_3/CMakeLists.txt | 2 +- Convex_hull_3/test/Convex_hull_3/CMakeLists.txt | 2 +- Convex_hull_d/test/Convex_hull_d/CMakeLists.txt | 2 +- Distance_2/test/Distance_2/CMakeLists.txt | 2 +- Distance_3/test/Distance_3/CMakeLists.txt | 2 +- Documentation/doc/CMakeLists.txt | 2 +- Envelope_2/examples/Envelope_2/CMakeLists.txt | 2 +- Envelope_2/test/Envelope_2/CMakeLists.txt | 2 +- Envelope_3/examples/Envelope_3/CMakeLists.txt | 2 +- Envelope_3/test/Envelope_3/CMakeLists.txt | 2 +- .../benchmark/Filtered_kernel/CMakeLists.txt | 2 +- .../examples/Filtered_kernel/CMakeLists.txt | 2 +- .../test/Filtered_kernel/CMakeLists.txt | 2 +- .../examples/Generalized_map/CMakeLists.txt | 2 +- .../test/Generalized_map/CMakeLists.txt | 2 +- Generator/benchmark/Generator/CMakeLists.txt | 2 +- Generator/examples/Generator/CMakeLists.txt | 2 +- Generator/test/Generator/CMakeLists.txt | 2 +- Geomview/demo/Geomview/CMakeLists.txt | 2 +- Geomview/test/Geomview/CMakeLists.txt | 2 +- GraphicsView/demo/Alpha_shapes_2/CMakeLists.txt | 2 +- .../demo/Apollonius_graph_2/CMakeLists.txt | 2 +- GraphicsView/demo/Bounding_volumes/CMakeLists.txt | 2 +- GraphicsView/demo/Circular_kernel_2/CMakeLists.txt | 2 +- GraphicsView/demo/Generator/CMakeLists.txt | 2 +- GraphicsView/demo/GraphicsView/CMakeLists.txt | 2 +- .../demo/L1_Voronoi_diagram_2/CMakeLists.txt | 2 +- .../demo/Largest_empty_rect_2/CMakeLists.txt | 2 +- .../demo/Periodic_2_triangulation_2/CMakeLists.txt | 2 +- GraphicsView/demo/Polygon/CMakeLists.txt | 2 +- .../demo/Segment_Delaunay_graph_2/CMakeLists.txt | 2 +- .../Segment_Delaunay_graph_Linf_2/CMakeLists.txt | 2 +- GraphicsView/demo/Snap_rounding_2/CMakeLists.txt | 2 +- .../demo/Spatial_searching_2/CMakeLists.txt | 2 +- GraphicsView/demo/Stream_lines_2/CMakeLists.txt | 2 +- GraphicsView/demo/Triangulation_2/CMakeLists.txt | 2 +- HalfedgeDS/examples/HalfedgeDS/CMakeLists.txt | 2 +- HalfedgeDS/test/HalfedgeDS/CMakeLists.txt | 2 +- Hash_map/benchmark/Hash_map/CMakeLists.txt | 12 +----------- Hash_map/test/Hash_map/CMakeLists.txt | 2 +- .../examples/Heat_method_3/CMakeLists.txt | 2 +- Heat_method_3/test/Heat_method_3/CMakeLists.txt | 2 +- .../Hyperbolic_triangulation_2/CMakeLists.txt | 2 +- .../demo/Hyperbolic_triangulation_2/CMakeLists.txt | 2 +- .../Hyperbolic_triangulation_2/CMakeLists.txt | 2 +- .../test/Hyperbolic_triangulation_2/CMakeLists.txt | 2 +- .../examples/Inscribed_areas/CMakeLists.txt | 2 +- .../test/Inscribed_areas/CMakeLists.txt | 2 +- Installation/CMakeLists.txt | 6 +----- Installation/demo/CMakeLists.txt | 2 +- Installation/examples/CMakeLists.txt | 2 +- Installation/test/CMakeLists.txt | 2 +- Installation/test/Installation/CMakeLists.txt | 2 +- Interpolation/demo/Interpolation/CMakeLists.txt | 2 +- .../examples/Interpolation/CMakeLists.txt | 2 +- Interpolation/test/Interpolation/CMakeLists.txt | 2 +- .../test/Intersections_2/CMakeLists.txt | 2 +- .../test/Intersections_3/CMakeLists.txt | 2 +- .../examples/Interval_skip_list/CMakeLists.txt | 2 +- .../test/Interval_skip_list/CMakeLists.txt | 2 +- .../test/Interval_support/CMakeLists.txt | 2 +- Inventor/test/Inventor/CMakeLists.txt | 2 +- .../examples/Jet_fitting_3/CMakeLists.txt | 2 +- Jet_fitting_3/test/Jet_fitting_3/CMakeLists.txt | 2 +- Kernel_23/examples/Kernel_23/CMakeLists.txt | 2 +- Kernel_23/test/Kernel_23/CMakeLists.txt | 2 +- Kernel_d/test/Kernel_d/CMakeLists.txt | 2 +- .../benchmark/Linear_cell_complex_2/CMakeLists.txt | 2 +- .../benchmark/Linear_cell_complex_3/CMakeLists.txt | 2 +- .../demo/Linear_cell_complex/CMakeLists.txt | 2 +- .../examples/Linear_cell_complex/CMakeLists.txt | 2 +- .../test/Linear_cell_complex/CMakeLists.txt | 2 +- .../examples/Matrix_search/CMakeLists.txt | 2 +- Matrix_search/test/Matrix_search/CMakeLists.txt | 2 +- Mesh_2/demo/Mesh_2/CMakeLists.txt | 2 +- Mesh_2/examples/Mesh_2/CMakeLists.txt | 2 +- Mesh_2/test/Mesh_2/CMakeLists.txt | 2 +- Mesh_3/archive/applications/CMakeLists.txt | 3 +-- Mesh_3/benchmark/Mesh_3/CMakeLists.txt | 2 +- Mesh_3/examples/Mesh_3/CMakeLists.txt | 2 +- Mesh_3/test/Mesh_3/CMakeLists.txt | 2 +- .../examples/Minkowski_sum_2/CMakeLists.txt | 2 +- .../test/Minkowski_sum_2/CMakeLists.txt | 2 +- .../examples/Minkowski_sum_3/CMakeLists.txt | 2 +- .../test/Minkowski_sum_3/CMakeLists.txt | 2 +- Modifier/test/Modifier/CMakeLists.txt | 2 +- .../examples/Modular_arithmetic/CMakeLists.txt | 2 +- .../test/Modular_arithmetic/CMakeLists.txt | 2 +- Nef_2/examples/Nef_2/CMakeLists.txt | 2 +- Nef_2/test/Nef_2/CMakeLists.txt | 2 +- Nef_3/examples/Nef_3/CMakeLists.txt | 2 +- Nef_3/test/Nef_3/CMakeLists.txt | 2 +- Nef_S2/examples/Nef_S2/CMakeLists.txt | 2 +- Nef_S2/test/Nef_S2/CMakeLists.txt | 2 +- NewKernel_d/test/NewKernel_d/CMakeLists.txt | 2 +- Number_types/test/Number_types/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 10 +--------- .../CMakeLists.txt | 10 +--------- Partition_2/examples/Partition_2/CMakeLists.txt | 2 +- Partition_2/test/Partition_2/CMakeLists.txt | 2 +- .../Periodic_2_triangulation_2/CMakeLists.txt | 2 +- .../test/Periodic_2_triangulation_2/CMakeLists.txt | 2 +- .../examples/Periodic_3_mesh_3/CMakeLists.txt | 2 +- .../test/Periodic_3_mesh_3/CMakeLists.txt | 2 +- .../demo/Periodic_3_triangulation_3/CMakeLists.txt | 2 +- .../demo/Periodic_Lloyd_3/CMakeLists.txt | 2 +- .../Periodic_3_triangulation_3/CMakeLists.txt | 2 +- .../test/Periodic_3_triangulation_3/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- Point_set_2/examples/Point_set_2/CMakeLists.txt | 2 +- Point_set_2/test/Point_set_2/CMakeLists.txt | 2 +- Point_set_3/examples/Point_set_3/CMakeLists.txt | 2 +- Point_set_3/test/Point_set_3/CMakeLists.txt | 2 +- .../examples/Point_set_processing_3/CMakeLists.txt | 2 +- .../test/Point_set_processing_3/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- Polygon/examples/Polygon/CMakeLists.txt | 2 +- Polygon/test/Polygon/CMakeLists.txt | 2 +- .../Polygon_mesh_processing/CMakeLists.txt | 12 +----------- .../Polygon_mesh_processing/CMakeLists.txt | 12 +----------- .../test/Polygon_mesh_processing/CMakeLists.txt | 12 +----------- Polyhedron/demo/Polyhedron/CMakeLists.txt | 2 +- .../Polyhedron/implicit_functions/CMakeLists.txt | 2 +- Polyhedron/examples/Polyhedron/CMakeLists.txt | 2 +- Polyhedron/test/Polyhedron/CMakeLists.txt | 2 +- Polyhedron_IO/demo/Polyhedron_IO/CMakeLists.txt | 2 +- .../examples/Polyhedron_IO/CMakeLists.txt | 2 +- Polyhedron_IO/test/Polyhedron_IO/CMakeLists.txt | 2 +- .../demo/Polyline_simplification_2/CMakeLists.txt | 2 +- .../Polyline_simplification_2/CMakeLists.txt | 2 +- .../test/Polyline_simplification_2/CMakeLists.txt | 2 +- Polynomial/examples/Polynomial/CMakeLists.txt | 2 +- Polynomial/test/Polynomial/CMakeLists.txt | 2 +- .../examples/Polytope_distance_d/CMakeLists.txt | 2 +- .../test/Polytope_distance_d/CMakeLists.txt | 2 +- .../Principal_component_analysis/CMakeLists.txt | 2 +- .../Principal_component_analysis/CMakeLists.txt | 2 +- .../Principal_component_analysis/CMakeLists.txt | 2 +- .../examples/Profiling_tools/CMakeLists.txt | 2 +- .../test/Profiling_tools/CMakeLists.txt | 2 +- Property_map/examples/Property_map/CMakeLists.txt | 2 +- Property_map/test/Property_map/CMakeLists.txt | 2 +- QP_solver/examples/QP_solver/CMakeLists.txt | 2 +- QP_solver/test/QP_solver/CMakeLists.txt | 2 +- Random_numbers/test/Random_numbers/CMakeLists.txt | 2 +- Ridges_3/examples/Ridges_3/CMakeLists.txt | 2 +- Ridges_3/test/Ridges_3/CMakeLists.txt | 2 +- .../compact_container_benchmark/CMakeLists.txt | 2 +- .../benchmark/copy_n_benchmark/CMakeLists.txt | 2 +- .../examples/STL_Extension/CMakeLists.txt | 2 +- STL_Extension/test/STL_Extension/CMakeLists.txt | 2 +- .../Scale_space_reconstruction_3/CMakeLists.txt | 2 +- .../cgal_create_release_with_cmake.cmake | 2 +- .../examples/RangeSegmentTrees/CMakeLists.txt | 2 +- .../test/RangeSegmentTrees/CMakeLists.txt | 2 +- .../Segment_Delaunay_graph_2/CMakeLists.txt | 2 +- .../Segment_Delaunay_graph_2/CMakeLists.txt | 2 +- .../test/Segment_Delaunay_graph_2/CMakeLists.txt | 2 +- .../Segment_Delaunay_graph_Linf_2/CMakeLists.txt | 2 +- .../Segment_Delaunay_graph_Linf_2/CMakeLists.txt | 2 +- .../Segment_Delaunay_graph_Linf_2/CMakeLists.txt | 2 +- .../Set_movable_separability_2/CMakeLists.txt | 2 +- .../test/Set_movable_separability_2/CMakeLists.txt | 2 +- .../benchmark/Shape_detection/CMakeLists.txt | 2 +- .../examples/Shape_detection/CMakeLists.txt | 2 +- .../test/Shape_detection/CMakeLists.txt | 2 +- .../examples/Skin_surface_3/CMakeLists.txt | 2 +- Skin_surface_3/test/Skin_surface_3/CMakeLists.txt | 2 +- .../examples/Snap_rounding_2/CMakeLists.txt | 2 +- .../test/Snap_rounding_2/CMakeLists.txt | 2 +- .../examples/Solver_interface/CMakeLists.txt | 2 +- .../benchmark/Spatial_searching/CMakeLists.txt | 2 +- .../Spatial_searching/tools/CMakeLists.txt | 2 +- .../examples/Spatial_searching/CMakeLists.txt | 2 +- .../test/Spatial_searching/CMakeLists.txt | 2 +- .../benchmark/Spatial_sorting/CMakeLists.txt | 2 +- .../examples/Spatial_sorting/CMakeLists.txt | 2 +- .../test/Spatial_sorting/CMakeLists.txt | 2 +- .../examples/Straight_skeleton_2/CMakeLists.txt | 2 +- .../test/Straight_skeleton_2/CMakeLists.txt | 2 +- .../examples/Stream_lines_2/CMakeLists.txt | 2 +- Stream_lines_2/test/Stream_lines_2/CMakeLists.txt | 2 +- .../benchmark/Stream_support/CMakeLists.txt | 2 +- .../examples/Stream_support/CMakeLists.txt | 2 +- Stream_support/test/Stream_support/CMakeLists.txt | 2 +- .../examples/Subdivision_method_3/CMakeLists.txt | 2 +- .../test/Subdivision_method_3/CMakeLists.txt | 2 +- Surface_mesh/benchmark/CMakeLists.txt | 2 +- Surface_mesh/examples/Surface_mesh/CMakeLists.txt | 2 +- Surface_mesh/test/Surface_mesh/CMakeLists.txt | 2 +- .../Surface_mesh_approximation/CMakeLists.txt | 2 +- .../Surface_mesh_approximation/CMakeLists.txt | 2 +- .../test/Surface_mesh_approximation/CMakeLists.txt | 2 +- .../optimal_rotation/CMakeLists.txt | 2 +- .../demo/Surface_mesh_deformation/CMakeLists.txt | 2 +- .../Surface_mesh_deformation/CMakeLists.txt | 2 +- .../test/Surface_mesh_deformation/CMakeLists.txt | 2 +- .../Surface_mesh_parameterization/CMakeLists.txt | 2 +- .../Surface_mesh_parameterization/CMakeLists.txt | 2 +- .../Surface_mesh_segmentation/CMakeLists.txt | 2 +- .../test/Surface_mesh_segmentation/CMakeLists.txt | 2 +- .../Surface_mesh_shortest_path/CMakeLists.txt | 2 +- .../test/Surface_mesh_shortest_path/CMakeLists.txt | 2 +- .../Surface_mesh_simplification/CMakeLists.txt | 2 +- .../Surface_mesh_simplification/CMakeLists.txt | 2 +- .../Surface_mesh_skeletonization/CMakeLists.txt | 2 +- .../Surface_mesh_skeletonization/CMakeLists.txt | 2 +- .../Surface_mesh_skeletonization/CMakeLists.txt | 2 +- Surface_mesher/demo/Surface_mesher/CMakeLists.txt | 2 +- .../examples/Surface_mesher/CMakeLists.txt | 2 +- Surface_mesher/test/Surface_mesher/CMakeLists.txt | 2 +- .../examples/Surface_sweep_2/CMakeLists.txt | 12 +----------- .../test/Surface_sweep_2/CMakeLists.txt | 2 +- TDS_2/test/TDS_2/CMakeLists.txt | 2 +- TDS_3/examples/TDS_3/CMakeLists.txt | 2 +- TDS_3/test/TDS_3/CMakeLists.txt | 2 +- Three/demo/Three/CMakeLists.txt | 2 +- Three/demo/Three/Example_plugin/CMakeLists.txt | 2 +- .../applications/Triangulation/CMakeLists.txt | 14 +------------- .../benchmark/Triangulation/CMakeLists.txt | 2 +- .../examples/Triangulation/CMakeLists.txt | 2 +- Triangulation/test/Triangulation/CMakeLists.txt | 2 +- .../examples/Triangulation_2/CMakeLists.txt | 2 +- .../test/Triangulation_2/CMakeLists.txt | 2 +- .../demo/Triangulation_3/CMakeLists.txt | 2 +- .../Triangulation_3_Geomview_demos/CMakeLists.txt | 2 +- .../examples/Triangulation_3/CMakeLists.txt | 2 +- .../test/Triangulation_3/CMakeLists.txt | 2 +- Union_find/test/Union_find/CMakeLists.txt | 2 +- Visibility_2/examples/Visibility_2/CMakeLists.txt | 2 +- Visibility_2/test/Visibility_2/CMakeLists.txt | 2 +- .../examples/Voronoi_diagram_2/CMakeLists.txt | 2 +- .../test/Voronoi_diagram_2/CMakeLists.txt | 2 +- 309 files changed, 309 insertions(+), 404 deletions(-) diff --git a/AABB_tree/benchmark/AABB_tree/CMakeLists.txt b/AABB_tree/benchmark/AABB_tree/CMakeLists.txt index 077df0007ca..0716a91ec94 100644 --- a/AABB_tree/benchmark/AABB_tree/CMakeLists.txt +++ b/AABB_tree/benchmark/AABB_tree/CMakeLists.txt @@ -1,19 +1,9 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( AABB_traits_benchmark) - -cmake_minimum_required(VERSION 3.1) - cmake_policy(VERSION 3.1) - - -if ( COMMAND cmake_policy ) - - cmake_policy( SET CMP0003 NEW ) - -endif() - # CGAL and its components find_package( CGAL QUIET) if ( CGAL_FOUND ) diff --git a/AABB_tree/demo/AABB_tree/CMakeLists.txt b/AABB_tree/demo/AABB_tree/CMakeLists.txt index 11a5922ccf6..a0c5d53950a 100644 --- a/AABB_tree/demo/AABB_tree/CMakeLists.txt +++ b/AABB_tree/demo/AABB_tree/CMakeLists.txt @@ -1,12 +1,12 @@ # This is the CMake script for compiling the AABB tree demo. +cmake_minimum_required(VERSION 3.1...3.15) project( AABB_tree_Demo ) # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/AABB_tree/examples/AABB_tree/CMakeLists.txt b/AABB_tree/examples/AABB_tree/CMakeLists.txt index c3317a79f65..87fa3857ab5 100644 --- a/AABB_tree/examples/AABB_tree/CMakeLists.txt +++ b/AABB_tree/examples/AABB_tree/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( AABB_tree_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/AABB_tree/test/AABB_tree/CMakeLists.txt b/AABB_tree/test/AABB_tree/CMakeLists.txt index 38a39723ead..7e06dbb8700 100644 --- a/AABB_tree/test/AABB_tree/CMakeLists.txt +++ b/AABB_tree/test/AABB_tree/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( AABB_tree_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt index 761ad7dd237..269a60864e8 100644 --- a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt +++ b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Advancing_front_surface_reconstruction_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Advancing_front_surface_reconstruction/test/Advancing_front_surface_reconstruction/CMakeLists.txt b/Advancing_front_surface_reconstruction/test/Advancing_front_surface_reconstruction/CMakeLists.txt index 3eeeba604c0..4112e7a65ce 100644 --- a/Advancing_front_surface_reconstruction/test/Advancing_front_surface_reconstruction/CMakeLists.txt +++ b/Advancing_front_surface_reconstruction/test/Advancing_front_surface_reconstruction/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Advancing_front_surface_reconstruction_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Algebraic_foundations/examples/Algebraic_foundations/CMakeLists.txt b/Algebraic_foundations/examples/Algebraic_foundations/CMakeLists.txt index d30a4c846c8..64184b35a89 100644 --- a/Algebraic_foundations/examples/Algebraic_foundations/CMakeLists.txt +++ b/Algebraic_foundations/examples/Algebraic_foundations/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Algebraic_foundations_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Algebraic_foundations/test/Algebraic_foundations/CMakeLists.txt b/Algebraic_foundations/test/Algebraic_foundations/CMakeLists.txt index 1eacdbebbfa..9b3ee11b5e7 100644 --- a/Algebraic_foundations/test/Algebraic_foundations/CMakeLists.txt +++ b/Algebraic_foundations/test/Algebraic_foundations/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Algebraic_foundations_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Algebraic_kernel_d/examples/Algebraic_kernel_d/CMakeLists.txt b/Algebraic_kernel_d/examples/Algebraic_kernel_d/CMakeLists.txt index d6a7178ec13..901221f91d0 100644 --- a/Algebraic_kernel_d/examples/Algebraic_kernel_d/CMakeLists.txt +++ b/Algebraic_kernel_d/examples/Algebraic_kernel_d/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Algebraic_kernel_d_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Algebraic_kernel_d/test/Algebraic_kernel_d/CMakeLists.txt b/Algebraic_kernel_d/test/Algebraic_kernel_d/CMakeLists.txt index a75ee88082e..35f3eb4d27a 100644 --- a/Algebraic_kernel_d/test/Algebraic_kernel_d/CMakeLists.txt +++ b/Algebraic_kernel_d/test/Algebraic_kernel_d/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Algebraic_kernel_d_Tests ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components diff --git a/Algebraic_kernel_for_circles/test/Algebraic_kernel_for_circles/CMakeLists.txt b/Algebraic_kernel_for_circles/test/Algebraic_kernel_for_circles/CMakeLists.txt index 4261dd0c584..f3b3894ae76 100644 --- a/Algebraic_kernel_for_circles/test/Algebraic_kernel_for_circles/CMakeLists.txt +++ b/Algebraic_kernel_for_circles/test/Algebraic_kernel_for_circles/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Algebraic_kernel_for_circles_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Algebraic_kernel_for_spheres/test/Algebraic_kernel_for_spheres/CMakeLists.txt b/Algebraic_kernel_for_spheres/test/Algebraic_kernel_for_spheres/CMakeLists.txt index 6b8567c4727..f6ef2f9d943 100644 --- a/Algebraic_kernel_for_spheres/test/Algebraic_kernel_for_spheres/CMakeLists.txt +++ b/Algebraic_kernel_for_spheres/test/Algebraic_kernel_for_spheres/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Algebraic_kernel_for_spheres_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Alpha_shapes_2/examples/Alpha_shapes_2/CMakeLists.txt b/Alpha_shapes_2/examples/Alpha_shapes_2/CMakeLists.txt index 79131b56ac0..977ebf3923a 100644 --- a/Alpha_shapes_2/examples/Alpha_shapes_2/CMakeLists.txt +++ b/Alpha_shapes_2/examples/Alpha_shapes_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Alpha_shapes_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Alpha_shapes_2/test/Alpha_shapes_2/CMakeLists.txt b/Alpha_shapes_2/test/Alpha_shapes_2/CMakeLists.txt index 8724fa225f4..0399340218c 100644 --- a/Alpha_shapes_2/test/Alpha_shapes_2/CMakeLists.txt +++ b/Alpha_shapes_2/test/Alpha_shapes_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Alpha_shapes_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt b/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt index 6df765a5b7a..15a15504881 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt @@ -1,13 +1,13 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Alpha_shapes_3_Demo) # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Alpha_shapes_3/examples/Alpha_shapes_3/CMakeLists.txt b/Alpha_shapes_3/examples/Alpha_shapes_3/CMakeLists.txt index c9d88b3942e..749ba649534 100644 --- a/Alpha_shapes_3/examples/Alpha_shapes_3/CMakeLists.txt +++ b/Alpha_shapes_3/examples/Alpha_shapes_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Alpha_shapes_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Alpha_shapes_3/test/Alpha_shapes_3/CMakeLists.txt b/Alpha_shapes_3/test/Alpha_shapes_3/CMakeLists.txt index 600a2a8ae41..9350624cb63 100644 --- a/Alpha_shapes_3/test/Alpha_shapes_3/CMakeLists.txt +++ b/Alpha_shapes_3/test/Alpha_shapes_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Alpha_shapes_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt b/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt index 07f5f6688ba..e61205e45ae 100644 --- a/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt +++ b/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Apollonius_graph_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt b/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt index 65c0c68062b..a98b5dd6571 100644 --- a/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt +++ b/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Apollonius_graph_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Arithmetic_kernel/test/Arithmetic_kernel/CMakeLists.txt b/Arithmetic_kernel/test/Arithmetic_kernel/CMakeLists.txt index 0df7f74c0f2..2807ba14ea0 100644 --- a/Arithmetic_kernel/test/Arithmetic_kernel/CMakeLists.txt +++ b/Arithmetic_kernel/test/Arithmetic_kernel/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Arithmetic_kernel_Tests ) -cmake_minimum_required(VERSION 3.1) diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt index 449c2d25303..cbb231c76f5 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt @@ -1,8 +1,8 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Arrangement_on_surface_2_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt index 9968ed5dfae..5f226853d87 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Arrangement_on_surface_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt index 6df47f3371d..0ffdc893571 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt @@ -2,11 +2,11 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Arrangement_on_surface_2_Tests ) enable_testing() -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core) diff --git a/BGL/examples/BGL_LCC/CMakeLists.txt b/BGL/examples/BGL_LCC/CMakeLists.txt index 1139bccedb8..0df74650e87 100644 --- a/BGL/examples/BGL_LCC/CMakeLists.txt +++ b/BGL/examples/BGL_LCC/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( BGL_LCC_Examples ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/BGL/examples/BGL_OpenMesh/CMakeLists.txt b/BGL/examples/BGL_OpenMesh/CMakeLists.txt index 118d52a20df..848b02e2604 100644 --- a/BGL/examples/BGL_OpenMesh/CMakeLists.txt +++ b/BGL/examples/BGL_OpenMesh/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( BGL_OpenMesh_Examples ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/BGL/examples/BGL_arrangement_2/CMakeLists.txt b/BGL/examples/BGL_arrangement_2/CMakeLists.txt index 55c9036e43a..676d1347aa3 100644 --- a/BGL/examples/BGL_arrangement_2/CMakeLists.txt +++ b/BGL/examples/BGL_arrangement_2/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( BGL_arrangement_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/BGL/examples/BGL_polyhedron_3/CMakeLists.txt b/BGL/examples/BGL_polyhedron_3/CMakeLists.txt index 9b1542ef967..ac3bd5256f2 100644 --- a/BGL/examples/BGL_polyhedron_3/CMakeLists.txt +++ b/BGL/examples/BGL_polyhedron_3/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( BGL_polyhedron_3_Examples ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/BGL/examples/BGL_surface_mesh/CMakeLists.txt b/BGL/examples/BGL_surface_mesh/CMakeLists.txt index c885f703675..13ba8575799 100644 --- a/BGL/examples/BGL_surface_mesh/CMakeLists.txt +++ b/BGL/examples/BGL_surface_mesh/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( BGL_surface_mesh_Examples ) -cmake_minimum_required(VERSION 3.1) find_package( CGAL QUIET ) diff --git a/BGL/examples/BGL_triangulation_2/CMakeLists.txt b/BGL/examples/BGL_triangulation_2/CMakeLists.txt index b3e337d3040..d6bb35f7d47 100644 --- a/BGL/examples/BGL_triangulation_2/CMakeLists.txt +++ b/BGL/examples/BGL_triangulation_2/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( BGL_triangulation_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/BGL/test/BGL/CMakeLists.txt b/BGL/test/BGL/CMakeLists.txt index 0949c353647..e7209f704d9 100644 --- a/BGL/test/BGL/CMakeLists.txt +++ b/BGL/test/BGL/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_cmake_script_with_options # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( BGL_Tests ) -cmake_minimum_required(VERSION 3.1) diff --git a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/CMakeLists.txt b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/CMakeLists.txt index afb44332279..2bfc68a24f3 100644 --- a/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/CMakeLists.txt +++ b/Barycentric_coordinates_2/examples/Barycentric_coordinates_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Barycentric_coordinates_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/CMakeLists.txt b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/CMakeLists.txt index 1d55dbc2fd2..01ca0f52145 100644 --- a/Barycentric_coordinates_2/test/Barycentric_coordinates_2/CMakeLists.txt +++ b/Barycentric_coordinates_2/test/Barycentric_coordinates_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Barycentric_coordinates_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Boolean_set_operations_2/archive/demo/Boolean_set_operations_2_GraphicsView/CMakeLists.txt b/Boolean_set_operations_2/archive/demo/Boolean_set_operations_2_GraphicsView/CMakeLists.txt index d7246839fe3..91381c3a6b5 100644 --- a/Boolean_set_operations_2/archive/demo/Boolean_set_operations_2_GraphicsView/CMakeLists.txt +++ b/Boolean_set_operations_2/archive/demo/Boolean_set_operations_2_GraphicsView/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Boolean_set_operations_2_GraphicsView_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Boolean_set_operations_2/examples/Boolean_set_operations_2/CMakeLists.txt b/Boolean_set_operations_2/examples/Boolean_set_operations_2/CMakeLists.txt index 98df7ce7446..e96e127c29f 100644 --- a/Boolean_set_operations_2/examples/Boolean_set_operations_2/CMakeLists.txt +++ b/Boolean_set_operations_2/examples/Boolean_set_operations_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Boolean_set_operations_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Boolean_set_operations_2/test/Boolean_set_operations_2/CMakeLists.txt b/Boolean_set_operations_2/test/Boolean_set_operations_2/CMakeLists.txt index f1069ba938b..c846aae2c29 100644 --- a/Boolean_set_operations_2/test/Boolean_set_operations_2/CMakeLists.txt +++ b/Boolean_set_operations_2/test/Boolean_set_operations_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Boolean_set_operations_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Bounding_volumes/examples/Approximate_min_ellipsoid_d/CMakeLists.txt b/Bounding_volumes/examples/Approximate_min_ellipsoid_d/CMakeLists.txt index 16a7ff583b6..8802463b72d 100644 --- a/Bounding_volumes/examples/Approximate_min_ellipsoid_d/CMakeLists.txt +++ b/Bounding_volumes/examples/Approximate_min_ellipsoid_d/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Approximate_min_ellipsoid_d_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Bounding_volumes/examples/Min_annulus_d/CMakeLists.txt b/Bounding_volumes/examples/Min_annulus_d/CMakeLists.txt index b406ed77552..6a578245a37 100644 --- a/Bounding_volumes/examples/Min_annulus_d/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_annulus_d/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Min_annulus_d_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Bounding_volumes/examples/Min_circle_2/CMakeLists.txt b/Bounding_volumes/examples/Min_circle_2/CMakeLists.txt index d1db7e242fe..2361ab9059e 100644 --- a/Bounding_volumes/examples/Min_circle_2/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_circle_2/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Min_circle_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Bounding_volumes/examples/Min_ellipse_2/CMakeLists.txt b/Bounding_volumes/examples/Min_ellipse_2/CMakeLists.txt index d0e44baa048..82d3b642425 100644 --- a/Bounding_volumes/examples/Min_ellipse_2/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_ellipse_2/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Min_ellipse_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Bounding_volumes/examples/Min_quadrilateral_2/CMakeLists.txt b/Bounding_volumes/examples/Min_quadrilateral_2/CMakeLists.txt index b59e56f2286..7b6caab79f6 100644 --- a/Bounding_volumes/examples/Min_quadrilateral_2/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_quadrilateral_2/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Min_quadrilateral_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Bounding_volumes/examples/Min_sphere_d/CMakeLists.txt b/Bounding_volumes/examples/Min_sphere_d/CMakeLists.txt index 685ac2e938b..158d28cebbb 100644 --- a/Bounding_volumes/examples/Min_sphere_d/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_sphere_d/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Min_sphere_d_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Bounding_volumes/examples/Min_sphere_of_spheres_d/CMakeLists.txt b/Bounding_volumes/examples/Min_sphere_of_spheres_d/CMakeLists.txt index 39ba7fb4af5..df0cadc7874 100644 --- a/Bounding_volumes/examples/Min_sphere_of_spheres_d/CMakeLists.txt +++ b/Bounding_volumes/examples/Min_sphere_of_spheres_d/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Min_sphere_of_spheres_d_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Bounding_volumes/examples/Rectangular_p_center_2/CMakeLists.txt b/Bounding_volumes/examples/Rectangular_p_center_2/CMakeLists.txt index 76fb954b161..75e7de0f867 100644 --- a/Bounding_volumes/examples/Rectangular_p_center_2/CMakeLists.txt +++ b/Bounding_volumes/examples/Rectangular_p_center_2/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Rectangular_p_center_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Bounding_volumes/test/Bounding_volumes/CMakeLists.txt b/Bounding_volumes/test/Bounding_volumes/CMakeLists.txt index f6a82d575ee..403e652475c 100644 --- a/Bounding_volumes/test/Bounding_volumes/CMakeLists.txt +++ b/Bounding_volumes/test/Bounding_volumes/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Bounding_volumes_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Box_intersection_d/examples/Box_intersection_d/CMakeLists.txt b/Box_intersection_d/examples/Box_intersection_d/CMakeLists.txt index 1d5ab39100c..15ece488e70 100644 --- a/Box_intersection_d/examples/Box_intersection_d/CMakeLists.txt +++ b/Box_intersection_d/examples/Box_intersection_d/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Box_intersection_d_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Box_intersection_d/test/Box_intersection_d/CMakeLists.txt b/Box_intersection_d/test/Box_intersection_d/CMakeLists.txt index bcdb064e633..1beb02ff8d0 100644 --- a/Box_intersection_d/test/Box_intersection_d/CMakeLists.txt +++ b/Box_intersection_d/test/Box_intersection_d/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Box_intersection_d_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/CGAL_Core/examples/Core/CMakeLists.txt b/CGAL_Core/examples/Core/CMakeLists.txt index ad932d6731a..1ff71a69b29 100644 --- a/CGAL_Core/examples/Core/CMakeLists.txt +++ b/CGAL_Core/examples/Core/CMakeLists.txt @@ -1,7 +1,7 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Core_Examples ) -cmake_minimum_required(VERSION 3.1) diff --git a/CGAL_ImageIO/archive/demo/CGALimageIO/CMakeLists.txt b/CGAL_ImageIO/archive/demo/CGALimageIO/CMakeLists.txt index a5f3c89d94b..1a27c127533 100644 --- a/CGAL_ImageIO/archive/demo/CGALimageIO/CMakeLists.txt +++ b/CGAL_ImageIO/archive/demo/CGALimageIO/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project(CGALimageIO_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/CGAL_ImageIO/examples/CGALimageIO/CMakeLists.txt b/CGAL_ImageIO/examples/CGALimageIO/CMakeLists.txt index 3dcdf8d8c3d..58de82637bb 100644 --- a/CGAL_ImageIO/examples/CGALimageIO/CMakeLists.txt +++ b/CGAL_ImageIO/examples/CGALimageIO/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( CGALimageIO_Examples ) -cmake_minimum_required(VERSION 3.1) if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) diff --git a/CGAL_ImageIO/test/CGAL_ImageIO/CMakeLists.txt b/CGAL_ImageIO/test/CGAL_ImageIO/CMakeLists.txt index 81eec777452..a5a57186c4b 100644 --- a/CGAL_ImageIO/test/CGAL_ImageIO/CMakeLists.txt +++ b/CGAL_ImageIO/test/CGAL_ImageIO/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( CGAL_ImageIO_Tests ) -cmake_minimum_required(VERSION 3.1) if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) diff --git a/CGAL_ipelets/demo/CGAL_ipelets/CMakeLists.txt b/CGAL_ipelets/demo/CGAL_ipelets/CMakeLists.txt index 80fcb5d2695..64206c30223 100644 --- a/CGAL_ipelets/demo/CGAL_ipelets/CMakeLists.txt +++ b/CGAL_ipelets/demo/CGAL_ipelets/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project(CGAL_ipelets_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/CGAL_ipelets/examples/CGAL_ipelets/CMakeLists.txt b/CGAL_ipelets/examples/CGAL_ipelets/CMakeLists.txt index 25e4407eaf9..eda52201269 100644 --- a/CGAL_ipelets/examples/CGAL_ipelets/CMakeLists.txt +++ b/CGAL_ipelets/examples/CGAL_ipelets/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( CGAL_ipelets_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc901cea606..16935eafc15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ # Top level CMakeLists.txt for CGAL-branchbuild message( "== CMake setup ==" ) +cmake_minimum_required(VERSION 3.1...3.15) project(CGAL CXX C) export(PACKAGE CGAL) # Minimal version of CMake: -cmake_minimum_required(VERSION 3.1) set( CGAL_BRANCH_BUILD ON CACHE INTERNAL "Create CGAL from a Git branch" FORCE) diff --git a/Circular_kernel_2/examples/Circular_kernel_2/CMakeLists.txt b/Circular_kernel_2/examples/Circular_kernel_2/CMakeLists.txt index 8072b3720da..1d1bb36d2cf 100644 --- a/Circular_kernel_2/examples/Circular_kernel_2/CMakeLists.txt +++ b/Circular_kernel_2/examples/Circular_kernel_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Circular_kernel_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Circular_kernel_2/test/Circular_kernel_2/CMakeLists.txt b/Circular_kernel_2/test/Circular_kernel_2/CMakeLists.txt index ac9e483e25f..74f626a1326 100644 --- a/Circular_kernel_2/test/Circular_kernel_2/CMakeLists.txt +++ b/Circular_kernel_2/test/Circular_kernel_2/CMakeLists.txt @@ -2,10 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Circular_kernel_2_Tests ) -CMAKE_MINIMUM_REQUIRED(VERSION 3.1) - find_package(CGAL QUIET) if ( CGAL_FOUND ) diff --git a/Circular_kernel_3/demo/Circular_kernel_3/CMakeLists.txt b/Circular_kernel_3/demo/Circular_kernel_3/CMakeLists.txt index f66a1c8c7b7..34fb62f0475 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/CMakeLists.txt +++ b/Circular_kernel_3/demo/Circular_kernel_3/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project (Circular_kernel_3_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Circular_kernel_3/examples/Circular_kernel_3/CMakeLists.txt b/Circular_kernel_3/examples/Circular_kernel_3/CMakeLists.txt index fceddecd46a..5c5a8f42781 100644 --- a/Circular_kernel_3/examples/Circular_kernel_3/CMakeLists.txt +++ b/Circular_kernel_3/examples/Circular_kernel_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Circular_kernel_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Circular_kernel_3/test/Circular_kernel_3/CMakeLists.txt b/Circular_kernel_3/test/Circular_kernel_3/CMakeLists.txt index 285115758a5..eb56bd82adf 100644 --- a/Circular_kernel_3/test/Circular_kernel_3/CMakeLists.txt +++ b/Circular_kernel_3/test/Circular_kernel_3/CMakeLists.txt @@ -2,10 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Circular_kernel_3_Tests ) -CMAKE_MINIMUM_REQUIRED(VERSION 3.1) - find_package(CGAL QUIET COMPONENTS Core ) if ( CGAL_FOUND ) diff --git a/Circulator/examples/Circulator/CMakeLists.txt b/Circulator/examples/Circulator/CMakeLists.txt index 25ebaaa3029..df3050fb2ac 100644 --- a/Circulator/examples/Circulator/CMakeLists.txt +++ b/Circulator/examples/Circulator/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Circulator_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Circulator/test/Circulator/CMakeLists.txt b/Circulator/test/Circulator/CMakeLists.txt index 330c0553644..413c1cdbfd2 100644 --- a/Circulator/test/Circulator/CMakeLists.txt +++ b/Circulator/test/Circulator/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Circulator_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Classification/examples/Classification/CMakeLists.txt b/Classification/examples/Classification/CMakeLists.txt index 73e009c7868..79ad8c5bf03 100644 --- a/Classification/examples/Classification/CMakeLists.txt +++ b/Classification/examples/Classification/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Classification_Examples ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Classification/test/Classification/CMakeLists.txt b/Classification/test/Classification/CMakeLists.txt index ba75c6ae11f..ae7699281d1 100644 --- a/Classification/test/Classification/CMakeLists.txt +++ b/Classification/test/Classification/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Classification_Tests ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Combinatorial_map/examples/Combinatorial_map/CMakeLists.txt b/Combinatorial_map/examples/Combinatorial_map/CMakeLists.txt index 78868a0c372..8a7390bdcb0 100644 --- a/Combinatorial_map/examples/Combinatorial_map/CMakeLists.txt +++ b/Combinatorial_map/examples/Combinatorial_map/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Combinatorial_map_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Combinatorial_map/test/Combinatorial_map/CMakeLists.txt b/Combinatorial_map/test/Combinatorial_map/CMakeLists.txt index f8dd901b528..6beb2c68493 100644 --- a/Combinatorial_map/test/Combinatorial_map/CMakeLists.txt +++ b/Combinatorial_map/test/Combinatorial_map/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Combinatorial_map_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Cone_spanners_2/examples/Cone_spanners_2/CMakeLists.txt b/Cone_spanners_2/examples/Cone_spanners_2/CMakeLists.txt index 720ae284d4c..815413763a5 100644 --- a/Cone_spanners_2/examples/Cone_spanners_2/CMakeLists.txt +++ b/Cone_spanners_2/examples/Cone_spanners_2/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.1...3.13) +cmake_minimum_required(VERSION 3.1...3.15) project( Cone_spanners_2_Examples ) find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core) diff --git a/Cone_spanners_2/test/Cone_spanners_2/CMakeLists.txt b/Cone_spanners_2/test/Cone_spanners_2/CMakeLists.txt index a859efd04e6..1a9a18f5016 100644 --- a/Cone_spanners_2/test/Cone_spanners_2/CMakeLists.txt +++ b/Cone_spanners_2/test/Cone_spanners_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Cone_spanners_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Convex_decomposition_3/examples/Convex_decomposition_3/CMakeLists.txt b/Convex_decomposition_3/examples/Convex_decomposition_3/CMakeLists.txt index 459d14c78b5..a2e6d17d236 100644 --- a/Convex_decomposition_3/examples/Convex_decomposition_3/CMakeLists.txt +++ b/Convex_decomposition_3/examples/Convex_decomposition_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Convex_decomposition_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Convex_decomposition_3/test/Convex_decomposition_3/CMakeLists.txt b/Convex_decomposition_3/test/Convex_decomposition_3/CMakeLists.txt index 8de39c59399..91dd854c203 100644 --- a/Convex_decomposition_3/test/Convex_decomposition_3/CMakeLists.txt +++ b/Convex_decomposition_3/test/Convex_decomposition_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Convex_decomposition_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Convex_hull_2/examples/Convex_hull_2/CMakeLists.txt b/Convex_hull_2/examples/Convex_hull_2/CMakeLists.txt index fb81c4d6131..35f20791847 100644 --- a/Convex_hull_2/examples/Convex_hull_2/CMakeLists.txt +++ b/Convex_hull_2/examples/Convex_hull_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Convex_hull_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Convex_hull_2/test/Convex_hull_2/CMakeLists.txt b/Convex_hull_2/test/Convex_hull_2/CMakeLists.txt index a39a58f5f99..e5373558182 100644 --- a/Convex_hull_2/test/Convex_hull_2/CMakeLists.txt +++ b/Convex_hull_2/test/Convex_hull_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Convex_hull_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Convex_hull_3/demo/Convex_hull_3/CMakeLists.txt b/Convex_hull_3/demo/Convex_hull_3/CMakeLists.txt index 59c80f4ec0e..37a6dd85f0c 100644 --- a/Convex_hull_3/demo/Convex_hull_3/CMakeLists.txt +++ b/Convex_hull_3/demo/Convex_hull_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Convex_hull_3_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Convex_hull_3/examples/Convex_hull_3/CMakeLists.txt b/Convex_hull_3/examples/Convex_hull_3/CMakeLists.txt index a2a70fa2592..18d983da969 100644 --- a/Convex_hull_3/examples/Convex_hull_3/CMakeLists.txt +++ b/Convex_hull_3/examples/Convex_hull_3/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Convex_hull_3_Examples ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Convex_hull_3/test/Convex_hull_3/CMakeLists.txt b/Convex_hull_3/test/Convex_hull_3/CMakeLists.txt index beb28619ce8..8282bc77bab 100644 --- a/Convex_hull_3/test/Convex_hull_3/CMakeLists.txt +++ b/Convex_hull_3/test/Convex_hull_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Convex_hull_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Convex_hull_d/test/Convex_hull_d/CMakeLists.txt b/Convex_hull_d/test/Convex_hull_d/CMakeLists.txt index fc19860c41c..39cd11743b1 100644 --- a/Convex_hull_d/test/Convex_hull_d/CMakeLists.txt +++ b/Convex_hull_d/test/Convex_hull_d/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Convex_hull_d_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Distance_2/test/Distance_2/CMakeLists.txt b/Distance_2/test/Distance_2/CMakeLists.txt index 0b93c5f718c..73491efcd2e 100644 --- a/Distance_2/test/Distance_2/CMakeLists.txt +++ b/Distance_2/test/Distance_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Distance_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Distance_3/test/Distance_3/CMakeLists.txt b/Distance_3/test/Distance_3/CMakeLists.txt index ce608ba48c7..9467abf2744 100644 --- a/Distance_3/test/Distance_3/CMakeLists.txt +++ b/Distance_3/test/Distance_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Distance_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Documentation/doc/CMakeLists.txt b/Documentation/doc/CMakeLists.txt index 1049c44db07..83b0918e75f 100644 --- a/Documentation/doc/CMakeLists.txt +++ b/Documentation/doc/CMakeLists.txt @@ -1,7 +1,7 @@ +cmake_minimum_required(VERSION 3.1...3.15) project(Documentation NONE) # Minimal version of CMake: -cmake_minimum_required(VERSION 3.1) # Check whether this cmake script is the top level one if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Envelope_2/examples/Envelope_2/CMakeLists.txt b/Envelope_2/examples/Envelope_2/CMakeLists.txt index 936b6d1dabb..4a25f90e742 100644 --- a/Envelope_2/examples/Envelope_2/CMakeLists.txt +++ b/Envelope_2/examples/Envelope_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Envelope_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Envelope_2/test/Envelope_2/CMakeLists.txt b/Envelope_2/test/Envelope_2/CMakeLists.txt index 01cd46d3976..5ea14d5d6cb 100644 --- a/Envelope_2/test/Envelope_2/CMakeLists.txt +++ b/Envelope_2/test/Envelope_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Envelope_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Envelope_3/examples/Envelope_3/CMakeLists.txt b/Envelope_3/examples/Envelope_3/CMakeLists.txt index 4f3dd717ad7..27e66795501 100644 --- a/Envelope_3/examples/Envelope_3/CMakeLists.txt +++ b/Envelope_3/examples/Envelope_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Envelope_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Envelope_3/test/Envelope_3/CMakeLists.txt b/Envelope_3/test/Envelope_3/CMakeLists.txt index da3fdcc438a..8ccc89c8780 100644 --- a/Envelope_3/test/Envelope_3/CMakeLists.txt +++ b/Envelope_3/test/Envelope_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Envelope_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Filtered_kernel/benchmark/Filtered_kernel/CMakeLists.txt b/Filtered_kernel/benchmark/Filtered_kernel/CMakeLists.txt index 5f557e993c4..c39a9422005 100644 --- a/Filtered_kernel/benchmark/Filtered_kernel/CMakeLists.txt +++ b/Filtered_kernel/benchmark/Filtered_kernel/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Filtered_kernel_test ) -cmake_minimum_required(VERSION 3.1) add_executable(bench_simple_comparisons bench_simple_comparisons.cpp) diff --git a/Filtered_kernel/examples/Filtered_kernel/CMakeLists.txt b/Filtered_kernel/examples/Filtered_kernel/CMakeLists.txt index ebcff9060b2..95f51a659ec 100644 --- a/Filtered_kernel/examples/Filtered_kernel/CMakeLists.txt +++ b/Filtered_kernel/examples/Filtered_kernel/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Filtered_kernel_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Filtered_kernel/test/Filtered_kernel/CMakeLists.txt b/Filtered_kernel/test/Filtered_kernel/CMakeLists.txt index 6b3d72637c4..ebe71fe250d 100644 --- a/Filtered_kernel/test/Filtered_kernel/CMakeLists.txt +++ b/Filtered_kernel/test/Filtered_kernel/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Filtered_kernel_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Generalized_map/examples/Generalized_map/CMakeLists.txt b/Generalized_map/examples/Generalized_map/CMakeLists.txt index 2fde81ed252..96e14762a6f 100644 --- a/Generalized_map/examples/Generalized_map/CMakeLists.txt +++ b/Generalized_map/examples/Generalized_map/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Generalized_map_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Generalized_map/test/Generalized_map/CMakeLists.txt b/Generalized_map/test/Generalized_map/CMakeLists.txt index 2fc8c4ac4a4..42a97871fe6 100644 --- a/Generalized_map/test/Generalized_map/CMakeLists.txt +++ b/Generalized_map/test/Generalized_map/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Generalized_map_Tests ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Generator/benchmark/Generator/CMakeLists.txt b/Generator/benchmark/Generator/CMakeLists.txt index cef6304650d..2fc34e54fd5 100644 --- a/Generator/benchmark/Generator/CMakeLists.txt +++ b/Generator/benchmark/Generator/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Generator_example ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Generator/examples/Generator/CMakeLists.txt b/Generator/examples/Generator/CMakeLists.txt index b5fc21b2fd3..8ef7883800d 100644 --- a/Generator/examples/Generator/CMakeLists.txt +++ b/Generator/examples/Generator/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Generator_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Generator/test/Generator/CMakeLists.txt b/Generator/test/Generator/CMakeLists.txt index a5606234f16..8842178b20b 100644 --- a/Generator/test/Generator/CMakeLists.txt +++ b/Generator/test/Generator/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Generator_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Geomview/demo/Geomview/CMakeLists.txt b/Geomview/demo/Geomview/CMakeLists.txt index fdba135eb21..0e03866d452 100644 --- a/Geomview/demo/Geomview/CMakeLists.txt +++ b/Geomview/demo/Geomview/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Geomview_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Geomview/test/Geomview/CMakeLists.txt b/Geomview/test/Geomview/CMakeLists.txt index 82a744ca346..960bdbb70c0 100644 --- a/Geomview/test/Geomview/CMakeLists.txt +++ b/Geomview/test/Geomview/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Geomview_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/GraphicsView/demo/Alpha_shapes_2/CMakeLists.txt b/GraphicsView/demo/Alpha_shapes_2/CMakeLists.txt index f7a8bc079d6..5f7ab12f0a5 100644 --- a/GraphicsView/demo/Alpha_shapes_2/CMakeLists.txt +++ b/GraphicsView/demo/Alpha_shapes_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Alpha_shapes_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt b/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt index 275cbce4285..a7010daf3a3 100644 --- a/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt +++ b/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Apollonius_graph_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Bounding_volumes/CMakeLists.txt b/GraphicsView/demo/Bounding_volumes/CMakeLists.txt index b05e83971bd..3e5c460cf57 100644 --- a/GraphicsView/demo/Bounding_volumes/CMakeLists.txt +++ b/GraphicsView/demo/Bounding_volumes/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Bounding_volumes_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Circular_kernel_2/CMakeLists.txt b/GraphicsView/demo/Circular_kernel_2/CMakeLists.txt index fcbf3c053aa..c41827b6ce9 100644 --- a/GraphicsView/demo/Circular_kernel_2/CMakeLists.txt +++ b/GraphicsView/demo/Circular_kernel_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Circular_kernel_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Generator/CMakeLists.txt b/GraphicsView/demo/Generator/CMakeLists.txt index b4087d159f3..80b2e0b418f 100644 --- a/GraphicsView/demo/Generator/CMakeLists.txt +++ b/GraphicsView/demo/Generator/CMakeLists.txt @@ -1,8 +1,8 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Generator_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/GraphicsView/CMakeLists.txt b/GraphicsView/demo/GraphicsView/CMakeLists.txt index 68f0d001b0a..7a2a221bce6 100644 --- a/GraphicsView/demo/GraphicsView/CMakeLists.txt +++ b/GraphicsView/demo/GraphicsView/CMakeLists.txt @@ -1,8 +1,8 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (GraphicsView_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/L1_Voronoi_diagram_2/CMakeLists.txt b/GraphicsView/demo/L1_Voronoi_diagram_2/CMakeLists.txt index 87cc95e584f..af449d606ac 100644 --- a/GraphicsView/demo/L1_Voronoi_diagram_2/CMakeLists.txt +++ b/GraphicsView/demo/L1_Voronoi_diagram_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (L1_Voronoi_diagram_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Largest_empty_rect_2/CMakeLists.txt b/GraphicsView/demo/Largest_empty_rect_2/CMakeLists.txt index 66a9c615dc7..f9ea83c3ec3 100644 --- a/GraphicsView/demo/Largest_empty_rect_2/CMakeLists.txt +++ b/GraphicsView/demo/Largest_empty_rect_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Largest_empty_rect_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Periodic_2_triangulation_2/CMakeLists.txt b/GraphicsView/demo/Periodic_2_triangulation_2/CMakeLists.txt index 8f4739f959c..7e50b5f1351 100644 --- a/GraphicsView/demo/Periodic_2_triangulation_2/CMakeLists.txt +++ b/GraphicsView/demo/Periodic_2_triangulation_2/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project (Periodic_2_triangulation_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Polygon/CMakeLists.txt b/GraphicsView/demo/Polygon/CMakeLists.txt index bceee253d9a..8d0df276e19 100644 --- a/GraphicsView/demo/Polygon/CMakeLists.txt +++ b/GraphicsView/demo/Polygon/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Polygon_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Segment_Delaunay_graph_2/CMakeLists.txt b/GraphicsView/demo/Segment_Delaunay_graph_2/CMakeLists.txt index aa0672531f5..ac922296998 100644 --- a/GraphicsView/demo/Segment_Delaunay_graph_2/CMakeLists.txt +++ b/GraphicsView/demo/Segment_Delaunay_graph_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Segment_Delaunay_graph_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/CMakeLists.txt b/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/CMakeLists.txt index 978a1c71b40..a87600e4507 100644 --- a/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/CMakeLists.txt +++ b/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Segment_Delaunay_graph_Linf_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Snap_rounding_2/CMakeLists.txt b/GraphicsView/demo/Snap_rounding_2/CMakeLists.txt index c7adc44e8dd..f4eb6c8b9d7 100644 --- a/GraphicsView/demo/Snap_rounding_2/CMakeLists.txt +++ b/GraphicsView/demo/Snap_rounding_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Snap_rounding_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Spatial_searching_2/CMakeLists.txt b/GraphicsView/demo/Spatial_searching_2/CMakeLists.txt index 47cb364fa44..fb30598a70e 100644 --- a/GraphicsView/demo/Spatial_searching_2/CMakeLists.txt +++ b/GraphicsView/demo/Spatial_searching_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Spatial_searching_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Stream_lines_2/CMakeLists.txt b/GraphicsView/demo/Stream_lines_2/CMakeLists.txt index 1ed1cb9be2a..b856b704cb9 100644 --- a/GraphicsView/demo/Stream_lines_2/CMakeLists.txt +++ b/GraphicsView/demo/Stream_lines_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Stream_lines_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/GraphicsView/demo/Triangulation_2/CMakeLists.txt b/GraphicsView/demo/Triangulation_2/CMakeLists.txt index ec05e490664..a4be4c94ca3 100644 --- a/GraphicsView/demo/Triangulation_2/CMakeLists.txt +++ b/GraphicsView/demo/Triangulation_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Triangulation_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/HalfedgeDS/examples/HalfedgeDS/CMakeLists.txt b/HalfedgeDS/examples/HalfedgeDS/CMakeLists.txt index 447e7b6ba16..bce6a8ffd4d 100644 --- a/HalfedgeDS/examples/HalfedgeDS/CMakeLists.txt +++ b/HalfedgeDS/examples/HalfedgeDS/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( HalfedgeDS_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/HalfedgeDS/test/HalfedgeDS/CMakeLists.txt b/HalfedgeDS/test/HalfedgeDS/CMakeLists.txt index f5f9cd20dc2..05a364aad47 100644 --- a/HalfedgeDS/test/HalfedgeDS/CMakeLists.txt +++ b/HalfedgeDS/test/HalfedgeDS/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( HalfedgeDS_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Hash_map/benchmark/Hash_map/CMakeLists.txt b/Hash_map/benchmark/Hash_map/CMakeLists.txt index 69c35aa6cf8..5a97491ec5e 100644 --- a/Hash_map/benchmark/Hash_map/CMakeLists.txt +++ b/Hash_map/benchmark/Hash_map/CMakeLists.txt @@ -1,19 +1,9 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Hash_map ) - -cmake_minimum_required(VERSION 3.1) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) - else() - cmake_policy(VERSION 2.6) - endif() -endif() - - # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Hash_map/test/Hash_map/CMakeLists.txt b/Hash_map/test/Hash_map/CMakeLists.txt index dc3c46af912..7cacc28f58d 100644 --- a/Hash_map/test/Hash_map/CMakeLists.txt +++ b/Hash_map/test/Hash_map/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Hash_map_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Heat_method_3/examples/Heat_method_3/CMakeLists.txt b/Heat_method_3/examples/Heat_method_3/CMakeLists.txt index bd784bb1f76..ee40274e08e 100644 --- a/Heat_method_3/examples/Heat_method_3/CMakeLists.txt +++ b/Heat_method_3/examples/Heat_method_3/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Heat_method_3_Examples ) -cmake_minimum_required(VERSION 2.8.11) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Heat_method_3/test/Heat_method_3/CMakeLists.txt b/Heat_method_3/test/Heat_method_3/CMakeLists.txt index d498076d5b6..adb6cfa80c0 100644 --- a/Heat_method_3/test/Heat_method_3/CMakeLists.txt +++ b/Heat_method_3/test/Heat_method_3/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Heat_method_3_Tests ) -cmake_minimum_required(VERSION 2.8.11) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Hyperbolic_triangulation_2/benchmark/Hyperbolic_triangulation_2/CMakeLists.txt b/Hyperbolic_triangulation_2/benchmark/Hyperbolic_triangulation_2/CMakeLists.txt index 9d590a059a8..dc3db6a4d0b 100644 --- a/Hyperbolic_triangulation_2/benchmark/Hyperbolic_triangulation_2/CMakeLists.txt +++ b/Hyperbolic_triangulation_2/benchmark/Hyperbolic_triangulation_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Hyperbolic_triangulation_2_benchmark ) -cmake_minimum_required(VERSION 2.8.10) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt index 2a5cc5b55a4..f74d3a16aff 100644 --- a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt +++ b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.1...3.13) +cmake_minimum_required(VERSION 3.1...3.15) project (Hyperbolic_triangulation_2_Demo) # Find includes in corresponding build directories diff --git a/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/CMakeLists.txt b/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/CMakeLists.txt index e0d12591bab..cfec6f7b943 100644 --- a/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/CMakeLists.txt +++ b/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Hyperbolic_triangulation_2_Examples ) -cmake_minimum_required(VERSION 3.1...3.13) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Hyperbolic_triangulation_2/test/Hyperbolic_triangulation_2/CMakeLists.txt b/Hyperbolic_triangulation_2/test/Hyperbolic_triangulation_2/CMakeLists.txt index 73ee571e17d..61144763f2f 100644 --- a/Hyperbolic_triangulation_2/test/Hyperbolic_triangulation_2/CMakeLists.txt +++ b/Hyperbolic_triangulation_2/test/Hyperbolic_triangulation_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Hyperbolic_triangulation_2_Tests ) -cmake_minimum_required(VERSION 3.1...3.13) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Inscribed_areas/examples/Inscribed_areas/CMakeLists.txt b/Inscribed_areas/examples/Inscribed_areas/CMakeLists.txt index 3d5706c5c0d..9246a135634 100644 --- a/Inscribed_areas/examples/Inscribed_areas/CMakeLists.txt +++ b/Inscribed_areas/examples/Inscribed_areas/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Inscribed_areas_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Inscribed_areas/test/Inscribed_areas/CMakeLists.txt b/Inscribed_areas/test/Inscribed_areas/CMakeLists.txt index bbf3e5e4984..4f80ea65904 100644 --- a/Inscribed_areas/test/Inscribed_areas/CMakeLists.txt +++ b/Inscribed_areas/test/Inscribed_areas/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Inscribed_areas_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 67c02505d4e..43ecf358f28 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -4,14 +4,10 @@ # ${CMAKE_SOURCE_DIR} and to the root binary directory of the project as # ${CMAKE_BINARY_DIR} or ${CMAKE_BINARY_DIR}. if(NOT PROJECT_NAME) + cmake_minimum_required(VERSION 3.1...3.15) project(CGAL CXX C) endif() -# Minimal version of CMake: -cmake_minimum_required(VERSION 3.1) - -# Tested version: -cmake_policy(VERSION 3.1) if(POLICY CMP0056) # https://cmake.org/cmake/help/v3.2/policy/CMP0056.html diff --git a/Installation/demo/CMakeLists.txt b/Installation/demo/CMakeLists.txt index bc7742627a1..d418f55efc5 100644 --- a/Installation/demo/CMakeLists.txt +++ b/Installation/demo/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project(CGAL_DEMOS) -cmake_minimum_required(VERSION 3.1) if (CGAL_BRANCH_BUILD) diff --git a/Installation/examples/CMakeLists.txt b/Installation/examples/CMakeLists.txt index 643083964e5..4bfe831125a 100644 --- a/Installation/examples/CMakeLists.txt +++ b/Installation/examples/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project(CGAL_EXAMPLES) -cmake_minimum_required(VERSION 3.1) if (CGAL_BRANCH_BUILD) diff --git a/Installation/test/CMakeLists.txt b/Installation/test/CMakeLists.txt index b3d48f783e6..4191a3d8132 100644 --- a/Installation/test/CMakeLists.txt +++ b/Installation/test/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project(CGAL_TESTS) -cmake_minimum_required(VERSION 3.1) if (CGAL_BRANCH_BUILD) diff --git a/Installation/test/Installation/CMakeLists.txt b/Installation/test/Installation/CMakeLists.txt index a8e11520ed3..1428689fa6b 100644 --- a/Installation/test/Installation/CMakeLists.txt +++ b/Installation/test/Installation/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Installation_Tests ) -cmake_minimum_required(VERSION 3.1) macro(create_link_to_program COMPONENT ) diff --git a/Interpolation/demo/Interpolation/CMakeLists.txt b/Interpolation/demo/Interpolation/CMakeLists.txt index 17bf86f2500..c725480248b 100644 --- a/Interpolation/demo/Interpolation/CMakeLists.txt +++ b/Interpolation/demo/Interpolation/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Interpolation_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Interpolation/examples/Interpolation/CMakeLists.txt b/Interpolation/examples/Interpolation/CMakeLists.txt index d12b05c9cf7..e67f810beaf 100644 --- a/Interpolation/examples/Interpolation/CMakeLists.txt +++ b/Interpolation/examples/Interpolation/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Interpolation_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Interpolation/test/Interpolation/CMakeLists.txt b/Interpolation/test/Interpolation/CMakeLists.txt index d0cf0974741..cd63391899a 100644 --- a/Interpolation/test/Interpolation/CMakeLists.txt +++ b/Interpolation/test/Interpolation/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Interpolation_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Intersections_2/test/Intersections_2/CMakeLists.txt b/Intersections_2/test/Intersections_2/CMakeLists.txt index 8776da99898..ca7c9af6f7f 100644 --- a/Intersections_2/test/Intersections_2/CMakeLists.txt +++ b/Intersections_2/test/Intersections_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Intersections_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Intersections_3/test/Intersections_3/CMakeLists.txt b/Intersections_3/test/Intersections_3/CMakeLists.txt index f218d33bd42..9c0b854325c 100644 --- a/Intersections_3/test/Intersections_3/CMakeLists.txt +++ b/Intersections_3/test/Intersections_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Intersections_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Interval_skip_list/examples/Interval_skip_list/CMakeLists.txt b/Interval_skip_list/examples/Interval_skip_list/CMakeLists.txt index 2d26929b883..5e56b2e0441 100644 --- a/Interval_skip_list/examples/Interval_skip_list/CMakeLists.txt +++ b/Interval_skip_list/examples/Interval_skip_list/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Interval_skip_list_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Interval_skip_list/test/Interval_skip_list/CMakeLists.txt b/Interval_skip_list/test/Interval_skip_list/CMakeLists.txt index 9245b8e32a4..ddd8e03515e 100644 --- a/Interval_skip_list/test/Interval_skip_list/CMakeLists.txt +++ b/Interval_skip_list/test/Interval_skip_list/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Interval_skip_list_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Interval_support/test/Interval_support/CMakeLists.txt b/Interval_support/test/Interval_support/CMakeLists.txt index 220902b3b7d..f2b07259aaa 100644 --- a/Interval_support/test/Interval_support/CMakeLists.txt +++ b/Interval_support/test/Interval_support/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Interval_support_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Inventor/test/Inventor/CMakeLists.txt b/Inventor/test/Inventor/CMakeLists.txt index cf2ec4f6944..0d296008396 100644 --- a/Inventor/test/Inventor/CMakeLists.txt +++ b/Inventor/test/Inventor/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Inventor_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Jet_fitting_3/examples/Jet_fitting_3/CMakeLists.txt b/Jet_fitting_3/examples/Jet_fitting_3/CMakeLists.txt index 51cf4c4b351..19a1b9d32bd 100644 --- a/Jet_fitting_3/examples/Jet_fitting_3/CMakeLists.txt +++ b/Jet_fitting_3/examples/Jet_fitting_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Jet_fitting_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Jet_fitting_3/test/Jet_fitting_3/CMakeLists.txt b/Jet_fitting_3/test/Jet_fitting_3/CMakeLists.txt index 14e3e10e01b..c1cbc58150d 100644 --- a/Jet_fitting_3/test/Jet_fitting_3/CMakeLists.txt +++ b/Jet_fitting_3/test/Jet_fitting_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Jet_fitting_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Kernel_23/examples/Kernel_23/CMakeLists.txt b/Kernel_23/examples/Kernel_23/CMakeLists.txt index efa36a2a3e9..0a49ed4e2b5 100644 --- a/Kernel_23/examples/Kernel_23/CMakeLists.txt +++ b/Kernel_23/examples/Kernel_23/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Kernel_23_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Kernel_23/test/Kernel_23/CMakeLists.txt b/Kernel_23/test/Kernel_23/CMakeLists.txt index 4a2dec20634..e75adb41e34 100644 --- a/Kernel_23/test/Kernel_23/CMakeLists.txt +++ b/Kernel_23/test/Kernel_23/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Kernel_23_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Kernel_d/test/Kernel_d/CMakeLists.txt b/Kernel_d/test/Kernel_d/CMakeLists.txt index d762e532a7a..a51d50d4063 100644 --- a/Kernel_d/test/Kernel_d/CMakeLists.txt +++ b/Kernel_d/test/Kernel_d/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Kernel_d_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Linear_cell_complex/benchmark/Linear_cell_complex_2/CMakeLists.txt b/Linear_cell_complex/benchmark/Linear_cell_complex_2/CMakeLists.txt index f80ad42a2ee..104ba1e1e06 100644 --- a/Linear_cell_complex/benchmark/Linear_cell_complex_2/CMakeLists.txt +++ b/Linear_cell_complex/benchmark/Linear_cell_complex_2/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project(LCC_performance_2) -cmake_minimum_required(VERSION 3.1) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/) diff --git a/Linear_cell_complex/benchmark/Linear_cell_complex_3/CMakeLists.txt b/Linear_cell_complex/benchmark/Linear_cell_complex_3/CMakeLists.txt index e3eff7e6d85..5deb9decee3 100644 --- a/Linear_cell_complex/benchmark/Linear_cell_complex_3/CMakeLists.txt +++ b/Linear_cell_complex/benchmark/Linear_cell_complex_3/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project(LCC_performance_3) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt b/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt index d23afa5eb3d..23122c42449 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt +++ b/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. # cmake ../ -DCMAKE_BUILD_TYPE=Debug +cmake_minimum_required(VERSION 3.1...3.15) project (Linear_cell_complex_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Linear_cell_complex/examples/Linear_cell_complex/CMakeLists.txt b/Linear_cell_complex/examples/Linear_cell_complex/CMakeLists.txt index 4ed3f8f2f2c..270c76321d8 100644 --- a/Linear_cell_complex/examples/Linear_cell_complex/CMakeLists.txt +++ b/Linear_cell_complex/examples/Linear_cell_complex/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Linear_cell_complex_Examples ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt b/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt index 9ae14e0d428..83ce4a56d3d 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt +++ b/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Linear_cell_complex_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Matrix_search/examples/Matrix_search/CMakeLists.txt b/Matrix_search/examples/Matrix_search/CMakeLists.txt index d72870c96af..06b6e55653e 100644 --- a/Matrix_search/examples/Matrix_search/CMakeLists.txt +++ b/Matrix_search/examples/Matrix_search/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Matrix_search_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Matrix_search/test/Matrix_search/CMakeLists.txt b/Matrix_search/test/Matrix_search/CMakeLists.txt index fd3de9c33ab..b64f9a2ce51 100644 --- a/Matrix_search/test/Matrix_search/CMakeLists.txt +++ b/Matrix_search/test/Matrix_search/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Matrix_search_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Mesh_2/demo/Mesh_2/CMakeLists.txt b/Mesh_2/demo/Mesh_2/CMakeLists.txt index f50101e391a..5d2a871c8bd 100644 --- a/Mesh_2/demo/Mesh_2/CMakeLists.txt +++ b/Mesh_2/demo/Mesh_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script (and then adapted manually). # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Mesh_2_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Mesh_2/examples/Mesh_2/CMakeLists.txt b/Mesh_2/examples/Mesh_2/CMakeLists.txt index 69148ac52ee..dba5c15ac7f 100644 --- a/Mesh_2/examples/Mesh_2/CMakeLists.txt +++ b/Mesh_2/examples/Mesh_2/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Mesh_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Mesh_2/test/Mesh_2/CMakeLists.txt b/Mesh_2/test/Mesh_2/CMakeLists.txt index e5bb16314ee..dbad6bab456 100644 --- a/Mesh_2/test/Mesh_2/CMakeLists.txt +++ b/Mesh_2/test/Mesh_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Mesh_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Mesh_3/archive/applications/CMakeLists.txt b/Mesh_3/archive/applications/CMakeLists.txt index 9ce425b3cd8..688379dab15 100644 --- a/Mesh_3/archive/applications/CMakeLists.txt +++ b/Mesh_3/archive/applications/CMakeLists.txt @@ -2,10 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Mesh_3_applications ) -CMAKE_MINIMUM_REQUIRED(VERSION 3.1) - include_directories(../include) diff --git a/Mesh_3/benchmark/Mesh_3/CMakeLists.txt b/Mesh_3/benchmark/Mesh_3/CMakeLists.txt index 27422304a52..5192a5b79a1 100644 --- a/Mesh_3/benchmark/Mesh_3/CMakeLists.txt +++ b/Mesh_3/benchmark/Mesh_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Mesh_3_benchmark ) -cmake_minimum_required(VERSION 3.1) # Creates a new CMake option, turned ON by default diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index 629102a8891..363821b8f97 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Mesh_3_Examples ) -cmake_minimum_required(VERSION 3.1) add_definitions(-DCGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX diff --git a/Mesh_3/test/Mesh_3/CMakeLists.txt b/Mesh_3/test/Mesh_3/CMakeLists.txt index 9416ffb65a5..03f021a7172 100644 --- a/Mesh_3/test/Mesh_3/CMakeLists.txt +++ b/Mesh_3/test/Mesh_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Mesh_3_Tests ) -cmake_minimum_required(VERSION 3.1) if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) diff --git a/Minkowski_sum_2/examples/Minkowski_sum_2/CMakeLists.txt b/Minkowski_sum_2/examples/Minkowski_sum_2/CMakeLists.txt index 2f136a10e3f..b6eba1ecf06 100644 --- a/Minkowski_sum_2/examples/Minkowski_sum_2/CMakeLists.txt +++ b/Minkowski_sum_2/examples/Minkowski_sum_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Minkowski_sum_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Minkowski_sum_2/test/Minkowski_sum_2/CMakeLists.txt b/Minkowski_sum_2/test/Minkowski_sum_2/CMakeLists.txt index d33c2b035fc..1399a98fe6b 100644 --- a/Minkowski_sum_2/test/Minkowski_sum_2/CMakeLists.txt +++ b/Minkowski_sum_2/test/Minkowski_sum_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Minkowski_sum_2_Tests ) -cmake_minimum_required(VERSION 3.1) # Commented out C++11 for now # list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_generalized_initializers has_cpp11) diff --git a/Minkowski_sum_3/examples/Minkowski_sum_3/CMakeLists.txt b/Minkowski_sum_3/examples/Minkowski_sum_3/CMakeLists.txt index 48979916032..1139a09ca1a 100644 --- a/Minkowski_sum_3/examples/Minkowski_sum_3/CMakeLists.txt +++ b/Minkowski_sum_3/examples/Minkowski_sum_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Minkowski_sum_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Minkowski_sum_3/test/Minkowski_sum_3/CMakeLists.txt b/Minkowski_sum_3/test/Minkowski_sum_3/CMakeLists.txt index 6dd6ab412ca..3e63dc654a9 100644 --- a/Minkowski_sum_3/test/Minkowski_sum_3/CMakeLists.txt +++ b/Minkowski_sum_3/test/Minkowski_sum_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Minkowski_sum_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Modifier/test/Modifier/CMakeLists.txt b/Modifier/test/Modifier/CMakeLists.txt index 5725a932f98..3963e02285c 100644 --- a/Modifier/test/Modifier/CMakeLists.txt +++ b/Modifier/test/Modifier/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Modifier_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Modular_arithmetic/examples/Modular_arithmetic/CMakeLists.txt b/Modular_arithmetic/examples/Modular_arithmetic/CMakeLists.txt index 7938201664d..4fd088120ec 100644 --- a/Modular_arithmetic/examples/Modular_arithmetic/CMakeLists.txt +++ b/Modular_arithmetic/examples/Modular_arithmetic/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Modular_arithmetic_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Modular_arithmetic/test/Modular_arithmetic/CMakeLists.txt b/Modular_arithmetic/test/Modular_arithmetic/CMakeLists.txt index 87d9c78a2c2..0af90f16bab 100644 --- a/Modular_arithmetic/test/Modular_arithmetic/CMakeLists.txt +++ b/Modular_arithmetic/test/Modular_arithmetic/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Modular_arithmetic_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Nef_2/examples/Nef_2/CMakeLists.txt b/Nef_2/examples/Nef_2/CMakeLists.txt index f9e6a9469f4..291dbb406ef 100644 --- a/Nef_2/examples/Nef_2/CMakeLists.txt +++ b/Nef_2/examples/Nef_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Nef_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Nef_2/test/Nef_2/CMakeLists.txt b/Nef_2/test/Nef_2/CMakeLists.txt index d7b38938cf1..4807a0e67e1 100644 --- a/Nef_2/test/Nef_2/CMakeLists.txt +++ b/Nef_2/test/Nef_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Nef_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Nef_3/examples/Nef_3/CMakeLists.txt b/Nef_3/examples/Nef_3/CMakeLists.txt index c2f45ea20a4..ec12fc129f2 100644 --- a/Nef_3/examples/Nef_3/CMakeLists.txt +++ b/Nef_3/examples/Nef_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Nef_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Nef_3/test/Nef_3/CMakeLists.txt b/Nef_3/test/Nef_3/CMakeLists.txt index d7661acf34e..298c66dea57 100644 --- a/Nef_3/test/Nef_3/CMakeLists.txt +++ b/Nef_3/test/Nef_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Nef_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Nef_S2/examples/Nef_S2/CMakeLists.txt b/Nef_S2/examples/Nef_S2/CMakeLists.txt index 7b698fa8636..6eaf799c38c 100644 --- a/Nef_S2/examples/Nef_S2/CMakeLists.txt +++ b/Nef_S2/examples/Nef_S2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Nef_S2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Nef_S2/test/Nef_S2/CMakeLists.txt b/Nef_S2/test/Nef_S2/CMakeLists.txt index 2690878885b..e4005c20794 100644 --- a/Nef_S2/test/Nef_S2/CMakeLists.txt +++ b/Nef_S2/test/Nef_S2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Nef_S2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/NewKernel_d/test/NewKernel_d/CMakeLists.txt b/NewKernel_d/test/NewKernel_d/CMakeLists.txt index 36b37c8bb60..9cbe76d8204 100644 --- a/NewKernel_d/test/NewKernel_d/CMakeLists.txt +++ b/NewKernel_d/test/NewKernel_d/CMakeLists.txt @@ -3,9 +3,9 @@ # Then modified by hand to add Eigen3. +cmake_minimum_required(VERSION 3.1...3.15) project( NewKernel_d_Tests ) -cmake_minimum_required(VERSION 3.1) if(CMAKE_COMPILER_IS_GNUCCX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) message(STATUS "NOTICE: this directory requires a version of gcc >= 4.4, and will not be compiled.") diff --git a/Number_types/test/Number_types/CMakeLists.txt b/Number_types/test/Number_types/CMakeLists.txt index fc85257730e..6a74945aea9 100644 --- a/Number_types/test/Number_types/CMakeLists.txt +++ b/Number_types/test/Number_types/CMakeLists.txt @@ -3,9 +3,9 @@ # that dependency so as to test all the number types not depending on CORE # when it is not installed +cmake_minimum_required(VERSION 3.1...3.15) project( Number_types_Tests ) -cmake_minimum_required(VERSION 3.1) find_package( CGAL QUIET COMPONENTS Core ) diff --git a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/CMakeLists.txt b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/CMakeLists.txt index 86f1b6be942..df6b3c38c1b 100644 --- a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/CMakeLists.txt +++ b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/CMakeLists.txt @@ -1,8 +1,8 @@ # This is the CMake script for compiling the Optimal_transportation_reconstruction_2 demo. +cmake_minimum_required(VERSION 3.1...3.15) project(Optimal_transportation_reconstruction_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Optimal_transportation_reconstruction_2/examples/Optimal_transportation_reconstruction_2/CMakeLists.txt b/Optimal_transportation_reconstruction_2/examples/Optimal_transportation_reconstruction_2/CMakeLists.txt index a36c1b65b10..7ed964cdd54 100644 --- a/Optimal_transportation_reconstruction_2/examples/Optimal_transportation_reconstruction_2/CMakeLists.txt +++ b/Optimal_transportation_reconstruction_2/examples/Optimal_transportation_reconstruction_2/CMakeLists.txt @@ -1,14 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Optimal_transportation_reconstruction_2_Examples ) -cmake_minimum_required(VERSION 3.1) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) - else() - cmake_policy(VERSION 2.6) - endif() -endif() - find_package(CGAL QUIET) if ( CGAL_FOUND ) diff --git a/Optimal_transportation_reconstruction_2/test/Optimal_transportation_reconstruction_2/CMakeLists.txt b/Optimal_transportation_reconstruction_2/test/Optimal_transportation_reconstruction_2/CMakeLists.txt index fb284c89da7..09505a34174 100644 --- a/Optimal_transportation_reconstruction_2/test/Optimal_transportation_reconstruction_2/CMakeLists.txt +++ b/Optimal_transportation_reconstruction_2/test/Optimal_transportation_reconstruction_2/CMakeLists.txt @@ -1,14 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Optimal_transportation_reconstruction_2_Tests ) -cmake_minimum_required(VERSION 3.1) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) - else() - cmake_policy(VERSION 2.6) - endif() -endif() - find_package(CGAL QUIET) if ( CGAL_FOUND ) diff --git a/Partition_2/examples/Partition_2/CMakeLists.txt b/Partition_2/examples/Partition_2/CMakeLists.txt index aafa87d0e5b..bd03b5b2bd5 100644 --- a/Partition_2/examples/Partition_2/CMakeLists.txt +++ b/Partition_2/examples/Partition_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Partition_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Partition_2/test/Partition_2/CMakeLists.txt b/Partition_2/test/Partition_2/CMakeLists.txt index 915bee9792f..8c5243d1204 100644 --- a/Partition_2/test/Partition_2/CMakeLists.txt +++ b/Partition_2/test/Partition_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Partition_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/CMakeLists.txt b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/CMakeLists.txt index 2f9d63ad422..71e272f464c 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/CMakeLists.txt +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_2_triangulation_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/CMakeLists.txt b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/CMakeLists.txt index 3c8e59f8f34..6a285a1b067 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/CMakeLists.txt +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_2_triangulation_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/CMakeLists.txt b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/CMakeLists.txt index 4c3efde1ded..b18274683b9 100644 --- a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/CMakeLists.txt +++ b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_3_mesh_3_Examples ) -cmake_minimum_required(VERSION 3.1) if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) diff --git a/Periodic_3_mesh_3/test/Periodic_3_mesh_3/CMakeLists.txt b/Periodic_3_mesh_3/test/Periodic_3_mesh_3/CMakeLists.txt index 68ab382ea9f..dddf3a8f260 100644 --- a/Periodic_3_mesh_3/test/Periodic_3_mesh_3/CMakeLists.txt +++ b/Periodic_3_mesh_3/test/Periodic_3_mesh_3/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_3_mesh_3_Tests ) -cmake_minimum_required(VERSION 3.1) if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt index 43189c01d4a..eb9fc4be537 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt @@ -2,9 +2,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_3_triangulation_3_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/CMakeLists.txt b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/CMakeLists.txt index 151d1e3afc1..769c1dd3f1c 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/CMakeLists.txt +++ b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Periodic_Lloyd_3_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Periodic_3_triangulation_3/examples/Periodic_3_triangulation_3/CMakeLists.txt b/Periodic_3_triangulation_3/examples/Periodic_3_triangulation_3/CMakeLists.txt index 2a5ab412405..0698a06d176 100644 --- a/Periodic_3_triangulation_3/examples/Periodic_3_triangulation_3/CMakeLists.txt +++ b/Periodic_3_triangulation_3/examples/Periodic_3_triangulation_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_3_triangulation_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Periodic_3_triangulation_3/test/Periodic_3_triangulation_3/CMakeLists.txt b/Periodic_3_triangulation_3/test/Periodic_3_triangulation_3/CMakeLists.txt index 8c11ea11b00..44e7beae244 100644 --- a/Periodic_3_triangulation_3/test/Periodic_3_triangulation_3/CMakeLists.txt +++ b/Periodic_3_triangulation_3/test/Periodic_3_triangulation_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_3_triangulation_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Periodic_4_hyperbolic_triangulation_2/benchmark/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt b/Periodic_4_hyperbolic_triangulation_2/benchmark/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt index 5f03ee9e575..c33f5aa4303 100644 --- a/Periodic_4_hyperbolic_triangulation_2/benchmark/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt +++ b/Periodic_4_hyperbolic_triangulation_2/benchmark/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_4_hyperbolic_triangulation_2_Benchmarks ) -cmake_minimum_required(VERSION 2.8.10) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Periodic_4_hyperbolic_triangulation_2/demo/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt b/Periodic_4_hyperbolic_triangulation_2/demo/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt index ee07f1a1066..663515d9ce9 100644 --- a/Periodic_4_hyperbolic_triangulation_2/demo/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt +++ b/Periodic_4_hyperbolic_triangulation_2/demo/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.1...3.13) +cmake_minimum_required(VERSION 3.1...3.15) project (Periodic_4_hyperbolic_triangulation_2_Demo) # Find includes in corresponding build directories diff --git a/Periodic_4_hyperbolic_triangulation_2/examples/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt b/Periodic_4_hyperbolic_triangulation_2/examples/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt index 62dc88202d6..0632fe87dfb 100644 --- a/Periodic_4_hyperbolic_triangulation_2/examples/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt +++ b/Periodic_4_hyperbolic_triangulation_2/examples/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.1...3.13) +cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_4_hyperbolic_triangulation_2_Examples ) find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core ) diff --git a/Periodic_4_hyperbolic_triangulation_2/test/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt b/Periodic_4_hyperbolic_triangulation_2/test/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt index 4a8d692d39a..d758a43f33d 100644 --- a/Periodic_4_hyperbolic_triangulation_2/test/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt +++ b/Periodic_4_hyperbolic_triangulation_2/test/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.1...3.13) +cmake_minimum_required(VERSION 3.1...3.15) project( Periodic_4_hyperbolic_triangulation_2_Tests ) find_package(CGAL REQUIRED QUIET OPTIONAL_COMPONENTS Core ) diff --git a/Point_set_2/examples/Point_set_2/CMakeLists.txt b/Point_set_2/examples/Point_set_2/CMakeLists.txt index 5c0becc7051..f477eb4d8bf 100644 --- a/Point_set_2/examples/Point_set_2/CMakeLists.txt +++ b/Point_set_2/examples/Point_set_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Point_set_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Point_set_2/test/Point_set_2/CMakeLists.txt b/Point_set_2/test/Point_set_2/CMakeLists.txt index 603c5f5a225..814bb1127a2 100644 --- a/Point_set_2/test/Point_set_2/CMakeLists.txt +++ b/Point_set_2/test/Point_set_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Point_set_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Point_set_3/examples/Point_set_3/CMakeLists.txt b/Point_set_3/examples/Point_set_3/CMakeLists.txt index 3820a32ef72..100e1919211 100644 --- a/Point_set_3/examples/Point_set_3/CMakeLists.txt +++ b/Point_set_3/examples/Point_set_3/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Point_set_3_Examples ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Point_set_3/test/Point_set_3/CMakeLists.txt b/Point_set_3/test/Point_set_3/CMakeLists.txt index 31df0bdf038..53f69efc6c3 100644 --- a/Point_set_3/test/Point_set_3/CMakeLists.txt +++ b/Point_set_3/test/Point_set_3/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Point_set_3_Tests ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Point_set_processing_3/examples/Point_set_processing_3/CMakeLists.txt b/Point_set_processing_3/examples/Point_set_processing_3/CMakeLists.txt index cf741624daa..c2da826d49b 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/CMakeLists.txt +++ b/Point_set_processing_3/examples/Point_set_processing_3/CMakeLists.txt @@ -1,8 +1,8 @@ # This is the CMake script for compiling this folder. +cmake_minimum_required(VERSION 3.1...3.15) project( Point_set_processing_3_Examples ) -cmake_minimum_required(VERSION 3.1) # Find CGAL diff --git a/Point_set_processing_3/test/Point_set_processing_3/CMakeLists.txt b/Point_set_processing_3/test/Point_set_processing_3/CMakeLists.txt index e168fc5f532..264c713ef55 100644 --- a/Point_set_processing_3/test/Point_set_processing_3/CMakeLists.txt +++ b/Point_set_processing_3/test/Point_set_processing_3/CMakeLists.txt @@ -1,8 +1,8 @@ # This is the CMake script for compiling this folder. +cmake_minimum_required(VERSION 3.1...3.15) project( Point_set_processing_3_Tests ) -cmake_minimum_required(VERSION 3.1) # Find CGAL diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/CMakeLists.txt b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/CMakeLists.txt index b3bba3377a4..ae0215158da 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/CMakeLists.txt +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/CMakeLists.txt @@ -1,8 +1,8 @@ # This is the CMake script for compiling this folder. +cmake_minimum_required(VERSION 3.1...3.15) project( Poisson_surface_reconstruction_3_Examples ) -cmake_minimum_required(VERSION 3.1) # Find CGAL find_package(CGAL QUIET) diff --git a/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/CMakeLists.txt b/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/CMakeLists.txt index 877911b52d0..e1d9326840b 100644 --- a/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/CMakeLists.txt +++ b/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/CMakeLists.txt @@ -1,8 +1,8 @@ # This is the CMake script for compiling this folder. +cmake_minimum_required(VERSION 3.1...3.15) project( Poisson_surface_reconstruction_3_Tests ) -cmake_minimum_required(VERSION 3.1) # Find CGAL find_package(CGAL QUIET) diff --git a/Polygon/examples/Polygon/CMakeLists.txt b/Polygon/examples/Polygon/CMakeLists.txt index af10e6bde24..fbd4cbe65e2 100644 --- a/Polygon/examples/Polygon/CMakeLists.txt +++ b/Polygon/examples/Polygon/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polygon_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Polygon/test/Polygon/CMakeLists.txt b/Polygon/test/Polygon/CMakeLists.txt index bff643827c4..8174c9a6be7 100644 --- a/Polygon/test/Polygon/CMakeLists.txt +++ b/Polygon/test/Polygon/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polygon_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Polygon_mesh_processing/benchmark/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/benchmark/Polygon_mesh_processing/CMakeLists.txt index b5c986dcaf0..45799830a42 100644 --- a/Polygon_mesh_processing/benchmark/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/benchmark/Polygon_mesh_processing/CMakeLists.txt @@ -1,19 +1,9 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Polygon_mesh_processing ) - -cmake_minimum_required(VERSION 3.1) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) - else() - cmake_policy(VERSION 2.6) - endif() -endif() - - # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index 2f853f6cbe6..23fad404af5 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -1,19 +1,9 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Polygon_mesh_processing_Examples ) - -cmake_minimum_required(VERSION 3.1) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) - else() - cmake_policy(VERSION 2.6) - endif() -endif() - - # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 686447f26d4..6242058639f 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -1,19 +1,9 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Polygon_mesh_processing_Tests ) - -cmake_minimum_required(VERSION 3.1) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) - else() - cmake_policy(VERSION 2.6) - endif() -endif() - - # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index 7b4a38c2349..d1c810bba9c 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -1,8 +1,8 @@ # This is the CMake script for compiling the CGAL Polyhedron demo. +cmake_minimum_required(VERSION 3.1...3.15) project( Polyhedron_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Polyhedron/demo/Polyhedron/implicit_functions/CMakeLists.txt b/Polyhedron/demo/Polyhedron/implicit_functions/CMakeLists.txt index 6d3fcbd6a36..119f805359f 100644 --- a/Polyhedron/demo/Polyhedron/implicit_functions/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/implicit_functions/CMakeLists.txt @@ -1,10 +1,10 @@ # This is the CMake script for compiling the CGAL Mesh_3 demo implicit functions. +cmake_minimum_required(VERSION 3.1...3.15) project( Mesh_3_implicit_functions ) include( polyhedron_demo_macros ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Polyhedron/examples/Polyhedron/CMakeLists.txt b/Polyhedron/examples/Polyhedron/CMakeLists.txt index e5574f90c81..a4860a0c20e 100644 --- a/Polyhedron/examples/Polyhedron/CMakeLists.txt +++ b/Polyhedron/examples/Polyhedron/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polyhedron_Examples ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. diff --git a/Polyhedron/test/Polyhedron/CMakeLists.txt b/Polyhedron/test/Polyhedron/CMakeLists.txt index 31d0d094a97..6a35171a29c 100644 --- a/Polyhedron/test/Polyhedron/CMakeLists.txt +++ b/Polyhedron/test/Polyhedron/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polyhedron_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Polyhedron_IO/demo/Polyhedron_IO/CMakeLists.txt b/Polyhedron_IO/demo/Polyhedron_IO/CMakeLists.txt index c87775195e5..642f5f5b4b1 100644 --- a/Polyhedron_IO/demo/Polyhedron_IO/CMakeLists.txt +++ b/Polyhedron_IO/demo/Polyhedron_IO/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polyhedron_IO_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Polyhedron_IO/examples/Polyhedron_IO/CMakeLists.txt b/Polyhedron_IO/examples/Polyhedron_IO/CMakeLists.txt index d2f8d510146..1de0b8a91f5 100644 --- a/Polyhedron_IO/examples/Polyhedron_IO/CMakeLists.txt +++ b/Polyhedron_IO/examples/Polyhedron_IO/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polyhedron_IO_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Polyhedron_IO/test/Polyhedron_IO/CMakeLists.txt b/Polyhedron_IO/test/Polyhedron_IO/CMakeLists.txt index 91a97ec855f..ac42c32b8d0 100644 --- a/Polyhedron_IO/test/Polyhedron_IO/CMakeLists.txt +++ b/Polyhedron_IO/test/Polyhedron_IO/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polyhedron_IO_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Polyline_simplification_2/demo/Polyline_simplification_2/CMakeLists.txt b/Polyline_simplification_2/demo/Polyline_simplification_2/CMakeLists.txt index 5ef3513ac7a..609cbec4045 100644 --- a/Polyline_simplification_2/demo/Polyline_simplification_2/CMakeLists.txt +++ b/Polyline_simplification_2/demo/Polyline_simplification_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Polyline_simplification_2_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Polyline_simplification_2/examples/Polyline_simplification_2/CMakeLists.txt b/Polyline_simplification_2/examples/Polyline_simplification_2/CMakeLists.txt index db749400699..f0fb3f70fd4 100644 --- a/Polyline_simplification_2/examples/Polyline_simplification_2/CMakeLists.txt +++ b/Polyline_simplification_2/examples/Polyline_simplification_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polyline_simplification_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Polyline_simplification_2/test/Polyline_simplification_2/CMakeLists.txt b/Polyline_simplification_2/test/Polyline_simplification_2/CMakeLists.txt index 3430ed90e69..5f17ccc05da 100644 --- a/Polyline_simplification_2/test/Polyline_simplification_2/CMakeLists.txt +++ b/Polyline_simplification_2/test/Polyline_simplification_2/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Polyline_simplification_2_Tests ) -cmake_minimum_required(VERSION 3.1) diff --git a/Polynomial/examples/Polynomial/CMakeLists.txt b/Polynomial/examples/Polynomial/CMakeLists.txt index b71a6c04a11..c48b015fbd2 100644 --- a/Polynomial/examples/Polynomial/CMakeLists.txt +++ b/Polynomial/examples/Polynomial/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polynomial_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Polynomial/test/Polynomial/CMakeLists.txt b/Polynomial/test/Polynomial/CMakeLists.txt index e274a106b8d..5df0e9350a0 100644 --- a/Polynomial/test/Polynomial/CMakeLists.txt +++ b/Polynomial/test/Polynomial/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polynomial_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Polytope_distance_d/examples/Polytope_distance_d/CMakeLists.txt b/Polytope_distance_d/examples/Polytope_distance_d/CMakeLists.txt index 1b63b201100..0aa288958b5 100644 --- a/Polytope_distance_d/examples/Polytope_distance_d/CMakeLists.txt +++ b/Polytope_distance_d/examples/Polytope_distance_d/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polytope_distance_d_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Polytope_distance_d/test/Polytope_distance_d/CMakeLists.txt b/Polytope_distance_d/test/Polytope_distance_d/CMakeLists.txt index 4e015e31e20..d9e10bd47c3 100644 --- a/Polytope_distance_d/test/Polytope_distance_d/CMakeLists.txt +++ b/Polytope_distance_d/test/Polytope_distance_d/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Polytope_distance_d_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt b/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt index 4c13d2781f5..128b250b8f1 100644 --- a/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt +++ b/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt @@ -1,8 +1,8 @@ # This is the CMake script for compiling the PCA demo. +cmake_minimum_required(VERSION 3.1...3.15) project( Principal_component_analysis_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Principal_component_analysis/examples/Principal_component_analysis/CMakeLists.txt b/Principal_component_analysis/examples/Principal_component_analysis/CMakeLists.txt index 832207a6daa..0518b6ea3cd 100644 --- a/Principal_component_analysis/examples/Principal_component_analysis/CMakeLists.txt +++ b/Principal_component_analysis/examples/Principal_component_analysis/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Principal_component_analysis_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Principal_component_analysis/test/Principal_component_analysis/CMakeLists.txt b/Principal_component_analysis/test/Principal_component_analysis/CMakeLists.txt index b7695c9965b..93abc4b5e32 100644 --- a/Principal_component_analysis/test/Principal_component_analysis/CMakeLists.txt +++ b/Principal_component_analysis/test/Principal_component_analysis/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Principal_component_analysis_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Profiling_tools/examples/Profiling_tools/CMakeLists.txt b/Profiling_tools/examples/Profiling_tools/CMakeLists.txt index f314d77d073..a6ceff687f1 100644 --- a/Profiling_tools/examples/Profiling_tools/CMakeLists.txt +++ b/Profiling_tools/examples/Profiling_tools/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Profiling_tools_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Profiling_tools/test/Profiling_tools/CMakeLists.txt b/Profiling_tools/test/Profiling_tools/CMakeLists.txt index b087980e759..516ea7993a5 100644 --- a/Profiling_tools/test/Profiling_tools/CMakeLists.txt +++ b/Profiling_tools/test/Profiling_tools/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Profiling_tools_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Property_map/examples/Property_map/CMakeLists.txt b/Property_map/examples/Property_map/CMakeLists.txt index 82384c7e7fb..19f1e6fa5ed 100644 --- a/Property_map/examples/Property_map/CMakeLists.txt +++ b/Property_map/examples/Property_map/CMakeLists.txt @@ -1,7 +1,7 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Property_map_Examples ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Property_map/test/Property_map/CMakeLists.txt b/Property_map/test/Property_map/CMakeLists.txt index 5208cf86184..610689246fa 100644 --- a/Property_map/test/Property_map/CMakeLists.txt +++ b/Property_map/test/Property_map/CMakeLists.txt @@ -1,8 +1,8 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Property_map_Tests ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/QP_solver/examples/QP_solver/CMakeLists.txt b/QP_solver/examples/QP_solver/CMakeLists.txt index 208ed0358ac..46c011aeed9 100644 --- a/QP_solver/examples/QP_solver/CMakeLists.txt +++ b/QP_solver/examples/QP_solver/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( QP_solver_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/QP_solver/test/QP_solver/CMakeLists.txt b/QP_solver/test/QP_solver/CMakeLists.txt index ec9ad49e801..b82ad8b0985 100644 --- a/QP_solver/test/QP_solver/CMakeLists.txt +++ b/QP_solver/test/QP_solver/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( QP_solver_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Random_numbers/test/Random_numbers/CMakeLists.txt b/Random_numbers/test/Random_numbers/CMakeLists.txt index 927421b6a3f..7f575e303ab 100644 --- a/Random_numbers/test/Random_numbers/CMakeLists.txt +++ b/Random_numbers/test/Random_numbers/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Random_numbers_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Ridges_3/examples/Ridges_3/CMakeLists.txt b/Ridges_3/examples/Ridges_3/CMakeLists.txt index b682835c270..c6409270728 100644 --- a/Ridges_3/examples/Ridges_3/CMakeLists.txt +++ b/Ridges_3/examples/Ridges_3/CMakeLists.txt @@ -1,7 +1,7 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Ridges_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET ) diff --git a/Ridges_3/test/Ridges_3/CMakeLists.txt b/Ridges_3/test/Ridges_3/CMakeLists.txt index 99a76fe4426..8ed993f8e6b 100644 --- a/Ridges_3/test/Ridges_3/CMakeLists.txt +++ b/Ridges_3/test/Ridges_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Ridges_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/STL_Extension/benchmark/compact_container_benchmark/CMakeLists.txt b/STL_Extension/benchmark/compact_container_benchmark/CMakeLists.txt index bb3785edbd3..4bfa4327eb0 100644 --- a/STL_Extension/benchmark/compact_container_benchmark/CMakeLists.txt +++ b/STL_Extension/benchmark/compact_container_benchmark/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Compact_container_benchmark ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/STL_Extension/benchmark/copy_n_benchmark/CMakeLists.txt b/STL_Extension/benchmark/copy_n_benchmark/CMakeLists.txt index 51f7a18b9eb..bd9affca7ab 100644 --- a/STL_Extension/benchmark/copy_n_benchmark/CMakeLists.txt +++ b/STL_Extension/benchmark/copy_n_benchmark/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( copy_n_benchmark_example ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/STL_Extension/examples/STL_Extension/CMakeLists.txt b/STL_Extension/examples/STL_Extension/CMakeLists.txt index 40753532e8a..8ec5a7c080e 100644 --- a/STL_Extension/examples/STL_Extension/CMakeLists.txt +++ b/STL_Extension/examples/STL_Extension/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( STL_Extension_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/STL_Extension/test/STL_Extension/CMakeLists.txt b/STL_Extension/test/STL_Extension/CMakeLists.txt index b7fb77d3d9d..419220ed841 100644 --- a/STL_Extension/test/STL_Extension/CMakeLists.txt +++ b/STL_Extension/test/STL_Extension/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( STL_Extension_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Scale_space_reconstruction_3/examples/Scale_space_reconstruction_3/CMakeLists.txt b/Scale_space_reconstruction_3/examples/Scale_space_reconstruction_3/CMakeLists.txt index bfa682995fa..bab0af3c5b1 100644 --- a/Scale_space_reconstruction_3/examples/Scale_space_reconstruction_3/CMakeLists.txt +++ b/Scale_space_reconstruction_3/examples/Scale_space_reconstruction_3/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Scale_space_reconstruction_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package( CGAL QUIET) diff --git a/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake b/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake index 66385cbc1a6..d70e17a3b4a 100644 --- a/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake +++ b/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake @@ -9,7 +9,7 @@ # TESTSUITE=indicate if the release is meant to be used by the testsuite, default if OFF # GPL_PACKAGE_LIST=path to a file containing the list of GPL packages to include in the release. If not provided all of them are. -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.1...3.15) function(process_package pkg) if(VERBOSE) diff --git a/SearchStructures/examples/RangeSegmentTrees/CMakeLists.txt b/SearchStructures/examples/RangeSegmentTrees/CMakeLists.txt index 8f06d64b9d5..090d14f7e7a 100644 --- a/SearchStructures/examples/RangeSegmentTrees/CMakeLists.txt +++ b/SearchStructures/examples/RangeSegmentTrees/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( RangeSegmentTrees_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/SearchStructures/test/RangeSegmentTrees/CMakeLists.txt b/SearchStructures/test/RangeSegmentTrees/CMakeLists.txt index 6b83c29ab11..f3530741ce2 100644 --- a/SearchStructures/test/RangeSegmentTrees/CMakeLists.txt +++ b/SearchStructures/test/RangeSegmentTrees/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( RangeSegmentTrees_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Segment_Delaunay_graph_2/benchmark/Segment_Delaunay_graph_2/CMakeLists.txt b/Segment_Delaunay_graph_2/benchmark/Segment_Delaunay_graph_2/CMakeLists.txt index 2ab90937fb8..38035c853e7 100644 --- a/Segment_Delaunay_graph_2/benchmark/Segment_Delaunay_graph_2/CMakeLists.txt +++ b/Segment_Delaunay_graph_2/benchmark/Segment_Delaunay_graph_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Segment_Delaunay_graph_2_example ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Segment_Delaunay_graph_2/examples/Segment_Delaunay_graph_2/CMakeLists.txt b/Segment_Delaunay_graph_2/examples/Segment_Delaunay_graph_2/CMakeLists.txt index 23695a3e08f..ef8e579b411 100644 --- a/Segment_Delaunay_graph_2/examples/Segment_Delaunay_graph_2/CMakeLists.txt +++ b/Segment_Delaunay_graph_2/examples/Segment_Delaunay_graph_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Segment_Delaunay_graph_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/CMakeLists.txt b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/CMakeLists.txt index fd781f8a8cf..0b91ac968f3 100644 --- a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/CMakeLists.txt +++ b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Segment_Delaunay_graph_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Segment_Delaunay_graph_Linf_2/benchmark/Segment_Delaunay_graph_Linf_2/CMakeLists.txt b/Segment_Delaunay_graph_Linf_2/benchmark/Segment_Delaunay_graph_Linf_2/CMakeLists.txt index 71ed0203b7f..60bea9ef71c 100644 --- a/Segment_Delaunay_graph_Linf_2/benchmark/Segment_Delaunay_graph_Linf_2/CMakeLists.txt +++ b/Segment_Delaunay_graph_Linf_2/benchmark/Segment_Delaunay_graph_Linf_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Segment_Delaunay_graph_2_example ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/CMakeLists.txt b/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/CMakeLists.txt index 553dba5a125..c6034d62225 100644 --- a/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/CMakeLists.txt +++ b/Segment_Delaunay_graph_Linf_2/examples/Segment_Delaunay_graph_Linf_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Segment_Delaunay_graph_Linf_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/CMakeLists.txt b/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/CMakeLists.txt index 29802b5b30c..16164766a1b 100644 --- a/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/CMakeLists.txt +++ b/Segment_Delaunay_graph_Linf_2/test/Segment_Delaunay_graph_Linf_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Segment_Delaunay_graph_Linf_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Set_movable_separability_2/examples/Set_movable_separability_2/CMakeLists.txt b/Set_movable_separability_2/examples/Set_movable_separability_2/CMakeLists.txt index c37b85c338c..dd91ba64e0f 100644 --- a/Set_movable_separability_2/examples/Set_movable_separability_2/CMakeLists.txt +++ b/Set_movable_separability_2/examples/Set_movable_separability_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Set_movable_separability_2_Examples ) -cmake_minimum_required(VERSION 3.1) list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_generalized_initializers has_cpp11) if (has_cpp11 LESS 0) diff --git a/Set_movable_separability_2/test/Set_movable_separability_2/CMakeLists.txt b/Set_movable_separability_2/test/Set_movable_separability_2/CMakeLists.txt index a2a4916572d..37fb88505b2 100644 --- a/Set_movable_separability_2/test/Set_movable_separability_2/CMakeLists.txt +++ b/Set_movable_separability_2/test/Set_movable_separability_2/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Set_movable_separability_2_Tests ) -cmake_minimum_required(VERSION 3.1) if (RUNNING_CGAL_AUTO_TEST) # Just to avoid a warning from CMake when that variable is set on the command line... diff --git a/Shape_detection/benchmark/Shape_detection/CMakeLists.txt b/Shape_detection/benchmark/Shape_detection/CMakeLists.txt index f314a33fe05..f2c7bf19d77 100644 --- a/Shape_detection/benchmark/Shape_detection/CMakeLists.txt +++ b/Shape_detection/benchmark/Shape_detection/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script. # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project(Shape_detection_Benchmarks) -cmake_minimum_required(VERSION 2.8.10) set(CMAKE_CXX_STANDARD 11) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Shape_detection/examples/Shape_detection/CMakeLists.txt b/Shape_detection/examples/Shape_detection/CMakeLists.txt index edc7922cf5d..d1c49d4986e 100644 --- a/Shape_detection/examples/Shape_detection/CMakeLists.txt +++ b/Shape_detection/examples/Shape_detection/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script. # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project(Shape_detection_Examples) -cmake_minimum_required(VERSION 2.8.10) set(CMAKE_CXX_STANDARD 11) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Shape_detection/test/Shape_detection/CMakeLists.txt b/Shape_detection/test/Shape_detection/CMakeLists.txt index a2489d3ac27..67551a95348 100644 --- a/Shape_detection/test/Shape_detection/CMakeLists.txt +++ b/Shape_detection/test/Shape_detection/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script. # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project(Shape_detection_Tests) -cmake_minimum_required(VERSION 2.8.10) set(CMAKE_CXX_STANDARD 11) find_package(CGAL QUIET COMPONENTS Core) diff --git a/Skin_surface_3/examples/Skin_surface_3/CMakeLists.txt b/Skin_surface_3/examples/Skin_surface_3/CMakeLists.txt index eb188b326f1..b5f2f268ff6 100644 --- a/Skin_surface_3/examples/Skin_surface_3/CMakeLists.txt +++ b/Skin_surface_3/examples/Skin_surface_3/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Skin_surface_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL) diff --git a/Skin_surface_3/test/Skin_surface_3/CMakeLists.txt b/Skin_surface_3/test/Skin_surface_3/CMakeLists.txt index 36a09ddce8b..d3a5d2acf28 100644 --- a/Skin_surface_3/test/Skin_surface_3/CMakeLists.txt +++ b/Skin_surface_3/test/Skin_surface_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Skin_surface_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Snap_rounding_2/examples/Snap_rounding_2/CMakeLists.txt b/Snap_rounding_2/examples/Snap_rounding_2/CMakeLists.txt index 224ff142065..af3e2569ac0 100644 --- a/Snap_rounding_2/examples/Snap_rounding_2/CMakeLists.txt +++ b/Snap_rounding_2/examples/Snap_rounding_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Snap_rounding_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Snap_rounding_2/test/Snap_rounding_2/CMakeLists.txt b/Snap_rounding_2/test/Snap_rounding_2/CMakeLists.txt index 13598b9fe4c..909b2060625 100644 --- a/Snap_rounding_2/test/Snap_rounding_2/CMakeLists.txt +++ b/Snap_rounding_2/test/Snap_rounding_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Snap_rounding_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Solver_interface/examples/Solver_interface/CMakeLists.txt b/Solver_interface/examples/Solver_interface/CMakeLists.txt index a81c8dd0ac7..348e6697fbf 100644 --- a/Solver_interface/examples/Solver_interface/CMakeLists.txt +++ b/Solver_interface/examples/Solver_interface/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Solver_interface_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Spatial_searching/benchmark/Spatial_searching/CMakeLists.txt b/Spatial_searching/benchmark/Spatial_searching/CMakeLists.txt index 51ab416ab53..ca8157f8a8e 100644 --- a/Spatial_searching/benchmark/Spatial_searching/CMakeLists.txt +++ b/Spatial_searching/benchmark/Spatial_searching/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Spatial_searching_ ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Spatial_searching/benchmark/Spatial_searching/tools/CMakeLists.txt b/Spatial_searching/benchmark/Spatial_searching/tools/CMakeLists.txt index a332558dc48..285b4853c31 100644 --- a/Spatial_searching/benchmark/Spatial_searching/tools/CMakeLists.txt +++ b/Spatial_searching/benchmark/Spatial_searching/tools/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( tools_ ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Spatial_searching/examples/Spatial_searching/CMakeLists.txt b/Spatial_searching/examples/Spatial_searching/CMakeLists.txt index 5c66f23a3ee..c4a335960b5 100644 --- a/Spatial_searching/examples/Spatial_searching/CMakeLists.txt +++ b/Spatial_searching/examples/Spatial_searching/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Spatial_searching_Examples ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components diff --git a/Spatial_searching/test/Spatial_searching/CMakeLists.txt b/Spatial_searching/test/Spatial_searching/CMakeLists.txt index 90cc940fc5b..736d25c1155 100644 --- a/Spatial_searching/test/Spatial_searching/CMakeLists.txt +++ b/Spatial_searching/test/Spatial_searching/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Spatial_searching_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Spatial_sorting/benchmark/Spatial_sorting/CMakeLists.txt b/Spatial_sorting/benchmark/Spatial_sorting/CMakeLists.txt index 5bf9e578e10..18e9aa776db 100644 --- a/Spatial_sorting/benchmark/Spatial_sorting/CMakeLists.txt +++ b/Spatial_sorting/benchmark/Spatial_sorting/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Spatial_sorting_ ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Spatial_sorting/examples/Spatial_sorting/CMakeLists.txt b/Spatial_sorting/examples/Spatial_sorting/CMakeLists.txt index 77db71cd55d..df5f623e1ba 100644 --- a/Spatial_sorting/examples/Spatial_sorting/CMakeLists.txt +++ b/Spatial_sorting/examples/Spatial_sorting/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Spatial_sorting_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Spatial_sorting/test/Spatial_sorting/CMakeLists.txt b/Spatial_sorting/test/Spatial_sorting/CMakeLists.txt index 98ded58f5b4..c8901de1414 100644 --- a/Spatial_sorting/test/Spatial_sorting/CMakeLists.txt +++ b/Spatial_sorting/test/Spatial_sorting/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Spatial_sorting_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Straight_skeleton_2/examples/Straight_skeleton_2/CMakeLists.txt b/Straight_skeleton_2/examples/Straight_skeleton_2/CMakeLists.txt index 732fb4b90bc..b873129ef94 100644 --- a/Straight_skeleton_2/examples/Straight_skeleton_2/CMakeLists.txt +++ b/Straight_skeleton_2/examples/Straight_skeleton_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Straight_skeleton_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt b/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt index 2272303a11b..070f91fbd69 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt +++ b/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Straight_skeleton_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Stream_lines_2/examples/Stream_lines_2/CMakeLists.txt b/Stream_lines_2/examples/Stream_lines_2/CMakeLists.txt index c12378e2b4b..df241d013bb 100644 --- a/Stream_lines_2/examples/Stream_lines_2/CMakeLists.txt +++ b/Stream_lines_2/examples/Stream_lines_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Stream_lines_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Stream_lines_2/test/Stream_lines_2/CMakeLists.txt b/Stream_lines_2/test/Stream_lines_2/CMakeLists.txt index 3349e59b68a..a4be4c9d3c9 100644 --- a/Stream_lines_2/test/Stream_lines_2/CMakeLists.txt +++ b/Stream_lines_2/test/Stream_lines_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Stream_lines_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Stream_support/benchmark/Stream_support/CMakeLists.txt b/Stream_support/benchmark/Stream_support/CMakeLists.txt index 3e1065efa78..f72b2f0f48b 100644 --- a/Stream_support/benchmark/Stream_support/CMakeLists.txt +++ b/Stream_support/benchmark/Stream_support/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Stream_support ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components diff --git a/Stream_support/examples/Stream_support/CMakeLists.txt b/Stream_support/examples/Stream_support/CMakeLists.txt index 69d953e830e..bb12e6cd1e4 100644 --- a/Stream_support/examples/Stream_support/CMakeLists.txt +++ b/Stream_support/examples/Stream_support/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Stream_support_Examples) -cmake_minimum_required(VERSION 2.8.11) # CGAL and its components find_package( CGAL QUIET) diff --git a/Stream_support/test/Stream_support/CMakeLists.txt b/Stream_support/test/Stream_support/CMakeLists.txt index 5eb7092e2b7..15bf8c30ac4 100644 --- a/Stream_support/test/Stream_support/CMakeLists.txt +++ b/Stream_support/test/Stream_support/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Stream_support_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Subdivision_method_3/examples/Subdivision_method_3/CMakeLists.txt b/Subdivision_method_3/examples/Subdivision_method_3/CMakeLists.txt index eb57c8246dc..b8fa8e47c50 100644 --- a/Subdivision_method_3/examples/Subdivision_method_3/CMakeLists.txt +++ b/Subdivision_method_3/examples/Subdivision_method_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Subdivision_method_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Subdivision_method_3/test/Subdivision_method_3/CMakeLists.txt b/Subdivision_method_3/test/Subdivision_method_3/CMakeLists.txt index 87cf9f130ba..74338524d72 100644 --- a/Subdivision_method_3/test/Subdivision_method_3/CMakeLists.txt +++ b/Subdivision_method_3/test/Subdivision_method_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Subdivision_method_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Surface_mesh/benchmark/CMakeLists.txt b/Surface_mesh/benchmark/CMakeLists.txt index 8d376836e91..8ca9774509b 100644 --- a/Surface_mesh/benchmark/CMakeLists.txt +++ b/Surface_mesh/benchmark/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project(Surface_mesh_performance) -cmake_minimum_required(VERSION 3.1) find_package(CGAL REQUIRED) diff --git a/Surface_mesh/examples/Surface_mesh/CMakeLists.txt b/Surface_mesh/examples/Surface_mesh/CMakeLists.txt index 6ad86b00d0d..6f5b413973d 100644 --- a/Surface_mesh/examples/Surface_mesh/CMakeLists.txt +++ b/Surface_mesh/examples/Surface_mesh/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_Examples ) -cmake_minimum_required(VERSION 3.1) if(POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. diff --git a/Surface_mesh/test/Surface_mesh/CMakeLists.txt b/Surface_mesh/test/Surface_mesh/CMakeLists.txt index 07743df73f9..8371685d73b 100644 --- a/Surface_mesh/test/Surface_mesh/CMakeLists.txt +++ b/Surface_mesh/test/Surface_mesh/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/CMakeLists.txt b/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/CMakeLists.txt index 586e65d7774..728c672fded 100644 --- a/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/CMakeLists.txt +++ b/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_approximation_Benchmarks ) -cmake_minimum_required(VERSION 2.8.11) # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/CMakeLists.txt b/Surface_mesh_approximation/examples/Surface_mesh_approximation/CMakeLists.txt index d4efe96cf06..e3b19a50cad 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/CMakeLists.txt +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_approximation_Examples ) -cmake_minimum_required(VERSION 2.8.11) # CGAL and its components find_package( CGAL QUIET) diff --git a/Surface_mesh_approximation/test/Surface_mesh_approximation/CMakeLists.txt b/Surface_mesh_approximation/test/Surface_mesh_approximation/CMakeLists.txt index 96ce72ae1cd..caac2a6f132 100644 --- a/Surface_mesh_approximation/test/Surface_mesh_approximation/CMakeLists.txt +++ b/Surface_mesh_approximation/test/Surface_mesh_approximation/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_approximation_Tests ) -cmake_minimum_required(VERSION 2.8.11) # CGAL and its components find_package( CGAL QUIET) diff --git a/Surface_mesh_deformation/benchmark/Surface_mesh_deformation/optimal_rotation/CMakeLists.txt b/Surface_mesh_deformation/benchmark/Surface_mesh_deformation/optimal_rotation/CMakeLists.txt index cd75dcec4e3..67a2731cdc5 100644 --- a/Surface_mesh_deformation/benchmark/Surface_mesh_deformation/optimal_rotation/CMakeLists.txt +++ b/Surface_mesh_deformation/benchmark/Surface_mesh_deformation/optimal_rotation/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( benchmark_for_closest_rotation ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Surface_mesh_deformation/demo/Surface_mesh_deformation/CMakeLists.txt b/Surface_mesh_deformation/demo/Surface_mesh_deformation/CMakeLists.txt index 17b6de5841c..b90af134997 100644 --- a/Surface_mesh_deformation/demo/Surface_mesh_deformation/CMakeLists.txt +++ b/Surface_mesh_deformation/demo/Surface_mesh_deformation/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_deformation_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Surface_mesh_deformation/examples/Surface_mesh_deformation/CMakeLists.txt b/Surface_mesh_deformation/examples/Surface_mesh_deformation/CMakeLists.txt index ceac6ce44de..aa90c5d271d 100644 --- a/Surface_mesh_deformation/examples/Surface_mesh_deformation/CMakeLists.txt +++ b/Surface_mesh_deformation/examples/Surface_mesh_deformation/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_deformation_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Surface_mesh_deformation/test/Surface_mesh_deformation/CMakeLists.txt b/Surface_mesh_deformation/test/Surface_mesh_deformation/CMakeLists.txt index a857d6c00e8..54163d64df1 100644 --- a/Surface_mesh_deformation/test/Surface_mesh_deformation/CMakeLists.txt +++ b/Surface_mesh_deformation/test/Surface_mesh_deformation/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_deformation_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt index c6d2227aec4..62640e3b6a9 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt @@ -1,9 +1,9 @@ # This is the CMake script for compiling this folder. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_parameterization_Examples ) -cmake_minimum_required(VERSION 3.1) # Find CGAL diff --git a/Surface_mesh_parameterization/test/Surface_mesh_parameterization/CMakeLists.txt b/Surface_mesh_parameterization/test/Surface_mesh_parameterization/CMakeLists.txt index 2375ad56670..4021770c494 100644 --- a/Surface_mesh_parameterization/test/Surface_mesh_parameterization/CMakeLists.txt +++ b/Surface_mesh_parameterization/test/Surface_mesh_parameterization/CMakeLists.txt @@ -1,9 +1,9 @@ # This is the CMake script for compiling this folder. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_parameterization_Tests ) -cmake_minimum_required(VERSION 3.1) # Find CGAL diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/CMakeLists.txt b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/CMakeLists.txt index be1faa2c864..79bb821c35e 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/CMakeLists.txt +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_cmake_script_with_options # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_segmentation_Examples ) -cmake_minimum_required(VERSION 3.1) diff --git a/Surface_mesh_segmentation/test/Surface_mesh_segmentation/CMakeLists.txt b/Surface_mesh_segmentation/test/Surface_mesh_segmentation/CMakeLists.txt index 677d2711e22..49ee7055e9e 100644 --- a/Surface_mesh_segmentation/test/Surface_mesh_segmentation/CMakeLists.txt +++ b/Surface_mesh_segmentation/test/Surface_mesh_segmentation/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_segmentation_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt index edd21e2855a..6b757a109e9 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt @@ -3,9 +3,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_shortest_path_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/CMakeLists.txt b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/CMakeLists.txt index 8b70d2db06f..f018de6f17b 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/CMakeLists.txt +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.1...3.13) +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_shortest_path_Tests ) find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Core) diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/CMakeLists.txt b/Surface_mesh_simplification/examples/Surface_mesh_simplification/CMakeLists.txt index 1090de74ac5..779611b831a 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/CMakeLists.txt +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/CMakeLists.txt @@ -1,10 +1,10 @@ # Created by the script cgal_create_cmake_script_with_options # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_simplification_Examples ) -cmake_minimum_required(VERSION 3.1) diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/CMakeLists.txt b/Surface_mesh_simplification/test/Surface_mesh_simplification/CMakeLists.txt index b7b1999faa4..245bbdb83e5 100644 --- a/Surface_mesh_simplification/test/Surface_mesh_simplification/CMakeLists.txt +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_simplification_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Surface_mesh_skeletonization/benchmark/Surface_mesh_skeletonization/CMakeLists.txt b/Surface_mesh_skeletonization/benchmark/Surface_mesh_skeletonization/CMakeLists.txt index a5b04d07df7..d73305b0549 100644 --- a/Surface_mesh_skeletonization/benchmark/Surface_mesh_skeletonization/CMakeLists.txt +++ b/Surface_mesh_skeletonization/benchmark/Surface_mesh_skeletonization/CMakeLists.txt @@ -1,13 +1,13 @@ # Created by the script cgal_create_cmake_script_with_options # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Mean_curvature_skeleton ) #SET(CMAKE_BUILD_TYPE "Debug") #SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage") #SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" ) -cmake_minimum_required(VERSION 3.1) # CGAL and its components diff --git a/Surface_mesh_skeletonization/examples/Surface_mesh_skeletonization/CMakeLists.txt b/Surface_mesh_skeletonization/examples/Surface_mesh_skeletonization/CMakeLists.txt index 9f711c7c4f6..7327aafc329 100644 --- a/Surface_mesh_skeletonization/examples/Surface_mesh_skeletonization/CMakeLists.txt +++ b/Surface_mesh_skeletonization/examples/Surface_mesh_skeletonization/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_skeletonization_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Surface_mesh_skeletonization/test/Surface_mesh_skeletonization/CMakeLists.txt b/Surface_mesh_skeletonization/test/Surface_mesh_skeletonization/CMakeLists.txt index 8aed6ec2d5a..fdab781a1ca 100644 --- a/Surface_mesh_skeletonization/test/Surface_mesh_skeletonization/CMakeLists.txt +++ b/Surface_mesh_skeletonization/test/Surface_mesh_skeletonization/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesh_skeletonization_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Surface_mesher/demo/Surface_mesher/CMakeLists.txt b/Surface_mesher/demo/Surface_mesher/CMakeLists.txt index b702b4bb27f..c1e5b5a4a5f 100644 --- a/Surface_mesher/demo/Surface_mesher/CMakeLists.txt +++ b/Surface_mesher/demo/Surface_mesher/CMakeLists.txt @@ -1,8 +1,8 @@ set ( prj Surface_mesher ) +cmake_minimum_required(VERSION 3.1...3.15) project ( Surface_mesher_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Surface_mesher/examples/Surface_mesher/CMakeLists.txt b/Surface_mesher/examples/Surface_mesher/CMakeLists.txt index 3446a487e88..645859a9fa1 100644 --- a/Surface_mesher/examples/Surface_mesher/CMakeLists.txt +++ b/Surface_mesher/examples/Surface_mesher/CMakeLists.txt @@ -1,9 +1,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesher_Examples ) -cmake_minimum_required(VERSION 3.1) if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) diff --git a/Surface_mesher/test/Surface_mesher/CMakeLists.txt b/Surface_mesher/test/Surface_mesher/CMakeLists.txt index dcc5829c499..48b2e73a09c 100644 --- a/Surface_mesher/test/Surface_mesher/CMakeLists.txt +++ b/Surface_mesher/test/Surface_mesher/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_mesher_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Surface_sweep_2/examples/Surface_sweep_2/CMakeLists.txt b/Surface_sweep_2/examples/Surface_sweep_2/CMakeLists.txt index 06dad81f73f..290fd852dc6 100644 --- a/Surface_sweep_2/examples/Surface_sweep_2/CMakeLists.txt +++ b/Surface_sweep_2/examples/Surface_sweep_2/CMakeLists.txt @@ -1,19 +1,9 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_sweep_2_Examples ) - -cmake_minimum_required(VERSION 3.1) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) - else() - cmake_policy(VERSION 2.6) - endif() -endif() - - # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt b/Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt index 7165020fb83..788981308c7 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Surface_sweep_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/TDS_2/test/TDS_2/CMakeLists.txt b/TDS_2/test/TDS_2/CMakeLists.txt index 93b60a87707..2df25a93b59 100644 --- a/TDS_2/test/TDS_2/CMakeLists.txt +++ b/TDS_2/test/TDS_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( TDS_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/TDS_3/examples/TDS_3/CMakeLists.txt b/TDS_3/examples/TDS_3/CMakeLists.txt index c3be4897d87..d0e2a5f766c 100644 --- a/TDS_3/examples/TDS_3/CMakeLists.txt +++ b/TDS_3/examples/TDS_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( TDS_3_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/TDS_3/test/TDS_3/CMakeLists.txt b/TDS_3/test/TDS_3/CMakeLists.txt index 4d8b2ce5862..0253c40548c 100644 --- a/TDS_3/test/TDS_3/CMakeLists.txt +++ b/TDS_3/test/TDS_3/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( TDS_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Three/demo/Three/CMakeLists.txt b/Three/demo/Three/CMakeLists.txt index b8a2631a535..65e6ee0b3ad 100644 --- a/Three/demo/Three/CMakeLists.txt +++ b/Three/demo/Three/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Three_Demo ) -cmake_minimum_required(VERSION 3.1) set(CMAKE_CXX_STANDARD 14) diff --git a/Three/demo/Three/Example_plugin/CMakeLists.txt b/Three/demo/Three/Example_plugin/CMakeLists.txt index 15d708e4137..421687cbfaa 100644 --- a/Three/demo/Three/Example_plugin/CMakeLists.txt +++ b/Three/demo/Three/Example_plugin/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Example_plugin ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Triangulation/applications/Triangulation/CMakeLists.txt b/Triangulation/applications/Triangulation/CMakeLists.txt index 4955332d74e..f95f8c19f46 100644 --- a/Triangulation/applications/Triangulation/CMakeLists.txt +++ b/Triangulation/applications/Triangulation/CMakeLists.txt @@ -1,21 +1,9 @@ # Created by the script cgal_create_cmake_script_with_options # This is the CMake script for compiling a set of CGAL applications. +cmake_minimum_required(VERSION 3.1...3.15) project( Triangulation_apps ) - -cmake_minimum_required(VERSION 3.1) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) - else() - cmake_policy(VERSION 2.6) - endif() -endif() - -set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true ) - - # CGAL and its components find_package( CGAL QUIET COMPONENTS ) diff --git a/Triangulation/benchmark/Triangulation/CMakeLists.txt b/Triangulation/benchmark/Triangulation/CMakeLists.txt index 8daf709e47b..f82e906db3d 100644 --- a/Triangulation/benchmark/Triangulation/CMakeLists.txt +++ b/Triangulation/benchmark/Triangulation/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Triangulation_benchmark ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET COMPONENTS Core ) diff --git a/Triangulation/examples/Triangulation/CMakeLists.txt b/Triangulation/examples/Triangulation/CMakeLists.txt index 741f732649b..69eacb3a05b 100644 --- a/Triangulation/examples/Triangulation/CMakeLists.txt +++ b/Triangulation/examples/Triangulation/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Triangulation_Examples ) -cmake_minimum_required(VERSION 3.1) if(CMAKE_COMPILER_IS_GNUCCX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) message(STATUS "NOTICE: this directory requires a version of gcc >= 4.4, and will not be compiled.") diff --git a/Triangulation/test/Triangulation/CMakeLists.txt b/Triangulation/test/Triangulation/CMakeLists.txt index 67ea3dc2a8b..49054feffce 100644 --- a/Triangulation/test/Triangulation/CMakeLists.txt +++ b/Triangulation/test/Triangulation/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Triangulation_Tests ) -cmake_minimum_required(VERSION 3.1) if(CMAKE_COMPILER_IS_GNUCCX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) message(STATUS "NOTICE: this directory requires a version of gcc >= 4.4, and will not be compiled.") diff --git a/Triangulation_2/examples/Triangulation_2/CMakeLists.txt b/Triangulation_2/examples/Triangulation_2/CMakeLists.txt index 20ef6aa9331..4911f1d9872 100644 --- a/Triangulation_2/examples/Triangulation_2/CMakeLists.txt +++ b/Triangulation_2/examples/Triangulation_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Triangulation_2_Examples ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. diff --git a/Triangulation_2/test/Triangulation_2/CMakeLists.txt b/Triangulation_2/test/Triangulation_2/CMakeLists.txt index 1441e226126..6599888b5aa 100644 --- a/Triangulation_2/test/Triangulation_2/CMakeLists.txt +++ b/Triangulation_2/test/Triangulation_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Triangulation_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Triangulation_3/demo/Triangulation_3/CMakeLists.txt b/Triangulation_3/demo/Triangulation_3/CMakeLists.txt index e3d3fe6d5ba..aca144a19b3 100644 --- a/Triangulation_3/demo/Triangulation_3/CMakeLists.txt +++ b/Triangulation_3/demo/Triangulation_3/CMakeLists.txt @@ -1,9 +1,9 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project (Triangulation_3_Demo) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Triangulation_3/demo/Triangulation_3_Geomview_demos/CMakeLists.txt b/Triangulation_3/demo/Triangulation_3_Geomview_demos/CMakeLists.txt index 20e8bf1d3b2..2e06bf1dc9c 100644 --- a/Triangulation_3/demo/Triangulation_3_Geomview_demos/CMakeLists.txt +++ b/Triangulation_3/demo/Triangulation_3_Geomview_demos/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Triangulation_3_Geomview_demos_Demo ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. cmake_policy(SET CMP0053 OLD) diff --git a/Triangulation_3/examples/Triangulation_3/CMakeLists.txt b/Triangulation_3/examples/Triangulation_3/CMakeLists.txt index 121d27795ca..390022efe04 100644 --- a/Triangulation_3/examples/Triangulation_3/CMakeLists.txt +++ b/Triangulation_3/examples/Triangulation_3/CMakeLists.txt @@ -1,6 +1,6 @@ +cmake_minimum_required(VERSION 3.1...3.15) project( Triangulation_3_Examples ) -cmake_minimum_required(VERSION 3.1) if(NOT POLICY CMP0070 AND POLICY CMP0053) # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. diff --git a/Triangulation_3/test/Triangulation_3/CMakeLists.txt b/Triangulation_3/test/Triangulation_3/CMakeLists.txt index 53e46c63ba4..0fdbcfc1d4e 100644 --- a/Triangulation_3/test/Triangulation_3/CMakeLists.txt +++ b/Triangulation_3/test/Triangulation_3/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Triangulation_3_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Union_find/test/Union_find/CMakeLists.txt b/Union_find/test/Union_find/CMakeLists.txt index 3894840ebee..fc2ae2c9189 100644 --- a/Union_find/test/Union_find/CMakeLists.txt +++ b/Union_find/test/Union_find/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Union_find_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Visibility_2/examples/Visibility_2/CMakeLists.txt b/Visibility_2/examples/Visibility_2/CMakeLists.txt index 68efc6b823d..0510897b193 100644 --- a/Visibility_2/examples/Visibility_2/CMakeLists.txt +++ b/Visibility_2/examples/Visibility_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Visibility_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Visibility_2/test/Visibility_2/CMakeLists.txt b/Visibility_2/test/Visibility_2/CMakeLists.txt index 211276c3e2a..eafdc9bced7 100644 --- a/Visibility_2/test/Visibility_2/CMakeLists.txt +++ b/Visibility_2/test/Visibility_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Visibility_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Voronoi_diagram_2/examples/Voronoi_diagram_2/CMakeLists.txt b/Voronoi_diagram_2/examples/Voronoi_diagram_2/CMakeLists.txt index 92893d16599..2741d391aec 100644 --- a/Voronoi_diagram_2/examples/Voronoi_diagram_2/CMakeLists.txt +++ b/Voronoi_diagram_2/examples/Voronoi_diagram_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Voronoi_diagram_2_Examples ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) diff --git a/Voronoi_diagram_2/test/Voronoi_diagram_2/CMakeLists.txt b/Voronoi_diagram_2/test/Voronoi_diagram_2/CMakeLists.txt index 6f57717084a..e0fc05a700f 100644 --- a/Voronoi_diagram_2/test/Voronoi_diagram_2/CMakeLists.txt +++ b/Voronoi_diagram_2/test/Voronoi_diagram_2/CMakeLists.txt @@ -2,9 +2,9 @@ # This is the CMake script for compiling a CGAL application. +cmake_minimum_required(VERSION 3.1...3.15) project( Voronoi_diagram_2_Tests ) -cmake_minimum_required(VERSION 3.1) find_package(CGAL QUIET) From 1957ecc26343281ce411888d40efc67132954feb Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 20 Jun 2019 10:14:26 +0200 Subject: [PATCH 181/203] Fix a warning See https://github.com/CGAL/cgal/pull/3660#issuecomment-503915741 --- NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h index e7a61332e57..65f73a2a182 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h @@ -149,7 +149,8 @@ template struct Compute_cartesian_coordinate { typedef Tag_true Is_exact; typedef decltype(std::declval()[0]) result_type; - result_type operator()(first_argument_type const& v,int i)const{ + template + result_type operator()(first_argument_type const& v,index_type i)const{ return v[i]; } }; From c1f337d585ff7c43806cb108f32bddc42a001348 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 20 Jun 2019 12:17:15 +0200 Subject: [PATCH 182/203] Triangulation_2: Fix CDT_plus_2::remove_constraint() --- .../CGAL/Polyline_constraint_hierarchy_2.h | 1 + .../test/Triangulation_2/issue_4010.cpp | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 Triangulation_2/test/Triangulation_2/issue_4010.cpp diff --git a/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h index 1f3071db44e..d310f46128a 100644 --- a/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h @@ -256,6 +256,7 @@ public: void remove_constraint(Vertex_handle va, Vertex_handle vb) { remove_constraint(constraint_map[make_edge(va,vb)]); + constraint_map.erase(make_edge(va,vb)); } void split_constraint(T va, T vb, T vc); diff --git a/Triangulation_2/test/Triangulation_2/issue_4010.cpp b/Triangulation_2/test/Triangulation_2/issue_4010.cpp new file mode 100644 index 00000000000..f3edfb17794 --- /dev/null +++ b/Triangulation_2/test/Triangulation_2/issue_4010.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include + + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Polygon_2 Polygon_2; +typedef CGAL::Exact_intersections_tag Itag_; +typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; +typedef CGAL::Constrained_triangulation_plus_2 CDTP; + +typedef CDTP::Point Point; +typedef CDTP::Constraint_id Cid; +typedef CDTP::Vertex_handle Vertex_handle; + + +int main() +{ + CDTP cdtp; + + Vertex_handle handle1=cdtp.insert(Point(0,0)); + Vertex_handle handle2=cdtp.insert(Point(0,10)); + Vertex_handle handle3=cdtp.insert(Point(10,10)); + Vertex_handle handle4=cdtp.insert(Point(10,0)); + + auto id = cdtp.insert_constraint(handle1,handle3); + + cdtp.remove_constraint(handle1,handle3); + + auto lastConstraintId=cdtp.insert_constraint(handle1,handle3); + + if (lastConstraintId == nullptr){ + std::cout << "problem" << std::endl; + assert(false); + } + return 0; +} From ed9dffe80df037c5243e7dfa9381c23efaea6d49 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 21 Jun 2019 09:39:42 +0200 Subject: [PATCH 183/203] remove the attempt for `os << std::pair` --- .../CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Mesh_3/include/CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h b/Mesh_3/include/CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h index 8eee712d970..604039ce667 100644 --- a/Mesh_3/include/CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h +++ b/Mesh_3/include/CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h @@ -41,13 +41,6 @@ struct Get_io_signature > { } }; // end Get_io_signature > -inline std::ostream& operator<<(std::ostream& out, const std::pair& id) { - return out << id.first << " " << id.second; -} -inline std::istream& operator>>(std::istream& in, std::pair& id) { - return in >> id.first >> id.second; -} - template <> class Output_rep > : public IO_rep_is_specialized { typedef std::pair T; From 056e846e0d19a7c8a61e48aefebf9f2b709e4c43 Mon Sep 17 00:00:00 2001 From: bryantcurto Date: Fri, 7 Jun 2019 11:57:19 -0400 Subject: [PATCH 184/203] Fixed do_intersect() ambiguity. Occurs when compiling with clang --- .../include/CGAL/Intersections_3/intersection_3_1_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Intersections_3/include/CGAL/Intersections_3/intersection_3_1_impl.h b/Intersections_3/include/CGAL/Intersections_3/intersection_3_1_impl.h index 0526ffe257d..989826b3532 100644 --- a/Intersections_3/include/CGAL/Intersections_3/intersection_3_1_impl.h +++ b/Intersections_3/include/CGAL/Intersections_3/intersection_3_1_impl.h @@ -556,7 +556,7 @@ do_intersect(const typename K::Segment_3 &s1, const K & k) { CGAL_precondition(! s1.is_degenerate () && ! s2.is_degenerate () ); - bool b=do_intersect(s1.supporting_line(),s2.supporting_line(),k); + bool b=internal::do_intersect(s1.supporting_line(),s2.supporting_line(),k); if (b) { //supporting_line intersects: points are coplanar From 4e1e7d8c16553d9b294f739c513c1f75dd788f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 26 Jun 2019 10:52:48 +0200 Subject: [PATCH 185/203] fix wrong index --- .../internal/Corefinement/Face_graph_output_builder.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index c9eed95cef6..d15a3c5d047 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -579,12 +579,12 @@ public: if ( opposite(next(h1, tm1), tm1) == prev(opposite(h1, tm1), tm1) ) { inter_edges_to_remove1.insert(edge(next(h1, tm1),tm1)); - inter_edges_to_remove1.insert(edge(next(h2, tm2),tm2)); + inter_edges_to_remove2.insert(edge(next(h2, tm2),tm2)); } if ( opposite(prev(h1, tm1), tm1) == next(opposite(h1, tm1), tm1) ) { inter_edges_to_remove1.insert(edge(prev(h1, tm1), tm1)); - inter_edges_to_remove1.insert(edge(prev(h2, tm2), tm2)); + inter_edges_to_remove2.insert(edge(prev(h2, tm2), tm2)); } } // same but for h2 @@ -598,12 +598,12 @@ public: if ( opposite(next(h2, tm2), tm2) == prev(opposite(h2, tm2), tm2) ) { inter_edges_to_remove1.insert(edge(next(h1, tm1),tm1)); - inter_edges_to_remove1.insert(edge(next(h2, tm2),tm2)); + inter_edges_to_remove2.insert(edge(next(h2, tm2),tm2)); } if ( opposite(prev(h2, tm2), tm2) == next(opposite(h2, tm2), tm2) ) { inter_edges_to_remove1.insert(edge(prev(h1, tm1), tm1)); - inter_edges_to_remove1.insert(edge(prev(h2, tm2), tm2)); + inter_edges_to_remove2.insert(edge(prev(h2, tm2), tm2)); } } } From 4435f93aaafa6493635ba492508cb87ba308e0c5 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 24 Jun 2019 16:42:24 +0200 Subject: [PATCH 186/203] Compatibility with VTK 9 (VTK master) Fix issue #3789 --- Mesh_3/examples/Mesh_3/CMakeLists.txt | 32 +++++++++++-------- .../demo/Polyhedron/Plugins/IO/CMakeLists.txt | 12 ++++--- .../Polyhedron/Plugins/Mesh_3/CMakeLists.txt | 13 +++++--- .../demo/Surface_mesher/CMakeLists.txt | 13 +++++--- 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index 629102a8891..7ae8a9ccd45 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -52,19 +52,22 @@ if ( CGAL_FOUND ) include( ${EIGEN3_USE_FILE} ) endif() - set(VTK_LIBS "") - find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) - if(VTK_FOUND) - include(${VTK_USE_FILE}) - if ("${VTK_VERSION_MAJOR}" GREATER "5") - message(STATUS "VTK found") - set( VTK_LIBS vtkImagingGeneral vtkIOImage ) - else() - message(STATUS "VTK version 6.0 or greater is required") - endif() - else() - message(STATUS "VTK was not found") + find_package(VTK COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) + if(VTK_FOUND) + if(VTK_USE_FILE) + include(${VTK_USE_FILE}) + endif() + if ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) + message(STATUS "VTK found") + if(TARGET VTK::IOImage) + set(VTK_LIBRARIES VTK::ImagingGeneral VTK::IOImage) endif() + else() + message(STATUS "VTK version 6.0 or greater is required") + endif() + else() + message(STATUS "VTK was not found") + endif() # Compilable examples @@ -87,9 +90,10 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "mesh_polyhedral_complex.cpp" ) create_single_source_cgal_program( "mesh_polyhedral_complex_sm.cpp" ) if( WITH_CGAL_ImageIO ) - if( VTK_FOUND AND "${VTK_VERSION_MAJOR}" GREATER "5" ) + if( VTK_FOUND AND ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) ) add_executable ( mesh_3D_gray_vtk_image mesh_3D_gray_vtk_image.cpp ) - target_link_libraries( mesh_3D_gray_vtk_image ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${VTK_LIBS}) + target_link_libraries( mesh_3D_gray_vtk_image ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${VTK_LIBRARIES}) + cgal_add_test( mesh_3D_gray_vtk_image ) endif() create_single_source_cgal_program( "mesh_3D_gray_image.cpp" ) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt index eff76a7c0d5..77cdb70cdda 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt @@ -31,13 +31,17 @@ target_link_libraries(surf_io_plugin PUBLIC scene_surface_mesh_item) find_package(VTK QUIET COMPONENTS vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML vtkFiltersCore vtkFiltersSources) if (VTK_FOUND) - include(${VTK_USE_FILE}) - if ("${VTK_VERSION_MAJOR}" GREATER "5") + if(VTK_USE_FILE) + include(${VTK_USE_FILE}) + endif() + if ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) + if(TARGET VTK::CommonCore) + set(VTK_LIBRARIES VTK::CommonCore VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::FiltersCore VTK::FiltersSources) + endif() if(VTK_LIBRARIES) polyhedron_demo_plugin(vtk_plugin VTK_io_plugin KEYWORDS IO Mesh_3) target_link_libraries(vtk_plugin PUBLIC scene_surface_mesh_item scene_polylines_item scene_c3t3_item scene_points_with_normal_item - vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML - vtkFiltersCore vtkFiltersSources) + ${VTK_LIBRARIES}) else() message(STATUS "NOTICE : the vtk IO plugin needs VTK libraries and will not be compiled.") diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt index 96575090599..9db4d61b2e1 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/CMakeLists.txt @@ -11,15 +11,18 @@ polyhedron_demo_plugin(mesh_3_plugin Mesh_3_plugin target_link_libraries(mesh_3_plugin PUBLIC scene_polygon_soup_item scene_polylines_item scene_implicit_function_item scene_image_item scene_surface_mesh_item scene_c3t3_item ${OPENGL_gl_LIBRARY} ) -set(VTK_LIBS "") find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) if (VTK_FOUND) - include(${VTK_USE_FILE}) - if ("${VTK_VERSION_MAJOR}" GREATER "5") + if(VTK_USE_FILE) + include(${VTK_USE_FILE}) + endif() + if ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) + if(TARGET VTK::IOImage) + set(VTK_LIBRARIES VTK::IOImage) + endif() if(VTK_LIBRARIES) add_definitions(-DCGAL_USE_VTK) - set(VTK_LIBS vtkImagingGeneral vtkIOImage) else() message(STATUS "NOTICE : the DICOM files (.dcm) need VTK libraries to be open and will not be able to.") endif() @@ -34,7 +37,7 @@ find_package(Boost QUIET OPTIONAL_COMPONENTS filesystem) if(Boost_FILESYSTEM_FOUND) qt5_wrap_ui( imgUI_FILES Image_res_dialog.ui raw_image.ui) polyhedron_demo_plugin(io_image_plugin Io_image_plugin Volume_plane_intersection.cpp Raw_image_dialog.cpp ${imgUI_FILES} ${VOLUME_MOC_OUTFILES} KEYWORDS IO Mesh_3) - target_link_libraries(io_image_plugin PUBLIC scene_image_item ${VTK_LIBS} CGAL::CGAL_ImageIO) + target_link_libraries(io_image_plugin PUBLIC scene_image_item ${VTK_LIBRARIES} CGAL::CGAL_ImageIO) if(TARGET Boost::filesystem) target_link_libraries(io_image_plugin PUBLIC Boost::filesystem) else() diff --git a/Surface_mesher/demo/Surface_mesher/CMakeLists.txt b/Surface_mesher/demo/Surface_mesher/CMakeLists.txt index 3bc6c16965c..242a5690481 100644 --- a/Surface_mesher/demo/Surface_mesher/CMakeLists.txt +++ b/Surface_mesher/demo/Surface_mesher/CMakeLists.txt @@ -97,14 +97,17 @@ if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND CGAL_ImageIO_FOUND) add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${prj} ) - set(VTK_LIBS "") find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) if(VTK_FOUND) - include(${VTK_USE_FILE}) - if ("${VTK_VERSION_MAJOR}" GREATER "5") + if(VTK_USE_FILE) + include(${VTK_USE_FILE}) + endif() + if ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) message(STATUS "VTK found") add_definitions(-DCGAL_USE_VTK) - set(VTK_LIBS vtkImagingGeneral vtkIOImage) + if(TARGET VTK::IOImage) + set(VTK_LIBRARIES VTK::IOImage VTK::ImagingGeneral) + endif() else() message(STATUS "Vtk must be at least Rel 6") endif() @@ -115,7 +118,7 @@ if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND CGAL_ImageIO_FOUND) target_link_libraries( ${prj} PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 CGAL::CGAL_ImageIO ${OPENGL_LIBRARIES} - ${VTK_LIBS} ) + ${VTK_LIBRARIES} ) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(${prj}) From aeac816801819212ed9e1d1b96e26246f8a56ec0 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 25 Jun 2019 15:06:10 +0200 Subject: [PATCH 187/203] Triangulation_2: Fix remove_vertex_from_constraint-GF --- .../CGAL/Polyline_constraint_hierarchy_2.h | 6 +- .../test/Triangulation_2/issue_4025.cpp | 89 +++++++++++++++++++ 2 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 Triangulation_2/test/Triangulation_2/issue_4025.cpp diff --git a/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h index 1f3071db44e..7731a8686ec 100644 --- a/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h @@ -760,13 +760,13 @@ Polyline_constraint_hierarchy_2::concatenate2(Constraint_id firs // now we really concatenate the vertex lists // Note that all iterators pointing into second remain valid. first.vl_ptr()->pop_back(); // because it is the same as second.front() - Vertex_it back_it = first.vl_ptr()->skip_end(); - --back_it; + Vertex_it back_it = second.vl_ptr()->skip_begin(); + second.vl_ptr()->splice(second.vl_ptr()->skip_begin(), *(first.vl_ptr()), first.vl_ptr()->skip_begin(), first.vl_ptr()->skip_end()); // Note that for VC8 with iterator debugging the iterators pointing into second // are NOT valid So we have to update them - for(Vertex_it it = back_it, succ = it, end = first.vl_ptr()->skip_end(); + for(Vertex_it it = second.vl_ptr()->skip_begin(), succ = it, end = back_it; ++succ != end; ++it){ typename Sc_to_c_map::iterator scit = sc_to_c_map.find(make_edge(*it,*succ)); diff --git a/Triangulation_2/test/Triangulation_2/issue_4025.cpp b/Triangulation_2/test/Triangulation_2/issue_4025.cpp new file mode 100644 index 00000000000..56c6e483ba0 --- /dev/null +++ b/Triangulation_2/test/Triangulation_2/issue_4025.cpp @@ -0,0 +1,89 @@ +#include +#include +#include +#include + + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Polygon_2 Polygon_2; +typedef CGAL::Exact_intersections_tag Itag_; +typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; +typedef CGAL::Constrained_triangulation_plus_2 CDTP; + +typedef CDTP::Point Point; +typedef CDTP::Constraint_id Cid; +typedef CDTP::Vertex_handle Vertex_handle; + + + +int countVertex(CDTP &cdtp, CDTP::Constraint_id id) +{ + auto v=cdtp.vertices_in_constraint_begin(id); + + int count=0; + while(v!=cdtp.vertices_in_constraint_end(id)) + { + count++; + v++; + } + + return count; +} + + +int main() +{ + CDTP cdtp; + + std::list pointsListCollinear; + + pointsListCollinear.push_back(Point(0,0)); + pointsListCollinear.push_back(Point(0,1)); + pointsListCollinear.push_back(Point(0,2)); + pointsListCollinear.push_back(Point(0,3)); + pointsListCollinear.push_back(Point(0,4)); + pointsListCollinear.push_back(Point(0,5)); + + std::list pointsListNoCollinear; + + pointsListNoCollinear.push_back(Point(1,0)); + pointsListNoCollinear.push_back(Point(2,1)); + pointsListNoCollinear.push_back(Point(4,2)); + pointsListNoCollinear.push_back(Point(2,3)); + pointsListNoCollinear.push_back(Point(4,4)); + pointsListNoCollinear.push_back(Point(1,5)); + + + auto ctIdCollinear=cdtp.insert_constraint(pointsListCollinear.begin(),pointsListCollinear.end()); + auto ctIdNoCollinear=cdtp.insert_constraint(pointsListNoCollinear.begin(),pointsListNoCollinear.end()); + + + //******************************* attempt with the collinear constraint + auto vertexToRemoveCollinear=cdtp.vertices_in_constraint_begin(ctIdCollinear); + vertexToRemoveCollinear++; + vertexToRemoveCollinear++; + + + std::cout<<"attempt to remove vertex "<<(*vertexToRemoveCollinear)->point().x()<<" , "<<(*vertexToRemoveCollinear)->point().y() < 5, expected 4 + std::cout<<"number of constraints "< 1 + std::cout<<"number of vertex in constraint "< 6, expected 5 + + + //******************************* attempt with the collinear constraint + auto vertexToRemoveNoCollinear=cdtp.vertices_in_constraint_begin(ctIdNoCollinear); + vertexToRemoveNoCollinear++; + vertexToRemoveNoCollinear++; + + std::cout<<"attempt to remove vertex "<<(*vertexToRemoveNoCollinear)->point().x()<<" , "<<(*vertexToRemoveNoCollinear)->point().y() << std::endl; + cdtp.remove_vertex_from_constraint(ctIdNoCollinear,vertexToRemoveNoCollinear); + + std::cout<<"number of subconstraints "< 4, ok + std::cout<<"number of constraints "< 1 + std::cout<<"number of vertex in constraint "< 5, ok + + return 0; + +} From 060ec7c5c2a54e733209ac0a84f55016fa4a025d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 26 Jun 2019 14:47:35 +0200 Subject: [PATCH 188/203] No auto --- .../test/Triangulation_2/issue_4025.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Triangulation_2/test/Triangulation_2/issue_4025.cpp b/Triangulation_2/test/Triangulation_2/issue_4025.cpp index 56c6e483ba0..af37b05ac06 100644 --- a/Triangulation_2/test/Triangulation_2/issue_4025.cpp +++ b/Triangulation_2/test/Triangulation_2/issue_4025.cpp @@ -13,12 +13,12 @@ typedef CGAL::Constrained_triangulation_plus_2 CDTP; typedef CDTP::Point Point; typedef CDTP::Constraint_id Cid; typedef CDTP::Vertex_handle Vertex_handle; - - +typedef CDTP::Constraint_id Constraint_id; +typedef CDTP::Vertices_in_constraint_iterator Vertices_in_constraint_iterator; int countVertex(CDTP &cdtp, CDTP::Constraint_id id) { - auto v=cdtp.vertices_in_constraint_begin(id); + Vertices_in_constraint_iterator v=cdtp.vertices_in_constraint_begin(id); int count=0; while(v!=cdtp.vertices_in_constraint_end(id)) @@ -54,12 +54,12 @@ int main() pointsListNoCollinear.push_back(Point(1,5)); - auto ctIdCollinear=cdtp.insert_constraint(pointsListCollinear.begin(),pointsListCollinear.end()); - auto ctIdNoCollinear=cdtp.insert_constraint(pointsListNoCollinear.begin(),pointsListNoCollinear.end()); + Constraint_id ctIdCollinear=cdtp.insert_constraint(pointsListCollinear.begin(),pointsListCollinear.end()); + Constraint_id ctIdNoCollinear=cdtp.insert_constraint(pointsListNoCollinear.begin(),pointsListNoCollinear.end()); //******************************* attempt with the collinear constraint - auto vertexToRemoveCollinear=cdtp.vertices_in_constraint_begin(ctIdCollinear); + Vertices_in_constraint_iterator vertexToRemoveCollinear=cdtp.vertices_in_constraint_begin(ctIdCollinear); vertexToRemoveCollinear++; vertexToRemoveCollinear++; @@ -73,7 +73,7 @@ int main() //******************************* attempt with the collinear constraint - auto vertexToRemoveNoCollinear=cdtp.vertices_in_constraint_begin(ctIdNoCollinear); + Vertices_in_constraint_iterator vertexToRemoveNoCollinear=cdtp.vertices_in_constraint_begin(ctIdNoCollinear); vertexToRemoveNoCollinear++; vertexToRemoveNoCollinear++; From f882c5d3a63dfc7060d1abf52b9daeba946eebf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 26 Jun 2019 15:09:19 +0200 Subject: [PATCH 189/203] Sanitize result of square root --- .../CGAL/Segment_Delaunay_graph_2/Basic_predicates_C2.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Basic_predicates_C2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Basic_predicates_C2.h index c6d3f292454..136d4722cae 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Basic_predicates_C2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Basic_predicates_C2.h @@ -146,8 +146,11 @@ public: static FT to_ft(const Sqrt_3& x) { - FT sqrt_e = compute_sqrt( to_ft(x.e()), FT_Has_sqrt() ); - FT sqrt_f = compute_sqrt( to_ft(x.f()), FT_Has_sqrt() ); + // If the number type does not offer a square root, x.e() and x.f() (which are of type sqrt_1) + // might be negative after (approximately) evaluating them. Taking the max sanitize these values + // to ensure that we do not take the square root of a negative number. + FT sqrt_e = compute_sqrt( (std::max)(FT(0), to_ft(x.e())), FT_Has_sqrt() ); + FT sqrt_f = compute_sqrt( (std::max)(FT(0), to_ft(x.f())), FT_Has_sqrt() ); FT sqrt_ef = sqrt_e * sqrt_f; return to_ft(x.a()) + to_ft(x.b()) * sqrt_e + to_ft(x.c()) * sqrt_f + to_ft(x.d()) * sqrt_ef; From aa0a9c848d545eb1537672cf1a78e243b7996dae Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 26 Jun 2019 15:16:36 +0200 Subject: [PATCH 190/203] Remove 'using namespace std' from namespaces --- CGAL_Core/include/CGAL/CORE/Gmp_impl.h | 37 ++++++++++++----------- CGAL_Core/include/CGAL/CORE/poly/Poly.h | 11 +++---- CGAL_Core/include/CGAL/CORE/poly/Poly.tcc | 36 +++++++++++----------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/Gmp_impl.h b/CGAL_Core/include/CGAL/CORE/Gmp_impl.h index e12f7f1c81e..324746d69dc 100644 --- a/CGAL_Core/include/CGAL/CORE/Gmp_impl.h +++ b/CGAL_Core/include/CGAL/CORE/Gmp_impl.h @@ -46,15 +46,14 @@ MA 02110-1301, USA. */ #include #include -using namespace std; - namespace CORE { CGAL_INLINE_FUNCTION int -__gmp_istream_set_base (istream &i, char &c, bool &zero, bool &showbase) +__gmp_istream_set_base (std::istream &i, char &c, bool &zero, bool &showbase) { int base; + using std::ios; zero = showbase = false; switch (i.flags() & ios::basefield) @@ -96,7 +95,7 @@ __gmp_istream_set_base (istream &i, char &c, bool &zero, bool &showbase) CGAL_INLINE_FUNCTION void -__gmp_istream_set_digits (string &s, istream &i, char &c, bool &ok, int base) +__gmp_istream_set_digits (std::string &s, std::istream &i, char &c, bool &ok, int base) { switch (base) { @@ -131,13 +130,14 @@ __gmp_istream_set_digits (string &s, istream &i, char &c, bool &ok, int base) } CGAL_INLINE_FUNCTION -istream & -//operator>> (istream &i, mpz_ptr z) -io_read (istream &i, mpz_ptr z) +std::istream & +//operator>> (std::istream &i, mpz_ptr z) +io_read (std::istream &i, mpz_ptr z) { + using namespace std; int base; char c = 0; - string s; + std::string s; bool ok = false, zero, showbase; i.get(c); // start reading @@ -175,13 +175,14 @@ io_read (istream &i, mpz_ptr z) } CGAL_INLINE_FUNCTION -istream & -//operator>> (istream &i, mpq_ptr q) -io_read (istream &i, mpq_ptr q) +std::istream & +//operator>> (std::istream &i, mpq_ptr q) +io_read (std::istream &i, mpq_ptr q) { + using namespace std; int base; char c = 0; - string s; + std::string s; bool ok = false, zero, showbase; i.get(c); // start reading @@ -253,9 +254,9 @@ io_read (istream &i, mpq_ptr q) } CGAL_INLINE_FUNCTION -ostream& -//operator<< (ostream &o, mpz_srcptr z) -io_write (ostream &o, mpz_srcptr z) +std::ostream& +//operator<< (std::ostream &o, mpz_srcptr z) +io_write (std::ostream &o, mpz_srcptr z) { char *str = new char [mpz_sizeinbase(z,10) + 2]; str = mpz_get_str(str, 10, z); @@ -265,9 +266,9 @@ io_write (ostream &o, mpz_srcptr z) } CGAL_INLINE_FUNCTION -ostream& -//operator<< (ostream &o, mpq_srcptr q) -io_write (ostream &o, mpq_srcptr q) +std::ostream& +//operator<< (std::ostream &o, mpq_srcptr q) +io_write (std::ostream &o, mpq_srcptr q) { // size according to GMP documentation char *str = new char [mpz_sizeinbase(mpq_numref(q), 10) + diff --git a/CGAL_Core/include/CGAL/CORE/poly/Poly.h b/CGAL_Core/include/CGAL/CORE/poly/Poly.h index 913c4773c7a..6f2becd9317 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Poly.h +++ b/CGAL_Core/include/CGAL/CORE/poly/Poly.h @@ -65,7 +65,6 @@ #include namespace CORE { -using namespace std; class Expr; // ================================================== // Typedefs @@ -117,25 +116,25 @@ public: Polynomial(const Polynomial &); Polynomial(const VecNT &); Polynomial(int n, const char* s[]); - Polynomial(const string & s, char myX='x'); + Polynomial(const std::string & s, char myX='x'); Polynomial(const char* s, char myX='x'); ~Polynomial(); private: void constructX(int n, Polynomial& P); - void constructFromString(string & s, char myX='x'); + void constructFromString(std::string & s, char myX='x'); int getnumber(const char* c, int i, unsigned int len, Polynomial & P); bool isint(char c); int getint(const char* c, int i, unsigned int len, int & n); int matchparen(const char* cstr, int start); - int getbasicterm(string & s, Polynomial & P); - int getterm(string & s, Polynomial & P); + int getbasicterm(std::string & s, Polynomial & P); + int getterm(std::string & s, Polynomial & P); public: //Returns a Polynomial corresponding to s, which is supposed to //contain as place-holders the chars 'x' and 'y'. - Polynomial getpoly(string & s); + Polynomial getpoly(std::string & s); // Assignment: Polynomial & operator=(const Polynomial&); diff --git a/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc b/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc index a4af8cd1825..8455a22c52f 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc +++ b/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc @@ -131,21 +131,21 @@ Polynomial::Polynomial(int n, const char * s[]) { // want to generalize this to BigFloat, etc. // template -Polynomial::Polynomial(const string & s, char myX) { - string ss(s); +Polynomial::Polynomial(const std::string & s, char myX) { + std::string ss(s); constructFromString(ss, myX); } template Polynomial::Polynomial(const char * s, char myX) { - string ss(s); + std::string ss(s); constructFromString(ss, myX); } template -void Polynomial::constructFromString(string & s, char myX) { +void Polynomial::constructFromString(std::string & s, char myX) { if(myX != 'x' || myX != 'X'){ //Replace myX with 'x'. - string::size_type loc = s.find(myX, 0); - while(loc != string::npos){ + std::string::size_type loc = s.find(myX, 0); + while(loc != std::string::npos){ s.replace(loc,1,1,'x'); loc = s.find(myX, loc+1); } @@ -241,7 +241,7 @@ int Polynomial::matchparen(const char* cstr, int start){ template -int Polynomial::getbasicterm(string & s, Polynomial & P){ +int Polynomial::getbasicterm(std::string & s, Polynomial & P){ const char * cstr = s.c_str(); unsigned int len = s.length(); int i=0; @@ -254,7 +254,7 @@ int Polynomial::getbasicterm(string & s, Polynomial & P){ }else if(cstr[i] =='('){ int oldi = i; i = matchparen(cstr, i); - string t = s.substr(oldi+1, i -oldi -1); + std::string t = s.substr(oldi+1, i -oldi -1); P = getpoly(t); }else{ #ifdef CGAL_CORE_TRACE @@ -272,7 +272,7 @@ int Polynomial::getbasicterm(string & s, Polynomial & P){ template -int Polynomial::getterm(string & s, Polynomial & P){ +int Polynomial::getterm(std::string & s, Polynomial & P){ unsigned int len = s.length(); if(len == 0){// Zero Polynomial P=Polynomial(); @@ -280,7 +280,7 @@ int Polynomial::getterm(string & s, Polynomial & P){ } unsigned int ind, oind; const char* cstr =s.c_str(); - string t; + std::string t; //P will be used to accumulate the product of basic terms. ind = getbasicterm(s, P); while(ind != len-1 && cstr[ind + 1]!='+' && cstr[ind + 1]!='-' ){ @@ -304,11 +304,11 @@ int Polynomial::getterm(string & s, Polynomial & P){ } template -Polynomial Polynomial::getpoly(string & s){ +Polynomial Polynomial::getpoly(std::string & s){ //Remove white spaces from the string - string::size_type cnt=s.find(' ',0); - while(cnt != string::npos){ + std::string::size_type cnt=s.find(' ',0); + while(cnt != std::string::npos){ s.erase(cnt, 1); cnt = s.find(' ', cnt); } @@ -321,10 +321,10 @@ Polynomial Polynomial::getpoly(string & s){ //To handle the case when there is one '=' sign //Suppose s is of the form s1 = s2. Then we assign s to //s1 + (-1)(s2) and reset len - string::size_type loc; - if((loc=s.find('=',0)) != string::npos){ + std::string::size_type loc; + if((loc=s.find('=',0)) != std::string::npos){ s.replace(loc,1,1,'+'); - string s3 = "(-1)("; + std::string s3 = "(-1)("; s.insert(loc+1, s3); len = s.length(); s.insert(len, 1, ')'); @@ -332,7 +332,7 @@ Polynomial Polynomial::getpoly(string & s){ len = s.length(); const char *cstr = s.c_str(); - string t; + std::string t; Polynomial P; // P will be the polynomial in which we accumulate the //sum and difference of the different terms. @@ -966,7 +966,7 @@ BigInt Polynomial::UpperBound() const { lhsNeg.makeCeilExact(); /* compute B^{deg} */ - if (rhs <= max(lhsPos,lhsNeg)) { + if (rhs <= (std::max)(lhsPos,lhsNeg)) { B <<= 1; rhs *= (BigInt(1)< Date: Wed, 26 Jun 2019 15:35:11 +0200 Subject: [PATCH 191/203] Do not use C++11 --- .../test/Triangulation_2/issue_4010.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Triangulation_2/test/Triangulation_2/issue_4010.cpp b/Triangulation_2/test/Triangulation_2/issue_4010.cpp index f3edfb17794..db08a006081 100644 --- a/Triangulation_2/test/Triangulation_2/issue_4010.cpp +++ b/Triangulation_2/test/Triangulation_2/issue_4010.cpp @@ -4,33 +4,32 @@ #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Polygon_2 Polygon_2; typedef CGAL::Exact_intersections_tag Itag_; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; typedef CGAL::Constrained_triangulation_plus_2 CDTP; typedef CDTP::Point Point; -typedef CDTP::Constraint_id Cid; typedef CDTP::Vertex_handle Vertex_handle; - +typedef CDTP::Constraint_id Constraint_id; int main() { CDTP cdtp; - Vertex_handle handle1=cdtp.insert(Point(0,0)); - Vertex_handle handle2=cdtp.insert(Point(0,10)); - Vertex_handle handle3=cdtp.insert(Point(10,10)); - Vertex_handle handle4=cdtp.insert(Point(10,0)); + Vertex_handle handle1 = cdtp.insert(Point(0,0)); + cdtp.insert(Point(0,10)); + Vertex_handle handle3 = cdtp.insert(Point(10,10)); + cdtp.insert(Point(10,0)); - auto id = cdtp.insert_constraint(handle1,handle3); + cdtp.insert_constraint(handle1,handle3); cdtp.remove_constraint(handle1,handle3); - auto lastConstraintId=cdtp.insert_constraint(handle1,handle3); + auto lastConstraintId = cdtp.insert_constraint(handle1,handle3); - if (lastConstraintId == nullptr){ + if (lastConstraintId == Constraint_id()){ std::cout << "problem" << std::endl; assert(false); } From c78f1ef812376504798c8de9470e3af11cf43965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 26 Jun 2019 15:57:32 +0200 Subject: [PATCH 192/203] Remove superfluous 'typename's --- Intersections_2/test/Intersections_2/test_intersections_2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Intersections_2/test/Intersections_2/test_intersections_2.cpp b/Intersections_2/test/Intersections_2/test_intersections_2.cpp index f501bf75211..073adae0846 100644 --- a/Intersections_2/test/Intersections_2/test_intersections_2.cpp +++ b/Intersections_2/test/Intersections_2/test_intersections_2.cpp @@ -798,9 +798,9 @@ int main() { CGAL::Set_ieee_double_precision pfr; - Test< CGAL::Simple_cartesian::Type > >().run(); + Test< CGAL::Simple_cartesian::Type > >().run(); Test< CGAL::Cartesian >().run(); - Test< CGAL::Homogeneous::Type > >().run(); + Test< CGAL::Homogeneous::Type > >().run(); Test< CGAL::Exact_predicates_inexact_constructions_kernel >().run(); Test< CGAL::Exact_predicates_exact_constructions_kernel >().run(); } From 7db6b5e5136369848e733e5aedba177e2165d714 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 26 Jun 2019 16:19:09 +0200 Subject: [PATCH 193/203] Older versions of gcc does not like that pair of const https://cgal.geometryfactory.com/CGAL/testsuite/results-4.14.1-I-173.shtml#Mesh_3_Examples --- Mesh_3/include/CGAL/IO/output_to_vtu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mesh_3/include/CGAL/IO/output_to_vtu.h b/Mesh_3/include/CGAL/IO/output_to_vtu.h index c154205d780..726175d254e 100644 --- a/Mesh_3/include/CGAL/IO/output_to_vtu.h +++ b/Mesh_3/include/CGAL/IO/output_to_vtu.h @@ -284,7 +284,7 @@ typedef boost::variant*, const std::vector*, template void output_to_vtu_with_attributes(std::ostream& os, const C3T3& c3t3, - std::vector >&attributes, + std::vector >&attributes, IO::Mode mode = IO::BINARY) { //CGAL_assertion(attributes.size() == attribute_types.size()); @@ -373,7 +373,7 @@ void output_to_vtu(std::ostream& os, mids.push_back(v); } - std::vector > atts; + std::vector > atts; Vtu_attributes v = &mids; atts.push_back(std::make_pair("MeshDomain", v)); output_to_vtu_with_attributes(os, c3t3, atts, mode); From df9a63b2b40f09b60ccb614bd3c9798d13597ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 27 Jun 2019 08:44:46 +0200 Subject: [PATCH 194/203] update marks on removed edges --- .../internal/Corefinement/Face_graph_output_builder.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index 2e4a3b33bc4..b079f204e1b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -560,9 +560,15 @@ public: ++epp_it; } BOOST_FOREACH(edge_descriptor ed, inter_edges_to_remove1) + { + put(marks_on_input_edges.ecm1, ed, false); intersection_edges1.erase(ed); + } BOOST_FOREACH(edge_descriptor ed, inter_edges_to_remove2) + { + put(marks_on_input_edges.ecm2, ed, false); intersection_edges2.erase(ed); + } // (1) Assign a patch id to each facet indicating in which connected // component limited by intersection edges of the surface they are. From 9346847f2033758917f173ab19d2ba0a22ee08d3 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 27 Jun 2019 11:26:26 +0200 Subject: [PATCH 195/203] Fix warnings about uninitialized variables --- .../test/Kernel_23/include/CGAL/_test_cls_triangle_3.h | 6 +++--- Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_3.h index 0b85fc87108..fbb1a21ef7a 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_triangle_3.h @@ -36,9 +36,6 @@ _test_cls_triangle_3(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; - typename R::Triangle_3 it; - CGAL::Triangle_3 t0(it); - RT n0 = 0; RT n1 = 12; RT n2 = 16; @@ -61,7 +58,10 @@ _test_cls_triangle_3(const R& ) CGAL::Point_3 ps2( n0, n7, n0, n5); // (0, 3, 0) CGAL::Point_3 ps1( n7, n0, n0, n5); // (3, 0, 0) + typename R::Triangle_3 it; // test default-constructor + const CGAL::Triangle_3 t1(p1,p2,p3); + CGAL::Triangle_3 t0(t1); CGAL::Triangle_3 t2(p4,p2,p3); CGAL::Triangle_3 t3(ps1,ps2,ps3); CGAL::Triangle_3 t4(ps2,ps1,ps3); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h index 6b5939a9afa..c96987f970f 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h @@ -221,8 +221,8 @@ test_new_3(const R& rep) typename R::Construct_tetrahedron_3 construct_tetrahedron = rep.construct_tetrahedron_3_object(); - Tetrahedron_3 th1; - Tetrahedron_3 th2 = construct_tetrahedron(p2,p3,p4,p5); + Tetrahedron_3 th0; // test default-constructor + Tetrahedron_3 th2 = construct_tetrahedron(p2,p3,p4,p5), th1 = th2; typename R::Construct_iso_cuboid_3 construct_iso_cuboid = rep.construct_iso_cuboid_3_object(); From e2b9c566754908cbeae365ab99a3805e84f9fbd5 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 27 Jun 2019 11:26:39 +0200 Subject: [PATCH 196/203] Fix the assertion "Expr: FPU_get_cw() == mode" --- Kernel_23/test/Kernel_23/Filtered_cartesian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp index 25a57e1965e..ee48df866ac 100644 --- a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp +++ b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp @@ -58,7 +58,7 @@ void test(); int main() { - CGAL::force_ieee_double_precision(); + CGAL::Set_ieee_double_precision double_precision_guard; typedef CGAL::Cartesian Clsdb; typedef CGAL::Filtered_kernel Clsd; From 5341998c7e103bd3fe09b45650454b9e70d7e53f Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 28 Jun 2019 12:45:29 +0200 Subject: [PATCH 197/203] Add a new ctest fixture, that checks the build system That will avoid that `cmake` is run in parallel several times, when `ctest -j` is used. --- Installation/cmake/modules/CGAL_add_test.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Installation/cmake/modules/CGAL_add_test.cmake b/Installation/cmake/modules/CGAL_add_test.cmake index a40e3c2f90d..d1f30fcec3a 100644 --- a/Installation/cmake/modules/CGAL_add_test.cmake +++ b/Installation/cmake/modules/CGAL_add_test.cmake @@ -89,6 +89,21 @@ function(cgal_add_compilation_test exe_name) COMMAND ${TIME_COMMAND} "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "${exe_name}") set_property(TEST "compilation_of__${exe_name}" APPEND PROPERTY LABELS "${PROJECT_NAME}") + if(NOT TARGET cgal_check_build_system) + add_custom_target(cgal_check_build_system) + endif() + if(NOT TEST check_build_system) + add_test(NAME "check_build_system" + COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "cgal_check_build_system") + if(POLICY CMP0066) # cmake 3.7 or later + set_property(TEST "check_build_system" + PROPERTY FIXTURES_SETUP "check_build_system_SetupFixture") + endif() + endif() + if(POLICY CMP0066) # cmake 3.7 or later + set_property(TEST "compilation_of__${exe_name}" + APPEND PROPERTY FIXTURES_REQUIRED "check_build_system_SetupFixture") + endif() endfunction(cgal_add_compilation_test) function(cgal_setup_test_properties test_name) From 1d5b626436a1ab43c6213285fb67a9871d30c462 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 1 Jul 2019 09:32:12 +0200 Subject: [PATCH 198/203] Fix the CMake warning --- Mesh_3/examples/Mesh_3/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index 7ae8a9ccd45..ecb2e646bc1 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -52,7 +52,7 @@ if ( CGAL_FOUND ) include( ${EIGEN3_USE_FILE} ) endif() - find_package(VTK COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) + find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) if(VTK_FOUND) if(VTK_USE_FILE) include(${VTK_USE_FILE}) From 327b310add14b469ce495d78159d43c5ded85ffa Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 1 Jul 2019 10:30:52 +0200 Subject: [PATCH 199/203] Fix the hopefully last warning --- .../test/Kernel_23/include/CGAL/_test_cls_tetrahedron_3.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_tetrahedron_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_tetrahedron_3.h index 3d54525e066..0b12bcfd8eb 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_tetrahedron_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_tetrahedron_3.h @@ -36,9 +36,6 @@ _test_cls_tetrahedron_3(const R& ) typedef typename R::RT RT; typedef typename R::FT FT; - typename R::Tetrahedron_3 it; - CGAL::Tetrahedron_3 t0(it); - RT n0 = 0; RT n1 = 12; RT n2 = 16; @@ -60,6 +57,10 @@ _test_cls_tetrahedron_3(const R& ) CGAL::Point_3 ps1( n7, n0, n0, n5); // (3, 0, 0) CGAL::Point_3 ps0( CGAL::ORIGIN ); // (0, 0, 0) + typename R::Tetrahedron_3 it0; // check the default-constructor + typename R::Tetrahedron_3 it(p1,p2,p3,p4); + CGAL::Tetrahedron_3 t0(it); + const CGAL::Tetrahedron_3 t1(p1,p2,p3,p4); CGAL::Tetrahedron_3 t2(p2,p1,p3,p4); CGAL::Tetrahedron_3 t3(ps0,ps1,ps2,ps3); // positive oriented From 4395fa5c4821839131391db49f888ebe9fb03e1c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 1 Jul 2019 10:51:28 +0200 Subject: [PATCH 200/203] warning, fix issue #4044 --- Polynomial/include/CGAL/Test/_test_polynomial_traits_d.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Polynomial/include/CGAL/Test/_test_polynomial_traits_d.h b/Polynomial/include/CGAL/Test/_test_polynomial_traits_d.h index 6527b0fb2c7..f53e5af0887 100644 --- a/Polynomial/include/CGAL/Test/_test_polynomial_traits_d.h +++ b/Polynomial/include/CGAL/Test/_test_polynomial_traits_d.h @@ -1860,7 +1860,9 @@ void test_rebind(const PT& /*traits*/){ typedef typename AT::Rational Rational; const int dimension = 4; typedef typename PT:: template Rebind::Other PT_Integer_4; + CGAL_USE_TYPE(PT_Integer_4); typedef typename PT:: template Rebind::Other PT_Rational_4; + CGAL_USE_TYPE(PT_Rational_4); CGAL_static_assertion((boost::is_same< typename PT_Integer_4::Innermost_coefficient_type, Integer>::value)); CGAL_static_assertion((boost::is_same< typename PT_Rational_4::Innermost_coefficient_type, From 44e4d1526c506a9de2566be1eb0dfdd44b04d8e5 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 1 Jul 2019 11:22:46 +0200 Subject: [PATCH 201/203] Fix the CHANGES.md --- Installation/CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 2e5541e2d5e..539996c0312 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -80,6 +80,9 @@ Release date: September 2019 `CGAL::Sphere_3`, `CGAL::Vector_2`, `CGAL::Vector_3`, `CGAL::Weighted_point_2` and `CGAL::Weighted_point_3`. +### dD Geometry Kernel +- New exact kernel `Epeck_d` + ### IO Streams - Added new functions to support some parts of the WKT file format: - `CGAL::read_point_WKT()` From f46751e48763260da7a8d23dbe1f7d362ed47d09 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 1 Jul 2019 12:02:08 +0200 Subject: [PATCH 202/203] Update CHANGES.md --- Installation/CHANGES.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 15043a31843..881856d6298 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -37,6 +37,13 @@ Release date: September 2019 for optional parameters is now removed (it was deprecated since CGAL 4.12). The current (and now only) API uses ranges and Named Parameters. + - Added the possibility to use the named parameter + `neighbor_radius` to use spherical neighbor queries instead of + K-nearest neighbors queries for the following functions: + `CGAL::bilateral_smooth_point_set()`, + `CGAL::jet_estimate_normals()`, `CGAL::jet_smooth_point_set()`, + `CGAL::mst_orient_normals()`, `CGAL::pca_estimate_normals()` and + `CGAL::remove_outliers()`. ### Polygon Mesh Processing - Added the function `CGAL::Polygon_mesh_processing::centroid()`, which computes From 2a96d5b42d95f67b41e2b47d811b52bcaf4eb218 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 1 Jul 2019 14:54:31 +0200 Subject: [PATCH 203/203] Remove lambda/auto from cxx03 code --- .../include/CGAL/Classification/Cluster.h | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Classification/include/CGAL/Classification/Cluster.h b/Classification/include/CGAL/Classification/Cluster.h index 46d0d49857b..85ce5a9893f 100644 --- a/Classification/include/CGAL/Classification/Cluster.h +++ b/Classification/include/CGAL/Classification/Cluster.h @@ -69,6 +69,28 @@ public: std::shared_ptr > neighbors; /// \endcond + /// \cond SKIP_IN_MANUAL + class Point_idx_to_point_unary_function + { + public: + typedef std::size_t argument_type; + typedef typename ItemMap::reference result_type; + typedef boost::readable_property_map_tag category; + + const ItemRange* m_range; + ItemMap m_item_map; + + Point_idx_to_point_unary_function (const ItemRange* range, ItemMap item_map) + : m_range (range), m_item_map (item_map) + { } + + result_type operator() (const argument_type& arg) const + { + return get (m_item_map, *(m_range->begin() + arg)); + } + }; + /// \endcond + private: const ItemRange* m_range; ItemMap m_item_map; @@ -139,14 +161,12 @@ public: */ const CGAL::Bbox_3& bbox() const { - auto transform = [&](const std::size_t& idx) -> typename ItemMap::reference - { - return get (m_item_map, *(m_range->begin() + idx)); - }; - if (m_bounding_box == CGAL::Bbox_3()) + { + Point_idx_to_point_unary_function transform (m_range, m_item_map); m_bounding_box = CGAL::bbox_3 (boost::make_transform_iterator (m_inliers->begin(), transform), boost::make_transform_iterator (m_inliers->end(), transform)); + } return m_bounding_box; }

    l) const { return operator()(l.begin(),l.end()); } -#else - //TODO -#endif }; } @@ -1213,15 +1140,9 @@ template struct Compare_lexicographically : private Store_kernel { CI c(this->kernel()); -#ifdef CGAL_CXX11 auto a_begin=c(a,Begin_tag()); auto b_begin=c(b,Begin_tag()); auto a_end=c(a,End_tag()); -#else - typename CI::result_type a_begin=c(a,Begin_tag()); - typename CI::result_type b_begin=c(b,Begin_tag()); - typename CI::result_type a_end=c(a,End_tag()); -#endif result_type res; // can't we do slightly better for Uncertain<*> ? // after res=...; if(is_uncertain(res))return indeterminate(); @@ -1285,15 +1206,9 @@ template struct Equal_points : private Store_kernel { CI c(this->kernel()); -#ifdef CGAL_CXX11 auto a_begin=c(a,Begin_tag()); auto b_begin=c(b,Begin_tag()); auto a_end=c(a,End_tag()); -#else - typename CI::result_type a_begin=c(a,Begin_tag()); - typename CI::result_type b_begin=c(b,Begin_tag()); - typename CI::result_type a_end=c(a,End_tag()); -#endif result_type res = true; // Is using CGAL::possibly for Uncertain really an optimization? From 16af3fcf81bbd712e80c3da39f2dbaf539d6f3b4 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:21:04 +0100 Subject: [PATCH 030/203] Remove macro CGAL_BOOSTD --- NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h | 6 +++--- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h index c4bd9292612..25a22695385 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h @@ -48,7 +48,7 @@ struct Cartesian_change_FT_base : public typedef transforming_iterator Vector_cartesian_const_iterator; //FIXME: use Iterator_list! /* - template::value_tag,FT_tag>::value> + template::value_tag,FT_tag>::value> struct Iterator : Get_type {}; template struct Iterator { typedef transforming_iterator::type> type; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h index ce32236d774..f92eb11d1cd 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h @@ -81,7 +81,7 @@ class KernelD_converter_ typedef typename Get_type::type K2_Obj; typedef typename Get_functor >::type K1_Conv; typedef KO_converter KOC; - typedef CGAL_BOOSTD is_same no_converter; + typedef std::is_same no_converter; typedef typename internal::Map_taglist_to_typelist::type::template contains duplicate; // Disable the conversion in some cases: @@ -99,10 +99,10 @@ class KernelD_converter_ //typedef typename KOC::result_type K2_Obj; public: using Base::operator(); // don't use directly, just make it accessible to the next level - K2_Obj helper(K1_Obj const& o,CGAL_BOOSTD true_type)const{ + K2_Obj helper(K1_Obj const& o, std::true_type)const{ return KOC()(this->myself().kernel(),this->myself().kernel2(),this->myself(),o); } - K2_Obj helper(K1_Obj const& o,CGAL_BOOSTD false_type)const{ + K2_Obj helper(K1_Obj const& o, std::false_type)const{ return K1_Conv(this->myself().kernel())(this->myself().kernel2(),this->myself(),o); } K2_Obj operator()(argument_type const& o)const{ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index fa4c043138a..86448acef02 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -43,8 +43,6 @@ #include #include -#define CGAL_BOOSTD std:: - namespace CGAL { namespace internal { BOOST_MPL_HAS_XXX_TRAIT_DEF(type) From c872a75e10a7501df84a9013ff1d1c844fcf3d6a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:23:35 +0100 Subject: [PATCH 031/203] Remove macro CGAL_CONSTEXPR --- NewKernel_d/include/CGAL/Epeck_d.h | 4 ++-- NewKernel_d/include/CGAL/Epick_d.h | 12 ++++++------ .../include/CGAL/NewKernel_d/Cartesian_LA_base.h | 4 ++-- .../include/CGAL/NewKernel_d/Cartesian_base.h | 4 ++-- .../include/CGAL/NewKernel_d/Cartesian_change_FT.h | 8 ++++---- .../include/CGAL/NewKernel_d/Cartesian_filter_K.h | 8 ++++---- .../include/CGAL/NewKernel_d/Cartesian_filter_NT.h | 4 ++-- .../CGAL/NewKernel_d/Cartesian_static_filters.h | 8 ++++---- .../include/CGAL/NewKernel_d/Kernel_d_interface.h | 4 ++-- .../include/CGAL/NewKernel_d/Lazy_cartesian.h | 4 ++-- .../CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h | 8 ++++---- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 1 - 12 files changed, 34 insertions(+), 35 deletions(-) diff --git a/NewKernel_d/include/CGAL/Epeck_d.h b/NewKernel_d/include/CGAL/Epeck_d.h index 8e88dc2d764..ced041e0887 100644 --- a/NewKernel_d/include/CGAL/Epeck_d.h +++ b/NewKernel_d/include/CGAL/Epeck_d.h @@ -46,8 +46,8 @@ template struct Epeck_d : CGAL_BASE { - CGAL_CONSTEXPR Epeck_d(){} - CGAL_CONSTEXPR Epeck_d(int d):CGAL_BASE(d){} + constexpr Epeck_d(){} + constexpr Epeck_d(int d):CGAL_BASE(d){} }; #undef CGAL_BASE } diff --git a/NewKernel_d/include/CGAL/Epick_d.h b/NewKernel_d/include/CGAL/Epick_d.h index 5728e41e745..f26a9faa547 100644 --- a/NewKernel_d/include/CGAL/Epick_d.h +++ b/NewKernel_d/include/CGAL/Epick_d.h @@ -44,8 +44,8 @@ template struct Epick_d_help1 : CGAL_BASE { - CGAL_CONSTEXPR Epick_d_help1(){} - CGAL_CONSTEXPR Epick_d_help1(int d):CGAL_BASE(d){} + constexpr Epick_d_help1(){} + constexpr Epick_d_help1(int d):CGAL_BASE(d){} }; #undef CGAL_BASE #define CGAL_BASE \ @@ -54,8 +54,8 @@ template struct Epick_d_help2 : CGAL_BASE { - CGAL_CONSTEXPR Epick_d_help2(){} - CGAL_CONSTEXPR Epick_d_help2(int d):CGAL_BASE(d){} + constexpr Epick_d_help2(){} + constexpr Epick_d_help2(int d):CGAL_BASE(d){} }; #undef CGAL_BASE #define CGAL_BASE \ @@ -67,8 +67,8 @@ template struct Epick_d : CGAL_BASE { - CGAL_CONSTEXPR Epick_d(){} - CGAL_CONSTEXPR Epick_d(int d):CGAL_BASE(d){} + constexpr Epick_d(){} + constexpr Epick_d(int d):CGAL_BASE(d){} }; #undef CGAL_BASE } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h index 533b953331c..cae9274f46a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h @@ -170,8 +170,8 @@ struct Cartesian_LA_base_d : public Dimension_base typedef CartesianDVectorBase::Identity_functor type; }; - CGAL_CONSTEXPR Cartesian_LA_base_d(){} - CGAL_CONSTEXPR Cartesian_LA_base_d(int d):Dimension_base(d){} + constexpr Cartesian_LA_base_d(){} + constexpr Cartesian_LA_base_d(int d):Dimension_base(d){} }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_base.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_base.h index 72595f1a355..c7c6ed97ef4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_base.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_base.h @@ -31,8 +31,8 @@ namespace CGAL { template < typename FT_, typename Dim_, typename Derived_=Default> struct Cartesian_base_d : public CGAL_BASE { - CGAL_CONSTEXPR Cartesian_base_d(){} - CGAL_CONSTEXPR Cartesian_base_d(int d):CGAL_BASE(d){} + constexpr Cartesian_base_d(){} + constexpr Cartesian_base_d(int d):CGAL_BASE(d){} }; #undef CGAL_BASE diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h index 25a22695385..6d1725ac42e 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h @@ -32,8 +32,8 @@ template < typename Base_, typename FT_, typename LA_=CGAL::LA_eigen struct Cartesian_change_FT : public Cartesian_change_FT_base { - CGAL_CONSTEXPR Cartesian_change_FT(){} - CGAL_CONSTEXPR Cartesian_change_FT(int d):Cartesian_change_FT_base(d){} + constexpr Cartesian_change_FT(){} + constexpr Cartesian_change_FT(int d):Cartesian_change_FT_base(d){} }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_K.h index 7fa283baf11..50d24b3cf25 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_K.h @@ -33,12 +33,12 @@ template < typename Base_, typename AK_, typename EK_ > struct Cartesian_filter_K : public Base_, private Store_kernel, private Store_kernel2 { - CGAL_CONSTEXPR Cartesian_filter_K(){} - CGAL_CONSTEXPR Cartesian_filter_K(int d):Base_(d){} + constexpr Cartesian_filter_K(){} + constexpr Cartesian_filter_K(int d):Base_(d){} //FIXME: or do we want an instance of AK and EK belonging to this kernel, //instead of a reference to external ones? - CGAL_CONSTEXPR Cartesian_filter_K(AK_ const&a,EK_ const&b):Base_(),Store_kernel(a),Store_kernel2(b){} - CGAL_CONSTEXPR Cartesian_filter_K(int d,AK_ const&a,EK_ const&b):Base_(d),Store_kernel(a),Store_kernel2(b){} + constexpr Cartesian_filter_K(AK_ const&a,EK_ const&b):Base_(),Store_kernel(a),Store_kernel2(b){} + constexpr Cartesian_filter_K(int d,AK_ const&a,EK_ const&b):Base_(d),Store_kernel(a),Store_kernel2(b){} typedef Base_ Kernel_base; typedef AK_ AK; typedef EK_ EK; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h index 99144377986..51a5cef6dd9 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h @@ -30,8 +30,8 @@ namespace CGAL { template < typename Base_ > struct Cartesian_filter_NT : public Base_ { - CGAL_CONSTEXPR Cartesian_filter_NT(){} - CGAL_CONSTEXPR Cartesian_filter_NT(int d):Base_(d){} + constexpr Cartesian_filter_NT(){} + constexpr Cartesian_filter_NT(int d):Base_(d){} typedef Base_ Kernel_base; typedef Cartesian_change_FT K1; typedef typename internal::Exact_field_selector::type>::Type Exact_nt; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h index 0963f87991d..49e6ae3a6e7 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h @@ -69,14 +69,14 @@ template struct Orientation_of_points_2 : private Store_k template struct Cartesian_static_filters : public R_ { - CGAL_CONSTEXPR Cartesian_static_filters(){} - CGAL_CONSTEXPR Cartesian_static_filters(int d):R_(d){} + constexpr Cartesian_static_filters(){} + constexpr Cartesian_static_filters(int d):R_(d){} }; template struct Cartesian_static_filters, R_, Derived_> : public R_ { - CGAL_CONSTEXPR Cartesian_static_filters(){} - CGAL_CONSTEXPR Cartesian_static_filters(int d):R_(d){} + constexpr Cartesian_static_filters(){} + constexpr Cartesian_static_filters(int d):R_(d){} typedef Cartesian_static_filters, R_, Derived_> Self; typedef typename Default::Get::type Derived; template struct Functor : Inherit_functor {}; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index 9210cb07600..e1fae9c1958 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -29,8 +29,8 @@ namespace CGAL { template struct Kernel_d_interface : public Base_ { - CGAL_CONSTEXPR Kernel_d_interface(){} - CGAL_CONSTEXPR Kernel_d_interface(int d):Base_(d){} + constexpr Kernel_d_interface(){} + constexpr Kernel_d_interface(int d):Base_(d){} typedef Base_ Base; typedef Kernel_d_interface Kernel; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index c62f3bbfde4..ddce8b7ead2 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -148,8 +148,8 @@ template struct Lazy_cartesian : Lazy_cartesian_types > { - CGAL_CONSTEXPR Lazy_cartesian(){} - CGAL_CONSTEXPR Lazy_cartesian(int d):ak(d),ek(d){} + constexpr Lazy_cartesian(){} + constexpr Lazy_cartesian(int d):ak(d),ek(d){} //TODO: Do we want to store an AK and an EK? Or just references? //FIXME: references would be better I guess. diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h index fb769112a4e..f21e74ced6b 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h @@ -122,8 +122,8 @@ CGAL_REGISTER_OBJECT_WRAPPER(Weighted_point); template < typename Base_ , typename Derived_ = Default > struct Cartesian_wrap : public Base_ { - CGAL_CONSTEXPR Cartesian_wrap(){} - CGAL_CONSTEXPR Cartesian_wrap(int d):Base_(d){} + constexpr Cartesian_wrap(){} + constexpr Cartesian_wrap(int d):Base_(d){} typedef Base_ Kernel_base; typedef Cartesian_wrap Self; // TODO: pass the 2 types Self and Derived to the wrappers, they can use Self for most purposes and Derived only for Kernel_traits' typedef R. @@ -178,8 +178,8 @@ struct Cartesian_wrap : public Base_ template < typename Base_ > struct Cartesian_refcount : public Base_ { - CGAL_CONSTEXPR Cartesian_refcount(){} - CGAL_CONSTEXPR Cartesian_refcount(int d):Base_(d){} + constexpr Cartesian_refcount(){} + constexpr Cartesian_refcount(int d):Base_(d){} typedef Base_ Kernel_base; typedef Cartesian_refcount Self; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index 86448acef02..bd2122590c1 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -34,7 +34,6 @@ #define CGAL_FORWARDABLE(T) T&& #define CGAL_FORWARD(T,t) std::forward(t) #define CGAL_MOVE(t) std::move(t) -#define CGAL_CONSTEXPR constexpr #include #include #include From 31dac099c57098153feacee86fffa30bc5e0437d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:26:36 +0100 Subject: [PATCH 032/203] Remove macro CGAL_MOVE --- .../include/CGAL/NewKernel_d/Coaffine.h | 6 ++-- .../include/CGAL/NewKernel_d/Types/Sphere.h | 2 +- .../CGAL/NewKernel_d/Types/Weighted_point.h | 4 +-- .../NewKernel_d/function_objects_cartesian.h | 28 +++++++++---------- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 1 - 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h index d60b5d896a8..6c81198b37d 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h @@ -215,7 +215,7 @@ template struct In_flat_orientation : private Store_kernel { if(*it != d) m(i,1+*it)=1; } - result_type ret = LA::sign_of_determinant(CGAL_MOVE(m)); + result_type ret = LA::sign_of_determinant(std::move(m)); if(o.reverse) ret=-ret; return ret; } @@ -264,7 +264,7 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel m(d+1,d+1)+=CGAL_NTS square(m(d+1,j+1)); } - result_type ret = -LA::sign_of_determinant(CGAL_MOVE(m)); + result_type ret = -LA::sign_of_determinant(std::move(m)); if(o.reverse) ret=-ret; return ret; } @@ -313,7 +313,7 @@ template struct In_flat_power_side_of_power_sphere_raw : private Store m(d+1,d+1)+=CGAL_NTS square(m(d+1,j+1)); } - result_type ret = -LA::sign_of_determinant(CGAL_MOVE(m)); + result_type ret = -LA::sign_of_determinant(std::move(m)); if(o.reverse) ret=-ret; return ret; } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h index b6c12e11c83..febe28022bd 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h @@ -60,7 +60,7 @@ template struct Construct_sphere : Store_kernel { // It should be possible to avoid copying the center by moving this code to a constructor. Point center = cc(f, e); FT const& r2 = sd(center, *f); - return this->operator()(CGAL_MOVE(center), r2); + return this->operator()(std::move(center), r2); } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h index 8bb92abdcfe..a23a838ce78 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h @@ -186,11 +186,11 @@ template struct Power_center : Store_kernel { CGAL_assertion (i == d); Vec res = typename CVec::Dimension()(d);; //std::cout << "Mat: " << m << "\n Vec: " << one << std::endl; - LA::solve(res, CGAL_MOVE(m), CGAL_MOVE(b)); + LA::solve(res, std::move(m), std::move(b)); //std::cout << "Sol: " << res << std::endl; Point center = cp(d,LA::vector_begin(res),LA::vector_end(res)); FT const& r2 = pdp (wp0, center); - return cwp(CGAL_MOVE(center), r2); + return cwp(std::move(center), r2); } }; } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 808bcafc2bb..1153a19bafc 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -68,7 +68,7 @@ template struct Orientation_of_vectors : private Store_kernel { m(i,j)=c(v,j); } } - return R::LA::sign_of_determinant(CGAL_MOVE(m)); + return R::LA::sign_of_determinant(std::move(m)); } template =3)>::type> @@ -208,7 +208,7 @@ template struct Linear_rank : private Store_kernel { m(j,i)=c(v,j); } } - return R::LA::rank(CGAL_MOVE(m)); + return R::LA::rank(std::move(m)); } }; } @@ -264,7 +264,7 @@ template struct Contained_in_linear_hull : private Store_kernel { int r1 = R::LA::rank(m); // FIXME: Don't use eigen directly, go through an interface in LA... m.conservativeResize(Eigen::NoChange, n); - int r2 = R::LA::rank(CGAL_MOVE(m)); + int r2 = R::LA::rank(std::move(m)); return r1 == r2; // TODO: This is very very far from optimal... } @@ -298,7 +298,7 @@ template struct Affine_rank : private Store_kernel { // TODO: cache p0[j] in case it is computed? } } - return R::LA::rank(CGAL_MOVE(m)); + return R::LA::rank(std::move(m)); } }; } @@ -363,8 +363,8 @@ template struct Contained_in_simplex : private Store_kernel { } // If the simplex has full dimension, there must be a solution, only the signs need to be checked. if (n == d+1) - LA::solve(a,CGAL_MOVE(m),CGAL_MOVE(b)); - else if (!LA::solve_and_check(a,CGAL_MOVE(m),CGAL_MOVE(b))) + LA::solve(a,std::move(m),std::move(b)); + else if (!LA::solve_and_check(a,std::move(m),std::move(b))) return false; for(int i=0;i struct Linear_base : private Store_kernel { m(i,j)=c(v,j); } } - Matrix b = R::LA::basis(CGAL_MOVE(m)); + Matrix b = R::LA::basis(std::move(m)); for(int i=0; i < R::LA::columns(b); ++i){ //*o++ = Vector(b.col(i)); typedef @@ -529,9 +529,9 @@ template struct Power_side_of_power_sphere_raw : private Store_kernel< } } if(d%2) - return -LA::sign_of_determinant(CGAL_MOVE(m)); + return -LA::sign_of_determinant(std::move(m)); else - return LA::sign_of_determinant(CGAL_MOVE(m)); + return LA::sign_of_determinant(std::move(m)); } }; } @@ -587,9 +587,9 @@ template struct Side_of_oriented_sphere : private Store_kernel { } } if(d%2) - return -LA::sign_of_determinant(CGAL_MOVE(m)); + return -LA::sign_of_determinant(std::move(m)); else - return LA::sign_of_determinant(CGAL_MOVE(m)); + return LA::sign_of_determinant(std::move(m)); } template =4)>::type> @@ -644,7 +644,7 @@ template struct Construct_circumcenter : Store_kernel { CGAL_assertion (i == d); Vec res = typename CVec::Dimension()(d);; //std::cout << "Mat: " << m << "\n Vec: " << one << std::endl; - LA::solve(res, CGAL_MOVE(m), CGAL_MOVE(b)); + LA::solve(res, std::move(m), std::move(b)); //std::cout << "Sol: " << res << std::endl; return cp(d,LA::vector_begin(res),LA::vector_end(res)); } @@ -688,7 +688,7 @@ template struct Construct_circumcenter : Store_kernel { for(j=0;j #define CGAL_FORWARDABLE(T) T&& #define CGAL_FORWARD(T,t) std::forward(t) -#define CGAL_MOVE(t) std::move(t) #include #include #include From 4b369cd70e0ba71a75614a6950ee6d785b255aa7 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:34:02 +0100 Subject: [PATCH 033/203] Remove macro CGAL_FORWARDABLE --- NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 1 - 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index e1fae9c1958..f75c2e8df07 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -168,7 +168,7 @@ template struct Kernel_d_interface : public Base_ { typedef Kernel R_; // for the macro CGAL_FUNCTOR_INIT_STORE(Compute_squared_radius_d) typedef FT result_type; - template FT operator()(CGAL_FORWARDABLE(S) s)const{ + template FT operator()(S&& s)const{ return typename Get_functor::type(this->kernel())(CGAL_FORWARD(S,s)); } template FT operator()(I b, I e)const{ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h index f61f80a79f0..4ec34b0454d 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h @@ -89,7 +89,7 @@ namespace CGAL { struct Iterator_and_last { template - result_type operator()(int d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { + result_type operator()(int d,Iter const& f,Iter const& e,T&& t) const { check_dim(d); CGAL_assertion(d==std::distance(f,e)+1); result_type a(d); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index ddce8b7ead2..85cdad76330 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -37,7 +37,7 @@ struct Nth_iterator_element : private Store_kernel { Nth_iterator_element(){} Nth_iterator_element(K const&k):Store_kernel(k){} typedef typename Get_type::value_tag>::type result_type; - template result_type operator()(CGAL_FORWARDABLE(U) u, int i) const { + template result_type operator()(U&& u, int i) const { typename Get_functor >::type ci(this->kernel()); return *cpp0x::next(ci(CGAL_FORWARD(U,u),Begin_tag()),i); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h index cca4b3d6754..feba00c8f2b 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h @@ -82,7 +82,7 @@ template struct Construct_segment : Store_kernel { } // T should only be std::piecewise_construct_t, but we shouldn't fail if it doesn't exist. template - result_type operator()(CGAL_FORWARDABLE(T),CGAL_FORWARDABLE(U) u,CGAL_FORWARDABLE(V) v)const{ + result_type operator()(T&&, U&& u, V&& v)const{ CP cp(this->kernel()); result_type r = {{ call_on_tuple_elements(cp, CGAL_FORWARD(U,u)), diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h index 71e17313ced..c63b8b179af 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h @@ -93,7 +93,7 @@ template struct Array_vector { struct Iterator_and_last { template - Vector operator()(unsigned CGAL_assertion_code(d),Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { + Vector operator()(unsigned CGAL_assertion_code(d),Iter const& f,Iter const& e,T&& t) const { CGAL_assertion(d==std::distance(f,e)+1); CGAL_assertion(d<=d_); //TODO: optimize for forward iterators diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h index 1f2023c0785..74f221ad1de 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h @@ -73,7 +73,7 @@ template struct Vector_vector { struct Iterator_and_last { template - Vector operator()(int d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { + Vector operator()(int d,Iter const& f,Iter const& e,T&& t) const { CGAL_assertion(d==std::distance(f,e)+1); Vector a; a.reserve(d+1); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index 5afe9c2b844..b467741ffc9 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -31,7 +31,6 @@ #include #include -#define CGAL_FORWARDABLE(T) T&& #define CGAL_FORWARD(T,t) std::forward(t) #include #include From 7b2dfaccffbb3db74834b13ed5d0d45703504332 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:37:38 +0100 Subject: [PATCH 034/203] Remove macro CGAL_FORWARD --- .../include/CGAL/NewKernel_d/Kernel_d_interface.h | 2 +- .../include/CGAL/NewKernel_d/LA_eigen/constructors.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h | 4 ++-- NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 9 ++++----- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index f75c2e8df07..e536b083f0a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -169,7 +169,7 @@ template struct Kernel_d_interface : public Base_ { CGAL_FUNCTOR_INIT_STORE(Compute_squared_radius_d) typedef FT result_type; template FT operator()(S&& s)const{ - return typename Get_functor::type(this->kernel())(CGAL_FORWARD(S,s)); + return typename Get_functor::type(this->kernel())(std::forward(s)); } template FT operator()(I b, I e)const{ return typename Get_functor::type(this->kernel())(b,e); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h index 4ec34b0454d..9590964f7f4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h @@ -94,7 +94,7 @@ namespace CGAL { CGAL_assertion(d==std::distance(f,e)+1); result_type a(d); std::copy(f,e,&a[0]); - a[d-1]=CGAL_FORWARD(T,t); + a[d-1]=std::forward(t); return a; } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 85cdad76330..3ada5ce2efe 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -39,7 +39,7 @@ struct Nth_iterator_element : private Store_kernel { typedef typename Get_type::value_tag>::type result_type; template result_type operator()(U&& u, int i) const { typename Get_functor >::type ci(this->kernel()); - return *cpp0x::next(ci(CGAL_FORWARD(U,u),Begin_tag()),i); + return *cpp0x::next(ci(std::forward(u),Begin_tag()),i); } }; //typedef typename Functor::nth_element>::type nth_elem; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h index feba00c8f2b..4434182c382 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h @@ -85,8 +85,8 @@ template struct Construct_segment : Store_kernel { result_type operator()(T&&, U&& u, V&& v)const{ CP cp(this->kernel()); result_type r = {{ - call_on_tuple_elements(cp, CGAL_FORWARD(U,u)), - call_on_tuple_elements(cp, CGAL_FORWARD(V,v)) }}; + call_on_tuple_elements(cp, std::forward(u)), + call_on_tuple_elements(cp, std::forward(v)) }}; return r; } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h index c63b8b179af..85b7f638b3f 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h @@ -99,7 +99,7 @@ template struct Array_vector { //TODO: optimize for forward iterators Vector a; std::copy(f,e,a.begin()); - a.back()=CGAL_FORWARD(T,t); + a.back()=std::forward(t); return a; } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h index 74f221ad1de..17157fb950b 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h @@ -78,7 +78,7 @@ template struct Vector_vector { Vector a; a.reserve(d+1); a.insert(a.end(),f,e); - a.push_back(CGAL_FORWARD(T,t)); + a.push_back(std::forward(t)); return a; } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index b467741ffc9..7b7981bc2ae 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -31,7 +31,6 @@ #include #include -#define CGAL_FORWARD(T,t) std::forward(t) #include #include #include @@ -83,7 +82,7 @@ struct Has_type_different_from template decltype(auto) operator()(FT&& x)const { - return scale*CGAL_FORWARD(FT,x); + return scale*std::forward(x); } }; template struct Divide { @@ -104,7 +103,7 @@ struct Has_type_different_from NT operator()(FT&& x)const { return Rational_traits(). - make_rational(CGAL_FORWARD(FT,x),scale); + make_rational(std::forward(x),scale); } }; @@ -120,7 +119,7 @@ struct Has_type_different_from template decltype(auto) operator()(A&&a,B&&b)const { - return CGAL_FORWARD(A,a)*CGAL_FORWARD(B,b); + return std::forward(a)*std::forward(b); } }; template < class Ret > @@ -128,7 +127,7 @@ struct Has_type_different_from template decltype(auto) operator()(A&&a,B&&b)const { - return CGAL_FORWARD(A,a)/CGAL_FORWARD(B,b); + return std::forward(a)/std::forward(b); } }; From 7d9e2a45fca36dfe3e21b7ae08f9966cb8d12f38 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:54:56 +0100 Subject: [PATCH 035/203] Remove some result_of --- .../CGAL/NewKernel_d/Wrapper/Point_d.h | 107 +----------------- .../CGAL/NewKernel_d/Wrapper/Vector_d.h | 107 ++---------------- 2 files changed, 13 insertions(+), 201 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index d4fe244e6c3..37bcef5d25a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -31,7 +31,6 @@ #include #include #include -#include namespace CGAL { namespace Wrap { @@ -104,18 +103,18 @@ public: : Rep(CPBase()(std::move(v))) {} - typename boost::result_of::type cartesian(int i)const{ + decltype(auto) cartesian(int i)const{ return CCBase()(rep(),i); } - typename boost::result_of::type operator[](int i)const{ + decltype(auto) operator[](int i)const{ return CCBase()(rep(),i); } - typename boost::result_of::type cartesian_begin()const{ + decltype(auto) cartesian_begin()const{ return CPI()(rep(),Begin_tag()); } - typename boost::result_of::type cartesian_end()const{ + decltype(auto) cartesian_end()const{ return CPI()(rep(),End_tag()); } @@ -131,94 +130,6 @@ public: friend auto operator!=(Point_d const&p, Point_d const&q) { return !(p==q); } - /* - Direction_d direction() const - { - return R().construct_direction_d_object()(*this); - } - - Vector_d transform(const Aff_transformation_d &t) const - { - return t.transform(*this); - } - - Vector_d operator/(const RT& c) const - { - return R().construct_divided_vector_d_object()(*this,c); - } - - Vector_d operator/(const typename First_if_different::Type & c) const - { - return R().construct_divided_vector_d_object()(*this,c); - } - - typename Qualified_result_of::type - x() const - { - return R().compute_x_3_object()(*this); - } - - typename Qualified_result_of::type - y() const - { - return R().compute_y_3_object()(*this); - } - - typename Qualified_result_of::type - z() const - { - return R().compute_z_3_object()(*this); - } - - typename Qualified_result_of::type - hx() const - { - return R().compute_hx_3_object()(*this); - } - - typename Qualified_result_of::type - hy() const - { - return R().compute_hy_3_object()(*this); - } - - typename Qualified_result_of::type - hz() const - { - return R().compute_hz_3_object()(*this); - } - - typename Qualified_result_of::type - hw() const - { - return R().compute_hw_3_object()(*this); - } - - typename Qualified_result_of::type - cartesian(int i) const - { - CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); - if (i==0) return x(); - if (i==1) return y(); - return z(); - } - - typename Qualified_result_of::type - homogeneous(int i) const - { - CGAL_kernel_precondition( (i >= 0) || (i <= 3) ); - if (i==0) return hx(); - if (i==1) return hy(); - if (i==2) return hz(); - return hw(); - } - - typename Qualified_result_of::type - squared_length() const - { - return R().compute_squared_length_3_object()(*this); - } -*/ }; #if 0 template Point_d::Point_d(Point_d &)=default; @@ -227,14 +138,8 @@ template Point_d::Point_d(Point_d &)=default; template std::ostream& operator <<(std::ostream& os, const Point_d& p) { - typedef typename R_::Kernel_base Kbase; - typedef typename Get_functor >::type CPI; - // Should just be "auto"... - typename CGAL::decay::Rep,Begin_tag) - >::type>::type - b = p.cartesian_begin(), - e = p.cartesian_end(); + auto b = p.cartesian_begin(); + auto e = p.cartesian_end(); if(is_ascii(os)) { os << p.dimension(); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h index 4df349df909..ec32210e88f 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h @@ -102,19 +102,19 @@ public: : Rep(CVBase()(std::move(v))) {} - typename boost::result_of::type cartesian(int i)const{ + decltype(auto) cartesian(int i)const{ return CCBase()(rep(),i); } - typename boost::result_of::type operator[](int i)const{ + decltype(auto) operator[](int i)const{ return CCBase()(rep(),i); } - typename boost::result_of::type cartesian_begin()const{ + decltype(auto) cartesian_begin()const{ return CVI()(rep(),Begin_tag()); } - typename boost::result_of::type cartesian_end()const{ + decltype(auto) cartesian_end()const{ return CVI()(rep(),End_tag()); } @@ -123,99 +123,12 @@ public: return typename Get_functor::type()(*this); } - /* - Direction_d direction() const - { - return R().construct_direction_d_object()(*this); - } - - Vector_d transform(const Aff_transformation_d &t) const - { - return t.transform(*this); - } - - Vector_d operator/(const RT& c) const - { - return R().construct_divided_vector_d_object()(*this,c); - } - - Vector_d operator/(const typename First_if_different::Type & c) const - { - return R().construct_divided_vector_d_object()(*this,c); - } - - typename Qualified_result_of::type - x() const - { - return R().compute_x_3_object()(*this); - } - - typename Qualified_result_of::type - y() const - { - return R().compute_y_3_object()(*this); - } - - typename Qualified_result_of::type - z() const - { - return R().compute_z_3_object()(*this); - } - - typename Qualified_result_of::type - hx() const - { - return R().compute_hx_3_object()(*this); - } - - typename Qualified_result_of::type - hy() const - { - return R().compute_hy_3_object()(*this); - } - - typename Qualified_result_of::type - hz() const - { - return R().compute_hz_3_object()(*this); - } - - typename Qualified_result_of::type - hw() const - { - return R().compute_hw_3_object()(*this); - } - - typename Qualified_result_of::type - cartesian(int i) const - { - CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); - if (i==0) return x(); - if (i==1) return y(); - return z(); - } - - typename Qualified_result_of::type - homogeneous(int i) const - { - CGAL_kernel_precondition( (i >= 0) || (i <= 3) ); - if (i==0) return hx(); - if (i==1) return hy(); - if (i==2) return hz(); - return hw(); - } - - int dimension() const // bad idea? - { - return rep.dimension(); - } -*/ int dimension() const { typedef typename Get_functor::type VDBase; return VDBase()(rep()); } - typename boost::result_of::type squared_length()const{ + decltype(auto) squared_length()const{ return SLBase()(rep()); } }; @@ -226,14 +139,8 @@ template Vector_d::Vector_d(Vector_d &)=default; template std::ostream& operator <<(std::ostream& os, const Vector_d& v) { - typedef typename R_::Kernel_base Kbase; - typedef typename Get_functor >::type CVI; - // Should just be "auto"... - typename CGAL::decay::Rep,Begin_tag) - >::type>::type - b = v.cartesian_begin(), - e = v.cartesian_end(); + auto b = v.cartesian_begin(); + auto e = v.cartesian_end(); if(is_ascii(os)) { os << v.dimension(); From 9fef604bc2846622bf5e48a4bdfba06c86a95bc6 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 16:03:07 +0100 Subject: [PATCH 036/203] Move some operators to inline friends. It gives nicer error messages... --- .../CGAL/NewKernel_d/Wrapper/Point_d.h | 105 +++++++------- .../CGAL/NewKernel_d/Wrapper/Vector_d.h | 129 +++++++++--------- 2 files changed, 111 insertions(+), 123 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index 37bcef5d25a..6c1020063f1 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -130,66 +130,61 @@ public: friend auto operator!=(Point_d const&p, Point_d const&q) { return !(p==q); } + friend std::ostream& operator <<(std::ostream& os, const Point_d& p) + { + auto b = p.cartesian_begin(); + auto e = p.cartesian_end(); + if(is_ascii(os)) + { + os << p.dimension(); + for(; b != e; ++b){ + os << " " << *b; + } + } + else + { + write(os, p.dimension()); + for(; b != e; ++b){ + write(os, *b); + } + } + return os; + } + + // TODO: test if the stream is binary or text? + friend std::istream& operator>>(std::istream &is, Point_d & p) + { + int dim; + if( is_ascii(is) ) + is >> dim; + else + { + read(is, dim); + } + + if(!is) return is; + std::vector coords(dim); + if(is_ascii(is)) + { + for(int i=0;i> iformat(coords[i]); + } + else + { + for(int i=0;i Point_d::Point_d(Point_d &)=default; #endif -template -std::ostream& operator <<(std::ostream& os, const Point_d& p) -{ - auto b = p.cartesian_begin(); - auto e = p.cartesian_end(); - if(is_ascii(os)) - { - os << p.dimension(); - for(; b != e; ++b){ - os << " " << *b; - } - } - else - { - write(os, p.dimension()); - for(; b != e; ++b){ - write(os, *b); - } - } - return os; -} - -// TODO: test if the stream is binary or text? -template -std::istream & -operator>>(std::istream &is, Point_d & p) -{ - typedef typename Get_type::type P; - typedef typename Get_type::type FT; - int dim; - if( is_ascii(is) ) - is >> dim; - else - { - read(is, dim); - } - - if(!is) return is; - std::vector coords(dim); - if(is_ascii(is)) - { - for(int i=0;i> iformat(coords[i]); - } - else - { - for(int i=0;i //Vector_d operator+(const Vector_d& v,const Vector_d& w) const diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h index ec32210e88f..4bfeb18f78b 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h @@ -131,79 +131,72 @@ public: decltype(auto) squared_length()const{ return SLBase()(rep()); } + + friend std::ostream& operator <<(std::ostream& os, const Vector_d& v) + { + auto b = v.cartesian_begin(); + auto e = v.cartesian_end(); + if(is_ascii(os)) + { + os << v.dimension(); + for(; b != e; ++b){ + os << " " << *b; + } + } + else + { + write(os, v.dimension()); + for(; b != e; ++b){ + write(os, *b); + } + } + + return os; + } + + friend std::istream & operator>>(std::istream &is, Vector_d & v) + { + int dim; + if( is_ascii(is) ) + is >> dim; + else + { + read(is, dim); + } + if(!is) return is; + + std::vector coords(dim); + if(is_ascii(is)) + { + for(int i=0;i> iformat(coords[i]); + } + else + { + for(int i=0;i::type()(v,w); + } + + friend Vector_d operator-(const Vector_d& v,const Vector_d& w) + { + return typename Get_functor::type()(v,w); + } }; #if 0 template Vector_d::Vector_d(Vector_d &)=default; #endif -template -std::ostream& operator <<(std::ostream& os, const Vector_d& v) -{ - auto b = v.cartesian_begin(); - auto e = v.cartesian_end(); - if(is_ascii(os)) - { - os << v.dimension(); - for(; b != e; ++b){ - os << " " << *b; - } - } - else - { - write(os, v.dimension()); - for(; b != e; ++b){ - write(os, *b); - } - } - - return os; -} - - -template -std::istream & -operator>>(std::istream &is, Vector_d & v) -{ - typedef typename Get_type::type V; - typedef typename Get_type::type FT; - int dim; - if( is_ascii(is) ) - is >> dim; - else - { - read(is, dim); - } - if(!is) return is; - - std::vector coords(dim); - if(is_ascii(is)) - { - for(int i=0;i> iformat(coords[i]); - } - else - { - for(int i=0;i -Vector_d operator+(const Vector_d& v,const Vector_d& w) -{ - return typename Get_functor::type()(v,w); -} - -template -Vector_d operator-(const Vector_d& v,const Vector_d& w) -{ - return typename Get_functor::type()(v,w); -} } //namespace Wrap } //namespace CGAL From 02cfcafb72ae09d2f2c84e68e87fa6e03632af58 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 16:16:20 +0100 Subject: [PATCH 037/203] Replace some boost with std. It doesn't help much, but we should still stop using those boost facilities that are now standard. --- .../CGAL/NewKernel_d/Cartesian_LA_functors.h | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h index da49afa43c2..e7a61332e57 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace CGAL { namespace CartesianDVectorBase { @@ -66,7 +67,7 @@ template struct Construct_LA_vector } template typename std::enable_if::value && - boost::is_same, Dimension>::value, + std::is_same, Dimension>::value, result_type>::type operator()(U&&...u)const{ return typename Constructor::Values()(std::forward(u)...); @@ -74,19 +75,19 @@ template struct Construct_LA_vector //template::value>::type,class=typename std::enable_if<(sizeof...(U)==static_dim+1)>::type,class=void> template typename std::enable_if::value && - boost::is_same, Dimension>::value, + std::is_same, Dimension>::value, result_type>::type operator()(U&&...u)const{ return Apply_to_last_then_rest()(typename Constructor::Values_divide(),std::forward(u)...); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (Iter f,Iter g,Cartesian_tag t)const { return this->operator()((int)std::distance(f,g),f,g,t); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (int d,Iter f,Iter g,Cartesian_tag)const { CGAL_assertion(d==std::distance(f,g)); @@ -94,28 +95,28 @@ template struct Construct_LA_vector return typename Constructor::Iterator()(d,f,g); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (Iter f,Iter g,Homogeneous_tag)const { --g; return this->operator()((int)std::distance(f,g),f,g,*g); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (int d,Iter f,Iter g,Homogeneous_tag)const { --g; return this->operator()(d,f,g,*g); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (Iter f,Iter g)const { // Shouldn't it try comparing dist(f,g) to the dimension if it is known? return this->operator()(f,g,typename R::Rep_tag()); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (int d,Iter f,Iter g)const { return this->operator()(d,f,g,typename R::Rep_tag()); @@ -123,7 +124,7 @@ template struct Construct_LA_vector // Last homogeneous coordinate given separately template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (int d,Iter f,Iter g,NT const&l)const { CGAL_assertion(d==std::distance(f,g)); @@ -132,7 +133,7 @@ template struct Construct_LA_vector return typename Constructor::Iterator()(d,CGAL::make_transforming_iterator(f,Divide(l)),CGAL::make_transforming_iterator(g,Divide(l))); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (Iter f,Iter g,NT const&l)const { return this->operator()((int)std::distance(f,g),f,g,l); From f099add88eb627dce8063426ce3a4fcc5ac86762 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 16:54:08 +0100 Subject: [PATCH 038/203] Various small simplifications --- .../CGAL/NewKernel_d/Filtered_predicate2.h | 4 +--- .../NewKernel_d/Kernel_object_converter.h | 6 +++--- .../include/CGAL/NewKernel_d/Types/Segment.h | 4 ++-- .../NewKernel_d/function_objects_cartesian.h | 4 ++-- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 21 ++++++------------- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h index 1fff3e19a49..323537d6776 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h @@ -60,8 +60,6 @@ class Filtered_predicate2 C2E c2e; C2A c2a; - typedef typename AP::result_type Ares; - public: typedef AP Approximate_predicate; @@ -92,7 +90,7 @@ public: try { // No forward here, the arguments may still be needed - Ares res = ap(c2a(args)...); + auto res = ap(c2a(args)...); if (is_certain(res)) return get_certain(res); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h index 3022ec4997a..93d279361dc 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h @@ -49,15 +49,15 @@ template struct Point_converter_help,K1,K2> { typedef typename Get_type::type argument_type; typedef typename Get_type::type result_type; - template - result_type help(Indices, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { + template + result_type help(std::index_sequence, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { typename Get_functor::type cc(k1); typename Get_functor >::type cp(k2); return cp(conv(cc(p,I))...); } template result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { - return help(typename N_increasing_indices::type(),k1,k2,conv,p); + return help(std::make_index_sequence(),k1,k2,conv,p); } }; } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h index 4434182c382..913700ba800 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h @@ -85,8 +85,8 @@ template struct Construct_segment : Store_kernel { result_type operator()(T&&, U&& u, V&& v)const{ CP cp(this->kernel()); result_type r = {{ - call_on_tuple_elements(cp, std::forward(u)), - call_on_tuple_elements(cp, std::forward(v)) }}; + call_on_tuple_elements(cp, std::forward(u)), + call_on_tuple_elements(cp, std::forward(v)) }}; return r; } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 1153a19bafc..bc8427d3355 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -91,7 +91,7 @@ template struct Orientation_of_points,true> typedef typename Get_type::type Point; typedef typename Get_type::type result_type; templatestruct Help; - templatestruct Help > { + templatestruct Help > { template result_type operator()(C const&c,P const&x,T&&t)const{ return sign_of_determinant(c(std::get(t),I%d)-c(x,I%d)...); } @@ -99,7 +99,7 @@ template struct Orientation_of_points,true> template result_type operator()(P0 const&x,P&&...p)const{ static_assert(d==sizeof...(P),"Wrong number of arguments"); typename Get_functor::type c(this->kernel()); - return Help::type>()(c,x,std::forward_as_tuple(std::forward