本文整理汇总了C#中Polygon.RemoveZeroEdges方法的典型用法代码示例。如果您正苦于以下问题:C# Polygon.RemoveZeroEdges方法的具体用法?C# Polygon.RemoveZeroEdges怎么用?C# Polygon.RemoveZeroEdges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon
的用法示例。
在下文中一共展示了Polygon.RemoveZeroEdges方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildNode
private static RooBSPItem BuildNode(List<RooWall> Walls, Polygon Polygon, int Sector)
{
if (Polygon.Count == 0 || (Walls.Count == 0 && Sector == 0))
return null;
Polygon.RemoveZeroEdges();
if (!Polygon.IsConvexPolygon())
{
if (FoundNonConvexPolygon != null)
FoundNonConvexPolygon(null, new PolygonEventArgs(Polygon));
//return null; // WTF ?
}
// No walls left ==> leaf
if (Walls.Count == 0)
{
RooSubSector leaf = new RooSubSector(RooFile.VERSIONHIGHRESGRID, (ushort)Sector, Polygon);
// fills in sector reference
leaf.ResolveIndices(room);
return leaf;
}
// get best splitter of remaining walls
RooWall splitter = ChooseSplitter(Walls);
if (splitter == null)
return null; // WTF ?
// split up walls into right/left
Tuple<List<RooWall>, List<RooWall>> splitWalls =
SplitWalls(Walls, splitter);
// split up polygon into right/left
Tuple<Polygon, Polygon> splitPolygons =
Polygon.SplitConvexPolygon(splitter.P1, splitter.P2);
Real a, b, c;
GetLineEquation2DCoefficients(splitter.P1, splitter.P2,
out a, out b, out c);
// create new splitter node
RooPartitionLine node = new RooPartitionLine(RooFile.VERSIONHIGHRESGRID,
Polygon.GetBoundingBox(), a, b, c, 0, 0, (ushort)splitter.Num);
// fills in wall reference
node.Wall = splitter;
// recursively descend to children
node.LeftChild = BuildNode(splitWalls.Item1, splitPolygons.Item1, splitter.LeftSectorNum);
node.RightChild = BuildNode(splitWalls.Item2, splitPolygons.Item2, splitter.RightSectorNum);
return node;
}
示例2: RemoveZeroEdges
public void RemoveZeroEdges()
{
Polygon poly = new Polygon();
int expected;
int returned;
// --- TEST ---
// 5 points, rectangle, but two points not of first three in on same coords
poly.Clear();
poly.Add(new V2(0.0f, 0.0f));
poly.Add(new V2(0.0f, 5.0f));
poly.Add(new V2(5.0f, 5.0f));
poly.Add(new V2(5.0f, 0.0f));
poly.Add(new V2(5.0f, 0.0f));
expected = 1;
returned = poly.RemoveZeroEdges();
Assert.AreEqual(expected, returned);
// --- TEST ---
// 5 points, rectangle, but two points not of first three in on same coords
poly.Clear();
poly.Add(new V2(0.0f, 0.0f));
poly.Add(new V2(0.0f, 5.0f));
poly.Add(new V2(5.0f, 5.0f));
poly.Add(new V2(5.0f, 0.0f));
poly.Add(new V2(5.0f, 0.0f));
expected = 1;
returned = poly.RemoveZeroEdges();
Assert.AreEqual(expected, returned);
// --- TEST ---
// n points, concave polygon
poly.Clear();
poly.Add(new V2(0.0f, 0.0f));
poly.Add(new V2(10.0f, 0.0f));
poly.Add(new V2(10.0f, 5.0f));
poly.Add(new V2(5.0f, 5.0f));
poly.Add(new V2(5.0f, 10.0f));
poly.Add(new V2(10.0f, 10.0f));
poly.Add(new V2(10.0f, 15.0f));
poly.Add(new V2(0.0f, 15.0f));
expected = 0;
returned = poly.RemoveZeroEdges();
Assert.AreEqual(expected, returned);
}