From 1d44e92a6e621524496a960d9c6ff88ddc2479ea Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 29 Nov 2016 19:29:24 +0100 Subject: [PATCH] Point dot operator and PointHash object for std unique_xxx functions. --- xs/src/libslic3r/Point.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xs/src/libslic3r/Point.hpp b/xs/src/libslic3r/Point.hpp index a69f8d9f8..66e78ae46 100644 --- a/xs/src/libslic3r/Point.hpp +++ b/xs/src/libslic3r/Point.hpp @@ -70,6 +70,12 @@ inline Point operator+(const Point& point1, const Point& point2) { return Point( inline Point operator-(const Point& point1, const Point& point2) { return Point(point1.x - point2.x, point1.y - point2.y); } inline Point operator*(double scalar, const Point& point2) { return Point(scalar * point2.x, scalar * point2.y); } +struct PointHash { + size_t operator()(const Point &pt) const { + return std::hash()(pt.x) ^ std::hash()(pt.y); + } +}; + class Point3 : public Point { public: @@ -107,6 +113,7 @@ inline Pointf operator-(const Pointf& point1, const Pointf& point2) { return Poi inline Pointf operator*(double scalar, const Pointf& point2) { return Pointf(scalar * point2.x, scalar * point2.y); } inline Pointf operator*(const Pointf& point2, double scalar) { return Pointf(scalar * point2.x, scalar * point2.y); } inline coordf_t cross(const Pointf &v1, const Pointf &v2) { return v1.x * v2.y - v1.y * v2.x; } +inline coordf_t dot(const Pointf &v1, const Pointf &v2) { return v1.x * v1.y + v2.x * v2.y; } class Pointf3 : public Pointf {