Geo.Point GetMemberPointOnEdge(int faceIndex, int edgeIndex, bool rightHand) { int direction; if (rightHand) { direction = 1; } else { direction = -1; } hVertex v1 = mesh.faces[faceIndex].vertices[edgeIndex]; hVertex v2 = mesh.faces[faceIndex].vertices[(edgeIndex + 1) % 4]; Geo.Point midPoint = Geo.Point.ByCoordinates((v1.x + v2.x) / 2, (v1.y + v2.y) / 2, (v1.z + v2.z) / 2); Geo.Vector move = Geo.Vector.ByTwoPoints(v1.ToPoint(), v2.ToPoint()); move = move.Normalized(); move = move.Scale(offset * direction); var returnPt = (Geo.Point)midPoint.Translate(move); // Dispose /*{ * midPoint.Dispose(); * move.Dispose(); * }*/ return(returnPt); }
internal int GetAdjacentFaceIndex(hFace currentFace, int edge) { hVertex edgeV1 = currentFace.vertices[edge]; hVertex edgeV2 = currentFace.vertices[(edge + 1) % currentFace.vertices.Count]; for (int i = 0; i < faces.Count; i++) { if (faces[i] != currentFace) { if (faces[i].vertices.Contains(edgeV1) && faces[i].vertices.Contains(edgeV2)) { return(i); } } } return(-1); }
public static hMesh hMeshFromOBJ(string filepath) { string[] lines = System.IO.File.ReadAllLines(filepath); // Get Vertices List <hVertex> vertices = new List <hVertex>(); foreach (string line in lines) { if (line.Length > 0 && line[0] == 'v') { string[] values = line.Split(' '); double x = Double.Parse(values[1]); double y = Double.Parse(values[2]); double z = Double.Parse(values[3]); hVertex v = new hVertex(x, y, z); vertices.Add(v); } } // Get Faces List <hFace> faces = new List <hFace>(); foreach (string line in lines) { if (line.Length > 0 && line[0] == 'f') { string[] values = line.Split(' '); List <hVertex> verts = new List <hVertex>(); for (int j = 1; j < values.Length; j++) { int index = int.Parse(values[j].Split('/')[0]); verts.Add(vertices[index - 1]); } hFace f = new hFace(verts); faces.Add(f); } } return(new hMesh(faces)); }