Пример #1
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
             base.IfcParse(propIndex, value);
             break;
         case 6:
             _relatingProduct = (IfcProduct) value.EntityVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Пример #2
0
        public override void IfcParse(int propIndex, IPropertyValue value)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                base.IfcParse(propIndex, value);
                break;

            case 6:
                _relatingProduct = (IfcProduct)value.EntityVal;
                break;

            default:
                this.HandleUnexpectedAttribute(propIndex, value); break;
            }
        }
Пример #3
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 6:
                _relatingProduct = (IfcProduct)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Пример #4
0
        public bool? Contains(IfcProduct first, IfcProduct second)
        {
            //this type of relation is always recursive
            if (first == second) return true;

            //check the case of spatial strucure element (specific relations)
            IfcSpatialStructureElement spatStruct = first as IfcSpatialStructureElement;
            IEnumerable<IfcProduct> prods = null;
            if (spatStruct != null)
            {
                prods = GetProductsInSpatStruct(spatStruct);
                foreach (var prod in prods)
                    if (Contains(prod, second) ?? false) return true;
            }
            prods = GetProductsInProduct(first);
            foreach (var prod in prods)
                if (Contains(prod, second) ?? false) return true;

            //if we don't know
            return null;
        }
Пример #5
0
 public TransformNode(IfcProduct prod)
 {
     if(prod!=null)
         _productLabel = prod.EntityLabel;
 }
Пример #6
0
 public bool? Crosses(IfcProduct first, IfcProduct second)
 {
     return Compare(first, second, _semanticAnalyser.Crosses, _geometryAnalyser.Crosses);
 }
Пример #7
0
 public bool? Relate(IfcProduct first, IfcProduct second)
 {
     if (Equals(first, second) ?? false) return true;
     if (Intersects(first, second) ?? false) return true;
     if (Touches(first, second) ?? false) return true;
     if (Crosses(first, second) ?? false) return true;
     if (Contains(first, second) ?? false) return true;
     if (Within(first, second) ?? false) return true;
     if (Overlaps(first, second) ?? false) return true;
     return null;
 }
Пример #8
0
 public bool? Intersects(IfcProduct first, IfcProduct second)
 {
     return null;
 }
Пример #9
0
 public bool? Disjoint(IfcProduct first, IfcProduct second)
 {
     if (first == second) return false;
     return null;
 }
Пример #10
0
 public IfcProductModelView(IfcProduct prod, IXbimViewModel parent)
 {
     CreatingParent = parent;
     this.product = prod;
 }
Пример #11
0
 public double? Distance(IfcProduct first, IfcProduct second)
 {
     return _geometryAnalyser.Distance(first, second);
 }
