예제 #1
0
        /// <summary>
        /// QL4BIM GeometryOperation Function
        /// </summary>
        /// <param name="elements"></param>
        /// <param name="xModelContext"></param>
        /// <returns></returns>
        public static List <TriangleMesh> CreateTriangleMeshes(List <IIfcProduct> elements, Xbim3DModelContext xModelContext)
        {
            var resList = new List <TriangleMesh>();

            foreach (var item in elements)
            {
                //  var mesh = GeometryHandler.WriteTriangles(item, xModelContext, new XbimMatrix3D())

                var mesh = GeometryHandler.WriteAllTriangles(item, xModelContext, new XbimMatrix3D());


                // Transformation
                // var vertices = jObject.SelectToken("vertices").ToList().Select(value => value.Value<double>()).ToArray();
                // var indices = jObject.SelectToken("faces").ToList().Select(value => value.Value<int>()).ToArray();
                // var faceSet = new IndexedFaceSet(item.Id.ToString(), indices, vertices);

                var vertices = new List <Tuple <double, double, double> >();

                // var posList = new List<double>();
                foreach (var pos in mesh.Positions)
                {
                    vertices.Add(new Tuple <double, double, double>(pos.X, pos.Y, pos.Z));
                    // posList.Add(pos.X);
                    // posList.Add(pos.Y);
                    // posList.Add(pos.Z);
                }

                var indices = new List <Tuple <int, int, int> >();
                for (int i = 0; i < mesh.TriangleIndices.Count; i = i + 3)
                {
                    indices.Add(new Tuple <int, int, int>(mesh.TriangleIndices[i], mesh.TriangleIndices[i + 1], mesh.TriangleIndices[i + 2]));
                }

                if (vertices.Count == 0 || indices.Count == 0)
                {
                    continue;
                }

                var faceSet = new IndexedFaceSet(vertices.ToArray(), indices.ToArray(), item.GlobalId.ToString(), 1);

                // var faceSet = new IndexedFaceSet(item.GlobalId.ToString(), mesh.TriangleIndices.ToArray(), posList.ToArray());
                resList.Add(faceSet.CreateMesh());
            }

            return(resList);
        }
        private List <TriangleMesh> CreateTriangleMeshes(ModelInfo modelInfo)
        {
            var elements1 = modelInfo.GetCurrentElements();
            var resList   = new List <TriangleMesh>();

            foreach (var item in elements1)
            {
                var jObject = item.AttributeGroups["geometry"]["threejs"] as JObject;
                if (jObject == null)
                {
                    continue;
                }

                // Transformation
                var vertices = jObject.SelectToken("vertices").ToList().Select(value => value.Value <double>()).ToArray();
                var indices  = jObject.SelectToken("faces").ToList().Select(value => value.Value <int>()).ToArray();
                // var faceSet = new IndexedFaceSet(item.Id.ToString(), indices, vertices);
                var faceSet = new IndexedFaceSet(item.Id.ToString(), indices, vertices);
                resList.Add(faceSet.CreateMesh());
            }

            return(resList);
        }
        private List<TriangleMesh> CreateTriangleMeshes(ModelInfo modelInfo)
        {
            var elements1 = modelInfo.GetCurrentElements();
            var resList = new List<TriangleMesh>();

            foreach (var item in elements1)
            {
                var jObject = item.AttributeGroups["geometry"]["threejs"] as JObject;
                if (jObject == null) continue;

                // var vertices = jObject.SelectToken("vertices").ToList().Select(value => value.Value<double>()).ToArray();

                // Transformation 
                var vertices = jObject.SelectToken("vertices").ToList().Select(value => value.Value<double>()).ToArray();
                var indices = jObject.SelectToken("faces").ToList().Select(value => value.Value<int>()).ToArray();
                // var faceSet = new IndexedFaceSet(item.Id.ToString(), indices, vertices);
                var faceSet = new IndexedFaceSet(item.Id.ToString(), indices, vertices);
                resList.Add(faceSet.CreateMesh());
            }

            return resList;
        }
예제 #4
0
        private static TriangleMesh CreateTriangleMeshes(string id, double[] vertices, int[] indices)
        {
            var faceSet = new IndexedFaceSet(id, indices, vertices);

            return(faceSet.CreateMesh());
        }