public Dictionary<string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection inputHandles)
 {
     var retvalues = new Dictionary<string, XbimGeometryHandleCollection>();
     if (inputHandles.Any() )
         retvalues.Add("WholeModel", inputHandles);
     return retvalues;
 }
예제 #2
0
        /// <summary>
        /// Generate a Scene
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public XbimScene <XbimMeshGeometry3D, WpfMaterial> GetModelScene(XbimModel model)
        {
            //we need a class which implements IXbimRenderMaterial for the material, you might also want to implement a class for Material depending on your needs,
            //using the WpfMaterial class that then used the Media3D material class as implemented by the XBimXplorer for convenience.

            XbimScene <XbimMeshGeometry3D, WpfMaterial> scene = new XbimScene <XbimMeshGeometry3D, WpfMaterial>(model);
            XbimGeometryHandleCollection handles = new XbimGeometryHandleCollection(model.GetGeometryHandles()
                                                                                    .Exclude(IfcEntityNameEnum.IFCFEATUREELEMENT));

            foreach (var layerContent in handles.GroupByBuildingElementTypes())
            {
                string elementTypeName = layerContent.Key;
                XbimGeometryHandleCollection   layerHandles = layerContent.Value;
                IEnumerable <XbimGeometryData> geomColl     = model.GetGeometryData(layerHandles);
                XbimColour colour = scene.LayerColourMap[elementTypeName];
                XbimMeshLayer <XbimMeshGeometry3D, WpfMaterial> layer = new XbimMeshLayer <XbimMeshGeometry3D, WpfMaterial>(model, colour)
                {
                    Name = elementTypeName
                };
                //add all content initially into the hidden field
                foreach (var geomData in geomColl)
                {
                    layer.AddToHidden(geomData, model);
                }
                scene.Add(layer);
            }
            return(scene);
        }
        public Dictionary<string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection inputHandles)
        {
            // creates a new dictionary and then fills it by type enumerating the known non-abstract subtypes of Product
            Dictionary<string, XbimGeometryHandleCollection> result = new Dictionary<string, XbimGeometryHandleCollection>();

            // prepares transparents first
            HashSet<short> traspTypes = new HashSet<short>();
            foreach (var ttp in _lightTransparentTypes)
            {
                traspTypes.Add(IfcMetaData.IfcTypeId(ttp));
            }
            XbimGeometryHandleCollection transp = new XbimGeometryHandleCollection(
                    inputHandles.Where(g =>
                        traspTypes.Contains(g.IfcTypeId)
                        ||
                        _lightTransparentEntities.Contains(g.ProductLabel)
                        )
                    );
            result.Add("_LightBlueTransparent", transp);

            // deal with ignore elements
            HashSet<short> hiddTypes = new HashSet<short>();
            foreach (var htp in _hiddenTypes)
            {
                hiddTypes.Add(IfcMetaData.IfcTypeId(htp));
            }
            XbimGeometryHandleCollection hidd = new XbimGeometryHandleCollection(
                    inputHandles.Where(g =>
                        hiddTypes.Contains(g.IfcTypeId)
                        ||
                        _hiddenEntities.Contains(g.ProductLabel)
                        )
                    );

            // now execute normal type loop, but with the exclusion of hidden and transparent
            //
            IfcType baseType = IfcMetaData.IfcType(typeof(IfcProduct));
            foreach (var subType in baseType.NonAbstractSubTypes)
            {
                short ifcTypeId = IfcMetaData.IfcTypeId(subType);
                XbimGeometryHandleCollection handles = new XbimGeometryHandleCollection(
                    inputHandles.Where(g =>
                        g.IfcTypeId == ifcTypeId
                        &&
                        !(transp.Contains(g))
                        &&
                        !(hidd.Contains(g))
                        )
                    );

                // only add the item if there are handles in it
                if (handles.Count > 0)
                    result.Add(subType.Name, handles);
            }
            return result;
        }
        public Dictionary <string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection inputHandles)
        {
            var retvalues = new Dictionary <string, XbimGeometryHandleCollection>();

            if (inputHandles.Any())
            {
                retvalues.Add("WholeModel", inputHandles);
            }
            return(retvalues);
        }
예제 #5
0
 public Dictionary<string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection inputHandles)
 {
     var retvalues = new Dictionary<string, XbimGeometryHandleCollection>();
     XbimGeometryHandleCollection odd = new XbimGeometryHandleCollection(inputHandles.Where(g => g.ProductLabel % 2 == 0));
     XbimGeometryHandleCollection even = new XbimGeometryHandleCollection(inputHandles.Where(g => g.ProductLabel % 2 == 1));
     if (even.Count > 0)
         retvalues.Add("Even", even);
     if (odd.Count > 0)
         retvalues.Add("Odd", odd);
     return retvalues;
 }
예제 #6
0
        public Dictionary<string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection InputHandles)
        {
            Dictionary<string, XbimGeometryHandleCollection> result = new Dictionary<string, XbimGeometryHandleCollection>();

            var f = InputHandles.GroupBy(p => p.ProductLabel).Select(g => g.First().ProductLabel).ToList();

            foreach (var label in f)
            {
                XbimGeometryHandleCollection handles = new XbimGeometryHandleCollection(InputHandles.Where(g => g.ProductLabel == label));
                if (handles.Count > 0)
                    result.Add(label.ToString(), handles);
            }
            return result;
        }
예제 #7
0
        public Dictionary <string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection inputHandles)
        {
            var retvalues = new Dictionary <string, XbimGeometryHandleCollection>();
            XbimGeometryHandleCollection odd  = new XbimGeometryHandleCollection(inputHandles.Where(g => g.ProductLabel % 2 == 0));
            XbimGeometryHandleCollection even = new XbimGeometryHandleCollection(inputHandles.Where(g => g.ProductLabel % 2 == 1));

            if (even.Count > 0)
            {
                retvalues.Add("Even", even);
            }
            if (odd.Count > 0)
            {
                retvalues.Add("Odd", odd);
            }
            return(retvalues);
        }
예제 #8
0
 public Dictionary<string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection InputHandles)
 {
     // creates a new dictionary and then fills it by type enumerating the known non-abstract subtypes of Product
     Dictionary<string, XbimGeometryHandleCollection> result = new Dictionary<string, XbimGeometryHandleCollection>();
     IfcType baseType = IfcMetaData.IfcType(typeof(IfcProduct));
     foreach (var subType in baseType.NonAbstractSubTypes)
     {
         short ifcTypeId = IfcMetaData.IfcTypeId(subType);
         XbimGeometryHandleCollection handles = new XbimGeometryHandleCollection(InputHandles.Where(g => g.IfcTypeId == ifcTypeId));
         
         // only add the item if there are handles in it
         if (handles.Count > 0) 
             result.Add(subType.Name, handles);
     }
     return result;
 }
예제 #9
0
        public Dictionary <string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection InputHandles)
        {
            Dictionary <string, XbimGeometryHandleCollection> result = new Dictionary <string, XbimGeometryHandleCollection>();

            var f = InputHandles.GroupBy(p => p.ProductLabel).Select(g => g.First().ProductLabel).ToList();

            foreach (var label in f)
            {
                XbimGeometryHandleCollection handles = new XbimGeometryHandleCollection(InputHandles.Where(g => g.ProductLabel == label));
                if (handles.Count > 0)
                {
                    result.Add(label.ToString(), handles);
                }
            }
            return(result);
        }
예제 #10
0
        public static XbimGeometryHandleCollection GetApproximateGeometryHandles(this Xbim3DModelContext context)
        {
            var retCollection = new XbimGeometryHandleCollection();

            foreach (var shapeInstance in context.ShapeInstances()
                .Where(s => s.RepresentationType == XbimGeometryRepresentationType.OpeningsAndAdditionsIncluded))
            {
                retCollection.Add(
                    new XbimGeometryHandle(
                        shapeInstance.InstanceLabel,
                        XbimGeometryType.TriangulatedMesh,
                        shapeInstance.IfcProductLabel,
                        shapeInstance.IfcTypeId,
                        shapeInstance.StyleLabel
                        )
                    );
            }
            return retCollection;
        }
예제 #11
0
        public Dictionary <string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection InputHandles)
        {
            // creates a new dictionary and then fills it by type enumerating the known non-abstract subtypes of Product
            Dictionary <string, XbimGeometryHandleCollection> result = new Dictionary <string, XbimGeometryHandleCollection>();
            IfcType baseType = IfcMetaData.IfcType(typeof(IfcProduct));

            foreach (var subType in baseType.NonAbstractSubTypes)
            {
                short ifcTypeId = IfcMetaData.IfcTypeId(subType);
                XbimGeometryHandleCollection handles = new XbimGeometryHandleCollection(InputHandles.Where(g => g.IfcTypeId == ifcTypeId));

                // only add the item if there are handles in it
                if (handles.Count > 0)
                {
                    result.Add(subType.Name, handles);
                }
            }
            return(result);
        }
예제 #12
0
        public static XbimGeometryHandleCollection GetApproximateGeometryHandles(this Xbim3DModelContext context, IEnumerable<int> loadLabels = null)
        {
            var retCollection = new XbimGeometryHandleCollection();

            if (loadLabels != null)
            {
                foreach (var shapeInstance in context.ShapeInstances()
                    .Where(x => loadLabels.Contains(x.InstanceLabel)))
                {
                    retCollection.Add(
                        new XbimGeometryHandle(
                            shapeInstance.InstanceLabel,
                            XbimGeometryType.TriangulatedMesh,
                            shapeInstance.IfcProductLabel,
                            shapeInstance.IfcTypeId,
                            shapeInstance.StyleLabel
                            )
                        );
                }
            }
            else
            {
                foreach (var shapeInstance in context.ShapeInstances()
                    .Where(s => s.RepresentationType == XbimGeometryRepresentationType.OpeningsAndAdditionsIncluded))
                {
                    retCollection.Add(
                        new XbimGeometryHandle(
                            shapeInstance.InstanceLabel,
                            XbimGeometryType.TriangulatedMesh,
                            shapeInstance.IfcProductLabel,
                            shapeInstance.IfcTypeId,
                            shapeInstance.StyleLabel
                            )
                        );
                }    
            }
            return retCollection;
        }
예제 #13
0
        public static XbimGeometryHandleCollection GetApproximateGeometryHandles(this Xbim3DModelContext context, IEnumerable <int> loadLabels = null)
        {
            var retCollection = new XbimGeometryHandleCollection();

            if (loadLabels != null)
            {
                foreach (var shapeInstance in context.ShapeInstances()
                         .Where(x => loadLabels.Contains(x.InstanceLabel)))
                {
                    retCollection.Add(
                        new XbimGeometryHandle(
                            shapeInstance.InstanceLabel,
                            XbimGeometryType.TriangulatedMesh,
                            shapeInstance.IfcProductLabel,
                            shapeInstance.IfcTypeId,
                            shapeInstance.StyleLabel
                            )
                        );
                }
            }
            else
            {
                foreach (var shapeInstance in context.ShapeInstances()
                         .Where(s => s.RepresentationType == XbimGeometryRepresentationType.OpeningsAndAdditionsIncluded))
                {
                    retCollection.Add(
                        new XbimGeometryHandle(
                            shapeInstance.InstanceLabel,
                            XbimGeometryType.TriangulatedMesh,
                            shapeInstance.IfcProductLabel,
                            shapeInstance.IfcTypeId,
                            shapeInstance.StyleLabel
                            )
                        );
                }
            }
            return(retCollection);
        }
예제 #14
0
        private void SetupModel(XbimGeometryHandleCollection ghc, XbimModel model, Int32 ModelID)
        {
            long geo;
            foreach (var xgh in ghc)
            {
                geo = Labelifier(ModelID, xgh.GeometryLabel);
                SetupMaterial(TypeMap, xgh, model, ModelID);
                var layer = xLayers[xgh.SurfaceStyle.IfcSurfaceStyleLabel.ToString()];
                layer.Add(geo);
                xModelMap[geo] = model;
                xProductMap[geo] = xgh.ProductLabel;

            }
        }
예제 #15
0
 public Dictionary <string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection InputHandles)
 {
     return(LayerGrouper.GroupLayers(InputHandles));
 }
예제 #16
0
        /// <summary>
        /// Generate a Scene
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public XbimScene<XbimMeshGeometry3D, WpfMaterial> GetModelScene(XbimModel model)
        {
            //we need a class which implements IXbimRenderMaterial for the material, you might also want to implement a class for Material depending on your needs, 
            //using the WpfMaterial class that then used the Media3D material class as implemented by the XBimXplorer for convenience.

            XbimScene<XbimMeshGeometry3D, WpfMaterial> scene = new XbimScene<XbimMeshGeometry3D, WpfMaterial>(model);
            XbimGeometryHandleCollection handles = new XbimGeometryHandleCollection(model.GetGeometryHandles()
                                                       .Exclude(IfcEntityNameEnum.IFCFEATUREELEMENT));
            foreach (var layerContent in handles.GroupByBuildingElementTypes())
            {
                string elementTypeName = layerContent.Key;
                XbimGeometryHandleCollection layerHandles = layerContent.Value;
                IEnumerable<XbimGeometryData> geomColl = model.GetGeometryData(layerHandles);
                XbimColour colour = scene.LayerColourMap[elementTypeName];
                XbimMeshLayer<XbimMeshGeometry3D, WpfMaterial> layer = new XbimMeshLayer<XbimMeshGeometry3D, WpfMaterial>(model, colour) { Name = elementTypeName };
                //add all content initially into the hidden field
                foreach (var geomData in geomColl)
                {
                    layer.AddToHidden(geomData, model);
                }
                scene.Add(layer);
            }
            return scene;
        }
예제 #17
0
        /// <summary>
        /// This function builds a scene of all IfcProducts in the model, excluding the geometry of Openings
        /// It will create a scene database, overwriting any of the same name
        /// </summary>
        /// <param name="model">Model containing the model entities</param>
        /// <param name="sceneDbName">Name of scene DB file</param>
        /// <param name="Logger">Logging engine for detailed feedback</param>
        public void BuildGlobalScene(XbimModel model, string sceneDbName, Common.Logging.ILogger Logger = null)
        {
            if (File.Exists(sceneDbName)) 
                File.Delete(sceneDbName);


            //get a connection
            using (var db = new XbimSqliteDB(sceneDbName))
            {
                try
                {
                    short spaceId = IfcMetaData.IfcTypeId(typeof(IfcSpace));
                    XbimGeometryHandleCollection handles = new XbimGeometryHandleCollection(model.GetGeometryHandles()
                                                               .Exclude(IfcEntityNameEnum.IFCFEATUREELEMENT));
                    XbimRect3D modelBounds = XbimRect3D.Empty;
                    XbimColourMap cmap = new XbimColourMap();
                    int layerid = 1;
                    IfcProject project = model.IfcProject;
                    int projectId = 0;
                    if (project != null) projectId = Math.Abs(project.EntityLabel);
                    
                    float mScalingReference = (float)model.ModelFactors.OneMetre;

                    if (Logger != null)
                        Logger.DebugFormat("XbimScene: Scaling reference {0}\r\n", mScalingReference);

                    XbimMatrix3D translate = XbimMatrix3D.Identity;
                    XbimMatrix3D scale = XbimMatrix3D.CreateScale(1 / mScalingReference);
                    XbimMatrix3D composed = translate * scale;
                    XbimGeometryData regionData = model.GetGeometryData(projectId, XbimGeometryType.Region).FirstOrDefault(); //get the region data should only be one
                    if (regionData != null)
                    {
                        // this results in centering the most populated area of the model
                        //
                        XbimRegionCollection regions = XbimRegionCollection.FromArray(regionData.ShapeData);
                        XbimRegion largest = regions.MostPopulated();
                        if (largest != null)
                        {
                            translate = XbimMatrix3D.CreateTranslation(
                                -largest.Centre.X,
                                -largest.Centre.Y,
                                -largest.Centre.Z
                                );
                        }
                        composed = translate * scale;

                        // store region information in Scene
                        if ((Options & GenerateSceneOption.IncludeRegions) == GenerateSceneOption.IncludeRegions)
                        {
                            if (Logger != null)
                                Logger.DebugFormat("XbimScene: Exporting regions.\r\n", mScalingReference);
                            foreach (var item in regions)
                            {
                                // the bounding box needs to be moved/scaled by the transform.
                                //
                                XbimRect3D transformed = item.ToXbimRect3D().Transform(composed);
                                db.AddMetaData(
                                        "Region",
                                        -1,
                                        string.Format("Name:{0};Box:{1};", item.Name, transformed.ToString()), // verbose, but only a few items are expected in the model
                                        item.Name
                                        );
                    }
                        }
                    }

                    if ((Options & GenerateSceneOption.IncludeTransform) == GenerateSceneOption.IncludeTransform)
                    {
                        if (Logger != null)
                            Logger.DebugFormat("XbimScene: Exporting transform.\r\n", mScalingReference);
                        db.AddMetaData(
                                "Transform",
                                -1,
                                composed.ToArray(false),
                                "World"
                                );
                        db.Flush();
                    }

                    if (Logger != null)
                        Logger.DebugFormat("XbimScene: Exporting layers.\r\n", mScalingReference);
                    foreach (var layerContent in handles.GroupByBuildingElementTypes())
                    {
                        string elementTypeName = layerContent.Key;
                        XbimGeometryHandleCollection layerHandles = layerContent.Value;
                        IEnumerable<XbimGeometryData> geomColl = model.GetGeometryData(layerHandles);
                        XbimColour colour = cmap[elementTypeName];
                        XbimMeshLayer<XbimMeshGeometry3D, XbimRenderMaterial> layer = new XbimMeshLayer<XbimMeshGeometry3D, XbimRenderMaterial>(model, colour) { Name = elementTypeName };
                        //add all content initially into the hidden field
                        foreach (var geomData in geomColl)
                        {
                            geomData.TransformBy(composed);
                            if (geomData.IfcTypeId == spaceId)
                                layer.AddToHidden(geomData);
                            else
                                layer.AddToHidden(geomData, model);
                        }

                        if (modelBounds.IsEmpty)
                            modelBounds = layer.BoundingBoxHidden();
                        else
                            modelBounds.Union(layer.BoundingBoxHidden());

                        // add  top level layers
                        layerid = RecursivelyPersistLayer(db, layer, layerid, -1);
                        layerid++;
                    }

                    // create scene row in Scenes tables
                    //
                    if (Logger != null)
                        Logger.DebugFormat("XbimScene: Exporting scene.\r\n", mScalingReference);
                    byte[] boundingBoxFull = modelBounds.ToFloatArray();
                    db.AddScene(1, "MainScene", boundingBoxFull);

                    //now add some meta data about spaces
                    if (
                        (Options & GenerateSceneOption.IncludeSpaces) == GenerateSceneOption.IncludeSpaces
                        ||
                        (Options & GenerateSceneOption.IncludeSpacesBBox) == GenerateSceneOption.IncludeSpacesBBox
                        ||
                        (Options & GenerateSceneOption.IncludeSpacesStoreyId) == GenerateSceneOption.IncludeSpacesStoreyId
                        )
                    {
                        if (Logger != null)
                            Logger.DebugFormat("XbimScene: Exporting spaces.\r\n", mScalingReference);

                        // string data loop
                        foreach (var space in model.Instances.OfType<IfcSpace>())
                        {
                            int iEntLabel = Math.Abs(space.EntityLabel);
                            if ((Options & GenerateSceneOption.IncludeSpaces) == GenerateSceneOption.IncludeSpaces)
                            {
                                db.AddMetaData(
                                    space.GetType().Name,
                                    iEntLabel,
                                    space.Name ?? "Unnamed Space",
                                    iEntLabel.ToString()
                                    );
                            }
                            if ((Options & GenerateSceneOption.IncludeSpacesStoreyId) == GenerateSceneOption.IncludeSpacesStoreyId)
                            {
                                var parent = space.GetContainingStructuralElement();
                                if (parent == null)
                                {
                                    // try with different application behaviours
                                    foreach (var item in space.Decomposes)
                                    {
                                        parent = item.RelatingObject as IfcSpatialStructureElement;
                                        if (parent != null)
                    {
                                            break;
                                        }
                                    }
                                    // parent = space.Decomposes.FirstOrDefault().RelatingObject;
                                    // Decomposes RelatingObject
                                }
                                if (parent != null)
                        {
                                    db.AddMetaData(
                                        "SpaceToStorey",
                                        iEntLabel,
                                        string.Format("StoreyName={0};StoreyLabel={1};", parent.Name, parent.EntityLabel),
                                        iEntLabel.ToString());
                                }
                        }
                    }

                        // binary data loop
                    foreach (var space in model.Instances.OfType<IfcSpace>())
                    {
                            int iEntLabel = Math.Abs(space.EntityLabel);
                            if ((Options & GenerateSceneOption.IncludeSpacesBBox) == GenerateSceneOption.IncludeSpacesBBox)
                            {
                                XbimGeometryData geomdata = model.GetGeometryData(iEntLabel, XbimGeometryType.BoundingBox).FirstOrDefault();
                                if (geomdata != null)
                                {
                                    XbimRect3D r3d = XbimRect3D.FromArray(geomdata.ShapeData);
                                    XbimRect3D transformed = r3d.Transform(composed);
                                    db.AddMetaData(
                                            "SpaceBBox",
                                            iEntLabel,
                                        // string.Format("Box:{1};", transformed.ToString()), // verbose, but only a few items are expected in the model
                                            transformed.ToFloatArray(),
                                            iEntLabel.ToString()
                                            );
                                }
                                // db.AddMetaData(space.GetType().Name, space.Name ?? "Undefined Space", space.EntityLabel.ToString());
                            }
                        }

                    }

                    
                    // Add storey information with elevation.
                    // 
                    IfcBuilding bld = model.IfcProject.GetBuildings().FirstOrDefault();
                    if (bld != null && (Options & GenerateSceneOption.IncludeStoreys) == GenerateSceneOption.IncludeStoreys)
                    {
                        if (Logger != null)
                            Logger.DebugFormat("XbimScene: Exporting storeys.\r\n", mScalingReference);
                        double storeyHeight = 0;//all scenes are in metres
                        int defaultStoreyName = 0;
                        foreach (var storey in bld.GetBuildingStoreys(true))
                        {
                            string cleanName;
                            if(storey.Name.HasValue)
                                cleanName = storey.Name.Value.ToString().Replace(';', ' ');
                            else
                                cleanName = "Floor " + defaultStoreyName++;

                            var spacesCount = storey.SpatialStructuralElementChildren.OfType<IfcSpatialStructureElement>().ToList().Count(); // add for checking spaces


                            // Storey Elevation is optional (and has been found unreliable), therefore
                            // Storey elevation values (in building reference system) are taken from the 
                            // objectplacement through the XbimGeometryType.TransformOnly geometry type
                            //
                            XbimGeometryData geomdata = model.GetGeometryData(storey.EntityLabel, XbimGeometryType.TransformOnly).FirstOrDefault();
                            if (geomdata != null)
                            {
                                storeyHeight = geomdata.Transform.OffsetZ;
                                // apply the transformation previously applied to the building 
                                XbimPoint3D InTranslatedReference = composed.Transform(
                                    new XbimPoint3D(0, 0, storeyHeight)
                                    );

                                double InTranslatedReferenceZ = InTranslatedReference.Z; // then express it in meters.
                                
                                // Logger.DebugFormat("StoreyName: {0}; Model Elevation: {1}; Scene Elevation: {2}", cleanName, storeyHeight, InTranslatedReferenceZ);

                                db.AddMetaData(
                                "Storey",
                                    Math.Abs(storey.EntityLabel),
                                    string.Format("Name:{0};Elevation:{1};SpaceCount:{2};", cleanName, InTranslatedReferenceZ, spacesCount), // storeyHeight),
                                cleanName);
                        }
                    }
                }
                }
                finally
                {
                    db.Flush();
                    GC.Collect();
                }
            }
        }
예제 #18
0
        public Dictionary <string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection inputHandles)
        {
            // creates a new dictionary and then fills it by type enumerating the known non-abstract subtypes of Product
            Dictionary <string, XbimGeometryHandleCollection> result = new Dictionary <string, XbimGeometryHandleCollection>();

            // prepares transparents first
            HashSet <short> traspTypes = new HashSet <short>();

            foreach (var ttp in _lightTransparentTypes)
            {
                traspTypes.Add(IfcMetaData.IfcTypeId(ttp));
            }
            XbimGeometryHandleCollection transp = new XbimGeometryHandleCollection(
                inputHandles.Where(g =>
                                   traspTypes.Contains(g.IfcTypeId)
                                   ||
                                   _lightTransparentEntities.Contains(g.ProductLabel)
                                   )
                );

            result.Add("_LightBlueTransparent", transp);

            // deal with ignore elements
            HashSet <short> hiddTypes = new HashSet <short>();

            foreach (var htp in _hiddenTypes)
            {
                hiddTypes.Add(IfcMetaData.IfcTypeId(htp));
            }
            XbimGeometryHandleCollection hidd = new XbimGeometryHandleCollection(
                inputHandles.Where(g =>
                                   hiddTypes.Contains(g.IfcTypeId)
                                   ||
                                   _hiddenEntities.Contains(g.ProductLabel)
                                   )
                );

            // now execute normal type loop, but with the exclusion of hidden and transparent
            //
            IfcType baseType = IfcMetaData.IfcType(typeof(IfcProduct));

            foreach (var subType in baseType.NonAbstractSubTypes)
            {
                short ifcTypeId = IfcMetaData.IfcTypeId(subType);
                XbimGeometryHandleCollection handles = new XbimGeometryHandleCollection(
                    inputHandles.Where(g =>
                                       g.IfcTypeId == ifcTypeId
                                       &&
                                       !(transp.Contains(g))
                                       &&
                                       !(hidd.Contains(g))
                                       )
                    );

                // only add the item if there are handles in it
                if (handles.Count > 0)
                {
                    result.Add(subType.Name, handles);
                }
            }
            return(result);
        }
