TriangleSelector: backend is aware of divided triangles
This commit is contained in:
parent
0756a7e4b3
commit
3b91d11ddf
5 changed files with 33 additions and 13 deletions
|
@ -1831,13 +1831,12 @@ arrangement::ArrangePolygon ModelInstance::get_arrange_polygon() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<int> FacetsAnnotation::get_facets(FacetSupportType type) const
|
indexed_triangle_set FacetsAnnotation::get_facets(const ModelVolume& mv, FacetSupportType type) const
|
||||||
{
|
{
|
||||||
std::vector<int> out;
|
TriangleSelector selector(mv.mesh());
|
||||||
/*for (auto& [facet_idx, this_type] : m_data)
|
selector.deserialize(m_data);
|
||||||
if (this_type == type)
|
indexed_triangle_set out = selector.get_facets(type);
|
||||||
out.push_back(facet_idx);
|
return out;
|
||||||
*/return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1932,7 +1931,7 @@ bool model_custom_supports_data_changed(const ModelObject& mo, const ModelObject
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
extern bool model_has_multi_part_objects(const Model &model)
|
extern bool model_has_multi_part_objects(const Model &model)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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; }
|
||||||
void set(const TriangleSelector& selector);
|
void set(const TriangleSelector& selector);
|
||||||
std::vector<int> get_facets(FacetSupportType type) const;
|
indexed_triangle_set get_facets(const ModelVolume& mv, FacetSupportType type) const;
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
ClockType::time_point get_timestamp() const { return timestamp; }
|
ClockType::time_point get_timestamp() const { return timestamp; }
|
||||||
|
|
|
@ -2673,8 +2673,8 @@ void PrintObject::project_and_append_custom_supports(
|
||||||
FacetSupportType type, std::vector<ExPolygons>& expolys) const
|
FacetSupportType type, std::vector<ExPolygons>& expolys) const
|
||||||
{
|
{
|
||||||
for (const ModelVolume* mv : this->model_object()->volumes) {
|
for (const ModelVolume* mv : this->model_object()->volumes) {
|
||||||
const std::vector<int> custom_facets = mv->m_supported_facets.get_facets(type);
|
const indexed_triangle_set custom_facets = mv->m_supported_facets.get_facets(*mv, type);
|
||||||
if (custom_facets.empty())
|
if (custom_facets.indices.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const TriangleMesh& mesh = mv->mesh();
|
const TriangleMesh& mesh = mv->mesh();
|
||||||
|
@ -2705,11 +2705,11 @@ void PrintObject::project_and_append_custom_supports(
|
||||||
};
|
};
|
||||||
|
|
||||||
// Vector to collect resulting projections from each triangle.
|
// Vector to collect resulting projections from each triangle.
|
||||||
std::vector<TriangleProjections> projections_of_triangles(custom_facets.size());
|
std::vector<TriangleProjections> projections_of_triangles(custom_facets.indices.size());
|
||||||
|
|
||||||
// Iterate over all triangles.
|
// Iterate over all triangles.
|
||||||
tbb::parallel_for(
|
tbb::parallel_for(
|
||||||
tbb::blocked_range<size_t>(0, custom_facets.size()),
|
tbb::blocked_range<size_t>(0, custom_facets.indices.size()),
|
||||||
[&](const tbb::blocked_range<size_t>& range) {
|
[&](const tbb::blocked_range<size_t>& range) {
|
||||||
for (size_t idx = range.begin(); idx < range.end(); ++ idx) {
|
for (size_t idx = range.begin(); idx < range.end(); ++ idx) {
|
||||||
|
|
||||||
|
@ -2717,7 +2717,7 @@ void PrintObject::project_and_append_custom_supports(
|
||||||
|
|
||||||
// Transform the triangle into worlds coords.
|
// Transform the triangle into worlds coords.
|
||||||
for (int i=0; i<3; ++i)
|
for (int i=0; i<3; ++i)
|
||||||
facet[i] = tr * mesh.its.vertices[mesh.its.indices[custom_facets[idx]](i)];
|
facet[i] = tr * custom_facets.vertices[custom_facets.indices[idx](i)];
|
||||||
|
|
||||||
// Ignore triangles with upward-pointing normal.
|
// Ignore triangles with upward-pointing normal.
|
||||||
if ((facet[1]-facet[0]).cross(facet[2]-facet[0]).z() > 0.)
|
if ((facet[1]-facet[0]).cross(facet[2]-facet[0]).z() > 0.)
|
||||||
|
|
|
@ -512,6 +512,25 @@ void TriangleSelector::perform_split(int facet_idx, FacetSupportType old_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
indexed_triangle_set TriangleSelector::get_facets(FacetSupportType state) const
|
||||||
|
{
|
||||||
|
indexed_triangle_set out;
|
||||||
|
for (const Triangle& tr : m_triangles) {
|
||||||
|
if (tr.valid && ! tr.is_split() && tr.get_state() == state) {
|
||||||
|
stl_triangle_vertex_indices indices;
|
||||||
|
for (int i=0; i<3; ++i) {
|
||||||
|
out.vertices.emplace_back(m_vertices[tr.verts_idxs[i]].v);
|
||||||
|
indices[i] = out.vertices.size() - 1;
|
||||||
|
}
|
||||||
|
out.indices.emplace_back(indices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::map<int, std::vector<bool>> TriangleSelector::serialize() const
|
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
|
||||||
|
|
|
@ -31,6 +31,8 @@ public:
|
||||||
float radius_sqr, // squared radius of the cursor
|
float radius_sqr, // squared radius of the cursor
|
||||||
FacetSupportType new_state); // enforcer or blocker?
|
FacetSupportType new_state); // enforcer or blocker?
|
||||||
|
|
||||||
|
// Get facets currently in the given state.
|
||||||
|
indexed_triangle_set get_facets(FacetSupportType 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, FacetSupportType state);
|
||||||
|
|
Loading…
Reference in a new issue