mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 21:21:58 +08:00
Compilation fixes, renamed CutObjectBase to CutId
This commit is contained in:
parent
fd0e9b1597
commit
a666effea7
@ -474,7 +474,7 @@ namespace Slic3r {
|
||||
float r_tolerance;
|
||||
float h_tolerance;
|
||||
};
|
||||
CutObjectBase id;
|
||||
CutId id;
|
||||
std::vector<Connector> connectors;
|
||||
};
|
||||
|
||||
@ -1185,15 +1185,15 @@ namespace Slic3r {
|
||||
continue;
|
||||
}
|
||||
|
||||
CutObjectBase cut_id;
|
||||
CutId cut_id;
|
||||
std::vector<CutObjectInfo::Connector> connectors;
|
||||
|
||||
for (const auto& obj_cut_info : object_tree) {
|
||||
if (obj_cut_info.first == "cut_id") {
|
||||
pt::ptree cut_id_tree = obj_cut_info.second;
|
||||
cut_id = CutObjectBase(cut_id_tree.get<size_t>("<xmlattr>.id"),
|
||||
cut_id_tree.get<size_t>("<xmlattr>.check_sum"),
|
||||
cut_id_tree.get<size_t>("<xmlattr>.connectors_cnt"));
|
||||
cut_id = CutId(cut_id_tree.get<size_t>("<xmlattr>.id"),
|
||||
cut_id_tree.get<size_t>("<xmlattr>.check_sum"),
|
||||
cut_id_tree.get<size_t>("<xmlattr>.connectors_cnt"));
|
||||
}
|
||||
if (obj_cut_info.first == "connectors") {
|
||||
pt::ptree cut_connectors_tree = obj_cut_info.second;
|
||||
|
@ -235,17 +235,25 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class CutObjectBase
|
||||
class CutId
|
||||
{
|
||||
size_t m_unique_id; // 0 = invalid
|
||||
size_t m_check_sum; // check sum of CutParts in initial Object
|
||||
size_t m_connectors_cnt; // connectors count
|
||||
|
||||
public:
|
||||
CutObjectBase() { invalidate(); }
|
||||
CutObjectBase(size_t id, size_t check_sum, size_t connectors_cnt) :
|
||||
CutId() { invalidate(); }
|
||||
CutId(size_t id, size_t check_sum, size_t connectors_cnt) :
|
||||
m_unique_id{ id }, m_check_sum{ check_sum }, m_connectors_cnt{ connectors_cnt } {}
|
||||
|
||||
bool operator< (const CutId& rhs) const { return this->m_unique_id < rhs.m_unique_id; }
|
||||
CutId& operator=(const CutId& rhs) {
|
||||
this->m_unique_id = rhs.id();
|
||||
this->m_check_sum = rhs.check_sum();
|
||||
this->m_connectors_cnt = rhs.connectors_cnt();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void invalidate() {
|
||||
m_unique_id = 0;
|
||||
m_check_sum = 1;
|
||||
@ -257,10 +265,10 @@ public:
|
||||
std::uniform_int_distribution<size_t> dist(1, std::numeric_limits<size_t>::max());
|
||||
m_unique_id = dist(mt);
|
||||
}
|
||||
bool has_same_id(const CutObjectBase& rhs) const { return id() == rhs.id(); }
|
||||
bool is_equal(const CutObjectBase& rhs) const { return id() == rhs.id() &&
|
||||
check_sum() == rhs.check_sum() &&
|
||||
connectors_cnt() == rhs.connectors_cnt() ; }
|
||||
bool has_same_id(const CutId& rhs) const { return id() == rhs.id(); }
|
||||
bool is_equal(const CutId& rhs) const { return id() == rhs.id() &&
|
||||
check_sum() == rhs.check_sum() &&
|
||||
connectors_cnt() == rhs.connectors_cnt() ; }
|
||||
size_t id() const { return m_unique_id; }
|
||||
bool valid() const { return m_unique_id != 0; }
|
||||
size_t check_sum() const { return m_check_sum; }
|
||||
@ -269,7 +277,6 @@ public:
|
||||
size_t connectors_cnt() const { return m_connectors_cnt; }
|
||||
void increase_connectors_cnt(size_t connectors_cnt) { m_connectors_cnt += connectors_cnt; }
|
||||
|
||||
private:
|
||||
template<class Archive> void serialize(Archive &ar) {
|
||||
ar(m_unique_id, m_check_sum, m_connectors_cnt);
|
||||
}
|
||||
@ -313,10 +320,6 @@ struct CutConnectorAttributes
|
||||
CutConnectorAttributes(const CutConnectorAttributes& rhs) :
|
||||
CutConnectorAttributes(rhs.type, rhs.style, rhs.shape) {}
|
||||
|
||||
bool operator==(const CutConnectorAttributes& other) const;
|
||||
|
||||
bool operator!=(const CutConnectorAttributes& other) const { return !(other == (*this)); }
|
||||
|
||||
bool operator<(const CutConnectorAttributes& other) const {
|
||||
return this->type < other.type ||
|
||||
(this->type == other.type && this->style < other.style) ||
|
||||
@ -350,10 +353,6 @@ struct CutConnector
|
||||
CutConnector(const CutConnector& rhs) :
|
||||
CutConnector(rhs.pos, rhs.rotation_m, rhs.radius, rhs.height, rhs.radius_tolerance, rhs.height_tolerance, rhs.z_angle, rhs.attribs) {}
|
||||
|
||||
bool operator==(const CutConnector& other) const;
|
||||
|
||||
bool operator!=(const CutConnector& other) const { return !(other == (*this)); }
|
||||
|
||||
template<class Archive> inline void serialize(Archive& ar) {
|
||||
ar(pos, rotation_m, radius, height, radius_tolerance, height_tolerance, z_angle, attribs);
|
||||
}
|
||||
@ -410,7 +409,7 @@ public:
|
||||
|
||||
// Connectors to be added into the object before cut and are used to create a solid/negative volumes during a cut perform
|
||||
CutConnectors cut_connectors;
|
||||
CutObjectBase cut_id;
|
||||
CutId cut_id;
|
||||
|
||||
/* This vector accumulates the total translation applied to the object by the
|
||||
center_around_origin() method. Callers might want to apply the same translation
|
||||
|
@ -2529,7 +2529,7 @@ void ObjectList::invalidate_cut_info_for_object(int obj_idx)
|
||||
|
||||
take_snapshot(_L("Invalidate cut info"));
|
||||
|
||||
const CutObjectBase cut_id = init_obj->cut_id;
|
||||
const CutId cut_id = init_obj->cut_id;
|
||||
// invalidate cut for related objects (which have the same cut_id)
|
||||
for (size_t idx = 0; idx < m_objects->size(); idx++)
|
||||
if (ModelObject* obj = object(int(idx)); obj->cut_id.is_equal(cut_id)) {
|
||||
@ -2559,7 +2559,7 @@ void ObjectList::delete_all_connectors_for_object(int obj_idx)
|
||||
|
||||
take_snapshot(_L("Delete all connectors"));
|
||||
|
||||
const CutObjectBase cut_id = init_obj->cut_id;
|
||||
const CutId cut_id = init_obj->cut_id;
|
||||
// Delete all connectors for related objects (which have the same cut_id)
|
||||
Model& model = wxGetApp().plater()->model();
|
||||
for (int idx = int(m_objects->size())-1; idx >= 0; idx--)
|
||||
@ -2682,7 +2682,7 @@ void ObjectList::part_selection_changed()
|
||||
disable_ss_manipulation = (*m_objects)[obj_idx]->is_cut();
|
||||
}
|
||||
else if (selection.is_mixed() || selection.is_multiple_full_object()) {
|
||||
std::map<CutObjectBase, std::set<int>> cut_objects;
|
||||
std::map<CutId, std::set<int>> cut_objects;
|
||||
|
||||
// find cut objects
|
||||
for (auto item : sels) {
|
||||
|
@ -3256,7 +3256,7 @@ Transform3d GLGizmoCut3D::get_cut_matrix(const Selection& selection)
|
||||
return translation_transform(cut_center_offset) * m_rotation_m;
|
||||
}
|
||||
|
||||
void update_object_cut_id(CutObjectBase& cut_id, ModelObjectCutAttributes attributes, const int dowels_count)
|
||||
void update_object_cut_id(CutId& cut_id, ModelObjectCutAttributes attributes, const int dowels_count)
|
||||
{
|
||||
// we don't save cut information, if result will not contains all parts of initial object
|
||||
if (!attributes.has(ModelObjectCutAttribute::KeepUpper) ||
|
||||
@ -3264,7 +3264,7 @@ void update_object_cut_id(CutObjectBase& cut_id, ModelObjectCutAttributes attrib
|
||||
attributes.has(ModelObjectCutAttribute::InvalidateCutInfo))
|
||||
return;
|
||||
|
||||
if (cut_id.id().invalid())
|
||||
if (! cut_id.valid())
|
||||
cut_id.init();
|
||||
// increase check sum, if it's needed
|
||||
{
|
||||
@ -3377,11 +3377,11 @@ static void check_objects_after_cut(const ModelObjectPtrs& objects)
|
||||
}
|
||||
}
|
||||
|
||||
void synchronize_model_after_cut(Model& model, const CutObjectBase& cut_id)
|
||||
void synchronize_model_after_cut(Model& model, const CutId& cut_id)
|
||||
{
|
||||
for (ModelObject* obj : model.objects)
|
||||
if (obj->is_cut() && obj->cut_id.has_same_id(cut_id) && !obj->cut_id.is_equal(cut_id))
|
||||
obj->cut_id.copy(cut_id);
|
||||
obj->cut_id = cut_id;
|
||||
}
|
||||
|
||||
void GLGizmoCut3D::perform_cut(const Selection& selection)
|
||||
@ -3432,7 +3432,7 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
|
||||
only_if(m_rotate_upper, ModelObjectCutAttribute::FlipUpper) |
|
||||
only_if(m_rotate_lower, ModelObjectCutAttribute::FlipLower) |
|
||||
only_if(dowels_count > 0, ModelObjectCutAttribute::CreateDowels) |
|
||||
only_if(!has_connectors && !cut_with_groove && cut_mo->cut_id.id().invalid(), ModelObjectCutAttribute::InvalidateCutInfo);
|
||||
only_if(!has_connectors && !cut_with_groove && ! cut_mo->cut_id.valid(), ModelObjectCutAttribute::InvalidateCutInfo);
|
||||
|
||||
// update cut_id for the cut object in respect to the attributes
|
||||
update_object_cut_id(cut_mo->cut_id, attributes, dowels_count);
|
||||
@ -3445,7 +3445,7 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
|
||||
check_objects_after_cut(new_objects);
|
||||
|
||||
// save cut_id to post update synchronization
|
||||
const CutObjectBase cut_id = cut_mo->cut_id;
|
||||
const CutId cut_id = cut_mo->cut_id;
|
||||
|
||||
// update cut results on plater and in the model
|
||||
plater->apply_cut_object_to_model(object_idx, new_objects);
|
||||
|
Loading…
x
Reference in New Issue
Block a user