Update geompp library
authorIOhannes m zmölnig (Debian/GNU) <umlaeute@debian.org>
Thu, 3 Mar 2022 12:47:18 +0000 (13:47 +0100)
committerIOhannes m zmölnig (Debian/GNU) <umlaeute@debian.org>
Thu, 3 Mar 2022 12:47:18 +0000 (13:47 +0100)
debian/patches/02-geompp.patch

index 7f3529597c1c95c50b143ed8b3e5cc2aa3e28ac5..4b5f32c432965d1c2fb5bfcaa0e890571fe702bf 100644 (file)
@@ -190,7 +190,7 @@ Last-Update: 2021-08-30
 +#endif
 --- /dev/null
 +++ giada/src/deps/geompp/src/range.hpp
-@@ -0,0 +1,61 @@
+@@ -0,0 +1,76 @@
 +/* -----------------------------------------------------------------------------
 + *
 + * geompp - Basic geometrical utilities for C++.
@@ -228,8 +228,9 @@ Last-Update: 2021-08-30
 +class Range
 +{
 +public:
-+      constexpr Range()
-+      : Range(0, 0)
++      constexpr Range() // Invalid default range
++      : a(0)
++      , b(0)
 +      {
 +      }
 +
@@ -240,8 +241,22 @@ Last-Update: 2021-08-30
 +              assert(a < b);
 +      }
 +
++      Range<T> operator*(const T m) const { return {a * m, b * m}; }
++      Range<T> operator*=(const T m) const { return {a * m, b * m}; }
++      Range<T> operator/(const T m) const { return {a / m, b / m}; }
++      Range<T> operator/=(const T m) const { return {a / m, b / m}; }
++      Range<T> operator+(const T m) const { return {a + m, b + m}; }
++      Range<T> operator+=(const T m) const { return {a + m, b + m}; }
++      Range<T> operator-(const T m) const { return {a - m, b - m}; }
++      Range<T> operator-=(const T m) const { return {a - m, b - m}; }
++
 +      T getLength() const { return b - a; }
 +
++      bool isValid() const
++      {
++              return a < b;
++      }
++
 +      bool contains(T t) const
 +      {
 +              return t >= a && t < b;
@@ -254,7 +269,7 @@ Last-Update: 2021-08-30
 +#endif
 --- /dev/null
 +++ giada/src/deps/geompp/src/rect.hpp
-@@ -0,0 +1,236 @@
+@@ -0,0 +1,234 @@
 +/* -----------------------------------------------------------------------------
 + *
 + * geompp - Basic geometrical utilities for C++.
@@ -284,6 +299,7 @@ Last-Update: 2021-08-30
 +#ifndef GEOMPP_RECT_HH
 +#define GEOMPP_RECT_HH
 +
++#include "border.hpp"
 +#include "line.hpp"
 +#include "point.hpp"
 +#include "range.hpp"
@@ -390,29 +406,30 @@ Last-Update: 2021-08-30
 +              yh = y + h;
 +      }
 +
-+      /* reduce (1)
-+    Reduces width and height by a certain amount around the center point. */
++      /* reduce
++    Reduces all four sides by a certain Border. */
 +
-+      void reduce(T amountX, T amountY)
++      void reduce(Border<T> b)
 +      {
-+              x += amountX;
-+              y += amountY;
-+              w -= amountX * 2;
-+              h -= amountY * 2;
++              x += b.left;
++              y += b.top;
++              w -= b.left + b.right;
++              h -= b.top + b.bottom;
 +              xw = x + w;
 +              yh = y + h;
 +      }
 +
-+      /* reduce (2)
-+    Reduces all four sides by a certain amount around the center point. */
-+
-+      void reduce(T amount) { reduce(amount, amount); }
-+
 +      /* isValid
 +      True if this Rect has size greater than zero. */
 +
 +      bool isValid() const { return w > 0 && h > 0; }
 +
++      /* expand (1), (2)
++      The opposite of reduce (1), (2). */
++
++      void expand(T amountX, T amountY) { reduce(-amountX, -amountY); }
++      void expand(T amount) { reduce(-amount); }
++
 +      /* with[...]
 +    Returns a copy of this Rect with a new position/size. */
 +
@@ -449,25 +466,21 @@ Last-Update: 2021-08-30
 +
 +      Point<T> getPosition() const { return Point(x, y); }
 +
-+      /* reduced (1)
-+    Returns a copy of this Rect with width and height reduced by a certain 
-+    amount. */
++      /* reduced 
++    Returns a copy of this Rect with all four sides reduced by a certain Border. */
 +
-+      Rect<T> reduced(T amountX, T amountY) const
++      Rect<T> reduced(Border<T> b) const
 +      {
 +              Rect r = *this;
-+              r.reduce(amountX, amountY);
++              r.reduce(b);
 +              return r;
 +      }
 +
-+      /* reduced (2)
-+    Returns a copy of this Rect with all four sides reduced by a certain amount 
-+    around the center point. */
++      /* expanded (1), (2)
++      The opposite of reduced (1), (2). */
 +
-+      Rect<T> reduced(T amount) const
-+      {
-+              return reduced(amount, amount);
-+      }
++      Rect<T> expanded(T amountX, T amountY) const { return reduced(-amountX, -amountY); }
++      Rect<T> expanded(T amount) const { return reduced(-amount); }
 +
 +      /* contains (1)
 +      Returns true if Point p is inside this Rect. */
@@ -492,3 +505,82 @@ Last-Update: 2021-08-30
 +
 +#endif
 \ No newline at end of file
+--- /dev/null
++++ giada/src/deps/geompp/src/border.hpp
+@@ -0,0 +1,75 @@
++/* -----------------------------------------------------------------------------
++ *
++ * geompp - Basic geometrical utilities for C++.
++ *
++ * -----------------------------------------------------------------------------
++ *
++ * Copyright (C) 2021 Giovanni A. Zuliani | Monocasual Laboratories
++ *
++ * This file is part of geompp - Basic geometrical utilities for C++.
++ *
++ * geompp - Basic geometrical utilities for C++ is free software: you can
++ * redistribute it and/or modify it under the terms of the GNU General
++ * Public License as published by the Free Software Foundation, either
++ * version 3 of the License, or (at your option) any later version.
++ *
++ * geompp - Basic geometrical utilities for C++ is distributed in the hope that 
++ * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
++ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
++ * See the GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with geompp - Basic geometrical utilities for C++. If not, see
++ * <http://www.gnu.org/licenses/>.
++ *
++ * -------------------------------------------------------------------------- */
++
++#ifndef GEOMPP_BORDER_HH
++#define GEOMPP_BORDER_HH
++
++namespace geompp
++{
++template <typename T>
++class Border
++{
++public:
++      /* Border (1) 
++    Empty border. */
++
++      constexpr Border()
++      : Border(0, 0, 0, 0)
++      {
++      }
++
++      /* Border (2) 
++    Normal border. */
++
++      constexpr Border(T t, T r, T b, T l)
++      : top(t)
++      , right(r)
++      , bottom(b)
++      , left(l)
++      {
++      }
++
++      /* Border (3) 
++    Normal border, all sides equal. */
++
++      constexpr Border(T v)
++      : Border(v, v, v, v)
++      {
++      }
++
++      /* Border (4) 
++    Normal border, horizontal and vertical sides equal. */
++
++      constexpr Border(T x, T y)
++      : Border(y, x, y, x)
++      {
++      }
++
++      T top, right, bottom, left;
++};
++} // namespace geompp
++
++#endif
+\ No newline at end of file