public Triangle(TriangleVertex nd1, TriangleVertex nd2, TriangleVertex nd3) { vetices[0] = nd1; vetices[1] = nd2; vetices[2] = nd3; index = new int[0]; }
private void GetVertexInZone(TriangleVertex node, ref int column, ref int row) { double X, Y; X = node.Location.X - bounds.X; column = (int)(X / zonesize); Y = node.Location.Y - bounds.Y; row = (int)(Y / zonesize); }
public Triangle(TriangleVertex nd1, TriangleVertex nd2, TriangleVertex nd3, int node1Index, int node2Index, int node3Index) { vetices[0] = nd1; vetices[1] = nd2; vetices[2] = nd3; index = new int[3]; index[0] = node1Index; index[1] = node2Index; index[2] = node3Index; }
public void ZoneTheModel(int zoneDensity) { try { int numZones = numZones = (int)(((meshmodel.TriangleIndices.Count / 3) * 1.2 / zoneDensity) + 1); double zoneArea = (bounds.SizeX * bounds.SizeY) / numZones; zonesize = System.Math.Sqrt(zoneArea); zonecountX = (int)((bounds.SizeX / zonesize) + 1); zonecountY = (int)((bounds.SizeY / zonesize) + 1); numZones = zonecountX * zonecountY; zonecollection = new List <TriZone>(numZones) { }; for (int i = 0; i < numZones; i++) { zonecollection.Add(new TriZone(zoneDensity)); } int[] col = new int[3]; int[] row = new int[3]; for (int p = 0; p < meshmodel.TriangleIndices.Count - 3; p++) { Vector3D vN = KneeInnovation3D.EntityTools.MeshGeometryFunctions.CalculateNorms(meshmodel.Positions[meshmodel.TriangleIndices[p]], meshmodel.Positions[meshmodel.TriangleIndices[p + 1]], meshmodel.Positions[meshmodel.TriangleIndices[p + 2]]); TriangleVertex t = new TriangleVertex(meshmodel.Positions[meshmodel.TriangleIndices[p]], vN); TriangleVertex t1 = new TriangleVertex(meshmodel.Positions[meshmodel.TriangleIndices[p + 1]], vN); TriangleVertex t2 = new TriangleVertex(meshmodel.Positions[meshmodel.TriangleIndices[p + 2]], vN); GetVertexInZone(t, ref col[0], ref row[0]); GetVertexInZone(t1, ref col[1], ref row[1]); GetVertexInZone(t2, ref col[2], ref row[2]); System.Array.Sort(col); System.Array.Sort(row); for (int c = col[0]; c <= col[col.Length - 1]; c++) { for (int r = row[0]; r <= row[row.Length - 1]; r++) { int zn = (r * zonecountX) + c; Triangle tri = new Triangle(t, t1, t2); zonecollection[zn].Triangles.Add(tri); } } p++; p++; } for (int i = 0; i < numZones; i++) { zonecollection[i].Triangles.TrimExcess(); } } catch { zonecollection = new List <TriZone> { }; throw; } }