From 453627440f13b541862eec0a459dd1cf23877882 Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 15 Aug 2018 15:39:35 +0200 Subject: [PATCH] Bugfix no_sort: support generator accept chained ExtrusionEntityCollection --- xs/src/libslic3r/SupportMaterial.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/xs/src/libslic3r/SupportMaterial.cpp b/xs/src/libslic3r/SupportMaterial.cpp index 0cecf0014..6c12c86ff 100644 --- a/xs/src/libslic3r/SupportMaterial.cpp +++ b/xs/src/libslic3r/SupportMaterial.cpp @@ -632,6 +632,20 @@ private: Points m_island_samples; }; +void push_entity_as_polyline(Polylines &push_into, ExtrusionEntity* entity) { + if (const ExtrusionPath* path = dynamic_cast(entity)) { + push_into.push_back(path->polyline); + } else if (const ExtrusionMultiPath* multipath = dynamic_cast(entity)) { + push_into.push_back(multipath->as_polyline()); + } else if (const ExtrusionLoop* loop = dynamic_cast(entity)) { + push_into.push_back(loop->as_polyline()); + } else if (const ExtrusionEntityCollection* coll = dynamic_cast(entity)) { + for (ExtrusionEntity* child_entity : coll->entities) { + push_entity_as_polyline(push_into, child_entity); + } + } +} + // Generate top contact layers supporting overhangs. // For a soluble interface material synchronize the layer heights with the object, otherwise leave the layer height undefined. // If supports over bed surface only are requested, don't generate contact layers over an object. @@ -776,15 +790,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_ // TODO: split_at_first_point() could split a bridge mid-way Polylines overhang_perimeters; for (ExtrusionEntity* extrusion_entity : layerm->perimeters.entities) { - const ExtrusionEntityCollection *island = dynamic_cast(extrusion_entity); - assert(island != NULL); - for (size_t i = 0; i < island->entities.size(); ++ i) { - ExtrusionEntity *entity = island->entities[i]; - ExtrusionLoop *loop = dynamic_cast(entity); - overhang_perimeters.push_back(loop ? - loop->as_polyline() : - dynamic_cast(entity)->polyline); - } + push_entity_as_polyline(overhang_perimeters, extrusion_entity); } // workaround for Clipper bug, see Slic3r::Polygon::clip_as_polyline()