From 25fa09178b7d0d0befa708e93ea5316ef381caa0 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 22 May 2015 10:23:27 +0200 Subject: Update to 2Geom revision 2396 (bzr r14059.2.16) --- src/2geom/d2.h | 88 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 41 deletions(-) (limited to 'src/2geom/d2.h') diff --git a/src/2geom/d2.h b/src/2geom/d2.h index 714319f99..bf764539d 100644 --- a/src/2geom/d2.h +++ b/src/2geom/d2.h @@ -33,7 +33,7 @@ #define LIB2GEOM_SEEN_D2_H #include -#include +#include #include #include <2geom/point.h> #include <2geom/interval.h> @@ -107,30 +107,36 @@ class D2{ //IMPL: FragmentConcept typedef Point output_type; bool isZero(double eps=EPSILON) const { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return f[X].isZero(eps) && f[Y].isZero(eps); } bool isConstant(double eps=EPSILON) const { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return f[X].isConstant(eps) && f[Y].isConstant(eps); } bool isFinite() const { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return f[X].isFinite() && f[Y].isFinite(); } Point at0() const { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return Point(f[X].at0(), f[Y].at0()); } Point at1() const { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return Point(f[X].at1(), f[Y].at1()); } + Point pointAt(double t) const { + BOOST_CONCEPT_ASSERT((FragmentConcept)); + return (*this)(t); + } Point valueAt(double t) const { - boost::function_requires >(); + // TODO: remove this alias + BOOST_CONCEPT_ASSERT((FragmentConcept)); return (*this)(t); } std::vector valueAndDerivatives(double t, unsigned n) const { + BOOST_CONCEPT_ASSERT((FragmentConcept)); std::vector x = f[X].valueAndDerivatives(t, n), y = f[Y].valueAndDerivatives(t, n); // always returns a vector of size n+1 std::vector res(n+1); @@ -140,7 +146,7 @@ class D2{ return res; } D2 toSBasis() const { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return D2(f[X].toSBasis(), f[Y].toSBasis()); } @@ -149,33 +155,33 @@ class D2{ }; template inline D2 reverse(const D2 &a) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return D2(reverse(a[X]), reverse(a[Y])); } template inline D2 portion(const D2 &a, Coord f, Coord t) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return D2(portion(a[X], f, t), portion(a[Y], f, t)); } template inline D2 portion(const D2 &a, Interval i) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return D2(portion(a[X], i), portion(a[Y], i)); } -//IMPL: boost::EqualityComparableConcept +//IMPL: EqualityComparableConcept template inline bool operator==(D2 const &a, D2 const &b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((EqualityComparableConcept)); return a[0]==b[0] && a[1]==b[1]; } template inline bool operator!=(D2 const &a, D2 const &b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((EqualityComparableConcept)); return a[0]!=b[0] || a[1]!=b[1]; } @@ -183,7 +189,7 @@ operator!=(D2 const &a, D2 const &b) { template inline bool are_near(D2 const &a, D2 const &b, double tol) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((NearConcept)); return are_near(a[0], b[0], tol) && are_near(a[1], b[1], tol); } @@ -191,7 +197,7 @@ are_near(D2 const &a, D2 const &b, double tol) { template inline D2 operator+(D2 const &a, D2 const &b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((AddableConcept)); D2 r; for(unsigned i = 0; i < 2; i++) @@ -201,7 +207,7 @@ operator+(D2 const &a, D2 const &b) { template inline D2 operator-(D2 const &a, D2 const &b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((AddableConcept)); D2 r; for(unsigned i = 0; i < 2; i++) @@ -211,7 +217,7 @@ operator-(D2 const &a, D2 const &b) { template inline D2 operator+=(D2 &a, D2 const &b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((AddableConcept)); for(unsigned i = 0; i < 2; i++) a[i] += b[i]; @@ -220,7 +226,7 @@ operator+=(D2 &a, D2 const &b) { template inline D2 operator-=(D2 &a, D2 const & b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((AddableConcept)); for(unsigned i = 0; i < 2; i++) a[i] -= b[i]; @@ -231,7 +237,7 @@ operator-=(D2 &a, D2 const & b) { template inline D2 operator-(D2 const & a) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((ScalableConcept)); D2 r; for(unsigned i = 0; i < 2; i++) r[i] = -a[i]; @@ -240,7 +246,7 @@ operator-(D2 const & a) { template inline D2 operator*(D2 const & a, Point const & b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((ScalableConcept)); D2 r; for(unsigned i = 0; i < 2; i++) @@ -250,7 +256,7 @@ operator*(D2 const & a, Point const & b) { template inline D2 operator/(D2 const & a, Point const & b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((ScalableConcept)); //TODO: b==0? D2 r; for(unsigned i = 0; i < 2; i++) @@ -260,7 +266,7 @@ operator/(D2 const & a, Point const & b) { template inline D2 operator*=(D2 &a, Point const & b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((ScalableConcept)); for(unsigned i = 0; i < 2; i++) a[i] *= b[i]; @@ -269,7 +275,7 @@ operator*=(D2 &a, Point const & b) { template inline D2 operator/=(D2 &a, Point const & b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((ScalableConcept)); //TODO: b==0? for(unsigned i = 0; i < 2; i++) a[i] /= b[i]; @@ -287,8 +293,8 @@ inline D2 operator/=(D2 & a, double b) { a[0] /= b; a[1] /= b; return a; } template D2 operator*(D2 const &v, Affine const &m) { - boost::function_requires >(); - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((AddableConcept)); + BOOST_CONCEPT_ASSERT((ScalableConcept)); D2 ret; for(unsigned i = 0; i < 2; i++) ret[i] = v[X] * m[i] + v[Y] * m[i + 2] + m[i + 4]; @@ -299,7 +305,7 @@ D2 operator*(D2 const &v, Affine const &m) { template inline D2 operator*(D2 const & a, T const & b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((MultiplicableConcept)); D2 ret; for(unsigned i = 0; i < 2; i++) ret[i] = a[i] * b; @@ -312,7 +318,7 @@ operator*(D2 const & a, T const & b) { template inline D2 operator+(D2 const & a, Point b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((OffsetableConcept)); D2 r; for(unsigned i = 0; i < 2; i++) r[i] = a[i] + b[i]; @@ -321,7 +327,7 @@ operator+(D2 const & a, Point b) { template inline D2 operator-(D2 const & a, Point b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((OffsetableConcept)); D2 r; for(unsigned i = 0; i < 2; i++) r[i] = a[i] - b[i]; @@ -330,7 +336,7 @@ operator-(D2 const & a, Point b) { template inline D2 operator+=(D2 & a, Point b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((OffsetableConcept)); for(unsigned i = 0; i < 2; i++) a[i] += b[i]; return a; @@ -338,7 +344,7 @@ operator+=(D2 & a, Point b) { template inline D2 operator-=(D2 & a, Point b) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((OffsetableConcept)); for(unsigned i = 0; i < 2; i++) a[i] -= b[i]; return a; @@ -347,8 +353,8 @@ operator-=(D2 & a, Point b) { template inline T dot(D2 const & a, D2 const & b) { - boost::function_requires >(); - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((AddableConcept)); + BOOST_CONCEPT_ASSERT((MultiplicableConcept)); T r; for(unsigned i = 0; i < 2; i++) @@ -362,8 +368,8 @@ dot(D2 const & a, D2 const & b) { template inline T dot(D2 const & a, Point const & b) { - boost::function_requires >(); - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((AddableConcept)); + BOOST_CONCEPT_ASSERT((ScalableConcept)); T r; for(unsigned i = 0; i < 2; i++) { @@ -378,8 +384,8 @@ dot(D2 const & a, Point const & b) { template inline T cross(D2 const & a, D2 const & b) { - boost::function_requires >(); - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((ScalableConcept)); + BOOST_CONCEPT_ASSERT((MultiplicableConcept)); return a[1] * b[0] - a[0] * b[1]; } @@ -389,7 +395,7 @@ cross(D2 const & a, D2 const & b) { template inline D2 rot90(D2 const & a) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((ScalableConcept)); return D2(-a[Y], a[X]); } @@ -468,17 +474,17 @@ namespace Geom { //Some D2 Fragment implementation which requires rect: template OptRect bounds_fast(const D2 &a) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return OptRect(bounds_fast(a[X]), bounds_fast(a[Y])); } template OptRect bounds_exact(const D2 &a) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return OptRect(bounds_exact(a[X]), bounds_exact(a[Y])); } template OptRect bounds_local(const D2 &a, const OptInterval &t) { - boost::function_requires >(); + BOOST_CONCEPT_ASSERT((FragmentConcept)); return OptRect(bounds_local(a[X], t), bounds_local(a[Y], t)); } -- cgit v1.2.3