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:
Diffstat (limited to 'xs/src/libslic3r/PrintObject.cpp')
-rw-r--r--xs/src/libslic3r/PrintObject.cpp97
1 files changed, 70 insertions, 27 deletions
diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp
index 7882c58a8..ef2364dc4 100644
--- a/xs/src/libslic3r/PrintObject.cpp
+++ b/xs/src/libslic3r/PrintObject.cpp
@@ -112,8 +112,18 @@ bool PrintObject::reload_model_instances()
Points copies;
copies.reserve(m_model_object->instances.size());
for (const ModelInstance *mi : m_model_object->instances)
+ {
+#if ENABLE_MODELINSTANCE_3D_OFFSET
+ if (mi->is_printable())
+ {
+ const Vec3d& offset = mi->get_offset();
+ copies.emplace_back(Point::new_scale(offset(0), offset(1)));
+ }
+#else
if (mi->is_printable())
copies.emplace_back(Point::new_scale(mi->offset(0), mi->offset(1)));
+#endif // ENABLE_MODELINSTANCE_3D_OFFSET
+ }
return this->set_copies(copies);
}
@@ -490,6 +500,7 @@ bool PrintObject::invalidate_state_by_config_options(const std::vector<t_config_
steps.emplace_back(posSlice);
} else if (
opt_key == "support_material"
+ || opt_key == "support_material_auto"
|| opt_key == "support_material_angle"
|| opt_key == "support_material_buildplate_only"
|| opt_key == "support_material_enforce_layers"
@@ -1560,34 +1571,66 @@ end:
std::vector<ExPolygons> PrintObject::_slice_region(size_t region_id, const std::vector<float> &z, bool modifier)
{
- std::vector<ExPolygons> layers;
+ std::vector<const ModelVolume*> volumes;
if (region_id < this->region_volumes.size()) {
- std::vector<int> &volumes = this->region_volumes[region_id];
- if (! volumes.empty()) {
- // Compose mesh.
- //FIXME better to perform slicing over each volume separately and then to use a Boolean operation to merge them.
- TriangleMesh mesh;
- for (int volume_id : volumes) {
- ModelVolume *volume = this->model_object()->volumes[volume_id];
- if (volume->modifier == modifier)
- mesh.merge(volume->mesh);
- m_print->throw_if_canceled();
- }
- if (mesh.stl.stats.number_of_facets > 0) {
- // transform mesh
- // we ignore the per-instance transformations currently and only
- // consider the first one
- this->model_object()->instances.front()->transform_mesh(&mesh, true);
- // align mesh to Z = 0 (it should be already aligned actually) and apply XY shift
- mesh.translate(- unscale<float>(m_copies_shift(0)), - unscale<float>(m_copies_shift(1)), - float(this->model_object()->bounding_box().min(2)));
- // perform actual slicing
- TriangleMeshSlicer mslicer;
- Print *print = this->print();
- auto callback = TriangleMeshSlicer::throw_on_cancel_callback_type([print](){print->throw_if_canceled();});
- mslicer.init(&mesh, callback);
- mslicer.slice(z, &layers, callback);
- m_print->throw_if_canceled();
- }
+ for (int volume_id : this->region_volumes[region_id]) {
+ const ModelVolume *volume = this->model_object()->volumes[volume_id];
+ if (modifier ? volume->is_modifier() : volume->is_model_part())
+ volumes.emplace_back(volume);
+ }
+ }
+ return this->_slice_volumes(z, volumes);
+}
+
+std::vector<ExPolygons> PrintObject::slice_support_enforcers() const
+{
+ std::vector<const ModelVolume*> volumes;
+ for (const ModelVolume *volume : this->model_object()->volumes)
+ if (volume->is_support_enforcer())
+ volumes.emplace_back(volume);
+ std::vector<float> zs;
+ zs.reserve(this->layers().size());
+ for (const Layer *l : this->layers())
+ zs.emplace_back(l->slice_z);
+ return this->_slice_volumes(zs, volumes);
+}
+
+std::vector<ExPolygons> PrintObject::slice_support_blockers() const
+{
+ std::vector<const ModelVolume*> volumes;
+ for (const ModelVolume *volume : this->model_object()->volumes)
+ if (volume->is_support_blocker())
+ volumes.emplace_back(volume);
+ std::vector<float> zs;
+ zs.reserve(this->layers().size());
+ for (const Layer *l : this->layers())
+ zs.emplace_back(l->slice_z);
+ return this->_slice_volumes(zs, volumes);
+}
+
+std::vector<ExPolygons> PrintObject::_slice_volumes(const std::vector<float> &z, const std::vector<const ModelVolume*> &volumes) const
+{
+ std::vector<ExPolygons> layers;
+ if (! volumes.empty()) {
+ // Compose mesh.
+ //FIXME better to perform slicing over each volume separately and then to use a Boolean operation to merge them.
+ TriangleMesh mesh;
+ for (const ModelVolume *v : volumes)
+ mesh.merge(v->mesh);
+ if (mesh.stl.stats.number_of_facets > 0) {
+ // transform mesh
+ // we ignore the per-instance transformations currently and only
+ // consider the first one
+ this->model_object()->instances.front()->transform_mesh(&mesh, true);
+ // align mesh to Z = 0 (it should be already aligned actually) and apply XY shift
+ mesh.translate(- unscale<float>(m_copies_shift(0)), - unscale<float>(m_copies_shift(1)), - float(this->model_object()->bounding_box().min(2)));
+ // perform actual slicing
+ TriangleMeshSlicer mslicer;
+ const Print *print = this->print();
+ auto callback = TriangleMeshSlicer::throw_on_cancel_callback_type([print](){print->throw_if_canceled();});
+ mslicer.init(&mesh, callback);
+ mslicer.slice(z, &layers, callback);
+ m_print->throw_if_canceled();
}
}
return layers;