Redefined the ==, != operators of Point and BoundingBox classes
to become members of their respective classes to avoid type clashes through implicit casting operators of ConfigOption classes.
This commit is contained in:
parent
a191fbbec8
commit
a91d7cb2f7
@ -42,6 +42,8 @@ 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<PointClass> &rhs) { return this->min == rhs.min && this->max == rhs.max; }
|
||||
bool operator!=(const BoundingBoxBase<PointClass> &rhs) { return ! (*this == rhs); }
|
||||
};
|
||||
|
||||
template <class PointClass>
|
||||
@ -87,6 +89,7 @@ class BoundingBox : public BoundingBoxBase<Point>
|
||||
|
||||
class BoundingBox3 : public BoundingBox3Base<Point3>
|
||||
{
|
||||
public:
|
||||
BoundingBox3() : BoundingBox3Base<Point3>() {};
|
||||
BoundingBox3(const Point3 &pmin, const Point3 &pmax) : BoundingBox3Base<Point3>(pmin, pmax) {};
|
||||
BoundingBox3(const std::vector<Point3> &points) : BoundingBox3Base<Point3>(points) {};
|
||||
@ -108,18 +111,6 @@ public:
|
||||
BoundingBoxf3(const std::vector<Pointf3> &points) : BoundingBox3Base<Pointf3>(points) {};
|
||||
};
|
||||
|
||||
template<typename VT>
|
||||
inline bool operator==(const BoundingBoxBase<VT> &bb1, const BoundingBoxBase<VT> &bb2)
|
||||
{
|
||||
return bb1.min == bb2.min && bb1.max == bb2.max;
|
||||
}
|
||||
|
||||
template<typename VT>
|
||||
inline bool operator!=(const BoundingBoxBase<VT> &bb1, const BoundingBoxBase<VT> &bb2)
|
||||
{
|
||||
return !(bb1 == bb2);
|
||||
}
|
||||
|
||||
template<typename VT>
|
||||
inline bool empty(const BoundingBoxBase<VT> &bb)
|
||||
{
|
||||
|
@ -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); }
|
||||
@ -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<typename TO> inline TO convert_to(const Point &src) { return TO(typename TO::coord_type(src.x), typename TO::coord_type(src.y)); }
|
||||
|
Loading…
Reference in New Issue
Block a user