public CMesh(CMesh _cmesh) { this.mesh = _cmesh.mesh.DuplicateMesh(); this.edgeInfo = _cmesh.edgeInfo; this.orig_faces = _cmesh.orig_faces; this.inner_edges = _cmesh.inner_edges; this.inner_edge_assignment = _cmesh.inner_edge_assignment; this.boundary_edges = _cmesh.boundary_edges; this.inner_boundary_edges = _cmesh.inner_boundary_edges; this.face_pairs = _cmesh.face_pairs; this.face_height_pairs = _cmesh.face_height_pairs; this.length_of_diagonal_edges = _cmesh.length_of_diagonal_edges; this.foldang = _cmesh.foldang; this.triangulated_edges = _cmesh.triangulated_edges; this.triangulated_face_pairs = _cmesh.triangulated_face_pairs; this.triangulated_face_height_pairs = _cmesh.triangulated_face_height_pairs; this.length_of_triangulated_diagonal_edges = _cmesh.length_of_triangulated_diagonal_edges; this.mountain_edges = _cmesh.mountain_edges; this.mountain_face_pairs = _cmesh.mountain_face_pairs; this.mountain_face_height_pairs = _cmesh.mountain_face_height_pairs; this.length_of_mountain_diagonal_edges = _cmesh.length_of_mountain_diagonal_edges; this.valley_edges = _cmesh.valley_edges; this.valley_face_pairs = _cmesh.valley_face_pairs; this.valley_face_height_pairs = _cmesh.valley_face_height_pairs; this.length_of_valley_diagonal_edges = _cmesh.length_of_valley_diagonal_edges; }
public static void GetStressesElemPoints(Mesh mesh, List <Vector3d> prinStresses, int nbElements, out List <Point3d> high, out List <int> highIndex, out List <Point3d> low, out double area) { List <double> vLengths = new List <double>(); List <int> indexes = new List <int>(); high = new List <Point3d>(); low = new List <Point3d>(); highIndex = new List <int>(); foreach (Vector3d v in prinStresses) { vLengths.Add(v.Length); } var sorted = vLengths .Select((x, i) => new KeyValuePair <double, int>(x, i)) .OrderByDescending(x => x.Key) .ToList(); // List<int> sortedLengths = sorted.Select(x => x.Key).ToList(); indexes = sorted.Select(x => x.Value).ToList(); indexes = indexes.Take(nbElements).ToList(); MeshFaceList faceList = mesh.Faces; //area for the high stressed element area = 0; for (int i = 0; i < faceList.Count; i++) { if (indexes.Contains(i)) { high.Add(faceList.GetFaceCenter(i)); highIndex.Add(i); //Get the area of the face Point3f pt1, pt2, pt3, pt4; faceList.GetFaceVertices(i, out pt1, out pt2, out pt3, out pt4); double a = pt1.DistanceTo(pt2); double b = pt2.DistanceTo(pt3); double c = pt3.DistanceTo(pt1); double s = (a + b + c) / 2; area += Math.Sqrt(s * (s - a) * (s - b) * (s - c)); } else { low.Add(faceList.GetFaceCenter(i)); } } }
private int GetIndicesBuffer(MeshFaceList faces, out int indicesCount, out int byteLength) { byte[] bytes = GetIndicesBytes(faces, out indicesCount); byteLength = bytes.Length; glTFLoader.Schema.Buffer indicesBuffer = new glTFLoader.Schema.Buffer() { Uri = Constants.TextBufferHeader + Convert.ToBase64String(bytes), ByteLength = bytes.Length, }; return(dummy.Buffers.AddAndReturnIndex(indicesBuffer)); }
private int GetIndicesAccessor(MeshFaceList faces, int verticesCount) { int?indicesBufferViewIdx = GetIndicesBufferView(faces, verticesCount, out float min, out float max, out int indicesCount); glTFLoader.Schema.Accessor indicesAccessor = new glTFLoader.Schema.Accessor() { BufferView = indicesBufferViewIdx, Count = indicesCount, Min = new float[] { min }, Max = new float[] { max }, Type = glTFLoader.Schema.Accessor.TypeEnum.SCALAR, ComponentType = glTFLoader.Schema.Accessor.ComponentTypeEnum.UNSIGNED_INT, ByteOffset = 0, }; return(dummy.Accessors.AddAndReturnIndex(indicesAccessor)); }
public static Topology ToTopologic(this Mesh mesh) { if (mesh == null) { return(null); } MeshVertexList ghMeshVertices = mesh.Vertices; int ghMeshVertexCount = ghMeshVertices.Count; MeshFaceList ghMeshFaces = mesh.Faces; int ghMeshFaceCount = ghMeshFaces.Count; List <Vertex> vertices = new List <Vertex>(); for (int i = 0; i < ghMeshVertexCount; ++i) { Vertex vertex = ghMeshVertices[i].ToTopologic(); vertices.Add(vertex); } List <IList <int> > indices2D = new List <IList <int> >(); for (int i = 0; i < ghMeshFaceCount; ++i) { MeshFace ghMeshFace = ghMeshFaces[i]; List <int> indices1D = new List <int>(); indices1D.Add(ghMeshFace.A); indices1D.Add(ghMeshFace.B); indices1D.Add(ghMeshFace.C); if (ghMeshFace.IsQuad) { indices1D.Add(ghMeshFace.D); } indices1D.Add(ghMeshFace.A); indices2D.Add(indices1D); } IList <Topology> topologies = Topology.ByVerticesIndices(vertices, indices2D); Cluster cluster = Cluster.ByTopologies(topologies); Topology topology = cluster.SelfMerge(); return(topology); }
public CMesh(Mesh _mesh) { this.mesh = _mesh.DuplicateMesh(); this.orig_faces = _mesh.Faces; var tri = this.InsertTriangulate(); var edges = this.mesh.TopologyEdges; List <bool> naked = new List <bool>(_mesh.GetNakedEdgePointStatus()); this.edgeInfo = new List <Char>(); for (int i = 0; i < mesh.TopologyEdges.Count; i++) { if (edges.GetConnectedFaces(i).Count() == 1) { edgeInfo.Add('B'); } if (edges.IsNgonInterior(i)) { edgeInfo.Add('T'); } else { edgeInfo.Add('U'); } } if (tri.Count != 0) { foreach (List <int> v in tri) { int ind = edges.GetEdgeIndex(v[0], v[1]); if (ind != -1) { this.edgeInfo[ind] = 'T'; } } } GetMeshFundamentalInfo(); GetFacePairBasicInfo(this); GetTriangulatedFacePairBasicInfo(this); GetMountainFacePairBasicInfo(this); GetValleyFacePairBasicInfo(this); this.inner_edge_assignment = GetInnerEdgeAssignment(); }
public override List <IfcBuildingElement> ToBuildingElementIfc(IfcStore model) { using (var transaction = model.BeginTransaction("Create Mesh Element")) { MeshFaceList faces = Mesh.Faces; MeshVertexList vertices = Mesh.Vertices; List <IfcCartesianPoint> ifcVertices = IfcTools.VerticesToIfcCartesianPoints(model, vertices); IfcFaceBasedSurfaceModel faceBasedSurfaceModel = IfcTools.CreateIfcFaceBasedSurfaceModel(model, faces, ifcVertices); var shape = IfcTools.CreateIfcShapeRepresentation(model, "Mesh"); shape.Items.Add(faceBasedSurfaceModel); var ifcRelAssociatesMaterial = IfcTools.CreateIfcRelAssociatesMaterial(model, Material.Name, Material.Grade); var buildingElements = IfcTools.CreateBuildingElements(model, ElementType, Name, shape, InsertPlanes, ifcRelAssociatesMaterial); transaction.Commit(); return(buildingElements); } }
private Topology ByMesh(Mesh ghMesh) { MeshVertexList ghMeshVertices = ghMesh.Vertices; int ghMeshVertexCount = ghMeshVertices.Count; MeshFaceList ghMeshFaces = ghMesh.Faces; int ghMeshFaceCount = ghMeshFaces.Count; List <global::Topologic.Vertex> vertices = new List <global::Topologic.Vertex>(); for (int i = 0; i < ghMeshVertexCount; ++i) { Point3f ghPoint = ghMeshVertices[i]; Vertex vertex = ByPoint(ghPoint); vertices.Add(vertex); } List <List <int> > indices2D = new List <List <int> >(); for (int i = 0; i < ghMeshFaceCount; ++i) { MeshFace ghMeshFace = ghMeshFaces[i]; List <int> indices1D = new List <int>(); indices1D.Add(ghMeshFace.A); indices1D.Add(ghMeshFace.B); indices1D.Add(ghMeshFace.C); if (ghMeshFace.IsQuad) { indices1D.Add(ghMeshFace.D); } indices1D.Add(ghMeshFace.A); indices2D.Add(indices1D); } List <Topology> topologies = Topology.ByVerticesIndices(vertices, indices2D); Cluster cluster = Cluster.ByTopologies(topologies); Topology topology = cluster.SelfMerge(); return(topology); }
private int?GetIndicesBufferView(MeshFaceList faces, int verticesCount, out float min, out float max, out int indicesCount) { if (options.UseDracoCompression) { min = currentGeometryInfo.IndicesMin; max = currentGeometryInfo.IndicesMax; indicesCount = currentGeometryInfo.IndicesCount; return(null); } int bufferIndex = 0; int byteOffset = 0; int byteLength = 0; if (binary) { byte[] bytes = GetIndicesBytes(faces, out indicesCount); byteLength = bytes.Length; byteOffset = binaryBuffer.Count; binaryBuffer.AddRange(bytes); } else { bufferIndex = GetIndicesBuffer(faces, out indicesCount, out byteLength); } glTFLoader.Schema.BufferView indicesBufferView = new glTFLoader.Schema.BufferView() { Buffer = bufferIndex, ByteOffset = byteOffset, ByteLength = byteLength, Target = glTFLoader.Schema.BufferView.TargetEnum.ELEMENT_ARRAY_BUFFER, }; min = 0; max = verticesCount - 1; return(dummy.BufferViews.AddAndReturnIndex(indicesBufferView)); }
private byte[] GetIndicesBytes(MeshFaceList faces, out int indicesCount) { List <uint> faceIndices = new List <uint>(faces.Count * 3); foreach (Rhino.Geometry.MeshFace face in faces) { if (face.IsTriangle) { faceIndices.AddRange(new uint[] { (uint)face.A, (uint)face.B, (uint)face.C }); } else { //Triangulate faceIndices.AddRange(new uint[] { (uint)face.A, (uint)face.B, (uint)face.C, (uint)face.A, (uint)face.C, (uint)face.D }); } } IEnumerable <byte> bytesEnumerable = faceIndices.SelectMany(value => BitConverter.GetBytes(value)); indicesCount = faceIndices.Count; return(bytesEnumerable.ToArray()); }
public FaceEnumerator(MeshFaceList <T> faces) { Faces = faces; }
public static IfcFaceBasedSurfaceModel CreateIfcFaceBasedSurfaceModel(IfcStore model, MeshFaceList faces, List <IfcCartesianPoint> ifcVertices) { var faceSet = model.Instances.New <IfcConnectedFaceSet>(); foreach (var meshFace in faces) { List <IfcCartesianPoint> points = new List <IfcCartesianPoint> { ifcVertices[meshFace.A], ifcVertices[meshFace.B], ifcVertices[meshFace.C] }; if (meshFace.C != meshFace.D) { points.Add(ifcVertices[meshFace.D]); } var polyLoop = model.Instances.New <IfcPolyLoop>(); polyLoop.Polygon.AddRange(points); var bound = model.Instances.New <IfcFaceOuterBound>(); bound.Bound = polyLoop; var face = model.Instances.New <IfcFace>(); face.Bounds.Add(bound); faceSet.CfsFaces.Add(face); } var faceBasedSurfaceModel = model.Instances.New <IfcFaceBasedSurfaceModel>(); faceBasedSurfaceModel.FbsmFaces.Add(faceSet); return(faceBasedSurfaceModel); }
public CMesh(Mesh _mesh, List <Char> _edgeinfo) { this.mesh = _mesh.DuplicateMesh(); this.edgeInfo = _edgeinfo; this.orig_faces = _mesh.Faces; }
public int StoreSerialized(Mesh mesh, string name) { MeshFaceList faces = mesh.Faces; MeshVertexList vertices = mesh.Vertices; MeshVertexNormalList normals = mesh.Normals; MeshTextureCoordinateList texCoords = mesh.TextureCoordinates; faces.ConvertQuadsToTriangles(); int vertexCount = vertices.Count; int triangleCount = faces.TriangleCount; Log("MeshStore[" + meshCount + "]: adding mesh with " + vertexCount + " vertices, " + triangleCount + " triangles" + (name != null && name.Length > 0 ? (" (\"" + name + "\")") : "")); meshDict.Add((ulong)output.Position); Serialize(output, MTS_FILEFORMAT_HEADER); Serialize(output, MTS_FILEFORMAT_VERSION_V4); Stream zStream = new ZlibStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, true); uint flags = MTS_SINGLE_PRECISION; if (texCoords.Count > 0) { flags |= MTS_HAS_TEXCOORDS; } if (normals.Count > 0) { flags |= MTS_HAS_NORMALS; } Serialize(zStream, flags); Serialize(zStream, (name == null) ? "" : name); Serialize(zStream, (ulong)vertexCount); Serialize(zStream, (ulong)triangleCount); for (int i = 0; i < vertexCount; ++i) { Point3f p = vertices[i]; Serialize(zStream, p.X); Serialize(zStream, p.Y); Serialize(zStream, p.Z); } if (normals.Count > 0) { for (int i = 0; i < vertexCount; ++i) { Vector3f n = normals[i]; Serialize(zStream, n.X); Serialize(zStream, n.Y); Serialize(zStream, n.Z); } } if (texCoords.Count > 0) { for (int i = 0; i < vertexCount; ++i) { Point2f uv = texCoords[i]; Serialize(zStream, uv.X); Serialize(zStream, uv.Y); } } for (int i = 0; i < triangleCount; ++i) { MeshFace face = faces[i]; if (!face.IsTriangle) { throw new Exception("Internal error: expected a triangle face!"); } Serialize(zStream, face.A); Serialize(zStream, face.B); Serialize(zStream, face.C); } zStream.Close(); return(meshCount++); }
public String StoreOBJ(Mesh mesh, string name) { MeshFaceList faces = mesh.Faces; MeshVertexList vertices = mesh.Vertices; MeshVertexNormalList normals = mesh.Normals; MeshTextureCoordinateList texCoords = mesh.TextureCoordinates; faces.ConvertQuadsToTriangles(); if (name == null || name.Length == 0) { name = "mesh" + meshCount.ToString(); } int vertexCount = vertices.Count; int triangleCount = faces.TriangleCount; Log("MeshStore[" + meshCount + "]: saving OBJ mesh with " + vertexCount + " vertices, " + triangleCount + " triangles" + "\"" + name + "\")"); //meshDict.Add((ulong)output.Position); //Serialize(output, MTS_FILEFORMAT_HEADER); //Serialize(output, MTS_FILEFORMAT_VERSION_V4); String filename = name + ".obj"; FileStream output = new FileStream(Path.Combine(basePath, filename), FileMode.Create); StreamWriter stream = new StreamWriter(output); stream.WriteLine("# Object " + name); stream.WriteLine("# Generated by the Mitsuba Rhino plugin."); stream.WriteLine("# Vertices: " + vertexCount.ToString()); stream.WriteLine("# Faces: " + triangleCount.ToString()); for (int i = 0; i < vertexCount; ++i) { Point3f p = vertices[i]; stream.WriteLine("v " + p.X.ToString() + " " + p.Y.ToString() + " " + p.Z.ToString()); } if (normals.Count > 0) { for (int i = 0; i < vertexCount; ++i) { Vector3f n = normals[i]; stream.WriteLine("vn " + n.X.ToString() + " " + n.Y.ToString() + " " + n.Z.ToString()); } } if (texCoords.Count > 0) { for (int i = 0; i < vertexCount; ++i) { Point2f uv = texCoords[i]; stream.WriteLine("vt " + uv.X.ToString() + " " + uv.Y.ToString()); } } for (int i = 0; i < triangleCount; ++i) { MeshFace face = faces[i]; if (!face.IsTriangle) { throw new Exception("Internal error: expected a triangle face!"); } String a = (face.A + 1).ToString(); String b = (face.B + 1).ToString(); String c = (face.C + 1).ToString(); if (texCoords.Count > 0) { stream.WriteLine("f " + a + "/" + a + "/" + a + " " + b + "/" + b + "/" + b + " " + c + "/" + c + "/" + c); } else { stream.WriteLine("f " + a + "//" + a + " " + b + "//" + b + " " + c + "//" + c); } } stream.Close(); meshCount++; return(filename); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Mesh mshin = new Mesh(); if (!DA.GetData(0, ref mshin)) { return; } CResults results = null; if (!DA.GetData(1, ref results)) { return; } int outputType = 0; if (!DA.GetData(2, ref outputType)) { outputType = 0; } Grasshopper.DataTree <double> avgI = new Grasshopper.DataTree <double>(); List <double> areas = new List <double>(); MeshFaceList mshfaces = mshin.Faces; for (int m = 0; m < mshfaces.Count; m++) { MeshFace fc = mshfaces[m]; int spA = fc.A; int spB = fc.B; int spC = fc.C; int spD = fc.D; int intvert = 3; double quadmulti = 0; if (fc.IsQuad) { intvert = 4; quadmulti = 1; } Grasshopper.Kernel.Data.GH_Path ghpath = new Grasshopper.Kernel.Data.GH_Path(m); List <double> sp_I = new List <double>(); switch (outputType) { case 0: avgI.Add((results.I_total[spA] + results.I_total[spB] + results.I_total[spC] + (results.I_total[spD] * quadmulti)) / intvert, ghpath); break; case 1: avgI.Add((results.Ib_total[spA] + results.Ib_total[spB] + results.Ib_total[spC] + (results.Ib_total[spD] * quadmulti)) / intvert, ghpath); break; case 2: avgI.Add((results.Id_total[spA] + results.Id_total[spB] + results.Id_total[spC] + (results.Id_total[spD] * quadmulti)) / intvert, ghpath); break; case 3: for (int t = 0; t < results.I_hourly.ColumnCount; t++) { avgI.Add((results.I_hourly[spA, t] + results.I_hourly[spB, t] + results.I_hourly[spC, t] + (results.I_hourly[spD, t] * quadmulti)) / intvert, ghpath); } break; case 4: for (int t = 0; t < results.Ib_hourly.ColumnCount; t++) { avgI.Add((results.Ib_hourly[spA, t] + results.Ib_hourly[spB, t] + results.Ib_hourly[spC, t] + (results.Ib_hourly[spD, t] * quadmulti)) / intvert, ghpath); } break; case 5: for (int t = 0; t < results.Id_hourly.ColumnCount; t++) { avgI.Add((results.Id_hourly[spA, t] + results.Id_hourly[spB, t] + results.Id_hourly[spC, t] + (results.Id_hourly[spD, t] * quadmulti)) / intvert, ghpath); } break; case 6: for (int t = 0; t < results.Ib_hourly.ColumnCount; t++) { int shdwcount = 0; if (results.Ib_hourly[spA, t] == 0) { shdwcount++; } if (results.Ib_hourly[spB, t] == 0) { shdwcount++; } if (results.Ib_hourly[spC, t] == 0) { shdwcount++; } if (results.Ib_hourly[spD, t] == 0) { shdwcount++; } if (shdwcount > 1) { avgI.Add(0, ghpath); } else { avgI.Add(1, ghpath); } } break; } areas.Add(CMisc.getMeshFaceArea(m, mshin)); } DA.SetDataTree(0, avgI); DA.SetDataList(1, areas); }
public CMesh(Mesh _mesh, List <Line> M, List <Line> V, List <Line> T) { this.mesh = _mesh.DuplicateMesh(); this.mesh.FaceNormals.ComputeFaceNormals(); this.orig_faces = _mesh.Faces; var tri = this.InsertTriangulate(); var edges = mesh.TopologyEdges; var verts = mesh.TopologyVertices; this.edgeInfo = new List <Char>(); for (int i = 0; i < edges.Count; i++) { if (edges.IsNgonInterior(i)) { edgeInfo.Add('T'); } else { edgeInfo.Add('U'); } } foreach (Line m in M) { Point3d a = m.From; Point3d b = m.To; int found = 0; int vertsCount = verts.Count; int j = 0; int fromIndex = -1; int toIndex = -1; while (found != 2 && j < vertsCount) { Point3d p = verts[j]; if (p.DistanceTo(a) < 0.1) { fromIndex = j; found++; } else if (p.DistanceTo(b) < 0.1) { toIndex = j; found++; } j++; } int ind = edges.GetEdgeIndex(fromIndex, toIndex); if (ind != -1) { edgeInfo[ind] = 'M'; } } foreach (Line v in V) { Point3d a = v.From; Point3d b = v.To; int found = 0; int vertsCount = verts.Count; int j = 0; int fromIndex = -1; int toIndex = -1; while (found != 2 && j < vertsCount) { Point3d p = verts[j]; if (p.DistanceTo(a) < 0.1) { fromIndex = j; found++; } else if (p.DistanceTo(b) < 0.1) { toIndex = j; found++; } j++; } int ind = edges.GetEdgeIndex(fromIndex, toIndex); if (ind != -1) { edgeInfo[ind] = 'V'; } } if (tri.Count != 0) { foreach (List <int> v in tri) { int ind = edges.GetEdgeIndex(v[0], v[1]); if (ind != -1) { this.edgeInfo[ind] = 'T'; } } } foreach (Line t in T) { Point3d a = t.From; Point3d b = t.To; int found = 0; int vertsCount = verts.Count; int j = 0; int fromIndex = -1; int toIndex = -1; while (found != 2 && j < vertsCount) { Point3d p = verts[j]; if (p.DistanceTo(a) < 0.1) { fromIndex = j; found++; } else if (p.DistanceTo(b) < 0.1) { toIndex = j; found++; } j++; } int ind = edges.GetEdgeIndex(fromIndex, toIndex); if (ind != -1) { edgeInfo[ind] = 'T'; } } List <bool> naked = new List <bool>(_mesh.GetNakedEdgePointStatus()); for (int i = 0; i < mesh.TopologyEdges.Count; i++) { if (edges.GetConnectedFaces(i).Count() == 1) { this.edgeInfo[i] = 'B'; } } GetMeshFundamentalInfo(); GetTriangulatedFacePairBasicInfo(this); GetMountainFacePairBasicInfo(this); GetValleyFacePairBasicInfo(this); this.inner_edge_assignment = GetInnerEdgeAssignment(); }
public Mesh() { Halfedges = new MeshHalfedgeList(this); Vertices = new MeshVertexList(this); Faces = new MeshFaceList(this); }
public override List <IfcReinforcingElement> ToReinforcingElementIfc(IfcStore model) { using (var transaction = model.BeginTransaction("Create Mesh Element")) { var rebars = new List <IfcReinforcingElement>(); switch (SpacingType) { case RebarSpacingType.NormalSpacing: { MeshFaceList faces = OriginRebarShape.RebarMesh.Faces; MeshVertexList vertices = OriginRebarShape.RebarMesh.Vertices; List <IfcCartesianPoint> ifcVertices = IfcTools.VerticesToIfcCartesianPoints(model, vertices); IfcFaceBasedSurfaceModel faceBasedSurfaceModel = IfcTools.CreateIfcFaceBasedSurfaceModel(model, faces, ifcVertices); var shape = IfcTools.CreateIfcShapeRepresentation(model, "Mesh"); shape.Items.Add(faceBasedSurfaceModel); var ifcRelAssociatesMaterial = IfcTools.CreateIfcRelAssociatesMaterial(model, Material.Name, Material.Grade); foreach (var insertPlane in RebarInsertPlanes) { var rebar = model.Instances.New <IfcReinforcingBar>(); rebar.Name = "Rebar"; rebar.NominalDiameter = Diameter; rebar.BarLength = (int)Math.Round(OriginRebarShape.RebarCurve.GetLength()); rebar.SteelGrade = Material.Grade; IfcTools.ApplyRepresentationAndPlacement(model, rebar, shape, insertPlane); ifcRelAssociatesMaterial.RelatedObjects.Add(rebar); rebars.Add(rebar); } break; } case RebarSpacingType.CustomSpacing: for (int i = 0; i < RebarGroupMesh.Count; i++) { MeshFaceList faces = RebarGroupMesh[i].Faces; MeshVertexList vertices = RebarGroupMesh[i].Vertices; List <IfcCartesianPoint> ifcVertices = IfcTools.VerticesToIfcCartesianPoints(model, vertices); IfcFaceBasedSurfaceModel faceBasedSurfaceModel = IfcTools.CreateIfcFaceBasedSurfaceModel(model, faces, ifcVertices); var shape = IfcTools.CreateIfcShapeRepresentation(model, "Mesh"); shape.Items.Add(faceBasedSurfaceModel); var ifcRelAssociatesMaterial = IfcTools.CreateIfcRelAssociatesMaterial(model, Material.Name, Material.Grade); var rebar = model.Instances.New <IfcReinforcingBar>(); rebar.Name = "Rebar"; rebar.NominalDiameter = Diameter; rebar.BarLength = (int)Math.Round(RebarGroupCurves[i].GetLength()); rebar.SteelGrade = Material.Grade; IfcTools.ApplyRepresentationAndPlacement(model, rebar, shape, Plane.WorldXY); ifcRelAssociatesMaterial.RelatedObjects.Add(rebar); rebars.Add(rebar); } break; default: throw new ArgumentException("Spacing type not recognized"); } transaction.Commit(); return(rebars); } }