public static Wire ToTopologic(PolylineCurve polylineCurve) { int count = polylineCurve.PointCount; if (count < 1) { return(null); } List <Vertex> vertices = new List <Vertex>(); List <int> indices = new List <int>(); for (int i = 0; i < count; ++i) { Vertex vertex = polylineCurve.Point(i).ToTopologic(); vertices.Add(vertex); indices.Add(i); } if (polylineCurve.IsClosed) { List <IList <int> > listOfIndices = new List <IList <int> >(); listOfIndices.Add(indices); return(Topology.ByVerticesIndices(vertices, listOfIndices)[0].Wires[0]); } else { List <IList <int> > listOfIndices = new List <IList <int> >(); listOfIndices.Add(indices); return(Topology.ByVerticesIndices(vertices, listOfIndices)[0] as Wire); } }
public static Topology ToTopologic(this Mesh mesh) { if (mesh == null) { return(null); } MeshVertexList ghMeshVertices = mesh.Vertices; int ghMeshVertexCount = ghMeshVertices.Count; MeshFaceList ghMeshFaces = mesh.Faces; int ghMeshFaceCount = ghMeshFaces.Count; List <Vertex> vertices = new List <Vertex>(); for (int i = 0; i < ghMeshVertexCount; ++i) { Vertex vertex = ghMeshVertices[i].ToTopologic(); vertices.Add(vertex); } List <IList <int> > indices2D = new List <IList <int> >(); for (int i = 0; i < ghMeshFaceCount; ++i) { MeshFace ghMeshFace = ghMeshFaces[i]; List <int> indices1D = new List <int>(); indices1D.Add(ghMeshFace.A); indices1D.Add(ghMeshFace.B); indices1D.Add(ghMeshFace.C); if (ghMeshFace.IsQuad) { indices1D.Add(ghMeshFace.D); } indices1D.Add(ghMeshFace.A); indices2D.Add(indices1D); } IList <Topology> topologies = Topology.ByVerticesIndices(vertices, indices2D); Cluster cluster = Cluster.ByTopologies(topologies); Topology topology = cluster.SelfMerge(); return(topology); }
private Topology ByMesh(Mesh ghMesh) { MeshVertexList ghMeshVertices = ghMesh.Vertices; int ghMeshVertexCount = ghMeshVertices.Count; MeshFaceList ghMeshFaces = ghMesh.Faces; int ghMeshFaceCount = ghMeshFaces.Count; List <global::Topologic.Vertex> vertices = new List <global::Topologic.Vertex>(); for (int i = 0; i < ghMeshVertexCount; ++i) { Point3f ghPoint = ghMeshVertices[i]; Vertex vertex = ByPoint(ghPoint); vertices.Add(vertex); } List <List <int> > indices2D = new List <List <int> >(); for (int i = 0; i < ghMeshFaceCount; ++i) { MeshFace ghMeshFace = ghMeshFaces[i]; List <int> indices1D = new List <int>(); indices1D.Add(ghMeshFace.A); indices1D.Add(ghMeshFace.B); indices1D.Add(ghMeshFace.C); if (ghMeshFace.IsQuad) { indices1D.Add(ghMeshFace.D); } indices1D.Add(ghMeshFace.A); indices2D.Add(indices1D); } List <Topology> topologies = Topology.ByVerticesIndices(vertices, indices2D); Cluster cluster = Cluster.ByTopologies(topologies); Topology topology = cluster.SelfMerge(); return(topology); }