public static float GetFaceArea(this ITVFace face, IList <IPoint3> verts) { // get all vert indices from this face int[] arrVertIndices = face.GetAllVerts(); // get the IPoints from the vertlist // since all max sdk interface are using the IDisposable interface // you have to call dispose, they will be not handled by the garbage collection using (IPoint3 v0 = verts[arrVertIndices[0]]) using (IPoint3 v1 = verts[arrVertIndices[1]]) using (IPoint3 v2 = verts[arrVertIndices[2]]) { // build the edge vestors and return the result using (IPoint3 v1v0 = v1.Subtract(v0)) using (IPoint3 v2v1 = v2.Subtract(v1)) return(v1v0.CrossProduct(v2v1).GetFaceArea()); } }
/// <summary> /// get all vert indices /// </summary> /// <param name="face"></param> /// <returns></returns> public static int[] GetAllVerts(this ITVFace face) { return(new[] { (int)face.GetTVert(0), (int)face.GetTVert(1), (int)face.GetTVert(2) }); }