本文整理汇总了C#中Polygons.SaveToGCode方法的典型用法代码示例。如果您正苦于以下问题:C# Polygons.SaveToGCode方法的具体用法?C# Polygons.SaveToGCode怎么用?C# Polygons.SaveToGCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygons
的用法示例。
在下文中一共展示了Polygons.SaveToGCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BridgeAngle
//.........这里部分代码省略.........
Polygons islandsToRestOn = new Polygons();
foreach (LayerIsland islandToRestOn in layerToRestOn.Islands)
{
if (!boundaryBox.Hit(islandToRestOn.BoundingBox))
{
continue;
}
islandsToRestOn.AddRange(areaAboveToFill.CreateIntersection(islandToRestOn.IslandOutline));
}
if (OUTPUT_DEBUG_DATA)
{
string outlineString = areaAboveToFill.WriteToString();
string islandOutlineString = "";
foreach (LayerIsland prevLayerIsland in layerToRestOn.Islands)
{
foreach (Polygon islandOutline in prevLayerIsland.IslandOutline)
{
islandOutlineString += islandOutline.WriteToString();
}
islandOutlineString += "|";
}
string islandsString = islandsToRestOn.WriteToString();
}
Polygons islandConvexHuls = new Polygons();
foreach(Polygon poly in islandsToRestOn)
{
islandConvexHuls.Add(poly.CreateConvexHull());
}
if (islandsToRestOn.Count > 5 || islandsToRestOn.Count < 1)
{
return false;
}
if (islandsToRestOn.Count == 1)
{
return GetSingleIslandAngle(areaAboveToFill, islandsToRestOn[0], out bridgeAngle, debugName);
}
// Find the 2 largest islands that we rest on.
double biggestArea = 0;
double nextBiggestArea = 0;
int indexOfBiggest = -1;
int indexOfNextBigest = -1;
for (int islandIndex = 0; islandIndex < islandsToRestOn.Count; islandIndex++)
{
//Skip internal holes
if (!islandsToRestOn[islandIndex].Orientation())
{
continue;
}
double area = Math.Abs(islandConvexHuls[islandIndex].Area());
if (area > biggestArea)
{
if (biggestArea > nextBiggestArea)
{
nextBiggestArea = biggestArea;
indexOfNextBigest = indexOfBiggest;
}
biggestArea = area;
indexOfBiggest = islandIndex;
}
else if (area > nextBiggestArea)
{
nextBiggestArea = area;
indexOfNextBigest = islandIndex;
}
}
if (indexOfBiggest < 0 || indexOfNextBigest < 0)
{
return false;
}
Polygons big1 = new Polygons() { islandConvexHuls[indexOfBiggest] };
Polygons big2 = new Polygons() { islandConvexHuls[indexOfNextBigest] };
Polygons intersection = big1.CreateIntersection(big2);
if(intersection.Count > 0)
{
return GetSingleIslandAngle(areaAboveToFill, islandsToRestOn[indexOfBiggest], out bridgeAngle, debugName);
}
IntPoint center1 = islandsToRestOn[indexOfBiggest].CenterOfMass();
IntPoint center2 = islandsToRestOn[indexOfNextBigest].CenterOfMass();
bridgeAngle = Math.Atan2(center2.Y - center1.Y, center2.X - center1.X) / Math.PI * 180;
Range0To360(ref bridgeAngle);
if (OUTPUT_DEBUG_DATA)
{
islandsToRestOn.SaveToGCode("{0} - angle {1:0.}.gcode".FormatWith(debugName, bridgeAngle));
}
return true;
}