示例#1
0
        public static EdgeGraph ConvertEdgeRawDataToGraph(EdgeRawData rawData, bool isSaveNormal)
        {
            if (!isSaveNormal || (rawData.normals == null))
            {
                return(ConvertEdgeRawDataToGraph(rawData));
            }
            else if (rawData.normals.Count == 0)
            {
                return(ConvertEdgeRawDataToGraph(rawData));
            }

            int       nodeNum  = rawData.getVertexNumber;
            EdgeGraph newGraph = new EdgeGraph(nodeNum, true);

            newGraph.InitEdgeGraphDict(nodeNum);
            for (int i = 0; i < rawData.getEdgeNumber; i++)
            {
                //get edge data
                Vector2Int edgeIndex = rawData.getEdge(i);

                //get edge vertex
                Vector3 edgeVertex1 = rawData.getVertex(edgeIndex.x);
                Vector3 edgeVertex2 = rawData.getVertex(edgeIndex.y);

                Vector3 vertexNormal1 = rawData.normals[edgeIndex.x];
                Vector3 vertexNormal2 = rawData.normals[edgeIndex.y];

                //save to graph
                newGraph.addEdge(edgeVertex1, edgeVertex2);
                newGraph.addNormal(edgeVertex1, vertexNormal1);
                newGraph.addNormal(edgeVertex2, vertexNormal2);
            }
            return(newGraph);
        }
示例#2
0
        public static EdgeGraph ConvertEdgeRawDataToGraph(EdgeRawData rawData)
        {
            int       nodeNum  = rawData.getVertexNumber;
            EdgeGraph newGraph = new EdgeGraph(nodeNum, true);

            newGraph.InitEdgeGraphDict(nodeNum);
            for (int i = 0; i < rawData.getEdgeNumber; i++)
            {
                //get edge data
                Vector2Int edgeIndex = rawData.getEdge(i);

                //get edge vertex
                Vector3 edgeVertex1 = rawData.getVertex(edgeIndex.x);
                Vector3 edgeVertex2 = rawData.getVertex(edgeIndex.y);

                //save to graph
                newGraph.addEdge(edgeVertex1, edgeVertex2);
            }
            return(newGraph);
        }
示例#3
0
 public void AddEdge(int u, int v)
 {
     edgeGraph.addEdge(u, v);
 }