diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2014-08-03 21:42:29 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2014-08-03 21:42:29 +0400 |
commit | 6adc3477c9d08d2cfa0e6902b3d241a9193e50d4 (patch) | |
tree | 98e1a403cec185a06501056d1811b4d39d731bf5 /xs/src/libslic3r/BoundingBox.hpp | |
parent | b8676241e0c9f91eb9db5b6757e73edfe7f85598 (diff) |
Moved C++ code into new libslic3r directory
Diffstat (limited to 'xs/src/libslic3r/BoundingBox.hpp')
-rw-r--r-- | xs/src/libslic3r/BoundingBox.hpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp new file mode 100644 index 000000000..0ea81b831 --- /dev/null +++ b/xs/src/libslic3r/BoundingBox.hpp @@ -0,0 +1,76 @@ +#ifndef slic3r_BoundingBox_hpp_ +#define slic3r_BoundingBox_hpp_ + +#include <myinit.h> +#include "Point.hpp" +#include "Polygon.hpp" + +namespace Slic3r { + +typedef Point Size; +typedef Point3 Size3; +typedef Pointf Sizef; +typedef Pointf3 Sizef3; + +template <class PointClass> +class BoundingBoxBase +{ + public: + PointClass min; + PointClass max; + + BoundingBoxBase() {}; + BoundingBoxBase(const std::vector<PointClass> &points); + void merge(const PointClass &point); + void merge(const BoundingBoxBase<PointClass> &bb); + void scale(double factor); + PointClass size() const; + void translate(coordf_t x, coordf_t y); + void offset(coordf_t delta); + PointClass center() const; +}; + +template <class PointClass> +class BoundingBox3Base : public BoundingBoxBase<PointClass> +{ + public: + BoundingBox3Base() {}; + BoundingBox3Base(const std::vector<PointClass> &points); + void merge(const PointClass &point); + void merge(const BoundingBox3Base<PointClass> &bb); + PointClass size() const; + void translate(coordf_t x, coordf_t y, coordf_t z); + void offset(coordf_t delta); + PointClass center() const; +}; + +class BoundingBox : public BoundingBoxBase<Point> +{ + public: + void polygon(Polygon* polygon) const; + Polygon polygon() const; + + BoundingBox() {}; + BoundingBox(const Points &points) : BoundingBoxBase<Point>(points) {}; + BoundingBox(const Lines &lines); +}; + +/* +class BoundingBox3 : public BoundingBox3Base<Point3> {}; +*/ + +class BoundingBoxf : public BoundingBoxBase<Pointf> { + public: + BoundingBoxf() {}; + BoundingBoxf(const std::vector<Pointf> &points) : BoundingBoxBase<Pointf>(points) {}; +}; + +class BoundingBoxf3 : public BoundingBox3Base<Pointf3> { + public: + BoundingBoxf3() {}; + BoundingBoxf3(const std::vector<Pointf3> &points) : BoundingBox3Base<Pointf3>(points) {}; +}; + +} + +#endif |