Use number_of_parts for is_splittable

It's there, why not use it
This commit is contained in:
Sijmen Schoon 2019-03-29 01:27:20 +01:00 committed by bubnikv
parent 4a9e05194c
commit cd3cec3e45
4 changed files with 1 additions and 25 deletions

View File

@ -1467,11 +1467,7 @@ int ModelVolume::extruder_id() const
bool ModelVolume::is_splittable() const bool ModelVolume::is_splittable() const
{ {
// the call mesh.is_splittable() is expensive, so cache the value to calculate it only once return mesh.stl.stats.number_of_parts > 1;
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()

View File

@ -420,12 +420,6 @@ 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)

View File

@ -338,19 +338,6 @@ 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.

View File

@ -68,7 +68,6 @@ 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;