/// <summary>
        /// Create BridgePart Entities
        /// </summary>
        /// <param name="model"></param>
        /// <exception cref="Exception"></exception>
        public void CreateIfcBridgePartEntities(ref IfcStore model)
        {
            // other services needed for this method:
            var placementService = new PlacementService();

            using (var txn = model.BeginTransaction("Add Bridge Part structure"))
            {
                var superStructure = model.Instances.New <IfcBridgePart>();
                superStructure.Name = "Superstructure";

                superStructure.ObjectPlacement = placementService.AddLocalPlacement(ref model, 0, 0, 0);
                superStructure.CompositionType = IfcElementCompositionEnum.ELEMENT;
                superStructure.PredefinedType  = IfcBridgePartTypeEnum.SUPERSTRUCTURE;

                var subStructure = model.Instances.New <IfcBridgePart>();
                subStructure.Name            = "Substructure";
                subStructure.ObjectPlacement = placementService.AddLocalPlacement(ref model, 0, 0, 0);
                subStructure.CompositionType = IfcElementCompositionEnum.ELEMENT;
                subStructure.PredefinedType  = IfcBridgePartTypeEnum.SUBSTRUCTURE;

                var surfaceStructure = model.Instances.New <IfcBridgePart>();
                surfaceStructure.Name            = "Surfacestructure";
                surfaceStructure.ObjectPlacement = placementService.AddLocalPlacement(ref model, 0, 0, 0);
                surfaceStructure.CompositionType = IfcElementCompositionEnum.ELEMENT;
                surfaceStructure.PredefinedType  = IfcBridgePartTypeEnum.SURFACESTRUCTURE;

                // grab the existing bridge
                var myBridge = model.Instances.OfType <IfcBridge>().FirstOrDefault();
                if (myBridge == null)
                {
                    throw new Exception("No IfcBridge Item in the current model. ");
                }
                var spatial2Bridge = model.Instances.New <IfcRelAggregates>();

                spatial2Bridge.RelatingObject = myBridge;

                spatial2Bridge.RelatedObjects.Add(superStructure);
                spatial2Bridge.RelatedObjects.Add(subStructure);
                spatial2Bridge.RelatedObjects.Add(surfaceStructure);

                txn.Commit();
            }
        }
        /// <summary>
        /// Fügt IfcBridge in die Hierachie ein
        /// </summary>
        /// <param name="model"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        public void CreateIfcBridgeEntity(ref IfcStore model, string name, string description)
        {
            using (var txn = model.BeginTransaction("Add IfcBridge to Instances"))
            {
                var bridge = model.Instances.New <IfcBridge>();
                bridge.Name        = name;
                bridge.Description = description;

                // placement
                var placementService = new PlacementService();
                bridge.ObjectPlacement = placementService.AddLocalPlacement(ref model, 0, 0, 0);

                // build relationship between bridge and Site
                var mySite         = model.Instances.OfType <IfcSite>().FirstOrDefault();
                var spatial2Bridge = model.Instances.New <IfcRelAggregates>();

                spatial2Bridge.RelatingObject = mySite;
                spatial2Bridge.RelatedObjects.Add(bridge);

                txn.Commit();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a product to the IFC file
        /// </summary>
        /// <param name="model">current XBIM model, must not be in running transaction</param>
        /// <param name="rawGeometry">product geometry</param>
        /// <param name="name">name of product</param>
        /// <param name="ifcElementType">desired Ifc class (choose one out of IfcBuildingElement</param>
        /// <param name="placementType">either "local", "linear" or "span"</param>
        /// <param name="spatialStructure">choose spatial container the product should be added to</param>
        public void AddBuildingElement(ref IfcStore model, DirectShapeToIfc rawGeometry, string name, string ifcElementType, string placementType, string spatialStructure)
        {
            // handle null inputs
            if (placementType == null)
            {
                placementType = "localPlacement";
            }


            // other services needed for this method:
            var placementService = new PlacementService();

            using (var txn = model.BeginTransaction("insert a product"))
            {
                IfcBuildingElement buildingElement;

                switch (ifcElementType) // ToDo: make use of enum
                {
                case "IfcBeam":
                {
                    buildingElement = model.Instances.New <IfcBeam>();
                    break;
                }

                case "IfcBearing":
                {
                    buildingElement = model.Instances.New <IfcBearing>();
                    break;
                }

                case "IfcChimney":
                {
                    buildingElement = model.Instances.New <IfcChimney>();
                    break;
                }

                case "IfcColumn":
                {
                    // call the bearing function in the toolkit
                    buildingElement = model.Instances.New <IfcColumn>();
                    break;
                }

                case "IfcCovering":
                {
                    // call the bearing function in the toolkit
                    buildingElement = model.Instances.New <IfcCovering>();
                    break;
                }

                case "IfcCurtainWall":
                {
                    // call the bearing function in the toolkit
                    buildingElement = model.Instances.New <IfcCurtainWall>();
                    break;
                }

                case "IfcDeepFoundation":
                {
                    buildingElement = model.Instances.New <IfcDeepFoundation>();
                    break;
                }

                case "IfcDoor":
                {
                    buildingElement = model.Instances.New <IfcDoor>();
                    break;
                }

                case "IfcFooting":
                {
                    buildingElement = model.Instances.New <IfcFooting>();
                    break;
                }

                case "IfcMember":
                {
                    buildingElement = model.Instances.New <IfcMember>();
                    break;
                }

                case "IfcPlate":
                {
                    buildingElement = model.Instances.New <IfcPlate>();
                    break;
                }

                case "IfcRailing":
                {
                    buildingElement = model.Instances.New <IfcRailing>();
                    break;
                }

                case "IfcRamp":
                {
                    buildingElement = model.Instances.New <IfcRamp>();
                    break;
                }

                case "IfcRampFlight":
                {
                    buildingElement = model.Instances.New <IfcRampFlight>();
                    break;
                }

                case "IfcRoof":
                {
                    buildingElement = model.Instances.New <IfcRoof>();
                    break;
                }

                case "IfcShadingDevice":
                {
                    buildingElement = model.Instances.New <IfcShadingDevice>();
                    break;
                }

                case "IfcSlab":
                {
                    buildingElement = model.Instances.New <IfcSlab>();
                    break;
                }

                case "IfcStair":
                {
                    buildingElement = model.Instances.New <IfcStair>();
                    break;
                }

                case "IfcWall":
                {
                    buildingElement = model.Instances.New <IfcWall>();
                    break;
                }

                case "IfcWindow":
                {
                    buildingElement = model.Instances.New <IfcWindow>();
                    break;
                }

                // if nothing fits, make an IfcBuildingElementProxy out of it
                default:
                    buildingElement = model.Instances.New <IfcBuildingElementProxy>();
                    break;
                }

                // fill name property
                buildingElement.Name = name;

                // add product placement (localPlacement or linearPlacement - Span is not supported by Ifc 4x2!)
                switch (placementType)
                {
                case "local":
                    buildingElement.ObjectPlacement = placementService.AddLocalPlacement(ref model, rawGeometry.location.Position);
                    break;

                case "linear":
                {
                    buildingElement.ObjectPlacement = placementService.AddLinearPlacement(ref model, null, 0);
                    break;
                }

                case "span":
                {
                    var e = new Exception("Span placement was not introduced by IfcBridge!");
                    throw e;
                }

                default:
                {
                    var e = new Exception("Placement method was not specified correctly .");
                    throw e;
                }
                }

                // add product representation
                buildingElement.Representation = ProdGeometryService.ConvertMyMeshToIfcFacetedBRep(ref model, "representation", rawGeometry);

                // add product to spatial structure
                AddToSpatialStructure(ref model, buildingElement, spatialStructure);

                txn.Commit();
            }
        }