Exemple #1
0
            bool IsBridgeValid(SimpleClosedPath exterior, ExtendedEdge bridge)
            {
                foreach (Edge e in exterior.AllEdges())
                {
                    List <Vector2> intersections = bridge.GetIntersectionsWith(e);

                    if (intersections.Count > 0 && !e.HasEqualEndpoint(bridge))
                    {
                        return(false);
                    }
                }

                return(true);
            }
Exemple #2
0
            bool IsJoiningHole(SimpleClosedPath path, Edge joiningEdge)
            {
                foreach (Edge e in path.AllEdges())
                {
                    List <Vector2> intersections = joiningEdge.GetIntersectionsWith(e);

                    if (intersections.Count > 0 && !e.HasEqualEndpoint(joiningEdge))
                    {
                        return(false);
                    }
                }

                return(true);
            }
    void DrawPolygons()
    {
        float show = System.Convert.ToSingle(showGradients);

        float z = 3.0f;

        for (int polygonIndex = 0; polygonIndex < polygons.Count; ++polygonIndex)
        {
            if (!showOperands && polygonIndex <= 1)
            {
                continue;
            }
            if (!showResult && polygonIndex == 2)
            {
                continue;
            }

            Polygon polygon      = polygons[polygonIndex];
            Color   polygonColor = colors[polygonIndex];

            int   depth    = 0;
            float maxDepth = 3.0f;

            for (int pathIndex = 0; pathIndex < polygon.GetNumPaths(); ++pathIndex)
            {
                SimpleClosedPath path = polygon.GetPath(pathIndex);

                maxDepth = path.GetNumEdges() + 1;

                z -= 0.05f;

                //foreach (Edge edge in path.OwnEdgesOnly())
                foreach (Edge edge in path.AllEdges())
                {
                    GL.Begin(GL.LINES);
                    lineMat.SetPass(0);
                    GL.Color(polygonColor * (1.0f - ((float)depth / maxDepth) * show));
                    GL.Vertex3(edge.From.x, edge.From.y, z);
                    GL.Color(polygonColor * (1.0f - ((float)++depth / maxDepth) * show));
                    GL.Vertex3(edge.To.x, edge.To.y, z);
                    GL.End();
                }
            }
        }

        if (showResult || showOperands)
        {
            return;
        }

        z = 3.0f;

        for (int i = 0; i < edges.Count; ++i)
        {
            Edge edge = edges[i].Edge;

            Color color = !edges[i].InOut ? Color.white : Color.green;

            if (edges[i].Type == EdgeType.NON_CONTRIBUTING)
            {
                color = Color.red;
            }
            else if (edges[i].Type == EdgeType.SAME_TRANSITION)
            {
                color = Color.blue;
            }

            if (edges[i].Final)
            {
                color = edges[i].Sign;
            }

            Vector2 middle = Vector2.Lerp(edge.From, edge.To, 0.75f);

            z -= 0.05f;

            GL.Begin(GL.LINES);
            lineMat.SetPass(0);
            GL.Color(color);
            GL.Vertex3(edge.From.x, edge.From.y, z);
            GL.Vertex3(middle.x, middle.y, z);
            GL.Vertex3(middle.x, middle.y, z);
            GL.Color(edges[i].Final ? color : color * 0.25f);
            GL.Vertex3(edge.To.x, edge.To.y, z);
            GL.End();
        }
    }