diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp index 533a19b56..4d0c1fe36 100644 --- a/xs/src/libslic3r/BoundingBox.hpp +++ b/xs/src/libslic3r/BoundingBox.hpp @@ -21,6 +21,7 @@ class BoundingBoxBase bool defined; BoundingBoxBase() : defined(false) {}; + BoundingBoxBase(const PointClass &pmin, const PointClass &pmax) : min(pmin), max(pmax) {} BoundingBoxBase(const std::vector &points); void merge(const PointClass &point); void merge(const std::vector &points); @@ -37,6 +38,7 @@ class BoundingBox3Base : public BoundingBoxBase { public: BoundingBox3Base() : BoundingBoxBase() {}; + BoundingBox3Base(const PointClass &pmin, const PointClass &pmax) : BoundingBoxBase(pmin, pmax) {} BoundingBox3Base(const std::vector &points); void merge(const PointClass &point); void merge(const std::vector &points); @@ -54,6 +56,7 @@ class BoundingBox : public BoundingBoxBase Polygon polygon() const; BoundingBox() : BoundingBoxBase() {}; + BoundingBox(const Point &pmin, const Point &pmax) : BoundingBoxBase(pmin, pmax) {}; BoundingBox(const Points &points) : BoundingBoxBase(points) {}; BoundingBox(const Lines &lines); }; @@ -65,15 +68,39 @@ class BoundingBox3 : public BoundingBox3Base {}; class BoundingBoxf : public BoundingBoxBase { public: BoundingBoxf() : BoundingBoxBase() {}; + BoundingBoxf(const Pointf &pmin, const Pointf &pmax) : BoundingBoxBase(pmin, pmax) {}; BoundingBoxf(const std::vector &points) : BoundingBoxBase(points) {}; }; class BoundingBoxf3 : public BoundingBox3Base { public: BoundingBoxf3() : BoundingBox3Base() {}; + BoundingBoxf3(const Pointf3 &pmin, const Pointf3 &pmax) : BoundingBox3Base(pmin, pmax) {}; BoundingBoxf3(const std::vector &points) : BoundingBox3Base(points) {}; }; +template +inline bool operator==(const BoundingBoxBase &bb1, const BoundingBoxBase &bb2) +{ + return bb1.min == bb2.min && bb1.max == bb2.max; +} + +template +inline bool operator!=(const BoundingBoxBase &bb1, const BoundingBoxBase &bb2) +{ + return !(bb1 == bb2); +} + +template +inline bool empty(const BoundingBoxBase &bb) +{ + return bb.min.x > bb.max.y || bb.min.y > bb.max.y; +} + +template +inline bool empty(const BoundingBox3Base &bb) +{ + return bb.min.x > bb.max.x || bb.min.y > bb.max.y || bb.min.z > bb.max.z;} } #endif