示例#1
0
        private void CreateFaceModels(IFCItem item, Vector3D center)
        {
            while (item != null) {
                if (item.ifcID != IntPtr.Zero && item.noVerticesForFaces != 0 && item.noPrimitivesForFaces != 0) {
                    var positions = new Point3DCollection();
                    var normals = new Vector3DCollection();
                    if (item.verticesForFaces != null) {
                        for (int i = 0; i < item.noVerticesForFaces; i++) {
                            var point = new Point3D(item.verticesForFaces[6 * i + 0] - center.X, item.verticesForFaces[6 * i + 1] - center.Y, item.verticesForFaces[6 * i + 2] - center.Z);
                            var normal = new Vector3D(item.verticesForFaces[6 * i + 3], item.verticesForFaces[6 * i + 4], item.verticesForFaces[6 * i + 5]);
                            positions.Add(point);
                            normals.Add(normal);
                        }

                        Debug.Assert(item.verticesForFaces.Length == item.noVerticesForFaces * 6);
                    }

                    var indices = new Int32Collection();
                    if (item.indicesForFaces != null) {
                        for (int i = 0; i < 3 * item.noPrimitivesForFaces; i++) {
                            indices.Add(item.indicesForFaces[i]);
                        }
                    }

                    MeshGeometry3D meshGeometry = new MeshGeometry3D();
                    meshGeometry.Positions = positions;
                    meshGeometry.Normals = normals;
                    meshGeometry.TriangleIndices = indices;
                    MeshGeometryVisual3D mesh = new MeshGeometryVisual3D();
                    mesh.MeshGeometry = meshGeometry;
                    item.Mesh3d = mesh;
                    _meshToIfcItems[mesh] = item;
            #if DEBUG
                    OutputObj(item.ifcID.ToString(), meshGeometry);
            #endif
                    FillMeshByIfcColor(item);

                    hVp3D.Children.Add(mesh);
                }

                CreateFaceModels(item.child, center);
                item = item.next;
            }
        }
示例#2
0
		public void GetModel(MeshGeometryVisual3D mesh)
		{
			MeshBuilder mb = new MeshBuilder(false, true);

			double Hdelta = MaxHeight - MinHeight;

			for (int x = 0; x < SizeX - 1; x++)
			{
				for (int y = 0; y < SizeY - 1; y++)
				{
					if (!Points[x, y].HasValue || !Points[x, y + 1].HasValue || !Points[x + 1, y].HasValue || !Points[x + 1, y + 1].HasValue)
						continue;

					mb.AddQuad(
						new Point3D(Min.X + (x + 1) * Delta.X / (SizeX - 1), Min.Y + (y) * Delta.Y / (SizeY - 1), Points[x + 1, y].Value),
						new Point3D(Min.X + (x + 1) * Delta.X / (SizeX - 1), Min.Y + (y + 1) * Delta.Y / (SizeY - 1), Points[x + 1, y + 1].Value),
						new Point3D(Min.X + (x) * Delta.X / (SizeX - 1), Min.Y + (y + 1) * Delta.Y / (SizeY - 1), Points[x, y + 1].Value),
						new Point3D(Min.X + (x) * Delta.X / (SizeX - 1), Min.Y + (y) * Delta.Y / (SizeY - 1), Points[x, y].Value),
						new Point(0, (Points[x + 1, y].Value - MinHeight) * Hdelta),
						new Point(0, (Points[x + 1, y + 1].Value - MinHeight) * Hdelta),
						new Point(0, (Points[x, y + 1].Value - MinHeight) * Hdelta),
						new Point(0, (Points[x, y].Value - MinHeight) * Hdelta)
						);
				}
			}

			mesh.MeshGeometry = mb.ToMesh();
		}