Пример #12
0
        /// <summary>
        /// Add a Bounding Box extrusion onto the ifcProduct
        /// </summary>
        /// <param name="row">COBieCoordinateRow holding the data for one corner</param>
        /// <param name="rowNext">COBieCoordinateRow holding the data for the other corner</param>
        /// <param name="placementRelToIfcProduct">Product which is parent of ifcProduct passed product to add extrusion onto</param>
        /// <param name="ifcProduct">IfcProduct to add the extrusion onto</param>
        private void AddExtrudedRectangle(COBieCoordinateRow row, COBieCoordinateRow rowNext, IfcProduct ifcProduct, IfcProduct placementRelToIfcProduct)
        {
            if (ifcProduct != null)
            {
                COBieCoordinateRow lowerLeftRow, upperRightRow;
                if (row.Category.ToLower() == "box-lowerleft")
                {
                    lowerLeftRow = row;
                    upperRightRow = rowNext;
                }
                else
                {
                    lowerLeftRow = rowNext;
                    upperRightRow = row;
                }
                IfcLocalPlacement objectPlacement = CalcObjectPlacement(lowerLeftRow, placementRelToIfcProduct);
                if (objectPlacement != null)
                {
                    //set the object placement for the space
                    ifcProduct.ObjectPlacement = objectPlacement;

                    //get matrix to the space placement
                    XbimMatrix3D matrix3D = ConvertMatrix3D(objectPlacement);
                    //invert matrix so we can convert row points back to the object space
                    matrix3D.Invert();
                    //lets get the points from the two rows
                    XbimPoint3D lowpt, highpt;
                    if ((GetPointFromRow(upperRightRow, out highpt)) &&
                         (GetPointFromRow(lowerLeftRow, out lowpt))
                        )
                    {
                        //transform the points back to object space
                        lowpt = matrix3D.Transform(lowpt);
                        highpt = matrix3D.Transform(highpt);
                        //in object space so we can use Rect3D as this will be aligned with coordinates systems X and Y
                        XbimRect3D bBox = new XbimRect3D();
                        bBox.Location = lowpt;
                        bBox.Union(highpt);
                        if ((double.NaN.CompareTo(bBox.SizeX) != 0) && (double.NaN.CompareTo(bBox.SizeY) != 0))
                        {
                            XbimPoint3D ctrPt = new XbimPoint3D(bBox.X + (bBox.SizeX / 2.0), bBox.Y + (bBox.SizeY / 2.0), bBox.Z + (bBox.SizeZ / 2.0));

                            //Create IfcRectangleProfileDef
                            IfcCartesianPoint IfcCartesianPointCtr = Model.Instances.New<IfcCartesianPoint>(cp => { cp.X = ctrPt.X; cp.Y = ctrPt.Y; cp.Z = 0.0; }); //centre point of 2D box
                            IfcDirection IfcDirectionXDir = Model.Instances.New<IfcDirection>(d => { d.X = 1.0; d.Y = 0; d.Z = 0.0; }); //default to X direction
                            IfcAxis2Placement2D ifcAxis2Placement2DCtr = Model.Instances.New<IfcAxis2Placement2D>(a2p => { a2p.Location = IfcCartesianPointCtr; a2p.RefDirection = IfcDirectionXDir; });
                            IfcRectangleProfileDef ifcRectangleProfileDef = Model.Instances.New<IfcRectangleProfileDef>(rpd => { rpd.ProfileType = IfcProfileTypeEnum.AREA; rpd.ProfileName = row.RowName; rpd.Position = ifcAxis2Placement2DCtr; rpd.XDim = bBox.SizeX; rpd.YDim = bBox.SizeY; });

                            //Create IfcExtrudedAreaSolid
                            IfcDirection IfcDirectionAxis = Model.Instances.New<IfcDirection>(d => { d.X = 0.0; d.Y = 0; d.Z = 1.0; }); //default to Z direction
                            IfcDirection IfcDirectionRefDir = Model.Instances.New<IfcDirection>(d => { d.X = 1.0; d.Y = 0; d.Z = 0.0; }); //default to X direction
                            IfcCartesianPoint IfcCartesianPointPosition = Model.Instances.New<IfcCartesianPoint>(cp => { cp.X = 0.0; cp.Y = 0.0; cp.Z = 0.0; }); //centre point of 2D box
                            IfcAxis2Placement3D ifcAxis2Placement3DPosition = Model.Instances.New<IfcAxis2Placement3D>(a2p3D => { a2p3D.Location = IfcCartesianPointPosition; a2p3D.Axis = IfcDirectionAxis; a2p3D.RefDirection = IfcDirectionRefDir; });
                            IfcDirection IfcDirectionExtDir = Model.Instances.New<IfcDirection>(d => { d.X = 0.0; d.Y = 0; d.Z = 1.0; }); //default to Z direction
                            IfcExtrudedAreaSolid ifcExtrudedAreaSolid = Model.Instances.New<IfcExtrudedAreaSolid>(eas => { eas.SweptArea = ifcRectangleProfileDef; eas.Position = ifcAxis2Placement3DPosition; eas.ExtrudedDirection = IfcDirectionExtDir; eas.Depth = bBox.SizeZ; });

                            //Create IfcShapeRepresentation
                            IfcShapeRepresentation ifcShapeRepresentation = Model.Instances.New<IfcShapeRepresentation>(sr => { sr.ContextOfItems = Model.IfcProject.ModelContext(); sr.RepresentationIdentifier = "Body"; sr.RepresentationType = "SweptSolid"; });
                            ifcShapeRepresentation.Items.Add(ifcExtrudedAreaSolid);

                            //create IfcProductDefinitionShape
                            IfcProductDefinitionShape ifcProductDefinitionShape = Model.Instances.New<IfcProductDefinitionShape>(pds => { pds.Name = row.Name; pds.Description = row.SheetName; });
                            ifcProductDefinitionShape.Representations.Add(ifcShapeRepresentation);

                            //Link to the IfcProduct
                            ifcProduct.Representation = ifcProductDefinitionShape;
                        }
                        else
                        {
#if DEBUG
                            Console.WriteLine("Failed to calculate box size for {0}", row.Name);
#endif
                        }
                    }
                    
                }
                else
                {
#if DEBUG
                    Console.WriteLine("Failed to add Object placement for {0}", row.Name);
#endif
                }

            }
        }
