当前位置: 首页>>代码示例>>C#>>正文


C# Poly2Tri.TriangulationPoint类代码示例

本文整理汇总了C#中Poly2Tri.TriangulationPoint的典型用法代码示例。如果您正苦于以下问题:C# TriangulationPoint类的具体用法?C# TriangulationPoint怎么用?C# TriangulationPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TriangulationPoint类属于Poly2Tri命名空间,在下文中一共展示了TriangulationPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PointOnEdgeException

 public PointOnEdgeException(string message, TriangulationPoint a, TriangulationPoint b, TriangulationPoint c)
     : base(message)
 {
     A = a;
     B = b;
     C = c;
 }
开发者ID:JonathanReid,项目名称:Unity-JellyPhysics,代码行数:7,代码来源:PointOnEdgeException.cs

示例2: DelaunayTriangle

		public DelaunayTriangle(TriangulationPoint p1, TriangulationPoint p2, TriangulationPoint p3, int i1, int i2, int i3) {
			Points[0] = p1;
			Points[1] = p2;
			Points[2] = p3;

            indices = new int[] { i1, i2, i3 };
		}
开发者ID:iamtanmay,项目名称:FiberToGraph,代码行数:7,代码来源:DelaunayTriangle.cs

示例3: GetBounds

    /// <summary>
    /// Creates a triangulation of the vertices given, and gives you the indices of it.
    /// </summary>
    /// <param name="aPoints">A list of points to triangulate.</param>
    /// <param name="aTreatAsPath">Should we discard any triangles at all? Use this if you want to get rid of triangles that are outside the path.</param>
    /// <param name="aInvert">if we're treating it as a path, should we instead sicard triangles inside the path?</param>
    /// <returns>A magical list of indices describing the triangulation!</returns>
	public  static List<int> GetIndices           (ref List<Vector2> aPoints, bool aTreatAsPath, bool aInvert, float aVertGridSpacing = 0) {
		
		Vector4 bounds = GetBounds(aPoints);
		
        if (aVertGridSpacing > 0) {
            SplitEdges(ref aPoints, aVertGridSpacing);
        }

		List<PolygonPoint> verts = new List<PolygonPoint>(aPoints.Count);
		for (int i = 0; i < aPoints.Count; i++) {
			verts.Add(new PolygonPoint( aPoints[i].x, aPoints[i].y));
		}

		Polygon poly;
		if (aInvert) {
			aPoints.Add(new Vector2(bounds.x - (bounds.z - bounds.x) * 1, bounds.w - (bounds.y - bounds.w) * 1)); // 4
			aPoints.Add(new Vector2(bounds.z + (bounds.z - bounds.x) * 1, bounds.w - (bounds.y - bounds.w) * 1)); // 3
			aPoints.Add(new Vector2(bounds.z + (bounds.z - bounds.x) * 1, bounds.y + (bounds.y - bounds.w) * 1)); // 2
			aPoints.Add(new Vector2(bounds.x - (bounds.z - bounds.x) * 1, bounds.y + (bounds.y - bounds.w) * 1)); // 1
			List<PolygonPoint> outer = new List<PolygonPoint>(4);
			for (int i = 0; i < 4; i++) {
				outer.Add( new PolygonPoint( aPoints[(aPoints.Count - 4) + i].x, aPoints[(aPoints.Count - 4) + i].y) );
			}
			poly = new Polygon(outer);
			poly.AddHole(new Polygon(verts));
		} else {
			poly = new Polygon(verts);
		}
		
		if (aVertGridSpacing > 0) {
			if (aInvert) bounds = GetBounds(aPoints);
			for (float y = bounds.w + aVertGridSpacing; y <= bounds.y; y+=aVertGridSpacing) {
				for (float x = bounds.x + aVertGridSpacing; x <= bounds.z; x+=aVertGridSpacing) {
					TriangulationPoint pt     = new TriangulationPoint(x, y);
					bool               inside = poly.IsPointInside(pt);
					if (inside) poly.AddSteinerPoint(pt);
				}
			}
		}
		P2T.Triangulate(poly);
		 
		aPoints.Clear();
		List<int> result= new List<int>(poly.Triangles.Count * 3);
		int       ind   = 0;
		foreach (DelaunayTriangle triangle in poly.Triangles) {
			TriangulationPoint p1 = triangle.Points[0];
			TriangulationPoint p2 = triangle.PointCWFrom(p1);
			TriangulationPoint p3 = triangle.PointCWFrom(p2);
			
			aPoints.Add(new Vector2(p1.Xf, p1.Yf));
			aPoints.Add(new Vector2(p2.Xf, p2.Yf));
			aPoints.Add(new Vector2(p3.Xf, p3.Yf));
			result.Add(ind++);
			result.Add(ind++);
			result.Add(ind++);
		}
		return result;
	}
