2014-01-06 17:29:10 +00:00
|
|
|
#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;
|
|
|
|
|
2014-01-06 18:42:31 +00:00
|
|
|
BoundingBoxBase();
|
2014-01-06 17:29:10 +00:00
|
|
|
BoundingBoxBase(const std::vector<PointClass> points);
|
2014-01-06 18:42:31 +00:00
|
|
|
void merge(const BoundingBoxBase<PointClass> &bb);
|
2014-01-06 17:29:10 +00:00
|
|
|
void scale(double factor);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class PointClass>
|
|
|
|
class BoundingBox2Base : public BoundingBoxBase<PointClass>
|
|
|
|
{
|
|
|
|
public:
|
2014-01-06 18:42:31 +00:00
|
|
|
BoundingBox2Base();
|
2014-01-06 17:29:10 +00:00
|
|
|
BoundingBox2Base(const std::vector<PointClass> points) : BoundingBoxBase<PointClass>(points) {};
|
|
|
|
PointClass size() const;
|
|
|
|
void translate(coordf_t x, coordf_t y);
|
|
|
|
PointClass center() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class PointClass>
|
|
|
|
class BoundingBox3Base : public BoundingBoxBase<PointClass>
|
|
|
|
{
|
|
|
|
public:
|
2014-01-06 18:42:31 +00:00
|
|
|
BoundingBox3Base();
|
2014-01-06 17:29:10 +00:00
|
|
|
BoundingBox3Base(const std::vector<PointClass> points);
|
2014-01-06 18:42:31 +00:00
|
|
|
void merge(const BoundingBox3Base<PointClass> &bb);
|
2014-01-06 17:29:10 +00:00
|
|
|
PointClass size() const;
|
|
|
|
void translate(coordf_t x, coordf_t y, coordf_t z);
|
|
|
|
PointClass center() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BoundingBox : public BoundingBox2Base<Point>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void polygon(Polygon* polygon) const;
|
|
|
|
|
2014-01-06 18:42:31 +00:00
|
|
|
BoundingBox() {};
|
2014-01-06 17:29:10 +00:00
|
|
|
BoundingBox(const Points points) : BoundingBox2Base<Point>(points) {};
|
|
|
|
};
|
|
|
|
|
|
|
|
class BoundingBoxf : public BoundingBox2Base<Pointf> {};
|
|
|
|
class BoundingBox3 : public BoundingBox3Base<Point3> {};
|
|
|
|
|
|
|
|
class BoundingBoxf3 : public BoundingBox3Base<Pointf3> {
|
|
|
|
public:
|
2014-01-06 18:42:31 +00:00
|
|
|
BoundingBoxf3() {};
|
2014-01-06 17:29:10 +00:00
|
|
|
BoundingBoxf3(const std::vector<Pointf3> points) : BoundingBox3Base<Pointf3>(points) {};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|