Пример #13
0
        /// <summary>
        /// Calculate the ObjectPlacment for an IfcProduct from row data and the parent object
        /// </summary>
        /// <param name="row">COBieCoordinateRow holding the data</param>
        /// <param name="placementRelToIfcProduct">IfcProduct that the ObjectPlacment relates too, i.e. the parent of the ifcProduct ObjectPlacment we are calculating</param>
        /// <returns></returns>
        private IfcLocalPlacement CalcObjectPlacement(COBieCoordinateRow row, IfcProduct placementRelToIfcProduct)
        {
            XbimPoint3D locationPt;
            bool havePoint = GetPointFromRow(row, out locationPt);
            if (havePoint)
            {
                if ((placementRelToIfcProduct != null) && (placementRelToIfcProduct.ObjectPlacement is IfcLocalPlacement))
                {
                    //TEST, change the building position to see if the same point comes out in Excel sheet, it should be, and in test was.
                    //((IfcAxis2Placement3D)((IfcLocalPlacement)placementRelToIfcProduct.ObjectPlacement).RelativePlacement).SetNewLocation(10.0, 10.0, 0.0);
                    IfcLocalPlacement placementRelTo = (IfcLocalPlacement)placementRelToIfcProduct.ObjectPlacement;
                    XbimMatrix3D matrix3D = ConvertMatrix3D(placementRelTo);
                    
                    //we want to take off the translations and rotations caused by IfcLocalPlacement of the parent objects as we will add these to the new IfcLocalPlacement for this floor
                    matrix3D.Invert(); //so invert matrix to remove the translations to give the origin for the next IfcLocalPlacement
                    locationPt = matrix3D.Transform(locationPt); //get the point with relation to the last IfcLocalPlacement i.e the parent element
                    
                    //Get the WCS matrix values
                    double rotX, rotY, rotZ;
                    if (!(double.TryParse(row.YawRotation, out rotX) && (double.NaN.CompareTo(rotX) != 0)))
                        rotX = 0.0;

                    if (!(double.TryParse(row.ElevationalRotation, out rotY) && (double.NaN.CompareTo(rotY) != 0)))
                        rotY = 0.0;

                    if (double.TryParse(row.ClockwiseRotation, out rotZ) && (double.NaN.CompareTo(rotZ) != 0))
                        rotZ = rotZ * -1; //convert back from clockwise to anti clockwise
                    else
                        rotZ = 0.0;

                    //apply the WCS rotation from COBie Coordinates stored values
                    XbimMatrix3D matrixNewRot3D = new XbimMatrix3D();
                    if (rotX != 0.0)
                        matrixNewRot3D.RotateAroundXAxis(TransformedBoundingBox.DegreesToRadians(rotX));
                    if (rotY != 0.0)
                        matrixNewRot3D.RotateAroundYAxis(TransformedBoundingBox.DegreesToRadians(rotY));
                    if (rotZ != 0.0)
                        matrixNewRot3D.RotateAroundZAxis(TransformedBoundingBox.DegreesToRadians(rotZ));
                    
                    //remove any displacement from the matrix which moved/rotated us to the object space
                    matrix3D.OffsetX = 0.0F;
                    matrix3D.OffsetY = 0.0F;
                    matrix3D.OffsetZ = 0.0F;
                    
                    //remove the matrix that got use to the object space from the WCS location of this object
                    XbimMatrix3D matrixRot3D = matrixNewRot3D * matrix3D;
                    
                    //get the rotation vectors to place in the new IfcAxis2Placement3D for the new IfcLocalPlacement for this object
                    XbimVector3D ucsAxisX = matrixRot3D.Transform(new XbimVector3D(1, 0, 0));
                    XbimVector3D ucsAxisZ = matrixRot3D.Transform(new XbimVector3D(0, 0, 1));
                    ucsAxisX.Normalize();
                    ucsAxisZ.Normalize();

                    //create the new IfcAxis2Placement3D 
                    IfcAxis2Placement3D relativePlacemant = Model.Instances.New<IfcAxis2Placement3D>();
                    relativePlacemant.SetNewDirectionOf_XZ(ucsAxisX.X, ucsAxisX.Y, ucsAxisX.Z, ucsAxisZ.X, ucsAxisZ.Y, ucsAxisZ.Z);
                    relativePlacemant.SetNewLocation(locationPt.X, locationPt.Y, locationPt.Z);

                    //Set up IfcLocalPlacement
                    IfcLocalPlacement objectPlacement = Model.Instances.New<IfcLocalPlacement>();
                    objectPlacement.PlacementRelTo = placementRelTo;
                    objectPlacement.RelativePlacement = relativePlacemant;

                    return objectPlacement;
                }
            }
            return null;
           
        }
