diff options
author | Vojtech Bubnik <bubnikv@gmail.com> | 2021-05-26 17:15:01 +0300 |
---|---|---|
committer | Vojtech Bubnik <bubnikv@gmail.com> | 2021-05-26 17:15:01 +0300 |
commit | 9e4d483453a720591e4ae9044114c2abaa2d12d0 (patch) | |
tree | 2c85dd21741f5f593fbb242402f0d09b156c8088 /src/libslic3r | |
parent | 409e1c5cc8696d6e75becdedc596c3e4225aeb79 (diff) | |
parent | b7769856d1877cb24c63342d0a845314252c1cd3 (diff) |
Merge branch 'vb_print_regions' of https://github.com/Prusa3d/PrusaSlicer into vb_print_regions
Diffstat (limited to 'src/libslic3r')
-rw-r--r-- | src/libslic3r/AppConfig.cpp | 3 | ||||
-rw-r--r-- | src/libslic3r/Model.cpp | 25 | ||||
-rw-r--r-- | src/libslic3r/Model.hpp | 30 |
3 files changed, 38 insertions, 20 deletions
diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index cf532160d..869c3e67f 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -126,6 +126,9 @@ void AppConfig::set_defaults() if (get("color_mapinulation_panel").empty()) set("color_mapinulation_panel", "0"); + + if (get("order_volumes").empty()) + set("order_volumes", "1"); } else { #ifdef _WIN32 diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index a212f2be1..018754bc0 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -652,19 +652,34 @@ ModelVolume* ModelObject::add_volume(const TriangleMesh &mesh) return v; } -ModelVolume* ModelObject::add_volume(TriangleMesh &&mesh) +static void add_v_to_volumes(ModelVolumePtrs* volumes, ModelVolume* v) { - ModelVolume* v = new ModelVolume(this, std::move(mesh)); - this->volumes.push_back(v); + if (volumes->empty() || v->type() >= volumes->back()->type()) + volumes->push_back(v); + else { + for (int pos = volumes->size() - 1; pos >= 0; pos--) + if (v->type() >= (*volumes)[pos]->type()) { + volumes->insert(volumes->begin() + pos + 1, v); + break; + } + } +} + +ModelVolume* ModelObject::add_volume(TriangleMesh &&mesh, ModelVolumeType type /*= ModelVolumeType::MODEL_PART*/) +{ + ModelVolume* v = new ModelVolume(this, std::move(mesh), type); + add_v_to_volumes(&(this->volumes), v); v->center_geometry_after_creation(); this->invalidate_bounding_box(); return v; } -ModelVolume* ModelObject::add_volume(const ModelVolume &other) +ModelVolume* ModelObject::add_volume(const ModelVolume &other, ModelVolumeType type /*= ModelVolumeType::MODEL_PART*/) { ModelVolume* v = new ModelVolume(this, other); - this->volumes.push_back(v); + if (v->type() != type) + v->set_type(type); + add_v_to_volumes(&(this->volumes), v); // The volume should already be centered at this point of time when copying shared pointers of the triangle mesh and convex hull. // v->center_geometry_after_creation(); // this->invalidate_bounding_box(); diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index ed8030c9b..69229860b 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -216,6 +216,16 @@ private: friend class ModelObject; }; +// Declared outside of ModelVolume, so it could be forward declared. +enum class ModelVolumeType : int { + INVALID = -1, + MODEL_PART = 0, + NEGATIVE_VOLUME, + PARAMETER_MODIFIER, + SUPPORT_BLOCKER, + SUPPORT_ENFORCER, +}; + // A printable object, possibly having multiple print volumes (each with its own set of parameters and materials), // and possibly having multiple modifier volumes, each modifier volume with its set of parameters and materials. // Each ModelObject may be instantiated mutliple times, each instance having different placement on the print bed, @@ -262,8 +272,8 @@ public: const Model* get_model() const { return m_model; } ModelVolume* add_volume(const TriangleMesh &mesh); - ModelVolume* add_volume(TriangleMesh &&mesh); - ModelVolume* add_volume(const ModelVolume &volume); + ModelVolume* add_volume(TriangleMesh &&mesh, ModelVolumeType type = ModelVolumeType::MODEL_PART); + ModelVolume* add_volume(const ModelVolume &volume, ModelVolumeType type = ModelVolumeType::MODEL_PART); ModelVolume* add_volume(const ModelVolume &volume, TriangleMesh &&mesh); void delete_volume(size_t idx); void clear_volumes(); @@ -482,16 +492,6 @@ private: } }; -// Declared outside of ModelVolume, so it could be forward declared. -enum class ModelVolumeType : int { - INVALID = -1, - MODEL_PART = 0, - NEGATIVE_VOLUME, - PARAMETER_MODIFIER, - SUPPORT_BLOCKER, - SUPPORT_ENFORCER, -}; - enum class EnforcerBlockerType : int8_t { // Maximum is 3. The value is serialized in TriangleSelector into 2 bits! NONE = 0, @@ -717,7 +717,7 @@ private: // 1 -> is splittable mutable int m_is_splittable{ -1 }; - ModelVolume(ModelObject *object, const TriangleMesh &mesh) : m_mesh(new TriangleMesh(mesh)), m_type(ModelVolumeType::MODEL_PART), object(object) + ModelVolume(ModelObject *object, const TriangleMesh &mesh, ModelVolumeType type = ModelVolumeType::MODEL_PART) : m_mesh(new TriangleMesh(mesh)), m_type(type), object(object) { assert(this->id().valid()); assert(this->config.id().valid()); @@ -731,8 +731,8 @@ private: if (mesh.stl.stats.number_of_facets > 1) calculate_convex_hull(); } - ModelVolume(ModelObject *object, TriangleMesh &&mesh, TriangleMesh &&convex_hull) : - m_mesh(new TriangleMesh(std::move(mesh))), m_convex_hull(new TriangleMesh(std::move(convex_hull))), m_type(ModelVolumeType::MODEL_PART), object(object) { + ModelVolume(ModelObject *object, TriangleMesh &&mesh, TriangleMesh &&convex_hull, ModelVolumeType type = ModelVolumeType::MODEL_PART) : + m_mesh(new TriangleMesh(std::move(mesh))), m_convex_hull(new TriangleMesh(std::move(convex_hull))), m_type(type), object(object) { assert(this->id().valid()); assert(this->config.id().valid()); assert(this->supported_facets.id().valid()); |