开发者ID:lancetipton04,项目名称:VG,代码行数:65,代码来源:Ferr2D_Triangulator.cs

示例4: IndexOf

        public int IndexOf(TriangulationPoint p)
        {
            int i = Points.IndexOf(p);
            if (i == -1)
            {
                throw new Exception("Calling index with a point that doesn't exist in triangle");
            }

            return i;
        }
开发者ID:XvWenJun,项目名称:Retuer_6,代码行数:10,代码来源:DelaunayTriangle.cs

示例5: FlipScanEdgeEvent

		/// <summary>
		/// Scan part of the FlipScan algorithm<br/>
		/// When a triangle pair isn't flippable we will scan for the next
		/// point that is inside the flip triangle scan area. When found
		/// we generate a new flipEdgeEvent
		/// </summary>
		/// <param name="tcx"></param>
		/// <param name="ep">last point on the edge we are traversing</param>
		/// <param name="eq">first point on the edge we are traversing</param>
		/// <param name="flipTriangle">the current triangle sharing the point eq with edge</param>
		/// <param name="t"></param>
		/// <param name="p"></param>
		private static void FlipScanEdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle flipTriangle, DelaunayTriangle t, TriangulationPoint p)
		{
			DelaunayTriangle ot;
			TriangulationPoint op, newP;
			bool inScanArea;

			ot = t.NeighborAcrossFrom(p);
			op = ot.OppositePoint(t, p);

			if (ot == null)
			{
				// If we want to integrate the fillEdgeEvent do it here
				// With current implementation we should never get here
				throw new Exception("[BUG:FIXME] FLIP failed due to missing triangle");
			}

			if (tcx.IsDebugEnabled)
			{
				Console.WriteLine("[FLIP:SCAN] - scan next point"); // TODO: remove
				tcx.DTDebugContext.PrimaryTriangle = t;
				tcx.DTDebugContext.SecondaryTriangle = ot;
			}

			inScanArea = TriangulationUtil.InScanArea(eq, flipTriangle.PointCCWFrom(eq), flipTriangle.PointCWFrom(eq), op);
			if (inScanArea)
			{
				// flip with new edge op->eq
				FlipEdgeEvent(tcx, eq, op, ot, op);
				// TODO: Actually I just figured out that it should be possible to
				//       improve this by getting the next ot and op before the the above
				//       flip and continue the flipScanEdgeEvent here
				// set new ot and op here and loop back to inScanArea test
				// also need to set a new flipTriangle first
				// Turns out at first glance that this is somewhat complicated
				// so it will have to wait.
			}
			else
			{
				newP = NextFlipPoint(ep, eq, ot, op);
				FlipScanEdgeEvent(tcx, ep, eq, flipTriangle, ot, newP);
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:54,代码来源:DTSweep.cs

示例6: NextFlipPoint

		/// <summary>
		/// When we need to traverse from one triangle to the next we need
		/// the point in current triangle that is the opposite point to the next
		/// triangle.
		/// </summary>
		private static TriangulationPoint NextFlipPoint(TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle ot, TriangulationPoint op)
		{
			Orientation o2d = TriangulationUtil.Orient2d(eq, op, ep);
			switch (o2d)
			{
				case Orientation.CW: return ot.PointCCWFrom(op);
				case Orientation.CCW: return ot.PointCWFrom(op);
				case Orientation.Collinear:
					// TODO: implement support for point on constraint edge
					throw new PointOnEdgeException("Point on constrained edge not supported yet", eq, op, ep);
				default:
					throw new NotImplementedException("Orientation not handled");
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:19,代码来源:DTSweep.cs

示例7: SplitEdge

		/// <summary>
		/// In the case of a pointset with some constraint edges. If a triangle side is collinear
		/// with a part of the constraint we split the constraint into two constraints. This could
		/// happen when the given constraint migth intersect a point in the set.<br/>
		/// This can never happen in the case when we are working with a polygon.
		///
		/// Think of two triangles that have non shared sides that are collinear and the constraint
		/// is set from a point in triangle A to a point in triangle B so that the constraint is
		/// the union of both those sides. We then have to split the constraint into two so we get
		/// one constraint for each triangle.
		/// </summary>
		/// <param name="ep"></param>
		/// <param name="eq"></param>
		/// <param name="p">point on the edge between ep->eq</param>
		private static void SplitEdge(TriangulationPoint ep, TriangulationPoint eq, TriangulationPoint p)
		{
			DTSweepConstraint edge = eq.Edges.First(e => e.Q == ep || e.P == ep);
			edge.P = p;
			new DTSweepConstraint(ep, p); // Et tu, Brute? --MM

			//        // Redo this edge now that we have split the constraint
			//          newEdgeEvent( tcx, edge, triangle, point );
			//          // Continue with new edge
			//          newEdgeEvent( tcx, edge, triangle, p2 );
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:25,代码来源:DTSweep.cs

示例8: IsEdgeSideOfTriangle

		private static bool IsEdgeSideOfTriangle(DelaunayTriangle triangle, TriangulationPoint ep, TriangulationPoint eq)
		{
			int index = triangle.EdgeIndex(ep, eq);
			if (index == -1) return false;
			triangle.MarkConstrainedEdge(index);
			triangle = triangle.Neighbors[index];
			if (triangle != null) triangle.MarkConstrainedEdge(ep, eq);
			return true;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:9,代码来源:DTSweep.cs

示例9: PointEvent

		/// <summary>
		/// Find closes node to the left of the new point and
		/// create a new triangle. If needed new holes and basins
		/// will be filled to.
		/// </summary>
		private static AdvancingFrontNode PointEvent(DTSweepContext tcx, TriangulationPoint point)
		{
			AdvancingFrontNode node, newNode;

			node = tcx.LocateNode(point);
			if (tcx.IsDebugEnabled) tcx.DTDebugContext.ActiveNode = node;
			newNode = NewFrontTriangle(tcx, point, node);

			// Only need to check +epsilon since point never have smaller
			// x value than node due to how we fetch nodes from the front
			if (point.X <= node.Point.X + TriangulationUtil.EPSILON) Fill(tcx, node);

			tcx.AddNode(newNode);

			FillAdvancingFront(tcx, newNode);
			return newNode;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:22,代码来源:DTSweep.cs

示例10: LocatePoint

        /// <summary>
        /// This implementation will use simple node traversal algorithm to find a point on the front
        /// </summary>
        public AdvancingFrontNode LocatePoint(TriangulationPoint point)
        {
            double px = point.X;
            AdvancingFrontNode node = FindSearchNode(px);
            double nx = node.Point.X;

            if (px == nx)
            {
                if (point != node.Point)
                {
                    // We might have two nodes with same x value for a short time
                    if (point == node.Prev.Point)
                    {
                        node = node.Prev;
                    }
                    else if (point == node.Next.Point)
                    {
                        node = node.Next;
                    }
                    else
                    {
                        throw new Exception("Failed to find Node for given afront point");
                    }
                }
            }
            else if (px < nx)
            {
                while ((node = node.Prev) != null)
                {
                    if (point == node.Point)
                    {
                        break;
                    }
                }
            }
            else
            {
                while ((node = node.Next) != null)
                {
                    if (point == node.Point)
                    {
                        break;
                    }
                }
            }
            Search = node;

            return node;
        }
开发者ID:Ayagami,项目名称:Tesis,代码行数:52,代码来源:AdvancingFront.cs

示例11: NeighborCWFrom

 public DelaunayTriangle NeighborCWFrom(TriangulationPoint point)
 {
     return Neighbors[(Points.IndexOf(point) + 1) % 3];
 }
开发者ID:JonathanReid,项目名称:Unity-JellyPhysics,代码行数:4,代码来源:DelaunayTriangle.cs

示例12: NeighborAcrossFrom

 public DelaunayTriangle NeighborAcrossFrom(TriangulationPoint point)
 {
     return Neighbors[Points.IndexOf(point)];
 }
开发者ID:JonathanReid,项目名称:Unity-JellyPhysics,代码行数:4,代码来源:DelaunayTriangle.cs

示例13: MarkConstrainedEdge

 /// <summary>
 /// Mark edge as constrained
 /// </summary>
 public void MarkConstrainedEdge(TriangulationPoint p, TriangulationPoint q)
 {
     int i = EdgeIndex(p, q);
     if (i != -1)
     {
         mEdgeIsConstrained[i] = true;
     }
 }
开发者ID:JonathanReid,项目名称:Unity-JellyPhysics,代码行数:11,代码来源:DelaunayTriangle.cs

示例14: Legalize

 /// <summary>
 /// Legalize triangle by rotating clockwise around oPoint
 /// </summary>
 /// <param name="oPoint">The origin point to rotate around</param>
 /// <param name="nPoint">???</param>
 public void Legalize(TriangulationPoint oPoint, TriangulationPoint nPoint)
 {
     RotateCW();
     Points[IndexCCWFrom(oPoint)] = nPoint;
 }
开发者ID:JonathanReid,项目名称:Unity-JellyPhysics,代码行数:10,代码来源:DelaunayTriangle.cs

示例15: IndexCWFrom

 public int IndexCWFrom(TriangulationPoint p)
 {
     return (IndexOf(p) + 2) % 3;
 }
开发者ID:JonathanReid,项目名称:Unity-JellyPhysics,代码行数:4,代码来源:DelaunayTriangle.cs


注:本文中的Poly2Tri.TriangulationPoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。