Пример #14
0
 private IXbimViewModel FindUnderContainingSpace(IPersistIfcEntity newVal, IfcProduct p)
 {
     var containingSpace = p.IsContainedIn().FirstOrDefault();
     if (containingSpace != null)
     {
         var containingSpaceView = FindItemBreadthFirst(containingSpace);
         if (containingSpaceView != null)
         {
             var found = FindItemDepthFirst(containingSpaceView, newVal);
             if (found != null)
             {
                 return found;
             }
         }
     }
     return null;
 }
Пример #15
0
 public bool? Equals(IfcProduct first, IfcProduct second)
 {
     return Compare(first, second, _semanticAnalyser.Equals, _geometryAnalyser.Equals);
 }
Пример #16
0
 public bool? EastOf(IfcProduct first, IfcProduct second)
 {
     return _geometryAnalyser.EastOf(first, second);
 }
Пример #17
0
 public IfcProduct Difference(IfcProduct first, IfcProduct second)
 {
     return _geometryAnalyser.Difference(first, second);
 }
Пример #18
0
 public bool? Within(IfcProduct first, IfcProduct second)
 {
     return Contains(second, first);
 }
        /// <summary>
        ///   Adds the  element to the set of  elements which are contained in this spatialstructure
        /// </summary>
        /// <param name = "se"></param>
        /// <param name = "prod"></param>
        public static void AddElement(this IfcSpatialStructureElement se, IfcProduct prod)
        {
            if (prod == null) return;

            IEnumerable<IfcRelContainedInSpatialStructure> relatedElements = se.ContainsElements;
            if (relatedElements.Count() == 0) //none defined create the relationship
            {
                IfcRelContainedInSpatialStructure relSe =
                    se.ModelOf.Instances.New<IfcRelContainedInSpatialStructure>();
                relSe.RelatingStructure = se;
                relSe.RelatedElements.Add(prod);
            }
            else
            {
                relatedElements.First().RelatedElements.Add(prod);
            }
        }
Пример #20
0
 public bool? Disjoint(IfcProduct first, IfcProduct second)
 {
     return Compare(first, second, _semanticAnalyser.Disjoint, _geometryAnalyser.Disjoint);
 }
