當前位置: 首頁>>代碼示例>>C#>>正文


C# DTSweepContext.FinalizeTriangulation方法代碼示例

本文整理匯總了C#中Poly2Tri.Triangulation.Delaunay.Sweep.DTSweepContext.FinalizeTriangulation方法的典型用法代碼示例。如果您正苦於以下問題:C# DTSweepContext.FinalizeTriangulation方法的具體用法?C# DTSweepContext.FinalizeTriangulation怎麽用?C# DTSweepContext.FinalizeTriangulation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Poly2Tri.Triangulation.Delaunay.Sweep.DTSweepContext的用法示例。


在下文中一共展示了DTSweepContext.FinalizeTriangulation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FinalizationConvexHull

        /// <summary>
        /// If this is a Delaunay Triangulation of a pointset we need to fill so the triangle mesh gets a ConvexHull 
        /// </summary>
        private static void FinalizationConvexHull(DTSweepContext tcx)
        {
            AdvancingFrontNode n1, n2;
            DelaunayTriangle t1, t2;
            TriangulationPoint first, p1;

            n1 = tcx.aFront.Head.Next;
            n2 = n1.Next;
            first = n1.Point;

            TurnAdvancingFrontConvex(tcx, n1, n2);

            // TODO: implement ConvexHull for lower right and left boundary

            // Lets remove triangles connected to the two "algorithm" points

            // XXX: When the first the nodes are points in a triangle we need to do a flip before 
            //      removing triangles or we will lose a valid triangle.
            //      Same for last three nodes!
            // !!! If I implement ConvexHull for lower right and left boundary this fix should not be 
            //     needed and the removed triangles will be added again by default
            n1 = tcx.aFront.Tail.Prev;
            if (n1.Triangle.Contains(n1.Next.Point) && n1.Triangle.Contains(n1.Prev.Point))
            {
                t1 = n1.Triangle.NeighborAcross(n1.Point);
                RotateTrianglePair(n1.Triangle, n1.Point, t1, t1.OppositePoint(n1.Triangle, n1.Point));
                tcx.MapTriangleToNodes(n1.Triangle);
                tcx.MapTriangleToNodes(t1);
            }
            n1 = tcx.aFront.Head.Next;
            if (n1.Triangle.Contains(n1.Prev.Point) && n1.Triangle.Contains(n1.Next.Point))
            {
                t1 = n1.Triangle.NeighborAcross(n1.Point);
                RotateTrianglePair(n1.Triangle, n1.Point, t1, t1.OppositePoint(n1.Triangle, n1.Point));
                tcx.MapTriangleToNodes(n1.Triangle);
                tcx.MapTriangleToNodes(t1);
            }

            // Lower right boundary 
            first = tcx.aFront.Head.Point;
            n2 = tcx.aFront.Tail.Prev;
            t1 = n2.Triangle;
            p1 = n2.Point;
            n2.Triangle = null;
            do
            {
                tcx.RemoveFromList(t1);
                p1 = t1.PointCCW(p1);
                if (p1 == first) break;
                t2 = t1.NeighborCCW(p1);
                t1.Clear();
                t1 = t2;
            } while (true);

            // Lower left boundary
            first = tcx.aFront.Head.Next.Point;
            p1 = t1.PointCW(tcx.aFront.Head.Point);
            t2 = t1.NeighborCW(tcx.aFront.Head.Point);
            t1.Clear();
            t1 = t2;
            while (p1 != first) //TODO: Port note. This was do while before.
            {
                tcx.RemoveFromList(t1);
                p1 = t1.PointCCW(p1);
                t2 = t1.NeighborCCW(p1);
                t1.Clear();
                t1 = t2;
            }

            // Remove current head and tail node now that we have removed all triangles attached
            // to them. Then set new head and tail node points
            tcx.aFront.Head = tcx.aFront.Head.Next;
            tcx.aFront.Head.Prev = null;
            tcx.aFront.Tail = tcx.aFront.Tail.Prev;
            tcx.aFront.Tail.Next = null;

            tcx.FinalizeTriangulation();
        }
開發者ID:Werkheisera2,項目名稱:RaginRovers,代碼行數:81,代碼來源:DTSweep.cs


注:本文中的Poly2Tri.Triangulation.Delaunay.Sweep.DTSweepContext.FinalizeTriangulation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。