public sMesh TosMesh(Mesh rhm) { Mesh rm = EnsureTriangulated(rhm); rm.FaceNormals.ComputeFaceNormals(); rm.Normals.ComputeNormals(); sMesh sm = new sMesh(); for (int i = 0; i < rm.Vertices.Count; ++i) { sm.SetVertex(i, new sXYZ(rm.Vertices[i].X, rm.Vertices[i].Y, rm.Vertices[i].Z)); sm.vertices[i].normal = this.TosXYZ(rm.Normals[i]); if (rm.VertexColors[i] != null) { sm.vertices[i].color = sColor.FromWinColor(rm.VertexColors[i]); } } for (int i = 0; i < rm.Faces.Count; ++i) { sm.SetFace(i, rm.Faces[i].A, rm.Faces[i].B, rm.Faces[i].C); sm.faces[i].normal = this.TosXYZ(rm.FaceNormals[i]); } return(sm); }
internal sMesh TosMesh(List <double> triVerticeInfo, sColor scol) { //nine conseq sMesh sm = new sMesh(); int faceCount = (int)(triVerticeInfo.Count / 9); int verID = 0; int infoID = 0; for (int i = 0; i < faceCount; ++i) { sm.SetVertex(verID + 0, new sXYZ(triVerticeInfo[infoID + 0], triVerticeInfo[infoID + 1], triVerticeInfo[infoID + 2]), scol); sm.SetVertex(verID + 1, new sXYZ(triVerticeInfo[infoID + 3], triVerticeInfo[infoID + 4], triVerticeInfo[infoID + 5]), scol); sm.SetVertex(verID + 2, new sXYZ(triVerticeInfo[infoID + 6], triVerticeInfo[infoID + 7], triVerticeInfo[infoID + 8]), scol); sm.SetFace(i, verID + 0, verID + 1, verID + 2); verID += 3; infoID += 9; } sm.ComputeNormals(); return(sm); }
internal sMesh TosMesh(Dyn.Mesh dym) { sMesh sm = new sMesh(); for (int i = 0; i < dym.VertexPositions.Length; ++i) { sm.SetVertex(i, new sXYZ(dym.VertexPositions[i].X, dym.VertexPositions[i].Y, dym.VertexPositions[i].Z)); // if (rm.VertexColors[i] != null) // { // sm.vertices[i].color = sColor.FromWinColor(rm.VertexColors[i]); // } } for (int i = 0; i < dym.FaceIndices.Length; ++i) { sm.SetFace(i, (int)dym.FaceIndices[i].A, (int)dym.FaceIndices[i].B, (int)dym.FaceIndices[i].C); } return(sm); }
public sMesh ConstructBeamColorMesh(sRange dataRange, eColorMode colorMode, sRange threshold, double du) { sMesh sm = new sMesh(); int vertexID = 0; for (int i = 0; i < this.results.Count; ++i) { sFrameResult br = this.results[i]; for (int j = 0; j < br.sectionResults.Count; ++j) { sFrameSectionResult sr = br.sectionResults[j]; sColor vcol = this.GetBeamResultColor(dataRange, colorMode, i, j, 255, threshold); sXYZ deflectionVec = du * (sr.deflection_mm * 0.001); sXYZ deflectedPt = sr.location + deflectionVec; sm.SetVertex(vertexID, deflectedPt, vcol); //or //sm.SetVertex(vertexID, sr.point, vcol); sr.ID = vertexID; vertexID++; } } int vertexCountPerFace = this.results[0].sectionResults.Count; int faceIndex = 0; for (int i = 0; i < this.results.Count - 1; ++i) { sFrameResult br_this = this.results[i]; sFrameResult br_next = this.results[i + 1]; for (int j = 0; j < br_this.sectionResults.Count; ++j) { int id0 = 0; int id1 = 0; int id2 = 0; int id3 = 0; if (j < br_this.sectionResults.Count - 1) { id0 = br_this.sectionResults[j].ID; id1 = br_next.sectionResults[j].ID; id2 = br_next.sectionResults[j + 1].ID; id3 = br_this.sectionResults[j + 1].ID; } else { id0 = br_this.sectionResults[j].ID; id1 = br_next.sectionResults[j].ID; id2 = br_next.sectionResults[0].ID; id3 = br_this.sectionResults[0].ID; } sm.SetFace(faceIndex, faceIndex + 1, id0, id1, id2, id3); faceIndex += 2; } } sm.ComputeNormals(); return(sm); }