Пример #21
0
        public bool? Touches(IfcProduct first, IfcProduct second)
        {
            //connects elements
            IEnumerable<IfcRelConnectsElements> connElemRels = _model.Instances.Where<IfcRelConnectsElements>
                (r => (r.RelatedElement == first && r.RelatingElement == second) || (r.RelatedElement == second && r.RelatingElement == first));
            if (connElemRels.FirstOrDefault() != null) return true;

            //Connects Path Elements
            IEnumerable<IfcRelConnectsPathElements> connPathElemRels = _model.Instances.Where<IfcRelConnectsPathElements>
                           (r => (r.RelatedElement == first && r.RelatingElement == second) || (r.RelatedElement == second && r.RelatingElement == first));
            if (connPathElemRels.FirstOrDefault() != null) return true;

            //Connects Port To Element
            IEnumerable<IfcRelConnectsPortToElement> connPortElemRels = _model.Instances.Where<IfcRelConnectsPortToElement>
            (r => (r.RelatedElement == first && r.RelatingPort == second) || (r.RelatedElement == second && r.RelatingPort == first));
            if (connPortElemRels.FirstOrDefault() != null) return true;

            //two elements might be connected via ports
            if (first is IfcElement && second is IfcElement)
            {
                IfcElement fElement = first as IfcElement;
                IfcElement sElement = second as IfcElement;
                IEnumerable<IfcRelConnectsPortToElement> connPortToElemRels = _model.Instances.Where<IfcRelConnectsPortToElement>
                    (r => (r.RelatingPort.ConnectedTo == fElement || r.RelatingPort.ConnectedTo == sElement));
                //get all ports
                List<IfcPort> ports = new List<IfcPort>();
                foreach (var relConPort in connPortToElemRels)
                {
                    ports.Add(relConPort.RelatingPort);
                }

                //find relations containing at least one of the ports
                IEnumerable<IfcRelConnectsPorts> connectPorts = _model.Instances.Where<IfcRelConnectsPorts>
                    (r => ports.Contains(r.RelatedPort) || ports.Contains(r.RelatingPort));

                //if there is such a connection than two elements are connected via port (like a pipe and the basin)
                if (connectPorts.FirstOrDefault() != null) return true;
            }

            //Connects Ports
            IEnumerable<IfcRelConnectsPorts> connPortsRels = _model.Instances.Where<IfcRelConnectsPorts>
                (r => (r.RelatedPort == first && r.RelatingPort == second) || (r.RelatedPort == second && r.RelatingPort == first));
            if (connPortsRels.FirstOrDefault() != null) return true;

            //Connects Structural Element
            IEnumerable<IfcRelConnectsStructuralElement> connStructRels = _model.Instances.Where<IfcRelConnectsStructuralElement>
                (r => (r.RelatedStructuralMember == first && r.RelatingElement == second) || (r.RelatedStructuralMember == second && r.RelatingElement == first));
            if (connStructRels.FirstOrDefault() != null) return true;

            //Connects Structural Member
            IEnumerable<IfcRelConnectsStructuralMember> connStructMemRels = _model.Instances.Where<IfcRelConnectsStructuralMember>
                (r => (r.RelatedStructuralConnection == first && r.RelatingStructuralMember == second) || (r.RelatedStructuralConnection == second && r.RelatingStructuralMember == first));
            if (connStructMemRels.FirstOrDefault() != null) return true;

            //Covers Bldg Elements
            IEnumerable<IfcRelCoversBldgElements> coversRels = _model.Instances.Where<IfcRelCoversBldgElements>
                (r => (r.RelatedCoverings.Contains(first) && r.RelatingBuildingElement == second) || (r.RelatedCoverings.Contains(second) && r.RelatingBuildingElement == first));
            if (coversRels.FirstOrDefault() != null) return true;

            //Covers Spaces
            IEnumerable<IfcRelCoversSpaces> coversSpacesRels = _model.Instances.Where<IfcRelCoversSpaces>
                (r => (r.RelatedCoverings.Contains(first) && r.RelatedSpace == second) || (r.RelatedCoverings.Contains(second) && r.RelatedSpace == first));
            if (coversSpacesRels.FirstOrDefault() != null) return true;

            //Space Boundary
            IEnumerable<IfcRelSpaceBoundary> spaceBoundRels = _model.Instances.Where<IfcRelSpaceBoundary>
                (r => (r.RelatedBuildingElement == first && r.RelatingSpace == second) || (r.RelatedBuildingElement == second && r.RelatingSpace == first));
            if (spaceBoundRels.FirstOrDefault() != null) return true;

            return null;
        }
Пример #22
0
        private void AddProductInBuildingStorey(XbimModel model, IfcBuildingStorey _buildingStorey, IfcProduct _prod)
        {
            if (model.IsTransacting)
                return;
            using (XbimReadWriteTransaction txn = model.BeginTransaction("AddProductToBuildingStorey"))
            {
                //if (_prod is IfcSpatialStructureElement)
                try
                {
                    _buildingStorey.AddElement(_prod);
                    if (model.Validate(txn.Modified(), Console.Out) == 0)
                    {
                        txn.Commit();
                    }
                }
                catch(Exception ex)
                {
                    AddMessages("Error in AddProductInBuildingStorey: " + ex.Message);
                    Debug.WriteLine("Error in AddProductInBuildingStorey: " + ex.Message);
                }

            }
        }
