PrusaSlicer-NonPlainar/xs/src/libslic3r/BoundingBox.hpp

80 lines
2.1 KiB
C++
Raw Normal View History

#ifndef slic3r_BoundingBox_hpp_
#define slic3r_BoundingBox_hpp_
#include "libslic3r.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-09-21 08:51:36 +00:00
bool defined;
2014-09-21 08:51:36 +00:00
BoundingBoxBase() : defined(false) {};
BoundingBoxBase(const std::vector<PointClass> &points);
2014-01-07 11:48:09 +00:00
void merge(const PointClass &point);
2014-11-15 21:41:22 +00:00
void merge(const std::vector<PointClass> &points);
2014-01-06 18:42:31 +00:00
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:
2014-09-21 08:51:36 +00:00
BoundingBox3Base() : BoundingBoxBase<PointClass>() {};
BoundingBox3Base(const std::vector<PointClass> &points);
2014-01-07 11:48:09 +00:00
void merge(const PointClass &point);
2014-11-15 21:41:22 +00:00
void merge(const std::vector<PointClass> &points);
2014-01-06 18:42:31 +00:00
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;
};
2014-01-07 11:48:09 +00:00
class BoundingBox : public BoundingBoxBase<Point>
{
public:
void polygon(Polygon* polygon) const;
Polygon polygon() const;
2014-09-21 08:51:36 +00:00
BoundingBox() : BoundingBoxBase<Point>() {};
BoundingBox(const Points &points) : BoundingBoxBase<Point>(points) {};
BoundingBox(const Lines &lines);
};
2014-01-07 11:48:09 +00:00
/*
class BoundingBox3 : public BoundingBox3Base<Point3> {};
2014-01-07 11:48:09 +00:00
*/
class BoundingBoxf : public BoundingBoxBase<Pointf> {
public:
2014-09-21 08:51:36 +00:00
BoundingBoxf() : BoundingBoxBase<Pointf>() {};
BoundingBoxf(const std::vector<Pointf> &points) : BoundingBoxBase<Pointf>(points) {};
};
class BoundingBoxf3 : public BoundingBox3Base<Pointf3> {
public:
2014-09-21 08:51:36 +00:00
BoundingBoxf3() : BoundingBox3Base<Pointf3>() {};
BoundingBoxf3(const std::vector<Pointf3> &points) : BoundingBox3Base<Pointf3>(points) {};
};
}
#endif