Exemplo n.º 1
0
        public static WpfMeshGeometry3D GetGeometry(IPersistEntity selection, XbimMatrix3D modelTransform, WpfMaterial mat)
        {
            var tgt = new WpfMeshGeometry3D(mat, mat);

            tgt.BeginUpdate();
            using (var geomstore = selection.Model.GeometryStore)
            {
                using (var geomReader = geomstore.BeginRead())
                {
                    foreach (var shapeInstance in geomReader.ShapeInstancesOfEntity(selection).Where(x => x.RepresentationType == XbimGeometryRepresentationType.OpeningsAndAdditionsIncluded))
                    {
                        IXbimShapeGeometryData shapegeom = geomReader.ShapeGeometry(shapeInstance.ShapeGeometryLabel);
                        if (shapegeom.Format != (byte)XbimGeometryType.PolyhedronBinary)
                        {
                            continue;
                        }
                        var transform = shapeInstance.Transformation * modelTransform;
                        tgt.Add(
                            shapegeom.ShapeData,
                            shapeInstance.IfcTypeId,
                            shapeInstance.IfcProductLabel,
                            shapeInstance.InstanceLabel,
                            transform,
                            (short)selection.Model.UserDefinedId
                            );
                    }
                }
            }
            tgt.EndUpdate();
            return(tgt);
        }
Exemplo n.º 2
0
 // attempting to load the shapeGeometry from the database; 
 // 
 internal static WpfMeshGeometry3D GetRepresentationGeometry(Material mat, IEnumerable<IIfcProduct> productContexts, IEnumerable<int> representationLabels, IModel selModel, XbimMatrix3D modelTransform, bool wcsAdjust)
 {
     var placementTree = new XbimPlacementTree(selModel, wcsAdjust);
     var tgt = new WpfMeshGeometry3D(mat, mat);
     tgt.BeginUpdate();
     using (var geomstore = selModel.GeometryStore)
     using (var geomReader = geomstore.BeginRead())
     {
         var matchingGeometries = geomReader.ShapeGeometries.Where(x => representationLabels.Contains(x.IfcShapeLabel));
         foreach (var contextualProduct in productContexts)
         {
             var trsf = placementTree[contextualProduct.ObjectPlacement.EntityLabel];
             foreach (IXbimShapeGeometryData shapegeom in matchingGeometries)
             {
                 if (shapegeom.Format != (byte)XbimGeometryType.PolyhedronBinary)
                     continue;
                 // Debug.WriteLine($"adding {shapegeom.ShapeLabel} at {DateTime.Now.ToLongTimeString()}");
                 var transform = trsf * modelTransform;
                 tgt.Add(
                     shapegeom.ShapeData,
                     453, // shapeInstance.IfcTypeId,
                     contextualProduct.EntityLabel, // shapeInstance.IfcProductLabel,
                     -1, // shapeInstance.InstanceLabel,
                     transform,
                     (short)contextualProduct.Model.UserDefinedId
                 );
             }
         }
     }
     tgt.EndUpdate();
     return tgt;
 }