Пример #23
0
        private IEnumerable<IfcProduct> GetProductsInProduct(IfcProduct prod)
        {
            //decomposes is a supertype of IfcRelAggregates, IfcRelNests
            IEnumerable<IfcRelDecomposes> decompRels = _model.Instances.Where<IfcRelDecomposes>(r => r.RelatingObject == prod);
            foreach (var item in decompRels)
            {
                foreach (var p in item.RelatedObjects)
                {
                    IfcProduct product = p as IfcProduct;
                    yield return product;
                }
            }

            //fills
            IfcOpeningElement opening = prod as IfcOpeningElement;
            if (opening != null)
            {
                IEnumerable<IfcRelFillsElement> fillsRels = _model.Instances.Where<IfcRelFillsElement>(r => r.RelatingOpeningElement == opening);
                foreach (var rel in fillsRels)
                {
                    yield return rel.RelatedBuildingElement;
                }
            }

            //voids
            IfcElement element = prod as IfcElement;
            if (element != null)
            {
                IEnumerable<IfcRelVoidsElement> voidsRels = _model.Instances.Where<IfcRelVoidsElement>(r => r.RelatingBuildingElement == element);
                foreach (var rel in voidsRels)
                {
                    yield return rel.RelatedOpeningElement;
                }
            }
        }
Пример #24
0
 private void ChangeRelProducts(XbimModel model, IfcBuildingStorey bs, IfcProduct _product)
 {
     //var products = model.Instances.OfType<IfcBuildingElement>();
     using (XbimReadWriteTransaction txn = model.BeginTransaction("ChangeRelProducts"))
     {
         var ifcRel = model.Instances.New<IfcRelContainedInSpatialStructure>();
         ifcRel.RelatingStructure = bs;
         ifcRel.RelatedElements.Add(_product);
         if (model.Validate(txn.Modified(), Console.Out) == 0)
         {
             txn.Commit();
         }
     }
 }
Пример #25
0
 public bool? Crosses(IfcProduct first, IfcProduct second)
 {
     return null;
 }
Пример #26
0
        private IfcProduct CopyProduct(XbimModel newmodel, XbimModel model, IfcProduct _prod)
        {
            using (XbimReadWriteTransaction txn = newmodel.BeginTransaction("CopyProduct"))
            {
                PropertyTranformDelegate propTransform = delegate (IfcMetaProperty prop, object toCopy)
                {
                    var value = prop.PropertyInfo.GetValue(toCopy, null);
                    return value;
                };

                var copied = new XbimInstanceHandleMap(model, newmodel);
                IPersistIfcEntity ent = _prod as IPersistIfcEntity;
                XbimInstanceHandle toCopyHandle = ent.GetHandle();
                XbimInstanceHandle copyHandle;
                if (copied.TryGetValue(toCopyHandle, out copyHandle))
                {
                    //Debug.Assert(copyHandle != null);
                    txn.Commit();
                    return copyHandle.GetEntity() as IfcProduct;
                }
                txn.Pulse();
                IfcType ifcType = IfcMetaData.IfcType(ent);
                //int copyLabel = ent.EntityLabel;
                var _ent = newmodel.Instances.New(ifcType.Type);
                copyHandle = _ent.GetHandle();//InsertNew(ifcType.Type, copyLabel);
                copied.Add(toCopyHandle, copyHandle);
                if (typeof(IfcCartesianPoint) == ifcType.Type || typeof(IfcDirection) == ifcType.Type)//special cases for cartesian point and direction for efficiency
                {
                    IPersistIfcEntity v = (IPersistIfcEntity)Activator.CreateInstance(ifcType.Type, new object[] { ent });
                    v.Bind(newmodel, copyHandle.EntityLabel, true);
                    v.Activate(true);
                    txn.Commit();
                    return copyHandle.GetEntity() as IfcProduct;
                    //read.TryAdd(copyHandle.EntityLabel, v);
                    //createdNew.TryAdd(copyHandle.EntityLabel, v);
                    //return (T)v;
                }
                else
                {
                    IPersistIfcEntity theCopy = (IPersistIfcEntity)Activator.CreateInstance(copyHandle.EntityType);
                    theCopy.Bind(newmodel, copyHandle.EntityLabel, true);
                    //read.TryAdd(copyHandle.EntityLabel, theCopy);
                    //createdNew.TryAdd(copyHandle.EntityLabel, theCopy);
                    // IfcRoot rt = theCopy as IfcRoot;
                    IEnumerable<IfcMetaProperty> props = ifcType.IfcProperties.Values.Where(p => !p.IfcAttribute.IsDerivedOverride);
                    // if (rt != null) rt.OwnerHistory = _model.OwnerHistoryAddObject;
                    foreach (IfcMetaProperty prop in props)
                    {
                        //if (rt != null && prop.PropertyInfo.Name == "OwnerHistory") //don't add the owner history in as this will be changed later
                        //    continue;
                        object value;
                        if (propTransform != null)
                            value = propTransform(prop, ent);
                        else
                            value = prop.PropertyInfo.GetValue(ent, null);
                        if (value != null)
                        {
                            Type theType = value.GetType();
                            //if it is an express type or a value type, set the value
                            if (theType.IsValueType || typeof(ExpressType).IsAssignableFrom(theType))
                            {
                                prop.PropertyInfo.SetValue(theCopy, value, null);
                            }

                        }
                    }
                    //  if (rt != null) rt.OwnerHistory = this.OwnerHistoryAddObject;
                    _prod = theCopy as IfcProduct;
                }

                if (newmodel.Validate(txn.Modified(), Console.Out) == 0)
                {
                    txn.Commit();
                    return _prod;
                }
            }
            return null;
        }
Пример #27
0
 public bool? Equals(IfcProduct first, IfcProduct second)
 {
     if (first == second) return true;
     return null;
 }
Пример #28
0
        private void AddProductInBuilding(XbimModel model, IfcBuilding _building, IfcProduct _prod)
        {
            using (XbimReadWriteTransaction txn = model.BeginTransaction("Add Product"))
            {
                //if (_prod is IfcSpatialStructureElement)
                try
                {
                    _building.AddElement(_prod);
                    txn.Commit();
                }
                catch
                {
                    //MessageBox.Show(_prod.GetType().Name);
                }

            }
        }
Пример #29
0
 /// <summary>
 /// This cannot be established from the semantic relations
 /// </summary>
 /// <param name="first"></param>
 /// <param name="second"></param>
 /// <returns></returns>
 public bool? Overlaps(IfcProduct first, IfcProduct second)
 {
     return null;
 }
Пример #30
0
 /// <summary>
 /// Adds the geometry to the mesh for the given product, returns the mesh fragment details
 /// </summary>
 /// <param name="geometryModel">Geometry to add</param>
 /// <param name="product">The product the geometry represents (this may be a partial representation)</param>
 /// <param name="transform">Transform the geometry to a new location or rotation</param>
 /// <param name="deflection">Deflection for triangulating curves, if null default defelction for the model is used</param>
 public XbimMeshFragment Add(IXbimGeometryModel geometryModel, IfcProduct product, XbimMatrix3D transform, double? deflection = null, short modelId = 0)
 {
     return geometryModel.MeshTo(this, product, transform, deflection ?? product.ModelOf.ModelFactors.DeflectionTolerance);
 }
Пример #31
0
 public static void AddElement(this IfcSite site, IfcProduct element)
 {
     IEnumerable<IfcRelContainedInSpatialStructure> relatedElements = site.ContainsElements;
     if (relatedElements.Count() == 0) //none defined create the relationship
     {
         IfcRelContainedInSpatialStructure relSe =
             site.ModelOf.Instances.New<IfcRelContainedInSpatialStructure>();
         relSe.RelatingStructure = site;
         relSe.RelatedElements.Add(element);
     }
     else
     {
         relatedElements.First().RelatedElements.Add(element);
     }
 }
Пример #32
0
 public IfcProduct ConvexHull(IfcProduct product)
 {
     return _geometryAnalyser.ConvexHull(product);
 }