예제 #1
0
 public void AddBoundingElement(Guid guid, XbimPhysicalOrVirtualEnum type, XbimInternalOrExternalEnum external)
 {
     IfcGloballyUniqueId gid = new IfcGloballyUniqueId(guid);
     IfcElement element = _document.Model.Instances.Where<IfcBuildingElement>(elem => elem.GlobalId == gid).FirstOrDefault();
     if (element == null) return;
     Space.AddBoundingElement(_document.Model, element, GetIfcPhysicalOrVirtualEnum(type), GetIfcInternalOrExternalEnum(external));
 }
 /// <summary>
 /// Adds element with specified GUID as element contained in the spatial structure element.
 /// If the element with that GUID does not exist, function returns false and nothing is added.
 /// </summary>
 /// <param name="guid">GUID of the element</param>
 /// <returns>TRUE if the element is added, FALSE otherwise</returns>
 public bool AddContainedBuildingElement(Guid guid)
 {
     IfcGloballyUniqueId globID = new IfcGloballyUniqueId(guid);
     IfcProduct product = _document.Model.Instances.Where<IfcProduct>(prod => prod.GlobalId == guid).FirstOrDefault();
     if (product != null)
     {
         _spatialElement.AddElement(product);
         return true;
     }
     return false;
 }
예제 #3
0
 private bool FindProductByGlobalId(XbimModel model, IfcGloballyUniqueId _globalId)
 {
     foreach (IfcProduct p in model.IfcProducts)
     {
         if (p.GlobalId == _globalId)
         {
             return true;
         }
     }
     return false;
 }
예제 #4
0
        /// <summary>
        /// Add space placement
        /// </summary>
        /// <param name="row">COBieCoordinateRow holding the data for one corner</param>
        /// <param name="rowNext">COBieCoordinateRow holding the data for the other corner</param>
        private void AddBoundingBoxAsExtrudedAreaSolid(COBieCoordinateRow row, COBieCoordinateRow rowNext)
        {
            if (row.SheetName.ToLower() == "floor")
            {
                IfcBuildingStorey ifcBuildingStorey = null;
                if (ValidateString(row.ExtIdentifier))
                {
                    IfcGloballyUniqueId id = new IfcGloballyUniqueId(row.ExtIdentifier);
                    ifcBuildingStorey = Model.Instances.Where<IfcBuildingStorey>(bs => bs.GlobalId == id).FirstOrDefault();
                }

                if ((ifcBuildingStorey == null) && (ValidateString(row.RowName)))
                {
                    ifcBuildingStorey = Model.Instances.Where<IfcBuildingStorey>(bs => bs.Name == row.RowName).FirstOrDefault();
                }

                if (ifcBuildingStorey != null)
                {
                    //using statement will set the Model.OwnerHistoryAddObject to IfcRoot.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, 
                    //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement
                    using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcBuildingStorey.OwnerHistory))
                    {
                        IfcProduct placementRelToIfcProduct = ifcBuildingStorey.SpatialStructuralElementParent as IfcProduct;
                        AddExtrudedRectangle(row, rowNext, ifcBuildingStorey, placementRelToIfcProduct);
                    }
                }
            } 
            if (row.SheetName.ToLower() == "space")
            {
                IfcSpace ifcSpace = null;
                if (ValidateString(row.ExtIdentifier))
                {
                    IfcGloballyUniqueId id = new IfcGloballyUniqueId(row.ExtIdentifier);
                    ifcSpace = Model.Instances.Where<IfcSpace>(bs => bs.GlobalId == id).FirstOrDefault();
                }
                if ((ifcSpace == null) && (ValidateString(row.RowName)))
                {
                    ifcSpace = Model.Instances.Where<IfcSpace>(bs => bs.Name == row.RowName).FirstOrDefault();
                }
                if ((ifcSpace == null) && (ValidateString(row.RowName)))
                {
                    IEnumerable<IfcSpace> ifcSpaces = Model.Instances.Where<IfcSpace>(bs => bs.Description == row.RowName);
                    //check we have one, if >1 then no match
                    if ((ifcSpaces.Any()) && (ifcSpaces.Count() == 1))
                        ifcSpace = ifcSpaces.FirstOrDefault();
                }

                if (ifcSpace != null)
                {
                    if (ifcSpace.Representation != null) //check it has no graphics attached, if it has then skip
                        return;
                    //using statement will set the Model.OwnerHistoryAddObject to IfcRoot.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, 
                    //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement
                    using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcSpace.OwnerHistory))
                    {
                        IfcProduct placementRelToIfcProduct = ifcSpace.SpatialStructuralElementParent as IfcProduct;

                        AddExtrudedRectangle(row, rowNext, ifcSpace, placementRelToIfcProduct);
                    }
                }

            }

            if (row.SheetName.ToLower() == "component")
            {
                IfcElement ifcElement = null;
                if (ValidateString(row.ExtIdentifier))
                {
                    IfcGloballyUniqueId id = new IfcGloballyUniqueId(row.ExtIdentifier);
                    ifcElement = Model.Instances.Where<IfcElement>(bs => bs.GlobalId == id).FirstOrDefault();
                }
                if ((ifcElement == null) && (ValidateString(row.RowName)))
                {
                    ifcElement = Model.Instances.Where<IfcElement>(bs => bs.Name == row.RowName).FirstOrDefault();
                }

                if ((ifcElement == null) && (ValidateString(row.RowName)))
                {
                    IEnumerable<IfcElement> ifcElements = Model.Instances.Where<IfcElement>(bs => bs.Description == row.RowName);
                    //check we have one, if >1 then no match
                    if ((ifcElements.Any()) && (ifcElements.Count() == 1))
                        ifcElement = ifcElements.FirstOrDefault();
                }

                if (ifcElement != null)
                {
                    if (ifcElement.Representation != null) //check it has no graphics attached, if it has then skip
                        return;

                    //using statement will set the Model.OwnerHistoryAddObject to IfcRoot.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, 
                    //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement
                    using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcElement.OwnerHistory))
                    {
                        IfcProduct placementRelToIfcProduct = ifcElement.ContainedInStructure as IfcProduct;
                        IfcRelContainedInSpatialStructure ifcRelContainedInSpatialStructure = Model.Instances.OfType<IfcRelContainedInSpatialStructure>().Where(rciss => rciss.RelatedElements.Contains(ifcElement)).FirstOrDefault();
                        if ((ifcRelContainedInSpatialStructure != null) &&
                            (ifcRelContainedInSpatialStructure.RelatingStructure != null)
                            )
                        {
                            placementRelToIfcProduct = ifcRelContainedInSpatialStructure.RelatingStructure as IfcProduct;
                            AddExtrudedRectangle(row, rowNext, ifcElement, placementRelToIfcProduct);
                        }
                        else
                        {
#if DEBUG
                            Console.WriteLine("COBieXBimCoordinate.AddBoundingBoxAsExtrudedAreaSolid: Cannot find Parent object placement");
#endif                        
                        }
                    }
                    
                }
                else
                {
#if DEBUG
                    Console.WriteLine("COBieXBimCoordinate.AddBoundingBoxAsExtrudedAreaSolid: Cannot find object to relate points too");
#endif
                }
            }
            
        }
