Added default object color in MMU segmentation according to the default extruder color for printing the object.

This commit is contained in:
Lukáš Hejl 2021-05-04 08:13:04 +02:00
parent 781e6607c8
commit 46a14abbaa
3 changed files with 17 additions and 16 deletions

View file

@ -463,7 +463,7 @@ TriangleSelector::TriangleSelector(const TriangleMesh& mesh)
}
void TriangleSelector::reset()
void TriangleSelector::reset(const EnforcerBlockerType reset_state)
{
if (m_orig_size_indices != 0) // unless this is run from constructor
garbage_collect();
@ -474,7 +474,7 @@ void TriangleSelector::reset()
for (size_t i=0; i<m_mesh->its.indices.size(); ++i) {
const stl_triangle_vertex_indices& ind = m_mesh->its.indices[i];
const Vec3f& normal = m_mesh->stl.facet_start[i].normal;
push_triangle(ind[0], ind[1], ind[2], normal);
push_triangle(ind[0], ind[1], ind[2], normal, reset_state);
}
m_orig_size_vertices = m_vertices.size();
m_orig_size_indices = m_triangles.size();
@ -500,13 +500,13 @@ void TriangleSelector::set_edge_limit(float edge_limit)
void TriangleSelector::push_triangle(int a, int b, int c, const Vec3f& normal)
void TriangleSelector::push_triangle(int a, int b, int c, const Vec3f& normal, const EnforcerBlockerType state)
{
for (int i : {a, b, c}) {
assert(i >= 0 && i < int(m_vertices.size()));
++m_vertices[i].ref_cnt;
}
m_triangles.emplace_back(a, b, c, normal);
m_triangles.emplace_back(a, b, c, normal, state);
}
@ -663,9 +663,9 @@ std::map<int, std::vector<bool>> TriangleSelector::serialize() const
return out;
}
void TriangleSelector::deserialize(const std::map<int, std::vector<bool>> data)
void TriangleSelector::deserialize(const std::map<int, std::vector<bool>> data, const EnforcerBlockerType init_state)
{
reset(); // dump any current state
reset(init_state); // dump any current state
for (const auto& [triangle_id, code] : data) {
assert(triangle_id < int(m_triangles.size()));
assert(! code.empty());

View file

@ -49,7 +49,7 @@ public:
void set_facet(int facet_idx, EnforcerBlockerType state);
// Clear everything and make the tree empty.
void reset();
void reset(const EnforcerBlockerType reset_state = EnforcerBlockerType{0});
// Remove all unnecessary data.
void garbage_collect();
@ -59,7 +59,7 @@ public:
std::map<int, std::vector<bool>> serialize() const;
// Load serialized data. Assumes that correct mesh is loaded.
void deserialize(const std::map<int, std::vector<bool>> data);
void deserialize(const std::map<int, std::vector<bool>> data, const EnforcerBlockerType init_state = EnforcerBlockerType{0});
// For all triangles, remove the flag indicating that the triangle was selected by seed fill.
void seed_fill_unselect_all_triangles();
@ -73,10 +73,10 @@ protected:
public:
// Use TriangleSelector::push_triangle to create a new triangle.
// It increments/decrements reference counter on vertices.
Triangle(int a, int b, int c, const Vec3f& normal_)
Triangle(int a, int b, int c, const Vec3f& normal_, const EnforcerBlockerType init_state)
: verts_idxs{a, b, c},
normal{normal_},
state{EnforcerBlockerType(0)},
state{init_state},
number_of_splits{0},
special_side_idx{0},
old_number_of_splits{0}
@ -178,7 +178,7 @@ protected:
void remove_useless_children(int facet_idx); // No hidden meaning. Triangles are meant.
bool is_pointer_in_triangle(int facet_idx) const;
bool is_edge_inside_cursor(int facet_idx) const;
void push_triangle(int a, int b, int c, const Vec3f& normal);
void push_triangle(int a, int b, int c, const Vec3f &normal, const EnforcerBlockerType state = EnforcerBlockerType{0});
void perform_split(int facet_idx, EnforcerBlockerType old_state);
};