diff options
author | daid <daid303@gmail.com> | 2014-12-12 13:00:33 +0300 |
---|---|---|
committer | daid <daid303@gmail.com> | 2014-12-12 13:00:33 +0300 |
commit | edf2f897d10b3a6af889c0d3e81f6d15ff659981 (patch) | |
tree | b9d31f90ba94927d4d194f4cc14db5f33b8e4361 | |
parent | cacffadc61f966ba6e871a3ef22416c49eab4682 (diff) |
Change how open polygons are saved. As std::vector never clears memory and the old implementation could mean a lot of memory was never freed.
-rw-r--r-- | src/fffProcessor.h | 2 | ||||
-rw-r--r-- | src/layerPart.cpp | 2 | ||||
-rw-r--r-- | src/slicer.cpp | 27 | ||||
-rw-r--r-- | src/slicer.h | 2 |
4 files changed, 12 insertions, 21 deletions
diff --git a/src/fffProcessor.h b/src/fffProcessor.h index 98359d7b3f..6844cb96f8 100644 --- a/src/fffProcessor.h +++ b/src/fffProcessor.h @@ -190,7 +190,7 @@ private: { //Reporting the outline here slows down the engine quite a bit, so only do so when debugging. //sendPolygonsToGui("outline", layerNr, slicer->layers[layerNr].z, slicer->layers[layerNr].polygonList); - sendPolygonsToGui("openoutline", layerNr, slicer->layers[layerNr].z, slicer->layers[layerNr].openPolygonList); + sendPolygonsToGui("openoutline", layerNr, slicer->layers[layerNr].z, slicer->layers[layerNr].openPolygons); } } cura::log("Sliced model in %5.3fs\n", timeKeeper.restart()); diff --git a/src/layerPart.cpp b/src/layerPart.cpp index 9b2912a46e..4893a7e2a9 100644 --- a/src/layerPart.cpp +++ b/src/layerPart.cpp @@ -20,7 +20,7 @@ namespace cura { void createLayerWithParts(SliceLayer& storageLayer, SlicerLayer* layer, int unionAllType) { - storageLayer.openLines = layer->openPolygonList; + storageLayer.openLines = layer->openPolygons; if (unionAllType & FIX_HORRIBLE_UNION_ALL_TYPE_B) { diff --git a/src/slicer.cpp b/src/slicer.cpp index 1fe6ebecfa..f542aeaae3 100644 --- a/src/slicer.cpp +++ b/src/slicer.cpp @@ -11,6 +11,8 @@ namespace cura { void SlicerLayer::makePolygons(OptimizedVolume* ov, bool keepNoneClosed, bool extensiveStitching) { + Polygons openPolygonList; + for(unsigned int startSegment=0; startSegment < segmentList.size(); startSegment++) { if (segmentList[startSegment].addedToPolygon) @@ -261,19 +263,6 @@ void SlicerLayer::makePolygons(OptimizedVolume* ov, bool keepNoneClosed, bool ex } } - /* - int q=0; - for(unsigned int i=0;i<openPolygonList.size();i++) - { - if (openPolygonList[i].size() < 2) continue; - if (!q) log("***\n"); - log("S: %f %f\n", float(openPolygonList[i][0].X), float(openPolygonList[i][0].Y)); - log("E: %f %f\n", float(openPolygonList[i][openPolygonList[i].size()-1].X), float(openPolygonList[i][openPolygonList[i].size()-1].Y)); - q = 1; - } - */ - //if (q) exit(1); - if (keepNoneClosed) { for(unsigned int n=0; n<openPolygonList.size(); n++) @@ -282,8 +271,11 @@ void SlicerLayer::makePolygons(OptimizedVolume* ov, bool keepNoneClosed, bool ex polygonList.add(openPolygonList[n]); } } - //Clear the openPolygonList to save memory, the only reason to keep it after this is for debugging. - //openPolygonList.clear(); + for(unsigned int i=0;i<openPolygonList.size();i++) + { + if (openPolygonList[i].size() > 0) + openPolygons.newPoly() = openPolygonList[i]; + } //Remove all the tiny polygons, or polygons that are not closed. As they do not contribute to the actual print. int snapDistance = MM2INT(1.0); @@ -403,10 +395,9 @@ void Slicer::dumpSegmentsToHTML(const char* filename) } fprintf(f, "\"/>"); fprintf(f, "</g>\n"); - for(unsigned int j=0; j<layers[i].openPolygonList.size(); j++) + for(unsigned int j=0; j<layers[i].openPolygons.size(); j++) { - PolygonRef p = layers[i].openPolygonList[j]; - if (p.size() < 1) continue; + PolygonRef p = layers[i].openPolygons[j]; fprintf(f, "<polyline marker-mid='url(#MidMarker)' points=\""); for(unsigned int n=0; n<p.size(); n++) { diff --git a/src/slicer.h b/src/slicer.h index d02190ffe2..60c0e57e66 100644 --- a/src/slicer.h +++ b/src/slicer.h @@ -44,7 +44,7 @@ public: int z; Polygons polygonList; - Polygons openPolygonList; + Polygons openPolygons; void makePolygons(OptimizedVolume* ov, bool keepNoneClosed, bool extensiveStitching); |