forked from Ultimaker/CuraEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskirt.h
34 lines (32 loc) · 1.39 KB
/
skirt.h
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
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#ifndef SKIRT_H
#define SKIRT_H
void generateSkirt(SliceDataStorage& storage, int distance, int extrusionWidth, int count, int minLength)
{
int length = 0;
for(int skirtNr=0; skirtNr<count;skirtNr++)
{
ClipperLib::Clipper skirtUnion;
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++)
{
Polygons skirt;
ClipperLib::OffsetPolygons(layer->parts[i].outline, skirt, distance + extrusionWidth * skirtNr + extrusionWidth / 2, ClipperLib::jtSquare, 2, false);
skirtUnion.AddPolygon(skirt[0], ClipperLib::ptSubject);
}
}
Polygons skirtResult;
skirtUnion.Execute(ClipperLib::ctUnion, skirtResult, ClipperLib::pftNonZero, ClipperLib::pftNonZero);
for(unsigned int n=0; n<skirtResult.size(); n++)
{
storage.skirt.push_back(skirtResult[n]);
length += polygonLength(skirtResult[n]);
}
if (skirtNr + 1 >= count && length > 0 && length < minLength)
count++;
}
}
#endif//SKIRT_H