예제 #1
0
        private List <PolygonVertex> findMonotones(PolygonEdge diagonal)
        {
            PolygonVertex        start, end;
            List <PolygonVertex> vert = new List <PolygonVertex>();

            if (diagonal.edge1.index < diagonal.edge2.index)
            {
                start = diagonal.edge1;
                end   = diagonal.edge2;
            }
            else
            {
                start = diagonal.edge2;
                end   = diagonal.edge1;
            }

            PolygonVertex fixedStart = vertices.Find(v => v == start);
            PolygonVertex fixedEnd   = vertices.Find(v => v == end);

            while (start != end)
            {
                vert.Add(start);
                start = start.neighboor2;
            }
            vert.Add(end);

            fixedStart.neighboor2 = fixedEnd;
            fixedEnd.neighboor1   = fixedStart;

            vertices = vertices.Except(vert.Except(new[] { diagonal.edge1, diagonal.edge2 })).ToList();
            return(vert);
        }
예제 #2
0
        private void HandleRegularVertex(PolygonVertex v)
        {
            if (v.neighboor2.Y < v.Y)
            {
                // interior of P lies to the right of v (counterclockwise ordering)
                PolygonEdge   d  = edges.findEdgeEndingIn(v);
                PolygonEdge   e  = edges.findEdgeStartingIn(v);
                PolygonVertex dh = helpers[d];
                if (dh.type == PolygonVertexType.merge)
                {
                    insertDiagonal(dh, v);
                }
                T.Remove(d);

                T.Add(e);
                helpers[e] = v;
            }
            else
            {
                // interior of P lies to the left of v
                // search in T to find the edge ej directly left of v
                Dictionary <PolygonEdge, PointF> interSections = getIntersections(T, v);
                // take intersections to the left of vertex & select the leftmost _edge_ from them
                PolygonEdge ej = interSections.Where(kvp => kvp.Value.X < v.X).OrderBy(kvp => kvp.Value.X).Last().Key;
                if (helpers[ej].type == PolygonVertexType.merge)
                {
                    insertDiagonal(helpers[ej], v);
                }
                helpers[ej] = v;
            }
        }
예제 #3
0
        private void HandleStartVertex(PolygonVertex v)
        {
            PolygonEdge e = edges.findEdgeStartingIn(v);

            T.Add(e);
            helpers[e] = v;
        }
예제 #4
0
        private void HandleEndVertex(PolygonVertex v)
        {
            PolygonEdge   d  = edges.findEdgeEndingIn(v);
            PolygonVertex dh = helpers[d];

            if (dh.type == PolygonVertexType.merge)
            {
                insertDiagonal(v, dh);
            }
            T.Remove(d);
        }
예제 #5
0
        private void HandleSplitVertex(PolygonVertex v)
        {
            // search in T to find the edge ej directly left of v
            Dictionary <PolygonEdge, PointF> interSections = getIntersections(T, v);
            // take intersections to the left of vertex & select the leftmost _edge_ from them
            PolygonEdge ej = interSections.Where(kvp => kvp.Value.X < v.X).OrderBy(kvp => kvp.Value.X).Last().Key;
            PolygonEdge e  = edges.findEdgeStartingIn(v);

            insertDiagonal(v, helpers[ej]);
            helpers[ej] = v;
            T.Add(e);
            helpers[e] = v;
        }
예제 #6
0
        private void HandleMergeVertex(PolygonVertex v)
        {
            PolygonEdge   d  = edges.findEdgeEndingIn(v);
            PolygonVertex dh = helpers[d];

            if (dh.type == PolygonVertexType.merge)
            {
                insertDiagonal(v, dh);
            }
            T.Remove(d);
            // search in T to find the edge ej directly left of v
            Dictionary <PolygonEdge, PointF> interSections = getIntersections(T, v);
            // take intersections to the left of vertex & select the leftmost _edge_ from them
            PolygonEdge ej = interSections.Where(kvp => kvp.Value.X < v.X).OrderBy(kvp => kvp.Value.X).Last().Key;

            if (helpers[ej].type == PolygonVertexType.merge)
            {
                insertDiagonal(v, helpers[ej]);
            }
            helpers[ej] = v;
        }