internal static int CompareStoreysByElevation(IIfcBuildingStorey x, IIfcBuildingStorey y)
        {
            double a = x.Elevation ?? 0;
            double b = y.Elevation ?? 0;

            return(a.CompareTo(b));
        }
    private void SetFloorMap()
    {
        var objectDatas = GameObject.Find(SpatialStructureTest.project.Name).transform.GetComponentsInChildren <BuildingStoreyData>();

        foreach (var o in objectDatas)
        {
            floorObjects.Add(o.TheGameObject);
            IIfcBuildingStorey s = o.TheStructure as IIfcBuildingStorey;

            floorElevations.Add((float)s.Elevation);
        }
    }
Beispiel #3
0
        public IIfcBuildingStorey NewStorey(string name = null, double elevation = 0)
        {
            IIfcBuildingStorey storey = null;

            Wrap(s =>
            {
                storey              = IfcProductScope.NewOf <IIfcBuildingStorey>();
                storey.Name         = name;
                storey.OwnerHistory = CurrentVersion;
                storey.Elevation    = elevation;

                NewContainer(storey);
            });

            return(storey);
        }
Beispiel #4
0
        public BuildingModel GetModel(IModel model, IIfcBuildingStorey ignored = null)
        {
            Definitions <PropertySetDef> propertyDefinitions = null;

            // prepare standard properties dictionary
            if (IncludeStandardPsets)
            {
                switch (model.Header.SchemaVersion.ToLowerInvariant())
                {
                case "ifc2x3":
                    propertyDefinitions = new Definitions <PropertySetDef>(Xbim.Properties.Version.IFC2x3);
                    break;

                case "ifc4":
                    propertyDefinitions = new Definitions <PropertySetDef>(Xbim.Properties.Version.IFC2x3);
                    break;

                default:
                    break;
                }
                if (propertyDefinitions != null)
                {
                    propertyDefinitions.LoadAllDefault();
                }
            }

            // cache systems list
            //
            var elementToSystem = new Dictionary <int, int>();
            var systemRels      = model.Instances.OfType <IIfcRelAssignsToGroup>().Where(x =>
                                                                                         x.RelatingGroup is IIfcSystem
                                                                                         );

            foreach (var systemRel in systemRels)
            {
                foreach (var relatedObject in systemRel.RelatedObjects)
                {
                    if (elementToSystem.ContainsKey(relatedObject.EntityLabel))
                    {
                        continue;
                    }
                    elementToSystem.Add(relatedObject.EntityLabel, systemRel.RelatingGroup.EntityLabel);
                }
            }

            // now extract
            BuildingModel m = new BuildingModel();

            List <IIfcBuildingStorey> storeys = new List <IIfcBuildingStorey>();
            List <IIfcSystem>         systems = new List <IIfcSystem>();

            foreach (var ifcElement in model.Instances.OfType <IIfcElement>())
            {
                if (CustomFilter != null)
                {
                    var skip = CustomFilter(ifcElement.EntityLabel, model);
                    if (skip)
                    {
                        continue;
                    }
                }

                BuildingElement semanticElement = new BuildingElement();
                semanticElement.SetBase(ifcElement);

                if (propertyDefinitions != null)
                {
                    var thisClass = new ApplicableClass();
                    thisClass.ClassName = ifcElement.ExpressType.Name;
                    var applicable = propertyDefinitions.DefinitionSets.Where(x => x.ApplicableClasses.Any(ac => ac.ClassName == thisClass.ClassName));

                    var psets = ifcElement.IsDefinedBy.Where(x => x.RelatingPropertyDefinition is IIfcPropertySet).Select(pd => pd.RelatingPropertyDefinition as IIfcPropertySetDefinition).ToList();
                    foreach (var definition in applicable)
                    {
                        var matchingSet = psets.Where(x => x.Name == definition.Name).FirstOrDefault();
                        if (matchingSet == null)
                        {
                            continue;
                        }
                        var ps = new ElementPropertySet();
                        ps.propertySetName = matchingSet.Name;

                        foreach (var singleProperty in definition.PropertyDefinitions)
                        {
                            var pFound = GetProperty(matchingSet, singleProperty);
                            if (!string.IsNullOrWhiteSpace(pFound))
                            {
                                ps.properties.Add(new IfcInfo(
                                                      singleProperty.Name,
                                                      pFound
                                                      ));
                            }
                        }
                        if (ps.properties.Any())
                        {
                            semanticElement.propertySets.Add(ps);
                        }
                    }
                }

                // storeys (prepares list and sets index, data extraction happens later)
                semanticElement.ifcStoreyIndex = GetStoreyId(ifcElement, storeys);
                if (semanticElement.ifcStoreyIndex == -1)
                {
                    // try through upper level of aggregation (up from the aggregates to the RelatingObject)
                    //
                    foreach (var relAggreg in ifcElement.Decomposes.OfType <IIfcRelAggregates>())
                    {
                        int found = GetStoreyId(relAggreg.RelatingObject as IIfcElement, storeys);
                        if (found != -1)
                        {
                            semanticElement.ifcStoreyIndex = found;
                            break;
                        }
                    }
                }

                // systems (prepares list and sets index, data extraction happens later)
                if (elementToSystem.ContainsKey(ifcElement.EntityLabel))
                {
                    var systemId = elementToSystem[ifcElement.EntityLabel];
                    var system   = model.Instances[systemId] as IIfcSystem;
                    if (system != null)
                    {
                        int index = systems.IndexOf(system);
                        if (index == -1)
                        {
                            index = systems.Count;
                            systems.Add(system);
                        }
                        semanticElement.ifcSystemIndex = index;
                    }
                }

                // now add element
                m.elements.Add(semanticElement);
            }

            // data extraction for the dicionaries happens here
            foreach (var storey in storeys)
            {
                var s = new BuildingStorey(
                    ToDouble(storey.Elevation)
                    );
                s.SetBase(storey);
                m.storeys.Add(s);
            }

            foreach (var system in systems)
            {
                var s = new BuildingSystem();
                s.SetBase(system);
                m.systems.Add(s);
            }

            return(m);
        }
Beispiel #5
0
        //[System.Xml.Serialization.XmlIgnoreAttribute()]
        //private IIfcBuildingStorey _ifcBuildingStorey;


        public FloorType(IIfcBuildingStorey ifcBuildingStorey, CoBieLiteHelper helper)
            : this()
        {
            //   _ifcBuildingStorey = ifcBuildingStorey;
            externalEntityName = helper.ExternalEntityName(ifcBuildingStorey);
            externalID         = helper.ExternalEntityIdentity(ifcBuildingStorey);
            externalSystemName = helper.ExternalSystemName(ifcBuildingStorey);
            FloorName          = ifcBuildingStorey.Name;
            FloorCategory      = helper.GetClassification(ifcBuildingStorey);
            FloorDescription   = ifcBuildingStorey.Description;
            //set the fall backs

            if (ifcBuildingStorey.Elevation.HasValue)
            {
                FloorElevationValue = new DecimalValueType
                {
                    DecimalValue          = ifcBuildingStorey.Elevation.Value,
                    DecimalValueSpecified = true
                };
                //TODO: work out if the units can change
                //FloorElevationValue.UnitName =
            }
            FloorHeightValue = helper.GetCoBieAttribute <DecimalValueType>("FloorHeightValue", ifcBuildingStorey);
            //var heightProperty = ifcBuildingStorey.GetTotalHeightProperty();
            //if (heightProperty != null)
            //{
            //    FloorHeightValue = new DecimalValueType
            //    {
            //        DecimalValue = heightProperty.LengthValue,
            //        DecimalValueSpecified = true,
            //        UnitName = heightProperty.Unit.GetName()
            //    };
            //}

            var spaces    = ifcBuildingStorey.Spaces;
            var ifcSpaces = spaces as IList <IIfcSpace> ?? spaces.ToList();

            if (ifcSpaces.Any())
            {
                Spaces = new SpaceCollectionType {
                    Space = new List <SpaceType>(ifcSpaces.Count)
                };
                for (var i = 0; i < ifcSpaces.Count; i++)
                {
                    Spaces.Add(new SpaceType(ifcSpaces[i], helper));
                }
            }

            //Attributes
            var ifcAttributes = helper.GetAttributes(ifcBuildingStorey);

            if (ifcAttributes != null && ifcAttributes.Any())
            {
                FloorAttributes = new AttributeCollectionType {
                    Attribute = ifcAttributes
                }
            }
            ;

            //TODO:
            //Space Issues
            //Space Documents
        }