Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2021-05-26 16:36:02 +0300
committerYuSanka <yusanka@gmail.com>2021-05-26 16:36:48 +0300
commitb7769856d1877cb24c63342d0a845314252c1cd3 (patch)
treec2fd2a54426e0d107649c33592060fc419906c34 /src/libslic3r
parent980ca195f523af20e08bd8e5fa3a4cf4a0991016 (diff)
Fixed DnD function for volumes inside the object in respect to the volume type
Diffstat (limited to 'src/libslic3r')
-rw-r--r--src/libslic3r/AppConfig.cpp3
-rw-r--r--src/libslic3r/Model.cpp25
-rw-r--r--src/libslic3r/Model.hpp30
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 ce359e7bf..bc6cb4236 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());