diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp index 1731bd2f1..90179d3f9 100644 --- a/xs/src/libslic3r/BoundingBox.hpp +++ b/xs/src/libslic3r/BoundingBox.hpp @@ -15,7 +15,7 @@ typedef Pointf3 Sizef3; template class BoundingBoxBase { - public: +public: PointClass min; PointClass max; bool defined; @@ -42,12 +42,14 @@ class BoundingBoxBase return ! (this->max.x < other.min.x || this->min.x > other.max.x || this->max.y < other.min.y || this->min.y > other.max.y); } + bool operator==(const BoundingBoxBase &rhs) { return this->min == rhs.min && this->max == rhs.max; } + bool operator!=(const BoundingBoxBase &rhs) { return ! (*this == rhs); } }; template class BoundingBox3Base : public BoundingBoxBase { - public: +public: BoundingBox3Base() : BoundingBoxBase() {}; BoundingBox3Base(const PointClass &pmin, const PointClass &pmax) : BoundingBoxBase(pmin, pmax) @@ -66,7 +68,7 @@ class BoundingBox3Base : public BoundingBoxBase class BoundingBox : public BoundingBoxBase { - public: +public: void polygon(Polygon* polygon) const; Polygon polygon() const; BoundingBox rotated(double angle) const; @@ -87,6 +89,7 @@ class BoundingBox : public BoundingBoxBase class BoundingBox3 : public BoundingBox3Base { +public: BoundingBox3() : BoundingBox3Base() {}; BoundingBox3(const Point3 &pmin, const Point3 &pmax) : BoundingBox3Base(pmin, pmax) {}; BoundingBox3(const std::vector &points) : BoundingBox3Base(points) {}; @@ -108,18 +111,6 @@ public: 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) { diff --git a/xs/src/libslic3r/Point.hpp b/xs/src/libslic3r/Point.hpp index a56e642aa..b81427f73 100644 --- a/xs/src/libslic3r/Point.hpp +++ b/xs/src/libslic3r/Point.hpp @@ -184,6 +184,12 @@ public: coord_t z; explicit Point3(coord_t _x = 0, coord_t _y = 0, coord_t _z = 0): Point(_x, _y), z(_z) {}; static Point3 new_scale(coordf_t x, coordf_t y, coordf_t z) { return Point3(coord_t(scale_(x)), coord_t(scale_(y)), coord_t(scale_(z))); } + bool operator==(const Point3 &rhs) const { return this->x == rhs.x && this->y == rhs.y && this->z == rhs.z; } + bool operator!=(const Point3 &rhs) const { return ! (*this == rhs); } +private: + // Hide the following inherited methods: + bool operator==(const Point &rhs); + bool operator!=(const Point &rhs); }; std::ostream& operator<<(std::ostream &stm, const Pointf &pointf); @@ -214,6 +220,9 @@ public: Pointf& operator+=(const Pointf& rhs) { this->x += rhs.x; this->y += rhs.y; return *this; } Pointf& operator-=(const Pointf& rhs) { this->x -= rhs.x; this->y -= rhs.y; return *this; } Pointf& operator*=(const coordf_t& rhs) { this->x *= rhs; this->y *= rhs; return *this; } + + bool operator==(const Pointf &rhs) const { return this->x == rhs.x && this->y == rhs.y; } + bool operator!=(const Pointf &rhs) const { return ! (*this == rhs); } }; inline Pointf operator+(const Pointf& point1, const Pointf& point2) { return Pointf(point1.x + point2.x, point1.y + point2.y); } @@ -228,7 +237,7 @@ inline double l2(const Vectorf &v) { return dot(v); } class Pointf3 : public Pointf { - public: +public: coordf_t z; explicit Pointf3(coordf_t _x = 0, coordf_t _y = 0, coordf_t _z = 0): Pointf(_x, _y), z(_z) {}; static Pointf3 new_unscale(coord_t x, coord_t y, coord_t z) { @@ -240,6 +249,14 @@ class Pointf3 : public Pointf double distance_to(const Pointf3 &point) const; Pointf3 negative() const; Vectorf3 vector_to(const Pointf3 &point) const; + + bool operator==(const Pointf3 &rhs) const { return this->x == rhs.x && this->y == rhs.y && this->z == rhs.z; } + bool operator!=(const Pointf3 &rhs) const { return ! (*this == rhs); } + +private: + // Hide the following inherited methods: + bool operator==(const Pointf &rhs); + bool operator!=(const Pointf &rhs); }; template inline TO convert_to(const Point &src) { return TO(typename TO::coord_type(src.x), typename TO::coord_type(src.y)); }