Exemplo n.º 3
0
        // attempting to load the shapeGeometry from the database;
        //
        public static WpfMeshGeometry3D GetGeometry(IIfcShapeRepresentation rep, XbimModelPositioningCollection positions, Material mat)
        {
            var placementTree = new XbimPlacementTree(rep.Model);

            var tgt = new WpfMeshGeometry3D(mat, mat);

            tgt.BeginUpdate();
            var prodShapes = rep.OfProductRepresentation.OfType <IIfcProductDefinitionShape>();

            foreach (var prodShape in prodShapes)
            {
                if (prodShape?.ShapeOfProduct == null)
                {
                    continue;
                }
                foreach (var contextualProduct in prodShape?.ShapeOfProduct)
                {
                    var trsf           = placementTree[contextualProduct.ObjectPlacement.EntityLabel];
                    var modelTransform = positions[rep.Model].Transform;
                    using (var geomstore = rep.Model.GeometryStore)
                        using (var geomReader = geomstore.BeginRead())
                        {
                            var dispitems = rep.Items.Select(x => x.EntityLabel);
                            var r2        = geomReader.ShapeGeometries.Where(x => dispitems.Contains(x.IfcShapeLabel));

                            foreach (IXbimShapeGeometryData shapegeom in r2)
                            {
                                if (shapegeom.Format != (byte)XbimGeometryType.PolyhedronBinary)
                                {
                                    continue;
                                }
                                // Debug.WriteLine($"adding {shapegeom.ShapeLabel} at {DateTime.Now.ToLongTimeString()}");
                                var transform = trsf * modelTransform;
                                tgt.Add(
                                    shapegeom.ShapeData,
                                    453,                           // shapeInstance.IfcTypeId,
                                    contextualProduct.EntityLabel, // shapeInstance.IfcProductLabel,
                                    -1,                            // shapeInstance.InstanceLabel,
                                    transform,
                                    (short)rep.Model.UserDefinedId
                                    );
                            }
                        }
                }
            }
            tgt.EndUpdate();
            return(tgt);
        }
Exemplo n.º 4
0
        public static WpfMeshGeometry3D GetGeometry(EntitySelection selection, XbimModelPositioningCollection positions, Material mat)
        {
            var tgt = new WpfMeshGeometry3D(mat, mat);

            tgt.BeginUpdate();
            foreach (var modelgroup in selection.GroupBy(i => i.Model))
            {
                var model          = modelgroup.Key;
                var modelTransform = positions[model]?.Transform;
                if (modelTransform != null)
                {
                    using (var geomstore = model.GeometryStore)
                        using (var geomReader = geomstore.BeginRead())
                        {
                            foreach (var item in modelgroup)
                            {
                                foreach (var shapeInstance in geomReader.ShapeInstancesOfEntity(item).Where(x => x.RepresentationType != XbimGeometryRepresentationType.OpeningsAndAdditionsExcluded))
                                {
                                    IXbimShapeGeometryData shapegeom = geomReader.ShapeGeometry(shapeInstance.ShapeGeometryLabel);
                                    if (shapegeom.Format != (byte)XbimGeometryType.PolyhedronBinary)
                                    {
                                        continue;
                                    }
                                    var transform = shapeInstance.Transformation * modelTransform;
                                    tgt.Add(
                                        shapegeom.ShapeData,
                                        shapeInstance.IfcTypeId,
                                        shapeInstance.IfcProductLabel,
                                        shapeInstance.InstanceLabel,
                                        transform,
                                        (short)model.UserDefinedId
                                        );
                                }
                            }
                        }
                }
            }
            tgt.EndUpdate();
            return(tgt);
        }
Exemplo n.º 5
0
        internal static WpfMeshGeometry3D GetRepresentationGeometry2(Material mat, IEnumerable <int> representationLabels, IModel selModel, XbimMatrix3D modelTransform, bool wcsAdjust, XbimShapeGeometry shapegeom, IIfcProduct contextualProduct)
        {
            var placementTree = new XbimPlacementTree(selModel, wcsAdjust);
            var trsf          = placementTree[contextualProduct.ObjectPlacement.EntityLabel];
            var tgt           = new WpfMeshGeometry3D(mat, mat);

            tgt.BeginUpdate();
            if (shapegeom.Format == XbimGeometryType.PolyhedronBinary)
            {
                // Debug.WriteLine($"adding {shapegeom.ShapeLabel} at {DateTime.Now.ToLongTimeString()}");
                var transform = trsf * modelTransform;
                tgt.Add(
                    ((IXbimShapeGeometryData)shapegeom).ShapeData,
                    contextualProduct.ExpressType.TypeId, // shapeInstance.IfcTypeId,
                    contextualProduct.EntityLabel,        // shapeInstance.IfcProductLabel,
                    -1,                                   // shapeInstance.InstanceLabel,
                    transform,
                    (short)contextualProduct.Model.UserDefinedId
                    );
            }
            tgt.EndUpdate();
            return(tgt);
        }