本文整理汇总了C#中Polygons类的典型用法代码示例。如果您正苦于以下问题:C# Polygons类的具体用法?C# Polygons怎么用?C# Polygons使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Polygons类属于命名空间,在下文中一共展示了Polygons类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PolygonToPathStorage
public static PathStorage PolygonToPathStorage(Polygons polygons)
{
PathStorage output = new PathStorage();
foreach (Polygon polygon in polygons)
{
bool first = true;
foreach (IntPoint point in polygon)
{
if (first)
{
output.Add(point.X, point.Y, ShapePath.FlagsAndCommand.CommandMoveTo);
first = false;
}
else
{
output.Add(point.X, point.Y, ShapePath.FlagsAndCommand.CommandLineTo);
}
}
output.ClosePolygon();
}
output.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop);
return output;
}
开发者ID:rorypond,项目名称:MatterControl,代码行数:26,代码来源:PlatingHelper.cs
示例2: AddAll
public static void AddAll(this Polygons polygons, Polygons other)
{
for (int n = 0; n < other.Count; n++)
{
polygons.Add(other[n]);
}
}
开发者ID:yushuiqiang,项目名称:MatterSlice,代码行数:7,代码来源:PolygonsHelper.cs
示例3: LoadButton_Click
private void LoadButton_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
pathText.Text = openFileDialog.FileName;
_polygons = DataLoader.LoadPolygons(openFileDialog.OpenFile());
}
}
开发者ID:qqzh002,项目名称:3DToy,代码行数:8,代码来源:3DToyForm.cs
示例4: AddPolygons
public void AddPolygons(Polygons poly)
{
if (poly.Count == 0) return;
PolyInfo pi = new PolyInfo();
pi.polygons = poly;
pi.si = style.Clone();
PolyInfoList.Add(pi);
}
开发者ID:caomw,项目名称:elementdiscovery,代码行数:8,代码来源:Program.cs
示例5: AvoidCrossingPerimeters
public AvoidCrossingPerimeters(Polygons bounderyPolygons)
{
this.bounderyPolygons = bounderyPolygons;
minXPosition = new long[bounderyPolygons.Count];
maxXPosition = new long[bounderyPolygons.Count];
indexOfMinX = new int[bounderyPolygons.Count];
indexOfMaxX = new int[bounderyPolygons.Count];
}
开发者ID:GearWalker,项目名称:MatterSlice,代码行数:8,代码来源:AvoidCrossingPerimeters.cs
示例6: Calculate
public void Calculate(Polygons polys)
{
min = new IntPoint(long.MaxValue, long.MaxValue);
max = new IntPoint(long.MinValue, long.MinValue);
for (int i = 0; i < polys.Count; i++)
{
for (int j = 0; j < polys[i].Count; j++)
{
if (min.X > polys[i][j].X) min.X = polys[i][j].X;
if (min.Y > polys[i][j].Y) min.Y = polys[i][j].Y;
if (max.X < polys[i][j].X) max.X = polys[i][j].X;
if (max.Y < polys[i][j].Y) max.Y = polys[i][j].Y;
}
}
}
开发者ID:broettge,项目名称:MatterSlice,代码行数:15,代码来源:PolygonHelper.cs
示例7: GenerateLinePaths
public static void GenerateLinePaths(Polygons polygonToInfill, ref Polygons infillLinesToPrint, int lineSpacing, int infillExtendIntoPerimeter_um, double rotation, long rotationOffset = 0)
{
if (polygonToInfill.Count > 0)
{
Polygons outlines = polygonToInfill.Offset(infillExtendIntoPerimeter_um);
if (outlines.Count > 0)
{
PointMatrix matrix = new PointMatrix(-(rotation + 90)); // we are rotating the part so we rotate by the negative so the lines go the way we expect
outlines.ApplyMatrix(matrix);
Aabb boundary = new Aabb(outlines);
boundary.min.X = ((boundary.min.X / lineSpacing) - 1) * lineSpacing - rotationOffset;
int xLineCount = (int)((boundary.max.X - boundary.min.X + (lineSpacing - 1)) / lineSpacing);
Polygons unclipedPatern = new Polygons();
long firstX = boundary.min.X / lineSpacing * lineSpacing;
for (int lineIndex = 0; lineIndex < xLineCount; lineIndex++)
{
Polygon line = new Polygon();
line.Add(new IntPoint(firstX + lineIndex * lineSpacing, boundary.min.Y));
line.Add(new IntPoint(firstX + lineIndex * lineSpacing, boundary.max.Y));
unclipedPatern.Add(line);
}
PolyTree ret = new PolyTree();
Clipper clipper = new Clipper();
clipper.AddPaths(unclipedPatern, PolyType.ptSubject, false);
clipper.AddPaths(outlines, PolyType.ptClip, true);
clipper.Execute(ClipType.ctIntersection, ret, PolyFillType.pftPositive, PolyFillType.pftEvenOdd);
Polygons newSegments = Clipper.OpenPathsFromPolyTree(ret);
PointMatrix inversematrix = new PointMatrix((rotation + 90));
newSegments.ApplyMatrix(inversematrix);
infillLinesToPrint.AddRange(newSegments);
}
}
}
开发者ID:GearWalker,项目名称:MatterSlice,代码行数:40,代码来源:infill.cs
示例8: Offset
public static Polygons Offset(this Polygons polygons, long distance)
{
ClipperOffset offseter = new ClipperOffset();
offseter.AddPaths(polygons, JoinType.jtMiter, EndType.etClosedPolygon);
Paths solution = new Polygons();
offseter.Execute(ref solution, distance);
return solution;
}
开发者ID:yushuiqiang,项目名称:MatterSlice,代码行数:8,代码来源:PolygonsHelper.cs
示例9: DeepCopy
public static Polygons DeepCopy(this Polygons polygons)
{
Polygons deepCopy = new Polygons();
foreach (Polygon poly in polygons)
{
deepCopy.Add(new Polygon(poly));
}
return deepCopy;
}
开发者ID:yushuiqiang,项目名称:MatterSlice,代码行数:10,代码来源:PolygonsHelper.cs
示例10: CreateUnion
public static Polygons CreateUnion(this Polygons polygons, Polygons other)
{
Clipper clipper = new Clipper();
clipper.AddPaths(polygons, PolyType.ptSubject, true);
clipper.AddPaths(other, PolyType.ptSubject, true);
Polygons ret = new Polygons();
clipper.Execute(ClipType.ctUnion, ret, PolyFillType.pftNonZero, PolyFillType.pftNonZero);
return ret;
}
开发者ID:yushuiqiang,项目名称:MatterSlice,代码行数:10,代码来源:PolygonsHelper.cs
示例11: CreateLineIntersections
public static Polygons CreateLineIntersections(this Polygons polygons, Polygons other)
{
Clipper clipper = new Clipper();
clipper.AddPaths(other, PolyType.ptSubject, false);
clipper.AddPaths(polygons, PolyType.ptClip, true);
PolyTree clippedLines = new PolyTree();
clipper.Execute(ClipType.ctIntersection, clippedLines);
return Clipper.OpenPathsFromPolyTree(clippedLines);
}
开发者ID:yushuiqiang,项目名称:MatterSlice,代码行数:13,代码来源:PolygonsHelper.cs
示例12: CreateIntersection
public static Polygons CreateIntersection(this Polygons polygons, Polygons other)
{
Polygons ret = new Polygons();
Clipper clipper = new Clipper();
clipper.AddPaths(polygons, PolyType.ptSubject, true);
clipper.AddPaths(other, PolyType.ptClip, true);
clipper.Execute(ClipType.ctIntersection, ret);
return ret;
}
开发者ID:yushuiqiang,项目名称:MatterSlice,代码行数:9,代码来源:PolygonsHelper.cs
示例13: BuildResult
//------------------------------------------------------------------------------
private void BuildResult(Polygons polyg)
{
polyg.Clear();
polyg.Capacity = m_PolyOuts.Count;
for (int i = 0; i < m_PolyOuts.Count; i++)
{
OutRec outRec = m_PolyOuts[i];
if (outRec.pts == null) continue;
OutPt p = outRec.pts;
int cnt = PointCount(p);
if (cnt < 3) continue;
Polygon pg = new Polygon(cnt);
for (int j = 0; j < cnt; j++)
{
pg.Add(p.pt);
p = p.prev;
}
polyg.Add(pg);
}
}
开发者ID:caomw,项目名称:elementdiscovery,代码行数:22,代码来源:clipper.cs
示例14: ProcessEvenOdd
public static Polygons ProcessEvenOdd(this Polygons polygons)
{
Polygons ret = new Polygons();
Clipper clipper = new Clipper();
clipper.AddPaths(polygons, PolyType.ptSubject, true);
clipper.Execute(ClipType.ctUnion, ret);
return ret;
}
开发者ID:yushuiqiang,项目名称:MatterSlice,代码行数:8,代码来源:PolygonsHelper.cs
示例15: SplitIntoMeshesOnOrthographicZ
public static Mesh[] SplitIntoMeshesOnOrthographicZ(Mesh meshToSplit, Vector3 buildVolume, ReportProgressRatio reportProgress)
{
// check if the part is bigger than the build plate (if it is we need to use that as our size)
AxisAlignedBoundingBox partBounds = meshToSplit.GetAxisAlignedBoundingBox();
buildVolume.x = Math.Max(buildVolume.x, partBounds.XSize + 2);
buildVolume.y = Math.Max(buildVolume.y, partBounds.YSize + 2);
buildVolume.z = Math.Max(buildVolume.z, partBounds.ZSize + 2);
// Find all the separate objects that are on the plate
// Create a 2D image the size of the printer bed at some scale with the parts draw on it top down
double scaleFactor = 5;
ImageBuffer partPlate = new ImageBuffer((int)(buildVolume.x * scaleFactor), (int)(buildVolume.y * scaleFactor), 32, new BlenderBGRA());
Vector2 renderOffset = new Vector2(buildVolume.x / 2, buildVolume.y / 2) - new Vector2(partBounds.Center.x, partBounds.Center.y);
PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partPlate.NewGraphics2D(), meshToSplit, renderOffset, scaleFactor, RGBA_Bytes.White);
bool continueProcessin = true;
if (reportProgress != null)
{
reportProgress(.2, "", out continueProcessin);
}
//ImageIO.SaveImageData("test part plate 0.png", partPlate);
// expand the bounds a bit so that we can collect all the vertices and polygons within each bound
Dilate.DoDilate3x3Binary(partPlate, 1);
//ImageIO.SaveImageData("test part plate 1.png", partPlate);
// trace all the bounds of the objects on the plate
PolyTree polyTreeForPlate = FindDistictObjectBounds(partPlate);
if (polyTreeForPlate == null)
{
Mesh[] singleMesh = new Mesh[1];
singleMesh[0] = meshToSplit;
return singleMesh;
}
// get all the discrete areas that are polygons so we can search them
Polygons discreteAreas = new Polygons();
GetAreasRecursive(polyTreeForPlate, discreteAreas);
if (discreteAreas.Count == 0)
{
return null;
}
else if (discreteAreas.Count == 1)
{
Mesh[] singleMesh = new Mesh[1];
singleMesh[0] = meshToSplit;
return singleMesh;
}
Graphics2D graphics2D = partPlate.NewGraphics2D();
graphics2D.Clear(RGBA_Bytes.Black);
Random rand = new Random();
foreach (Polygon polygon in discreteAreas)
{
graphics2D.Render(PlatingHelper.PolygonToPathStorage(polygon), new RGBA_Bytes(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255)));
}
if (reportProgress != null)
{
reportProgress(.5, "", out continueProcessin);
}
//ImageIO.SaveImageData("test part plate 2.png", partPlate);
// add each of the separate bounds polygons to new meshes
Mesh[] discreteMeshes = new Mesh[discreteAreas.Count];
for (int i = 0; i < discreteAreas.Count; i++)
{
discreteMeshes[i] = new Mesh();
}
foreach (Face face in meshToSplit.Faces)
{
bool faceDone = false;
// figure out which area one or more of the vertices are in add the face to the right new mesh
foreach (FaceEdge faceEdge in face.FaceEdges())
{
Vector2 position = new Vector2(faceEdge.firstVertex.Position.x, faceEdge.firstVertex.Position.y);
position += renderOffset;
position *= scaleFactor;
for (int areaIndex = discreteAreas.Count - 1; areaIndex >= 0; areaIndex--)
{
if (PointInPolygon(discreteAreas[areaIndex], new IntPoint((int)position.x, (int)position.y)))
{
List<Vertex> faceVertices = new List<Vertex>();
foreach (FaceEdge faceEdgeToAdd in face.FaceEdges())
{
Vertex newVertex = discreteMeshes[areaIndex].CreateVertex(faceEdgeToAdd.firstVertex.Position);
faceVertices.Add(newVertex);
}
discreteMeshes[areaIndex].CreateFace(faceVertices.ToArray());
faceDone = true;
break;
}
}
if (faceDone)
//.........这里部分代码省略.........
开发者ID:broettge,项目名称:MatterControl,代码行数:101,代码来源:CreateDiscreteMeshes.cs
示例16: ProcessPolyTreeNodeIntoSeparatIslands
private static void ProcessPolyTreeNodeIntoSeparatIslands(this Polygons polygonsIn, PolyNode node, List<Polygons> ret)
{
for (int n = 0; n < node.ChildCount; n++)
{
PolyNode child = node.Childs[n];
Polygons polygons = new Polygons();
polygons.Add(child.Contour);
for (int i = 0; i < child.ChildCount; i++)
{
polygons.Add(child.Childs[i].Contour);
polygonsIn.ProcessPolyTreeNodeIntoSeparatIslands(child.Childs[i], ret);
}
ret.Add(polygons);
}
}
开发者ID:yushuiqiang,项目名称:MatterSlice,代码行数:15,代码来源:PolygonsHelper.cs
示例17: PolyTreeToPolygons
//------------------------------------------------------------------------------
public static void PolyTreeToPolygons(PolyTree polytree, Polygons polygons)
{
polygons.Clear();
polygons.Capacity = polytree.Total;
AddPolyNodeToPolygons(polytree, polygons);
}
开发者ID:caomw,项目名称:elementdiscovery,代码行数:8,代码来源:clipper.cs
示例18: SimplifyPolygons
//------------------------------------------------------------------------------
public static Polygons SimplifyPolygons(Polygons polys,
PolyFillType fillType = PolyFillType.pftEvenOdd)
{
Polygons result = new Polygons();
Clipper c = new Clipper();
c.AddPolygons(polys, PolyType.ptSubject);
c.Execute(ClipType.ctUnion, result, fillType, fillType);
return result;
}
开发者ID:caomw,项目名称:elementdiscovery,代码行数:11,代码来源:clipper.cs
示例19: OffsetPolygons
//------------------------------------------------------------------------------
public static Polygons OffsetPolygons(Polygons poly, double delta)
{
Polygons result = new Polygons(poly.Count);
new PolyOffsetBuilder(poly, result, delta, JoinType.jtSquare, 2.0, true);
return result;
}
开发者ID:caomw,项目名称:elementdiscovery,代码行数:8,代码来源:clipper.cs
示例20: PolyOffsetBuilder
public PolyOffsetBuilder(Polygons pts, Polygons solution, double delta,
JoinType jointype, double MiterLimit = 2, bool AutoFix = true)
{
//precondtion: solution != pts
if (delta == 0)
{
solution = pts;
return;
}
this.pts = pts;
this.delta = delta;
//AutoFix - fixes polygon orientation if necessary and removes
//duplicate vertices. Can be set false when you're sure that polygon
//orientation is correct and that there are no duplicate vertices.
if (AutoFix)
{
int Len = pts.Count, botI = 0;
while (botI < Len && pts[botI].Count == 0) botI++;
if (botI == Len) return;
//botPt: used to find the lowermost (in inverted Y-axis) & leftmost point
//This point (on pts[botI]) must be on an outer polygon ring and if
//its orientation is false (counterclockwise) then assume all polygons
//need reversing ...
IntPoint botPt = pts[botI][0];
for (int i = botI; i < Len; ++i)
{
if (pts[i].Count == 0) continue;
if (UpdateBotPt(pts[i][0], ref botPt)) botI = i;
for (int j = pts[i].Count -1; j > 0; j--)
{
if (PointsEqual(pts[i][j], pts[i][j -1]))
pts[i].RemoveAt(j);
else if (UpdateBotPt(pts[i][j], ref botPt))
botI = i;
}
}
if (!Orientation(pts[botI]))
ReversePolygons(pts);
}
if (MiterLimit <= 1) MiterLimit = 1;
double RMin = 2.0 / (MiterLimit*MiterLimit);
normals = new List<DoublePoint>();
double deltaSq = delta*delta;
solution.Clear();
solution.Capacity = pts.Count;
for (m_i = 0; m_i < pts.Count; m_i++)
{
int len = pts[m_i].Count;
if (len > 1 && pts[m_i][0].X == pts[m_i][len - 1].X &&
pts[m_i][0].Y == pts[m_i][len - 1].Y) len--;
if (len == 0 || (len < 3 && delta <= 0))
continue;
else if (len == 1)
{
Polygon arc;
arc = BuildArc(pts[m_i][len - 1], 0, 2 * Math.PI, delta);
solution.Add(arc);
continue;
}
//build normals ...
normals.Clear();
normals.Capacity = len;
for (int j = 0; j < len -1; ++j)
normals.Add(GetUnitNormal(pts[m_i][j], pts[m_i][j+1]));
normals.Add(GetUnitNormal(pts[m_i][len - 1], pts[m_i][0]));
currentPoly = new Polygon();
m_k = len - 1;
for (m_j = 0; m_j < len; ++m_j)
{
switch (jointype)
{
case JoinType.jtMiter:
{
m_R = 1 + (normals[m_j].X*normals[m_k].X +
normals[m_j].Y*normals[m_k].Y);
if (m_R >= RMin) DoMiter(); else DoSquare(MiterLimit);
break;
}
case JoinType.jtRound:
DoRound();
break;
case JoinType.jtSquare:
DoSquare(1);
break;
}
m_k = m_j;
}
solution.Add(currentPoly);
}
//.........这里部分代码省略.........
开发者ID:caomw,项目名称:elementdiscovery,代码行数:101,代码来源:clipper.cs
注:本文中的Polygons类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论