本文整理汇总了C#中Vertices.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Vertices.Remove方法的具体用法?C# Vertices.Remove怎么用?C# Vertices.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertices
的用法示例。
在下文中一共展示了Vertices.Remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSimplePolygon
/// <summary>
///
/// </summary>
/// <param name="entrance"></param>
/// <param name="last"></param>
/// <returns></returns>
private Vertices CreateSimplePolygon(Vector2 entrance, Vector2 last)
{
bool entranceFound = false;
bool endOfHull = false;
Vertices polygon = new Vertices(32);
Vertices hullArea = new Vertices(32);
Vertices endOfHullArea = new Vertices(32);
Vector2 current = Vector2.Zero;
#region Entrance check
// Get the entrance point. //todo: alle möglichkeiten testen
if (entrance == Vector2.Zero || !InBounds(ref entrance))
{
entranceFound = SearchHullEntrance(out entrance);
if (entranceFound)
{
current = new Vector2(entrance.X - 1f, entrance.Y);
}
}
else
{
if (IsSolid(ref entrance))
{
if (IsNearPixel(ref entrance, ref last))
{
current = last;
entranceFound = true;
}
else
{
Vector2 temp;
if (SearchNearPixels(false, ref entrance, out temp))
{
current = temp;
entranceFound = true;
}
else
{
entranceFound = false;
}
}
}
}
#endregion
if (entranceFound)
{
polygon.Add(entrance);
hullArea.Add(entrance);
Vector2 next = entrance;
do
{
// Search in the pre vision list for an outstanding point.
Vector2 outstanding;
if (SearchForOutstandingVertex(hullArea, out outstanding))
{
if (endOfHull)
{
// We have found the next pixel, but is it on the last bit of the hull?
if (endOfHullArea.Contains(outstanding))
{
// Indeed.
polygon.Add(outstanding);
}
// That's enough, quit.
break;
}
// Add it and remove all vertices that don't matter anymore
// (all the vertices before the outstanding).
polygon.Add(outstanding);
hullArea.RemoveRange(0, hullArea.IndexOf(outstanding));
}
// Last point gets current and current gets next. Our little spider is moving forward on the hull ;).
last = current;
current = next;
// Get the next point on hull.
if (GetNextHullPoint(ref last, ref current, out next))
{
// Add the vertex to a hull pre vision list.
hullArea.Add(next);
}
else
{
//.........这里部分代码省略.........
示例2: MergeIdenticalNeighborPoints
/// <summary>
/// Merges Identical points that are connected to eachother in the polygon.
/// </summary>
/// <param name="vertices">The vertices.</param>
public static Vertices MergeIdenticalNeighborPoints(Vertices vertices)
{
for (int i = 0; i < vertices.Count ; i++)
{
Point2D cur = vertices[i];
Point2D nex = vertices.NextVertex(i);
if (cur.X == nex.X && cur.Y == nex.Y)
{
vertices.Remove(nex);
}
}
return new Vertices(vertices);
}
示例3: simplify
private void simplify(Vertices v)
{
int j = 0;
do
{
if (v.Count <= 3) break;
Vector2 v1 = v[j];
Vector2 v2 = v[j + 1];
Vector2 v3 = v[j + 2];
Vector2 k1 = Vector2.Normalize(v3 - v1);
Vector2 k2 = Vector2.Normalize(v2 - v1);
if (k1 == k2) v.Remove(v[j + 1]);
else j += 1;
}
while (j + 2 != v.Count - 1);
}