Beispiel #1
0
        /// <summary>
        /// Adds a triangle to the advancing front to fill a hole.
        /// </summary>
        /// <param name="tcx"></param>
        /// <param name="node">middle node, that is the bottom of the hole</param>
        private static void Fill(DTSweepContext tcx, AdvancingFrontNode node)
        {
            DelaunayTriangle triangle = new DelaunayTriangle(node.Prev.Point, node.Point, node.Next.Point);

            // TODO: should copy the cEdge value from neighbor triangles
            //       for now cEdge values are copied during the legalize
            triangle.MarkNeighbor(node.Prev.Triangle);
            triangle.MarkNeighbor(node.Triangle);
            tcx.Triangles.Add(triangle);

            // Update the advancing front
            node.Prev.Next = node.Next;
            node.Next.Prev = node.Prev;
            tcx.RemoveNode(node);

            // If it was legalized the triangle has already been mapped
            if (!Legalize(tcx, triangle))
            {
                tcx.MapTriangleToNodes(triangle);
            }
        }
 /// <summary>
 /// Exhaustive search to update neighbor pointers
 /// </summary>
 public void MarkNeighbor(DelaunayTriangle t)
 {
     if (t.Contains(Points[1], Points[2]))
     {
         Neighbors[0] = t;
         t.MarkNeighbor(Points[1], Points[2], this);
     }
     else if (t.Contains(Points[0], Points[2]))
     {
         Neighbors[1] = t;
         t.MarkNeighbor(Points[0], Points[2], this);
     }
     else if (t.Contains(Points[0], Points[1]))
     {
         Neighbors[2] = t;
         t.MarkNeighbor(Points[0], Points[1], this);
     }
     else
     {
         Debug.WriteLine("markNeighbor failed");
     }
 }
Beispiel #3
0
        /// <summary>
        /// Creates a new front triangle and legalize it
        /// </summary>
        private static AdvancingFrontNode NewFrontTriangle(DTSweepContext tcx, TriangulationPoint point, AdvancingFrontNode node)
        {
            DelaunayTriangle triangle = new DelaunayTriangle(point, node.Point, node.Next.Point);

            triangle.MarkNeighbor(node.Triangle);
            tcx.Triangles.Add(triangle);

            AdvancingFrontNode newNode = new AdvancingFrontNode(point);

            newNode.Next   = node.Next;
            newNode.Prev   = node;
            node.Next.Prev = newNode;
            node.Next      = newNode;

            tcx.AddNode(newNode); // XXX: BST

            if (!Legalize(tcx, triangle))
            {
                tcx.MapTriangleToNodes(triangle);
            }

            return(newNode);
        }