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); }
void DrawEdge(EdgeRawData edgeList) { foreach (var edge in edgeList.edges) { Vector3 head = edgeList.vertices[edge.x]; Vector3 tail = edgeList.vertices[edge.y]; Gizmos.DrawLine(transform.TransformPoint(head), transform.TransformPoint(tail)); Gizmos.DrawSphere(transform.TransformPoint(head), scale); Gizmos.DrawSphere(transform.TransformPoint(tail), scale); } }
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); }
// public EdgeRawData rawData; public SimplifyModelData(EdgeRawData _rawData) { // rawData = _rawData; edgeGraph = new EdgeGraph(_rawData.getVertexNumber, false); }