Renamed FacetSupportType to EnforcerBlockerType

So it's not misleading if we use it for seam painting
This commit is contained in:
Lukas Matena 2020-08-05 14:03:22 +02:00
parent 7fd2209b48
commit 97bc092cce
8 changed files with 40 additions and 40 deletions

View file

@ -1831,7 +1831,7 @@ arrangement::ArrangePolygon ModelInstance::get_arrange_polygon() const
} }
indexed_triangle_set FacetsAnnotation::get_facets(const ModelVolume& mv, FacetSupportType type) const indexed_triangle_set FacetsAnnotation::get_facets(const ModelVolume& mv, EnforcerBlockerType type) const
{ {
TriangleSelector selector(mv.mesh()); TriangleSelector selector(mv.mesh());
selector.deserialize(m_data); selector.deserialize(m_data);

View file

@ -394,7 +394,7 @@ enum class ModelVolumeType : int {
SUPPORT_BLOCKER, SUPPORT_BLOCKER,
}; };
enum class FacetSupportType : int8_t { enum class EnforcerBlockerType : int8_t {
// Maximum is 3. The value is serialized in TriangleSelector into 2 bits! // Maximum is 3. The value is serialized in TriangleSelector into 2 bits!
NONE = 0, NONE = 0,
ENFORCER = 1, ENFORCER = 1,
@ -407,7 +407,7 @@ public:
const std::map<int, std::vector<bool>>& get_data() const { return m_data; } const std::map<int, std::vector<bool>>& get_data() const { return m_data; }
bool set(const TriangleSelector& selector); bool set(const TriangleSelector& selector);
indexed_triangle_set get_facets(const ModelVolume& mv, FacetSupportType type) const; indexed_triangle_set get_facets(const ModelVolume& mv, EnforcerBlockerType type) const;
void clear(); void clear();
std::string get_triangle_as_string(int i) const; std::string get_triangle_as_string(int i) const;
void set_triangle_from_string(int triangle_id, const std::string& str); void set_triangle_from_string(int triangle_id, const std::string& str);

View file

@ -187,9 +187,9 @@ public:
std::vector<ExPolygons> slice_support_enforcers() const { return this->slice_support_volumes(ModelVolumeType::SUPPORT_ENFORCER); } std::vector<ExPolygons> slice_support_enforcers() const { return this->slice_support_volumes(ModelVolumeType::SUPPORT_ENFORCER); }
// Helpers to project custom supports on slices // Helpers to project custom supports on slices
void project_and_append_custom_supports(FacetSupportType type, std::vector<ExPolygons>& expolys) const; void project_and_append_custom_supports(EnforcerBlockerType type, std::vector<ExPolygons>& expolys) const;
void project_and_append_custom_enforcers(std::vector<ExPolygons>& enforcers) const { project_and_append_custom_supports(FacetSupportType::ENFORCER, enforcers); } void project_and_append_custom_enforcers(std::vector<ExPolygons>& enforcers) const { project_and_append_custom_supports(EnforcerBlockerType::ENFORCER, enforcers); }
void project_and_append_custom_blockers(std::vector<ExPolygons>& blockers) const { project_and_append_custom_supports(FacetSupportType::BLOCKER, blockers); } void project_and_append_custom_blockers(std::vector<ExPolygons>& blockers) const { project_and_append_custom_supports(EnforcerBlockerType::BLOCKER, blockers); }
private: private:
// to be called from Print only. // to be called from Print only.

View file

@ -2670,7 +2670,7 @@ void PrintObject::_generate_support_material()
void PrintObject::project_and_append_custom_supports( void PrintObject::project_and_append_custom_supports(
FacetSupportType type, std::vector<ExPolygons>& expolys) const EnforcerBlockerType type, std::vector<ExPolygons>& expolys) const
{ {
for (const ModelVolume* mv : this->model_object()->volumes) { for (const ModelVolume* mv : this->model_object()->volumes) {
const indexed_triangle_set custom_facets = mv->m_supported_facets.get_facets(*mv, type); const indexed_triangle_set custom_facets = mv->m_supported_facets.get_facets(*mv, type);

View file

@ -35,7 +35,7 @@ void TriangleSelector::Triangle::set_division(int sides_to_split, int special_si
void TriangleSelector::select_patch(const Vec3f& hit, int facet_start, void TriangleSelector::select_patch(const Vec3f& hit, int facet_start,
const Vec3f& source, const Vec3f& dir, const Vec3f& source, const Vec3f& dir,
float radius, FacetSupportType new_state) float radius, EnforcerBlockerType new_state)
{ {
assert(facet_start < m_orig_size_indices); assert(facet_start < m_orig_size_indices);
assert(is_approx(dir.norm(), 1.f)); assert(is_approx(dir.norm(), 1.f));
@ -77,7 +77,7 @@ void TriangleSelector::select_patch(const Vec3f& hit, int facet_start,
// the triangle recursively, selecting just subtriangles truly inside the circle. // the triangle recursively, selecting just subtriangles truly inside the circle.
// This is done by an actual recursive call. Returns false if the triangle is // This is done by an actual recursive call. Returns false if the triangle is
// outside the cursor. // outside the cursor.
bool TriangleSelector::select_triangle(int facet_idx, FacetSupportType type, bool recursive_call) bool TriangleSelector::select_triangle(int facet_idx, EnforcerBlockerType type, bool recursive_call)
{ {
assert(facet_idx < int(m_triangles.size())); assert(facet_idx < int(m_triangles.size()));
@ -140,7 +140,7 @@ bool TriangleSelector::select_triangle(int facet_idx, FacetSupportType type, boo
void TriangleSelector::set_facet(int facet_idx, FacetSupportType state) void TriangleSelector::set_facet(int facet_idx, EnforcerBlockerType state)
{ {
assert(facet_idx < m_orig_size_indices); assert(facet_idx < m_orig_size_indices);
undivide_triangle(facet_idx); undivide_triangle(facet_idx);
@ -157,7 +157,7 @@ void TriangleSelector::split_triangle(int facet_idx)
Triangle* tr = &m_triangles[facet_idx]; Triangle* tr = &m_triangles[facet_idx];
FacetSupportType old_type = tr->get_state(); EnforcerBlockerType old_type = tr->get_state();
if (tr->was_split_before() != 0) { if (tr->was_split_before() != 0) {
// This triangle is not split at the moment, but was at one point // This triangle is not split at the moment, but was at one point
@ -323,7 +323,7 @@ void TriangleSelector::remove_useless_children(int facet_idx)
// Return if a child is not leaf or two children differ in type. // Return if a child is not leaf or two children differ in type.
FacetSupportType first_child_type = FacetSupportType::NONE; EnforcerBlockerType first_child_type = EnforcerBlockerType::NONE;
for (int child_idx=0; child_idx<=tr.number_of_split_sides(); ++child_idx) { for (int child_idx=0; child_idx<=tr.number_of_split_sides(); ++child_idx) {
if (m_triangles[tr.children[child_idx]].is_split()) if (m_triangles[tr.children[child_idx]].is_split())
return; return;
@ -456,7 +456,7 @@ void TriangleSelector::push_triangle(int a, int b, int c)
} }
void TriangleSelector::perform_split(int facet_idx, FacetSupportType old_state) void TriangleSelector::perform_split(int facet_idx, EnforcerBlockerType old_state)
{ {
Triangle* tr = &m_triangles[facet_idx]; Triangle* tr = &m_triangles[facet_idx];
@ -520,7 +520,7 @@ void TriangleSelector::perform_split(int facet_idx, FacetSupportType old_state)
indexed_triangle_set TriangleSelector::get_facets(FacetSupportType state) const indexed_triangle_set TriangleSelector::get_facets(EnforcerBlockerType state) const
{ {
indexed_triangle_set out; indexed_triangle_set out;
for (const Triangle& tr : m_triangles) { for (const Triangle& tr : m_triangles) {
@ -542,7 +542,7 @@ std::map<int, std::vector<bool>> TriangleSelector::serialize() const
{ {
// Each original triangle of the mesh is assigned a number encoding its state // Each original triangle of the mesh is assigned a number encoding its state
// or how it is split. Each triangle is encoded by 4 bits (xxyy): // or how it is split. Each triangle is encoded by 4 bits (xxyy):
// leaf triangle: xx = FacetSupportType, yy = 0 // leaf triangle: xx = EnforcerBlockerType, yy = 0
// non-leaf: xx = special side, yy = number of split sides // non-leaf: xx = special side, yy = number of split sides
// These are bitwise appended and formed into one 64-bit integer. // These are bitwise appended and formed into one 64-bit integer.
@ -553,7 +553,7 @@ std::map<int, std::vector<bool>> TriangleSelector::serialize() const
for (int i=0; i<m_orig_size_indices; ++i) { for (int i=0; i<m_orig_size_indices; ++i) {
const Triangle& tr = m_triangles[i]; const Triangle& tr = m_triangles[i];
if (! tr.is_split() && tr.get_state() == FacetSupportType::NONE) if (! tr.is_split() && tr.get_state() == EnforcerBlockerType::NONE)
continue; // no need to save anything, unsplit and unselected is default continue; // no need to save anything, unsplit and unselected is default
std::vector<bool> data; // complete encoding of this mesh triangle std::vector<bool> data; // complete encoding of this mesh triangle
@ -627,7 +627,7 @@ void TriangleSelector::deserialize(const std::map<int, std::vector<bool>> data)
int num_of_split_sides = (next_code & 0b11); int num_of_split_sides = (next_code & 0b11);
int num_of_children = num_of_split_sides != 0 ? num_of_split_sides + 1 : 0; int num_of_children = num_of_split_sides != 0 ? num_of_split_sides + 1 : 0;
bool is_split = num_of_children != 0; bool is_split = num_of_children != 0;
FacetSupportType state = FacetSupportType(next_code >> 2); EnforcerBlockerType state = EnforcerBlockerType(next_code >> 2);
int special_side = (next_code >> 2); int special_side = (next_code >> 2);
// Take care of the first iteration separately, so handling of the others is simpler. // Take care of the first iteration separately, so handling of the others is simpler.
@ -641,7 +641,7 @@ void TriangleSelector::deserialize(const std::map<int, std::vector<bool>> data)
// then go to the next. // then go to the next.
parents.push_back({triangle_id, 0, num_of_children}); parents.push_back({triangle_id, 0, num_of_children});
m_triangles[triangle_id].set_division(num_of_children-1, special_side); m_triangles[triangle_id].set_division(num_of_children-1, special_side);
perform_split(triangle_id, FacetSupportType::NONE); perform_split(triangle_id, EnforcerBlockerType::NONE);
continue; continue;
} }
} }
@ -655,7 +655,7 @@ void TriangleSelector::deserialize(const std::map<int, std::vector<bool>> data)
const ProcessingInfo& last = parents.back(); const ProcessingInfo& last = parents.back();
int this_idx = m_triangles[last.facet_id].children[last.processed_children]; int this_idx = m_triangles[last.facet_id].children[last.processed_children];
m_triangles[this_idx].set_division(num_of_children-1, special_side); m_triangles[this_idx].set_division(num_of_children-1, special_side);
perform_split(this_idx, FacetSupportType::NONE); perform_split(this_idx, EnforcerBlockerType::NONE);
parents.push_back({this_idx, 0, num_of_children}); parents.push_back({this_idx, 0, num_of_children});
} else { } else {
// this triangle belongs to last split one // this triangle belongs to last split one

View file

@ -9,7 +9,7 @@
namespace Slic3r { namespace Slic3r {
enum class FacetSupportType : int8_t; enum class EnforcerBlockerType : int8_t;
@ -29,13 +29,13 @@ public:
const Vec3f& source, // camera position (mesh coords) const Vec3f& source, // camera position (mesh coords)
const Vec3f& dir, // direction of the ray (mesh coords) const Vec3f& dir, // direction of the ray (mesh coords)
float radius, // radius of the cursor float radius, // radius of the cursor
FacetSupportType new_state); // enforcer or blocker? EnforcerBlockerType new_state); // enforcer or blocker?
// Get facets currently in the given state. // Get facets currently in the given state.
indexed_triangle_set get_facets(FacetSupportType state) const; indexed_triangle_set get_facets(EnforcerBlockerType state) const;
// Set facet of the mesh to a given state. Only works for original triangles. // Set facet of the mesh to a given state. Only works for original triangles.
void set_facet(int facet_idx, FacetSupportType state); void set_facet(int facet_idx, EnforcerBlockerType state);
// Clear everything and make the tree empty. // Clear everything and make the tree empty.
void reset(); void reset();
@ -59,7 +59,7 @@ protected:
// It increments/decrements reference counter on vertices. // It increments/decrements reference counter on vertices.
Triangle(int a, int b, int c) Triangle(int a, int b, int c)
: verts_idxs{a, b, c}, : verts_idxs{a, b, c},
state{FacetSupportType(0)}, state{EnforcerBlockerType(0)},
number_of_splits{0}, number_of_splits{0},
special_side_idx{0}, special_side_idx{0},
old_number_of_splits{0} old_number_of_splits{0}
@ -77,8 +77,8 @@ protected:
void set_division(int sides_to_split, int special_side_idx = -1); void set_division(int sides_to_split, int special_side_idx = -1);
// Get/set current state. // Get/set current state.
void set_state(FacetSupportType type) { assert(! is_split()); state = type; } void set_state(EnforcerBlockerType type) { assert(! is_split()); state = type; }
FacetSupportType get_state() const { assert(! is_split()); return state; } EnforcerBlockerType get_state() const { assert(! is_split()); return state; }
// Get info on how it's split. // Get info on how it's split.
bool is_split() const { return number_of_split_sides() != 0; } bool is_split() const { return number_of_split_sides() != 0; }
@ -90,7 +90,7 @@ protected:
private: private:
int number_of_splits; int number_of_splits;
int special_side_idx; int special_side_idx;
FacetSupportType state; EnforcerBlockerType state;
// How many children were spawned during last split? // How many children were spawned during last split?
// Is not reset on remerging the triangle. // Is not reset on remerging the triangle.
@ -133,7 +133,7 @@ protected:
float m_old_cursor_radius; float m_old_cursor_radius;
// Private functions: // Private functions:
bool select_triangle(int facet_idx, FacetSupportType type, bool select_triangle(int facet_idx, EnforcerBlockerType type,
bool recursive_call = false); bool recursive_call = false);
bool is_point_inside_cursor(const Vec3f& point) const; bool is_point_inside_cursor(const Vec3f& point) const;
int vertices_inside(int facet_idx) const; int vertices_inside(int facet_idx) const;
@ -144,7 +144,7 @@ protected:
bool is_pointer_in_triangle(int facet_idx) const; bool is_pointer_in_triangle(int facet_idx) const;
bool is_edge_inside_cursor(int facet_idx) const; bool is_edge_inside_cursor(int facet_idx) const;
void push_triangle(int a, int b, int c); void push_triangle(int a, int b, int c);
void perform_split(int facet_idx, FacetSupportType old_state); void perform_split(int facet_idx, EnforcerBlockerType old_state);
}; };

View file

@ -296,16 +296,16 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
if (m_triangle_selectors.empty()) if (m_triangle_selectors.empty())
return false; return false;
FacetSupportType new_state = FacetSupportType::NONE; EnforcerBlockerType new_state = EnforcerBlockerType::NONE;
if (! shift_down) { if (! shift_down) {
if (action == SLAGizmoEventType::Dragging) if (action == SLAGizmoEventType::Dragging)
new_state = m_button_down == Button::Left new_state = m_button_down == Button::Left
? FacetSupportType::ENFORCER ? EnforcerBlockerType::ENFORCER
: FacetSupportType::BLOCKER; : EnforcerBlockerType::BLOCKER;
else else
new_state = action == SLAGizmoEventType::LeftDown new_state = action == SLAGizmoEventType::LeftDown
? FacetSupportType::ENFORCER ? EnforcerBlockerType::ENFORCER
: FacetSupportType::BLOCKER; : EnforcerBlockerType::BLOCKER;
} }
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
@ -465,8 +465,8 @@ void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool block)
if (facet.normal.dot(down) > dot_limit) if (facet.normal.dot(down) > dot_limit)
m_triangle_selectors[mesh_id]->set_facet(idx, m_triangle_selectors[mesh_id]->set_facet(idx,
block block
? FacetSupportType::BLOCKER ? EnforcerBlockerType::BLOCKER
: FacetSupportType::ENFORCER); : EnforcerBlockerType::ENFORCER);
} }
} }
@ -719,13 +719,13 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
m_iva_blockers.release_geometry(); m_iva_blockers.release_geometry();
for (const Triangle& tr : m_triangles) { for (const Triangle& tr : m_triangles) {
if (! tr.valid || tr.is_split() || tr.get_state() == FacetSupportType::NONE) if (! tr.valid || tr.is_split() || tr.get_state() == EnforcerBlockerType::NONE)
continue; continue;
GLIndexedVertexArray& va = tr.get_state() == FacetSupportType::ENFORCER GLIndexedVertexArray& va = tr.get_state() == EnforcerBlockerType::ENFORCER
? m_iva_enforcers ? m_iva_enforcers
: m_iva_blockers; : m_iva_blockers;
int& cnt = tr.get_state() == FacetSupportType::ENFORCER int& cnt = tr.get_state() == EnforcerBlockerType::ENFORCER
? enf_cnt ? enf_cnt
: blc_cnt; : blc_cnt;

View file

@ -15,7 +15,7 @@
namespace Slic3r { namespace Slic3r {
enum class FacetSupportType : int8_t; enum class EnforcerBlockerType : int8_t;
namespace GUI { namespace GUI {