mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Revert "Use number_of_parts for is_splittable"
It is too dangerous to rely on the admesh flag without inspecting the
admesh code line by line and a through test.
This reverts commit cd3cec3e45
.
This commit is contained in:
parent
cd3cec3e45
commit
d728f4be5e
4 changed files with 25 additions and 1 deletions
|
@ -1467,7 +1467,11 @@ int ModelVolume::extruder_id() const
|
||||||
|
|
||||||
bool ModelVolume::is_splittable() const
|
bool ModelVolume::is_splittable() const
|
||||||
{
|
{
|
||||||
return mesh.stl.stats.number_of_parts > 1;
|
// the call mesh.is_splittable() is expensive, so cache the value to calculate it only once
|
||||||
|
if (m_is_splittable == -1)
|
||||||
|
m_is_splittable = (int)mesh.is_splittable();
|
||||||
|
|
||||||
|
return m_is_splittable == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelVolume::center_geometry()
|
void ModelVolume::center_geometry()
|
||||||
|
|
|
@ -420,6 +420,12 @@ private:
|
||||||
TriangleMesh m_convex_hull;
|
TriangleMesh m_convex_hull;
|
||||||
Geometry::Transformation m_transformation;
|
Geometry::Transformation m_transformation;
|
||||||
|
|
||||||
|
// flag to optimize the checking if the volume is splittable
|
||||||
|
// -1 -> is unknown value (before first cheking)
|
||||||
|
// 0 -> is not splittable
|
||||||
|
// 1 -> is splittable
|
||||||
|
mutable int m_is_splittable{ -1 };
|
||||||
|
|
||||||
ModelVolume(ModelObject *object, const TriangleMesh &mesh) : mesh(mesh), m_type(ModelVolumeType::MODEL_PART), object(object)
|
ModelVolume(ModelObject *object, const TriangleMesh &mesh) : mesh(mesh), m_type(ModelVolumeType::MODEL_PART), object(object)
|
||||||
{
|
{
|
||||||
if (mesh.stl.stats.number_of_facets > 1)
|
if (mesh.stl.stats.number_of_facets > 1)
|
||||||
|
|
|
@ -338,6 +338,19 @@ void TriangleMesh::rotate(double angle, Point* center)
|
||||||
this->translate(c(0), c(1), 0);
|
this->translate(c(0), c(1), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates whether or not the mesh is splittable.
|
||||||
|
*/
|
||||||
|
bool TriangleMesh::is_splittable() const
|
||||||
|
{
|
||||||
|
std::vector<bool> visited;
|
||||||
|
find_unvisited_neighbors(visited);
|
||||||
|
|
||||||
|
// Try finding an unvisited facet. If there are none, the mesh is not splittable.
|
||||||
|
auto it = std::find(visited.begin(), visited.end(), false);
|
||||||
|
return it != visited.end();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visit all unvisited neighboring facets that are reachable from the first unvisited facet,
|
* Visit all unvisited neighboring facets that are reachable from the first unvisited facet,
|
||||||
* and return them.
|
* and return them.
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
size_t facets_count() const { return this->stl.stats.number_of_facets; }
|
size_t facets_count() const { return this->stl.stats.number_of_facets; }
|
||||||
bool empty() const { return this->facets_count() == 0; }
|
bool empty() const { return this->facets_count() == 0; }
|
||||||
|
|
||||||
|
bool is_splittable() const;
|
||||||
std::deque<uint32_t> find_unvisited_neighbors(std::vector<bool> &facet_visited) const;
|
std::deque<uint32_t> find_unvisited_neighbors(std::vector<bool> &facet_visited) const;
|
||||||
|
|
||||||
stl_file stl;
|
stl_file stl;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue