mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-06 15:21:09 +00:00
Merge remote-tracking branch 'origin/main' into feature/texture_displacement
This commit is contained in:
+57
-4
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "libslic3r/Geometry/ConvexHull.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <float.h>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
@@ -1229,6 +1230,7 @@ ModelObject& ModelObject::assign_copy(const ModelObject &rhs)
|
||||
this->volumes.emplace_back(new ModelVolume(*model_volume));
|
||||
this->volumes.back()->set_model_object(this);
|
||||
}
|
||||
|
||||
this->clear_instances();
|
||||
this->instances.reserve(rhs.instances.size());
|
||||
for (const ModelInstance *model_instance : rhs.instances) {
|
||||
@@ -1267,6 +1269,7 @@ ModelObject& ModelObject::assign_copy(ModelObject &&rhs)
|
||||
rhs.volumes.clear();
|
||||
for (ModelVolume *model_volume : this->volumes)
|
||||
model_volume->set_model_object(this);
|
||||
|
||||
this->clear_instances();
|
||||
this->instances = std::move(rhs.instances);
|
||||
rhs.instances.clear();
|
||||
@@ -1390,7 +1393,9 @@ ModelVolume* ModelObject::add_volume_with_shared_mesh(const ModelVolume &other,
|
||||
void ModelObject::delete_volume(size_t idx)
|
||||
{
|
||||
ModelVolumePtrs::iterator i = this->volumes.begin() + idx;
|
||||
delete *i;
|
||||
ModelVolume* volume_to_delete = *i;
|
||||
|
||||
delete volume_to_delete;
|
||||
this->volumes.erase(i);
|
||||
|
||||
if (this->volumes.size() == 1)
|
||||
@@ -1449,6 +1454,20 @@ void ModelObject::sort_volumes(bool full_sort)
|
||||
// sort volumes inside the object to order "Model Part, Negative Volume, Modifier, Support Blocker and Support Enforcer. "
|
||||
if (full_sort)
|
||||
std::stable_sort(volumes.begin(), volumes.end(), [](ModelVolume* vl, ModelVolume* vr) {
|
||||
// Special handling for Precise Seam modifiers: group-based sorting with user order preservation
|
||||
if (vl->is_precise_seam() && vr->is_precise_seam()) {
|
||||
// Strong (center/left/right) always before weak (enforced/blocked/neutral)
|
||||
bool vl_strong = vl->is_precise_seam_strong();
|
||||
bool vr_strong = vr->is_precise_seam_strong();
|
||||
if (vl_strong != vr_strong)
|
||||
return vl_strong; // strong < weak → strong group appears first
|
||||
|
||||
// Within same group (both strong or both weak): preserve current order
|
||||
// stable_sort will maintain relative positions when comparator returns false
|
||||
return false;
|
||||
}
|
||||
|
||||
// For non-Precise-Seam or mixed types: use standard enum-based ordering
|
||||
return vl->type() < vr->type();
|
||||
});
|
||||
// sort have to controll "place" of the support blockers/enforcers. But one of the model parts have to be on the first place.
|
||||
@@ -1456,10 +1475,19 @@ void ModelObject::sort_volumes(bool full_sort)
|
||||
std::stable_sort(volumes.begin(), volumes.end(), [](ModelVolume* vl, ModelVolume* vr) {
|
||||
ModelVolumeType vl_type = vl->type() > ModelVolumeType::PARAMETER_MODIFIER ? vl->type() : ModelVolumeType::PARAMETER_MODIFIER;
|
||||
ModelVolumeType vr_type = vr->type() > ModelVolumeType::PARAMETER_MODIFIER ? vr->type() : ModelVolumeType::PARAMETER_MODIFIER;
|
||||
|
||||
// Apply same Precise Seam grouping logic for partial sort
|
||||
if (vl->is_precise_seam() && vr->is_precise_seam()) {
|
||||
bool vl_strong = vl->is_precise_seam_strong();
|
||||
bool vr_strong = vr->is_precise_seam_strong();
|
||||
if (vl_strong != vr_strong)
|
||||
return vl_strong;
|
||||
return false; // preserve order within same group
|
||||
}
|
||||
|
||||
return vl_type < vr_type;
|
||||
});
|
||||
}
|
||||
|
||||
ModelInstance* ModelObject::add_instance()
|
||||
{
|
||||
ModelInstance* i = new ModelInstance(this);
|
||||
@@ -2620,7 +2648,8 @@ std::vector<int> ModelVolume::get_extruders() const
|
||||
if (m_type == ModelVolumeType::INVALID
|
||||
|| m_type == ModelVolumeType::NEGATIVE_VOLUME
|
||||
|| m_type == ModelVolumeType::SUPPORT_BLOCKER
|
||||
|| m_type == ModelVolumeType::SUPPORT_ENFORCER)
|
||||
|| m_type == ModelVolumeType::SUPPORT_ENFORCER
|
||||
|| this->is_precise_seam()) // Precise Seam is non-printing helper geometry
|
||||
return std::vector<int>();
|
||||
|
||||
if (mmu_segmentation_facets.timestamp() != mmuseg_ts) {
|
||||
@@ -2824,6 +2853,19 @@ ModelVolumeType ModelVolume::type_from_string(const std::string &s)
|
||||
return ModelVolumeType::SUPPORT_ENFORCER;
|
||||
if (s == "support_blocker")
|
||||
return ModelVolumeType::SUPPORT_BLOCKER;
|
||||
// Precise Seam types
|
||||
if (s == "precise_seam_center")
|
||||
return ModelVolumeType::PRECISE_SEAM_CENTER;
|
||||
if (s == "precise_seam_left")
|
||||
return ModelVolumeType::PRECISE_SEAM_LEFT;
|
||||
if (s == "precise_seam_right")
|
||||
return ModelVolumeType::PRECISE_SEAM_RIGHT;
|
||||
if (s == "precise_seam_enforced")
|
||||
return ModelVolumeType::PRECISE_SEAM_ENFORCED;
|
||||
if (s == "precise_seam_blocked")
|
||||
return ModelVolumeType::PRECISE_SEAM_BLOCKED;
|
||||
if (s == "precise_seam_neutral")
|
||||
return ModelVolumeType::PRECISE_SEAM_NEUTRAL;
|
||||
//assert(s == "0");
|
||||
// Default value if invalud type string received.
|
||||
return ModelVolumeType::MODEL_PART;
|
||||
@@ -2838,6 +2880,12 @@ std::string ModelVolume::type_to_string(const ModelVolumeType t)
|
||||
case ModelVolumeType::PARAMETER_MODIFIER: return "modifier_part";
|
||||
case ModelVolumeType::SUPPORT_ENFORCER: return "support_enforcer";
|
||||
case ModelVolumeType::SUPPORT_BLOCKER: return "support_blocker";
|
||||
case ModelVolumeType::PRECISE_SEAM_CENTER: return "precise_seam_center";
|
||||
case ModelVolumeType::PRECISE_SEAM_LEFT: return "precise_seam_left";
|
||||
case ModelVolumeType::PRECISE_SEAM_RIGHT: return "precise_seam_right";
|
||||
case ModelVolumeType::PRECISE_SEAM_ENFORCED: return "precise_seam_enforced";
|
||||
case ModelVolumeType::PRECISE_SEAM_BLOCKED: return "precise_seam_blocked";
|
||||
case ModelVolumeType::PRECISE_SEAM_NEUTRAL: return "precise_seam_neutral";
|
||||
default:
|
||||
assert(false);
|
||||
return "normal_part";
|
||||
@@ -3712,7 +3760,11 @@ void FacetsAnnotation::set_triangle_from_string(int triangle_id, const std::stri
|
||||
m_data.bitstream.insert(m_data.bitstream.end(), bool(dec & (1 << i)));
|
||||
}
|
||||
|
||||
m_data.update_used_states(bitstream_start_idx);
|
||||
if (!m_data.update_used_states(bitstream_start_idx)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": dropping malformed paint data of triangle " << triangle_id;
|
||||
m_data.bitstream.resize(bitstream_start_idx);
|
||||
m_data.triangles_to_split.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
bool FacetsAnnotation::equals(const FacetsAnnotation &other) const
|
||||
@@ -3795,6 +3847,7 @@ bool model_volume_list_changed(const ModelObject &model_object_old, const ModelO
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
template< typename TypeFilterFn, typename CompareFn>
|
||||
bool model_property_changed(const ModelObject &model_object_old, const ModelObject &model_object_new, TypeFilterFn type_filter, CompareFn compare)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user