From c96d7946040d4bb6f943fd596bc42e5c063bc06a Mon Sep 17 00:00:00 2001 From: bubnikv <bubnikv@gmail.com> Date: Mon, 13 Mar 2017 16:03:11 +0100 Subject: [PATCH] BoundingBox, Print - methods inlined, added const accessors. --- xs/src/libslic3r/BoundingBox.cpp | 36 -------------------------------- xs/src/libslic3r/BoundingBox.hpp | 16 ++++++++++---- xs/src/libslic3r/Print.cpp | 6 ------ xs/src/libslic3r/Print.hpp | 8 ++++--- 4 files changed, 17 insertions(+), 49 deletions(-) diff --git a/xs/src/libslic3r/BoundingBox.cpp b/xs/src/libslic3r/BoundingBox.cpp index 75ece90bf..f268bb3fb 100644 --- a/xs/src/libslic3r/BoundingBox.cpp +++ b/xs/src/libslic3r/BoundingBox.cpp @@ -203,23 +203,6 @@ BoundingBox3Base<PointClass>::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 BoundingBoxBase<PointClass>::offset(coordf_t delta) { @@ -259,25 +242,6 @@ BoundingBox3Base<PointClass>::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, // 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) { diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp index 232dada80..8a562c789 100644 --- a/xs/src/libslic3r/BoundingBox.hpp +++ b/xs/src/libslic3r/BoundingBox.hpp @@ -30,11 +30,18 @@ class BoundingBoxBase void scale(double factor); PointClass size() 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); PointClass center() const; - bool contains(const PointClass &point) const; - bool overlap(const BoundingBoxBase<PointClass> &other) const; + bool 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; + } + 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> @@ -51,7 +58,8 @@ class BoundingBox3Base : public BoundingBoxBase<PointClass> void merge(const BoundingBox3Base<PointClass> &bb); PointClass size() 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); PointClass center() const; }; diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 4c14599c9..18b01fea3 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -36,12 +36,6 @@ Print::clear_objects() this->clear_regions(); } -PrintObject* -Print::get_object(size_t idx) -{ - return objects.at(idx); -} - void Print::delete_object(size_t idx) { diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index 6dd9a8094..3398260e3 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -198,7 +198,7 @@ typedef std::vector<PrintRegion*> PrintRegionPtrs; // The complete print tray with possibly multiple objects. class Print { - public: +public: PrintConfig config; PrintObjectConfig default_object_config; PrintRegionConfig default_region_config; @@ -218,7 +218,9 @@ class Print // methods for handling 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 reload_object(size_t idx); bool reload_model_instances(); @@ -258,7 +260,7 @@ class Print std::string output_filename(); std::string output_filepath(const std::string &path); - private: +private: void clear_regions(); void delete_region(size_t idx); PrintRegionConfig _region_config_from_model_volume(const ModelVolume &volume);