Example #1
0
        /// <summary>
        /// Inserts a new site into the Subdivision, connecting it to the vertices of
        /// the containing triangle (or quadrilateral, if the split point falls on an
        /// existing edge).
        /// </summary>
        /// <remarks>
        /// <para>
        /// This method does NOT maintain the Delaunay condition. If desired, this must
        /// be checked and enforced by the caller.
        /// </para>
        /// <para>
        /// This method does NOT check if the inserted vertex falls on an edge. This
        /// must be checked by the caller, since this situation may cause erroneous
        /// triangulation
        /// </para>
        /// </remarks>
        /// <param name="v">the vertex to insert</param>
        /// <returns>a new quad edge terminating in v</returns>
        public QuadEdge InsertSite(Vertex v)
        {
            QuadEdge e = Locate(v);

            if ((v.Equals(e.Orig, _tolerance)) || (v.Equals(e.Dest, _tolerance)))
            {
                return(e); // point already in subdivision.
            }

            // Connect the new point to the vertices of the containing
            // triangle (or quadrilateral, if the new point fell on an
            // existing edge.)
            QuadEdge baseQE = MakeEdge(e.Orig, v);

            QuadEdge.Splice(baseQE, e);
            QuadEdge startEdge = baseQE;

            do
            {
                baseQE = Connect(e, baseQE.Sym);
                e      = baseQE.OPrev;
            } while (e.LNext != startEdge);

            return(startEdge);
        }
Example #2
0
        private QuadEdge InitSubdiv()
        {
            // build initial subdivision from frame
            QuadEdge ea = MakeEdge(_frameVertex[0], _frameVertex[1]);
            QuadEdge eb = MakeEdge(_frameVertex[1], _frameVertex[2]);

            QuadEdge.Splice(ea.Sym, eb);
            QuadEdge ec = MakeEdge(_frameVertex[2], _frameVertex[0]);

            QuadEdge.Splice(eb.Sym, ec);
            QuadEdge.Splice(ec.Sym, ea);
            return(ea);
        }
Example #3
0
        /// <summary>
        /// Deletes a quadedge from the subdivision. Linked quadedges are updated to
        /// reflect the deletion.
        /// </summary>
        /// <param name="e">the quadedge to delete</param>
        public void Delete(QuadEdge e)
        {
            QuadEdge.Splice(e, e.OPrev);
            QuadEdge.Splice(e.Sym, e.Sym.OPrev);

            QuadEdge eSym    = e.Sym;
            QuadEdge eRot    = e.Rot;
            QuadEdge eRotSym = e.Rot.Sym;

            // this is inefficient on an ArrayList, but this method should be called infrequently
            _quadEdges.Remove(e);
            _quadEdges.Remove(eSym);
            _quadEdges.Remove(eRot);
            _quadEdges.Remove(eRotSym);

            e.Delete();
            eSym.Delete();
            eRot.Delete();
            eRotSym.Delete();
        }