//FIND INDICES OF FIXED VERTICES /*find the corresponding indices for the fixed points in the pMesh */ public List <int> findPtIndices(PlanktonMesh pMesh, List <Point3d> fixedPts, bool isUnitmm) { List <int> fixityIndices = new List <int>(); int numDec = 3; if (isUnitmm) { numDec = 1; } //Create a list of vertex points with rounded off coordinate values List <Point3d> verticesPts = new List <Point3d>(); for (int j = 0; j < pMesh.Vertices.Count; j++) { verticesPts.Add(new Point3d(Math.Round(pMesh.Vertices[j].X, numDec), Math.Round(pMesh.Vertices[j].Y, numDec), Math.Round(pMesh.Vertices[j].Z, numDec))); } //Check against fixed points foreach (Point3d pt in fixedPts) { Point3d ptDec = new Point3d(Math.Round(pt.X, numDec), Math.Round(pt.Y, numDec), Math.Round(pt.Z, numDec)); for (int i = 0; i < pMesh.Vertices.Count; i++) { //compareTo returns 0 if identical if (ptDec.CompareTo(verticesPts[i]) == 0) { fixityIndices.Add(i); continue; } } } return(fixityIndices); }
//create plankton mesh from points and polygons public PlanktonMesh createPlanktonMesh(List <Point3d> list_pt_vertices, List <Polyline> list_pl_facePolygons) { //Create plankton mesh PlanktonMesh pMesh = new PlanktonMesh(); //Add verticesXYZ foreach (Point3d pt in list_pt_vertices) { pMesh.Vertices.Add(pt.X, pt.Y, pt.Z); } //Add faces from polylines foreach (Polyline pl in list_pl_facePolygons) { List <Point3d> list_pt_face = new List <Point3d>(); for (int i = 0; i < pl.Count - 1; i++) { list_pt_face.Add(pl[i]); } //decrease accuracy to specified number of decimals int numDec = 3; List <int> list_int_faceIndices = new List <int>(); for (int j = 0; j < list_pt_face.Count; j++) { Point3d facePtNew = new Point3d(Math.Round(list_pt_face[j].X, numDec), Math.Round(list_pt_face[j].Y, numDec), Math.Round(list_pt_face[j].Z, numDec)); for (int k = 0; k < list_pt_vertices.Count; k++) { Point3d vertexPtNew = new Point3d(Math.Round(list_pt_vertices[k].X, numDec), Math.Round(list_pt_vertices[k].Y, numDec), Math.Round(list_pt_vertices[k].Z, numDec)); if (facePtNew.CompareTo(vertexPtNew) == 0) { list_int_faceIndices.Add(k); break; } } } pMesh.Faces.AddFace(list_int_faceIndices); } return(pMesh); }