forked from Ultimaker/CuraEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skirt.cpp
39 lines (33 loc) · 1.7 KB
/
skirt.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#include "skirt.h"
#include "support.h"
void generateSkirt(SliceDataStorage& storage, int distance, int extrusionWidth, int count, int minLength, int initialLayerHeight)
{
for(int skirtNr=0; skirtNr<count;skirtNr++)
{
int offsetDistance = distance + extrusionWidth * skirtNr + extrusionWidth / 2;
Polygons skirtPolygons(storage.wipeTower.offset(offsetDistance));
for(unsigned int volumeIdx = 0; volumeIdx < storage.volumes.size(); volumeIdx++)
{
if (storage.volumes[volumeIdx].layers.size() < 1) continue;
SliceLayer* layer = &storage.volumes[volumeIdx].layers[0];
for(unsigned int i=0; i<layer->parts.size(); i++)
{
skirtPolygons = skirtPolygons.unionPolygons(layer->parts[i].outline.offset(offsetDistance));
}
}
SupportPolyGenerator supportGenerator(storage.support, initialLayerHeight);
skirtPolygons = skirtPolygons.unionPolygons(supportGenerator.polygons.offset(offsetDistance));
//Remove small inner skirt holes. Holes have a negative area, remove anything smaller then 100x extrusion "area"
for(unsigned int n=0; n<skirtPolygons.size(); n++)
{
double area = skirtPolygons[n].area();
if (area < 0 && area > -extrusionWidth * extrusionWidth * 100)
skirtPolygons.remove(n--);
}
storage.skirt.add(skirtPolygons);
int lenght = storage.skirt.polygonLength();
if (skirtNr + 1 >= count && lenght > 0 && lenght < minLength)
count++;
}
}