Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-07-27 11:39:43 +0300
committerbubnikv <bubnikv@gmail.com>2017-07-27 11:39:43 +0300
commita6ea01a23f1f4013845fce4ec80c6511b6f40f37 (patch)
tree02bdb4d4146e0da9a8ecb3abfb2bf9c323a79bc2 /xs/src/libslic3r/Point.hpp
parent3b51f644110978f69edaf95b50a8796e992aab23 (diff)
Moved some math macros (sqr, lerp, clamp) to libslic3r.h
Added UNUSED macro to libslic3r.h, used it to reduce some compile warnings. Split the Int128 class from Clipper library to a separate file, extended Int128 with intrinsic types wherever possible for performance, added new geometric predicates. Added a draft of new FillRectilinear3, which should reduce overfill near the perimeters in the future.
Diffstat (limited to 'xs/src/libslic3r/Point.hpp')
-rw-r--r--xs/src/libslic3r/Point.hpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/xs/src/libslic3r/Point.hpp b/xs/src/libslic3r/Point.hpp
index 8f11bd50a..9fd4f13ae 100644
--- a/xs/src/libslic3r/Point.hpp
+++ b/xs/src/libslic3r/Point.hpp
@@ -27,7 +27,8 @@ typedef std::vector<Pointf3> Pointf3s;
class Point
{
- public:
+public:
+ typedef coord_t coord_type;
coord_t x;
coord_t y;
Point(coord_t _x = 0, coord_t _y = 0): x(_x), y(_y) {};
@@ -77,6 +78,7 @@ class Point
inline Point operator+(const Point& point1, const Point& point2) { return Point(point1.x + point2.x, point1.y + point2.y); }
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); }
+inline int64_t cross(const Point &v1, const Point &v2) { return int64_t(v1.x) * int64_t(v2.y) - int64_t(v1.y) * int64_t(v2.x); }
// To be used by std::unordered_map, std::unordered_multimap and friends.
struct PointHash {
@@ -189,6 +191,7 @@ std::ostream& operator<<(std::ostream &stm, const Pointf &pointf);
class Pointf
{
public:
+ typedef coordf_t coord_type;
coordf_t x;
coordf_t y;
explicit Pointf(coordf_t _x = 0, coordf_t _y = 0): x(_x), y(_y) {};
@@ -239,6 +242,11 @@ class Pointf3 : public Pointf
Vectorf3 vector_to(const Pointf3 &point) const;
};
+template<typename TO> inline TO convert_to(const Point &src) { return TO(TO::coord_type(src.x), TO::coord_type(src.y)); }
+template<typename TO> inline TO convert_to(const Pointf &src) { return TO(TO::coord_type(src.x), TO::coord_type(src.y)); }
+template<typename TO> inline TO convert_to(const Point3 &src) { return TO(TO::coord_type(src.x), TO::coord_type(src.y), TO::coord_type(src.z)); }
+template<typename TO> inline TO convert_to(const Pointf3 &src) { return TO(TO::coord_type(src.x), TO::coord_type(src.y), TO::coord_type(src.z)); }
+
} // namespace Slic3r
// start Boost