BoundingBox, Print - methods inlined, added const accessors.
This commit is contained in:
parent
e6fddd364d
commit
c96d794604
4 changed files with 17 additions and 49 deletions
xs/src/libslic3r
|
@ -203,23 +203,6 @@ BoundingBox3Base<PointClass>::radius() const
|
||||||
}
|
}
|
||||||
template double BoundingBox3Base<Pointf3>::radius() const;
|
template double BoundingBox3Base<Pointf3>::radius() const;
|
||||||
|
|
||||||
template <class PointClass> void
|
|
||||||
BoundingBoxBase<PointClass>::translate(coordf_t x, coordf_t y)
|
|
||||||
{
|
|
||||||
this->min.translate(x, y);
|
|
||||||
this->max.translate(x, y);
|
|
||||||
}
|
|
||||||
template void BoundingBoxBase<Point>::translate(coordf_t x, coordf_t y);
|
|
||||||
template void BoundingBoxBase<Pointf>::translate(coordf_t x, coordf_t y);
|
|
||||||
|
|
||||||
template <class PointClass> void
|
|
||||||
BoundingBox3Base<PointClass>::translate(coordf_t x, coordf_t y, coordf_t z)
|
|
||||||
{
|
|
||||||
this->min.translate(x, y, z);
|
|
||||||
this->max.translate(x, y, z);
|
|
||||||
}
|
|
||||||
template void BoundingBox3Base<Pointf3>::translate(coordf_t x, coordf_t y, coordf_t z);
|
|
||||||
|
|
||||||
template <class PointClass> void
|
template <class PointClass> void
|
||||||
BoundingBoxBase<PointClass>::offset(coordf_t delta)
|
BoundingBoxBase<PointClass>::offset(coordf_t delta)
|
||||||
{
|
{
|
||||||
|
@ -259,25 +242,6 @@ BoundingBox3Base<PointClass>::center() const
|
||||||
}
|
}
|
||||||
template Pointf3 BoundingBox3Base<Pointf3>::center() const;
|
template Pointf3 BoundingBox3Base<Pointf3>::center() const;
|
||||||
|
|
||||||
template <class PointClass> bool
|
|
||||||
BoundingBoxBase<PointClass>::contains(const PointClass &point) const
|
|
||||||
{
|
|
||||||
return point.x >= this->min.x && point.x <= this->max.x
|
|
||||||
&& point.y >= this->min.y && point.y <= this->max.y;
|
|
||||||
}
|
|
||||||
template bool BoundingBoxBase<Point>::contains(const Point &point) const;
|
|
||||||
template bool BoundingBoxBase<Pointf>::contains(const Pointf &point) const;
|
|
||||||
|
|
||||||
template <class PointClass> bool
|
|
||||||
BoundingBoxBase<PointClass>::overlap(const BoundingBoxBase<PointClass> &other) const
|
|
||||||
{
|
|
||||||
return ! (this->max.x < other.min.x || this->min.x > other.max.x ||
|
|
||||||
this->max.y < other.min.y || this->min.y > other.max.y);
|
|
||||||
}
|
|
||||||
template bool BoundingBoxBase<Point>::overlap(const BoundingBoxBase<Point> &point) const;
|
|
||||||
template bool BoundingBoxBase<Pointf>::overlap(const BoundingBoxBase<Pointf> &point) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Align a coordinate to a grid. The coordinate may be negative,
|
// Align a coordinate to a grid. The coordinate may be negative,
|
||||||
// the aligned value will never be bigger than the original one.
|
// the aligned value will never be bigger than the original one.
|
||||||
static inline coord_t _align_to_grid(const coord_t coord, const coord_t spacing) {
|
static inline coord_t _align_to_grid(const coord_t coord, const coord_t spacing) {
|
||||||
|
|
|
@ -30,11 +30,18 @@ class BoundingBoxBase
|
||||||
void scale(double factor);
|
void scale(double factor);
|
||||||
PointClass size() const;
|
PointClass size() const;
|
||||||
double radius() const;
|
double radius() const;
|
||||||
void translate(coordf_t x, coordf_t y);
|
void translate(coordf_t x, coordf_t y) { this->min.translate(x, y); this->max.translate(x, y); }
|
||||||
|
void translate(const Pointf &pos) { this->translate(pos.x, pos.y); }
|
||||||
void offset(coordf_t delta);
|
void offset(coordf_t delta);
|
||||||
PointClass center() const;
|
PointClass center() const;
|
||||||
bool contains(const PointClass &point) const;
|
bool contains(const PointClass &point) const {
|
||||||
bool overlap(const BoundingBoxBase<PointClass> &other) const;
|
return point.x >= this->min.x && point.x <= this->max.x
|
||||||
|
&& point.y >= this->min.y && point.y <= this->max.y;
|
||||||
|
}
|
||||||
|
bool overlap(const BoundingBoxBase<PointClass> &other) const {
|
||||||
|
return ! (this->max.x < other.min.x || this->min.x > other.max.x ||
|
||||||
|
this->max.y < other.min.y || this->min.y > other.max.y);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class PointClass>
|
template <class PointClass>
|
||||||
|
@ -51,7 +58,8 @@ class BoundingBox3Base : public BoundingBoxBase<PointClass>
|
||||||
void merge(const BoundingBox3Base<PointClass> &bb);
|
void merge(const BoundingBox3Base<PointClass> &bb);
|
||||||
PointClass size() const;
|
PointClass size() const;
|
||||||
double radius() const;
|
double radius() const;
|
||||||
void translate(coordf_t x, coordf_t y, coordf_t z);
|
void translate(coordf_t x, coordf_t y, coordf_t z) { this->min.translate(x, y, z); this->max.translate(x, y, z); }
|
||||||
|
void translate(const Pointf3 &pos) { this->translate(pos.x, pos.y, pos.z); }
|
||||||
void offset(coordf_t delta);
|
void offset(coordf_t delta);
|
||||||
PointClass center() const;
|
PointClass center() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,12 +36,6 @@ Print::clear_objects()
|
||||||
this->clear_regions();
|
this->clear_regions();
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintObject*
|
|
||||||
Print::get_object(size_t idx)
|
|
||||||
{
|
|
||||||
return objects.at(idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Print::delete_object(size_t idx)
|
Print::delete_object(size_t idx)
|
||||||
{
|
{
|
||||||
|
|
|
@ -198,7 +198,7 @@ typedef std::vector<PrintRegion*> PrintRegionPtrs;
|
||||||
// The complete print tray with possibly multiple objects.
|
// The complete print tray with possibly multiple objects.
|
||||||
class Print
|
class Print
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PrintConfig config;
|
PrintConfig config;
|
||||||
PrintObjectConfig default_object_config;
|
PrintObjectConfig default_object_config;
|
||||||
PrintRegionConfig default_region_config;
|
PrintRegionConfig default_region_config;
|
||||||
|
@ -218,7 +218,9 @@ class Print
|
||||||
|
|
||||||
// methods for handling objects
|
// methods for handling objects
|
||||||
void clear_objects();
|
void clear_objects();
|
||||||
PrintObject* get_object(size_t idx);
|
PrintObject* get_object(size_t idx) { return objects.at(idx); }
|
||||||
|
const PrintObject* get_object(size_t idx) const { return objects.at(idx); }
|
||||||
|
|
||||||
void delete_object(size_t idx);
|
void delete_object(size_t idx);
|
||||||
void reload_object(size_t idx);
|
void reload_object(size_t idx);
|
||||||
bool reload_model_instances();
|
bool reload_model_instances();
|
||||||
|
@ -258,7 +260,7 @@ class Print
|
||||||
std::string output_filename();
|
std::string output_filename();
|
||||||
std::string output_filepath(const std::string &path);
|
std::string output_filepath(const std::string &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clear_regions();
|
void clear_regions();
|
||||||
void delete_region(size_t idx);
|
void delete_region(size_t idx);
|
||||||
PrintRegionConfig _region_config_from_model_volume(const ModelVolume &volume);
|
PrintRegionConfig _region_config_from_model_volume(const ModelVolume &volume);
|
||||||
|
|
Loading…
Reference in a new issue