本文整理汇总了C#中Polygons.CreateUnion方法的典型用法代码示例。如果您正苦于以下问题:C# Polygons.CreateUnion方法的具体用法?C# Polygons.CreateUnion怎么用?C# Polygons.CreateUnion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygons
的用法示例。
在下文中一共展示了Polygons.CreateUnion方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateSkirt
public void GenerateSkirt(int distance, int extrusionWidth_um, int numberOfLoops, int minLength, int initialLayerHeight, ConfigSettings config)
{
LayerDataStorage storage = this;
bool externalOnly = (distance > 0);
for (int skirtLoop = 0; skirtLoop < numberOfLoops; skirtLoop++)
{
int offsetDistance = distance + extrusionWidth_um * skirtLoop + extrusionWidth_um / 2;
Polygons skirtPolygons = new Polygons(storage.wipeTower.Offset(offsetDistance));
for (int extrudeIndex = 0; extrudeIndex < storage.Extruders.Count; extrudeIndex++)
{
if (config.continuousSpiralOuterPerimeter && extrudeIndex > 0)
{
continue;
}
if (storage.Extruders[extrudeIndex].Layers.Count < 1)
{
continue;
}
SliceLayer layer = storage.Extruders[extrudeIndex].Layers[0];
for (int partIndex = 0; partIndex < layer.Islands.Count; partIndex++)
{
if (config.continuousSpiralOuterPerimeter && partIndex > 0)
{
continue;
}
if (externalOnly)
{
Polygons p = new Polygons();
p.Add(layer.Islands[partIndex].IslandOutline[0]);
//p.Add(IntPointHelper.CreateConvexHull(layer.parts[partIndex].outline[0]));
skirtPolygons = skirtPolygons.CreateUnion(p.Offset(offsetDistance));
}
else
{
skirtPolygons = skirtPolygons.CreateUnion(layer.Islands[partIndex].IslandOutline.Offset(offsetDistance));
}
}
}
if (storage.support != null)
{
skirtPolygons = skirtPolygons.CreateUnion(storage.support.GetBedOutlines().Offset(offsetDistance));
}
//Remove small inner skirt holes. Holes have a negative area, remove anything smaller then 100x extrusion "area"
for (int n = 0; n < skirtPolygons.Count; n++)
{
double area = skirtPolygons[n].Area();
if (area < 0 && area > -extrusionWidth_um * extrusionWidth_um * 100)
{
skirtPolygons.RemoveAt(n--);
}
}
storage.skirt.AddAll(skirtPolygons);
int lenght = (int)storage.skirt.PolygonLength();
if (skirtLoop + 1 >= numberOfLoops && lenght > 0 && lenght < minLength)
{
// add more loops for as long as we have not extruded enough length
numberOfLoops++;
}
}
}
示例2: CreateWipeShields
private void CreateWipeShields(LayerDataStorage slicingData, int totalLayers)
{
for (int layerNr = 0; layerNr < totalLayers; layerNr++)
{
Polygons wipeShield = new Polygons();
for (int extruderIndex = 0; extruderIndex < slicingData.Extruders.Count; extruderIndex++)
{
for (int partNr = 0; partNr < slicingData.Extruders[extruderIndex].Layers[layerNr].Islands.Count; partNr++)
{
wipeShield = wipeShield.CreateUnion(slicingData.Extruders[extruderIndex].Layers[layerNr].Islands[partNr].IslandOutline.Offset(config.wipeShieldDistanceFromShapes_um));
}
}
slicingData.wipeShield.Add(wipeShield);
}
for (int layerIndex = 0; layerIndex < totalLayers; layerIndex++)
{
slicingData.wipeShield[layerIndex] = slicingData.wipeShield[layerIndex].Offset(-1000).Offset(1000);
}
int offsetAngle = (int)Math.Tan(60.0 * Math.PI / 180) * config.layerThickness_um;//Allow for a 60deg angle in the wipeShield.
for (int layerNr = 1; layerNr < totalLayers; layerNr++)
{
slicingData.wipeShield[layerNr] = slicingData.wipeShield[layerNr].CreateUnion(slicingData.wipeShield[layerNr - 1].Offset(-offsetAngle));
}
for (int layerNr = totalLayers - 1; layerNr > 0; layerNr--)
{
slicingData.wipeShield[layerNr - 1] = slicingData.wipeShield[layerNr - 1].CreateUnion(slicingData.wipeShield[layerNr].Offset(-offsetAngle));
}
}
示例3: RemoveSupportFromInternalSpaces
private static List<Polygons> RemoveSupportFromInternalSpaces(List<Polygons> inputPolys, List<Polygons> allPartOutlines)
{
int numLayers = inputPolys.Count;
Polygons accumulatedLayers = new Polygons();
for (int layerIndex = 0; layerIndex < numLayers; layerIndex++)
{
accumulatedLayers = accumulatedLayers.CreateUnion(allPartOutlines[layerIndex]);
accumulatedLayers = Clipper.CleanPolygons(accumulatedLayers, cleanDistance_um);
inputPolys[layerIndex] = inputPolys[layerIndex].CreateDifference(accumulatedLayers);
inputPolys[layerIndex] = Clipper.CleanPolygons(inputPolys[layerIndex], cleanDistance_um);
}
return inputPolys;
}
示例4: AddIslandsToPolygons
private static Polygons AddIslandsToPolygons(List<LayerIsland> islands, Aabb boundsToConsider, Polygons polysToAddTo)
{
Polygons polysToIntersect = new Polygons();
for (int islandIndex = 0; islandIndex < islands.Count; islandIndex++)
{
if (boundsToConsider.Hit(islands[islandIndex].BoundingBox))
{
polysToIntersect = polysToIntersect.CreateUnion(islands[islandIndex].InsetToolPaths[islands[islandIndex].InsetToolPaths.Count - 1]);
polysToIntersect = Clipper.CleanPolygons(polysToIntersect, cleanDistance_um);
}
}
polysToAddTo = polysToAddTo.CreateIntersection(polysToIntersect);
return polysToAddTo;
}
示例5: OverlapMultipleExtrudersSlightly
//Expand each layer a bit and then keep the extra overlapping parts that overlap with other extruders.
//This generates some overlap in dual extrusion, for better bonding in touching parts.
public static void OverlapMultipleExtrudersSlightly(List<ExtruderLayers> extruders, int overlapUm)
{
if (extruders.Count < 2 || overlapUm <= 0)
{
return;
}
for (int layerIndex = 0; layerIndex < extruders[0].Layers.Count; layerIndex++)
{
Polygons fullLayer = new Polygons();
for (int extruderIndex = 0; extruderIndex < extruders.Count; extruderIndex++)
{
SliceLayer layer1 = extruders[extruderIndex].Layers[layerIndex];
fullLayer = fullLayer.CreateUnion(layer1.AllOutlines.Offset(20));
}
fullLayer = fullLayer.Offset(-20);
for (int extruderIndex = 0; extruderIndex < extruders.Count; extruderIndex++)
{
SliceLayer layer1 = extruders[extruderIndex].Layers[layerIndex];
layer1.AllOutlines = fullLayer.CreateIntersection(layer1.AllOutlines.Offset(overlapUm / 2));
}
}
}