Fix of SPE-777
Added a flag to optimize the checking if the volume is splittable
This commit is contained in:
parent
fe8a149fb4
commit
5dafad3816
@ -315,6 +315,9 @@ public:
|
||||
// Extruder ID is only valid for FFF. Returns -1 for SLA or if the extruder ID is not applicable (support volumes).
|
||||
int extruder_id() const;
|
||||
|
||||
void set_splittable(const int val) { m_is_splittable = val; }
|
||||
int is_splittable() const { return m_is_splittable; }
|
||||
|
||||
// Split this volume, append the result to the object owning this volume.
|
||||
// Return the number of volumes created from this one.
|
||||
// This is useful to assign different materials to different volumes of an object.
|
||||
@ -387,6 +390,12 @@ private:
|
||||
TriangleMesh m_convex_hull;
|
||||
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
|
||||
int m_is_splittable {-1};
|
||||
|
||||
ModelVolume(ModelObject *object, const TriangleMesh &mesh) : mesh(mesh), m_type(MODEL_PART), object(object)
|
||||
{
|
||||
if (mesh.stl.stats.number_of_facets > 1)
|
||||
|
@ -1105,10 +1105,14 @@ bool ObjectList::is_splittable()
|
||||
if (!get_volume_by_item(item, volume) || !volume)
|
||||
return false;
|
||||
|
||||
if (volume->is_splittable() != -1) // if is_splittable value is already known
|
||||
return volume->is_splittable() == 0 ? false : true;
|
||||
|
||||
TriangleMeshPtrs meshptrs = volume->mesh.split();
|
||||
bool splittable = meshptrs.size() > 1;
|
||||
for (TriangleMesh* m : meshptrs) { delete m; }
|
||||
|
||||
volume->set_splittable(splittable ? 1 : 0);
|
||||
return splittable;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user