예제 #5
0
        /// <summary>
        /// Add floor placement point
        /// </summary>
        /// <param name="row">COBieCoordinateRow holding the data</param>
        private void AddFloorPlacement(COBieCoordinateRow row)
        {
            IfcBuildingStorey ifcBuildingStorey = null;
            if (ValidateString(row.ExtIdentifier))
            {
                IfcGloballyUniqueId id = new IfcGloballyUniqueId(row.ExtIdentifier);
                ifcBuildingStorey = Model.Instances.Where<IfcBuildingStorey>(bs => bs.GlobalId == id).FirstOrDefault();
            }

            if ((ifcBuildingStorey == null) && (ValidateString(row.RowName)))
            {
                ifcBuildingStorey = Model.Instances.Where<IfcBuildingStorey>(bs => bs.Name == row.RowName).FirstOrDefault();
            }

            if (ifcBuildingStorey != null)
            {
                IfcProduct placementRelToIfcProduct = ifcBuildingStorey.SpatialStructuralElementParent as IfcProduct;
                IfcLocalPlacement objectPlacement = CalcObjectPlacement(row, placementRelToIfcProduct);
                if (objectPlacement != null)
                {
                    //using statement will set the Model.OwnerHistoryAddObject to IfcRoot.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, 
                    //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement
                    using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcBuildingStorey.OwnerHistory))
                    {
                        ifcBuildingStorey.ObjectPlacement = objectPlacement;
                    }
                }
            }
        }
예제 #6
0
 public virtual void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _globalId = value.StringVal;
             break;
         case 1:
             _ownerHistory = (IfcOwnerHistory) value.EntityVal;
             break;
         case 2:
             _name = value.StringVal;
             break;
         case 3:
             _description = value.StringVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
예제 #7
0
 public IfcRoot()
 {
     _globalId = IfcGloballyUniqueId.NewGuid();
 }