예제 #19
0
        private XbimGeometryHandleCollection GetGeometryHandlesBySurfaceStyle(XbimGeometryType geomType)
        {
            XbimGeometryHandleCollection result = new XbimGeometryHandleCollection();
            Api.JetSetCurrentIndex(sesid, table, geometryTableStyleIndex);
            Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey);
            if (Api.TrySeek(sesid, table, SeekGrbit.SeekGE))
            {
                Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey | MakeKeyGrbit.FullColumnEndLimit);
                if (Api.TrySetIndexRange(sesid, table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive))
                {
                    do
                    {
                        int? style = Api.RetrieveColumnAsInt32(sesid, table, _colIdStyleLabel, RetrieveColumnGrbit.RetrieveFromIndex);
                        short? ifcType = Api.RetrieveColumnAsInt16(sesid, table, _colIdProductIfcTypeId, RetrieveColumnGrbit.RetrieveFromIndex);
                        int? product = Api.RetrieveColumnAsInt32(sesid, table, _colIdProductLabel, RetrieveColumnGrbit.RetrieveFromIndex);
                        int? geomId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel, RetrieveColumnGrbit.RetrieveFromIndex);
                        result.Add(new XbimGeometryHandle(geomId.Value, geomType, product.Value, ifcType.Value, style.Value));
                    } while (Api.TryMoveNext(sesid, table));
                }

            }
            return result;
        }
예제 #20
0
        private XbimGeometryHandleCollection GetGeometryHandlesById(XbimGeometryType geomType)
        {
            XbimGeometryHandleCollection result = new XbimGeometryHandleCollection();
            Api.JetSetCurrentIndex(sesid, table, geometryTablePrimaryIndex);

            Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey);
            if (Api.TrySeek(sesid, table, SeekGrbit.SeekGE))
            {
                Api.MakeKey(sesid, table, (byte)geomType, MakeKeyGrbit.NewKey | MakeKeyGrbit.FullColumnEndLimit);
                if (Api.TrySetIndexRange(sesid, table, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive))
                {
                    do
                    {
                        int? style = Api.RetrieveColumnAsInt32(sesid, table, _colIdStyleLabel);
                        short? ifcType = Api.RetrieveColumnAsInt16(sesid, table, _colIdProductIfcTypeId);
                        int? product = Api.RetrieveColumnAsInt32(sesid, table, _colIdProductLabel);
                        int? geomId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryLabel);
                        int? hashId = Api.RetrieveColumnAsInt32(sesid, table, _colIdGeometryHash);
                        //srl note casting to UINT, needs to be resolved at database level
                        result.Add(new XbimGeometryHandle(geomId.Value, geomType, product.Value, ifcType.Value, style.Value, hashId.Value));
                    } while (Api.TryMoveNext(sesid, table));
                }

            }
            return result;
        }
 // redirects the grouping requirement to the style using the LayerGrouper
 public Dictionary<string, XbimGeometryHandleCollection> GroupLayers(XbimGeometryHandleCollection InputHandles)
 {
     return _LayerGrouper.GroupLayers(InputHandles);
 }