Esempio n. 1
0
        public IIfcElement CreateExtrusion(
            ref List <IIfcProduct> elements,
            List <Point> points,
            List <double> chamfers,
            double height,
            Guid guid)
        {
            IfcAxis2Placement          plateLocation          = new IfcAxis2Placement(IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(this.Position.get_X(), this.Position.get_Y(), this.Position.get_Z()), this.DirZ, this.DirY));
            IIfcAxis2Placement3D       axis2Placement3D       = IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(0.0, 0.0, 0.0), IfcTools.CreateDirection(0.0, 1.0, 0.0), IfcTools.CreateDirection(0.0, 0.0, 1.0));
            IIfcProductDefinitionShape productDefinitionShape = IfcTools.IfcDatabase.CreateIfcProductDefinitionShape((IfcLabel)null, (IfcText)null, new List <IIfcRepresentation>()
            {
                IfcTools.CreateShapeRepresentation((IIfcRepresentationItem)IfcTools.CreateExtrudedAreaSolid((IIfcProfileDef)IfcTools.CreateArbitraryClosedProfileDef(IfcProfileTypeEnum.IFC_AREA, (IIfcCurve)IfcTools.CreateChamferedCurvedPolyline(points, chamfers)), axis2Placement3D, IfcTools.CreateDirection(0.0, 0.0, 1.0), (IfcPositiveLengthMeasure)height), "Body", "SweptSolid")
            });
            IIfcPlate plate = IfcTools.CreatePlate(plateLocation, (IIfcProductRepresentation)productDefinitionShape, guid);

            IfcTools.AddQuantities((IIfcObject)plate);
            IfcTools.AddColorToElement((IIfcElement)plate, "brown");
            IfcTools.AddMaterialToElement(new List <IIfcRoot>()
            {
                (IIfcRoot)plate
            }, "Undefined");
            if (!string.IsNullOrEmpty(this.Reference))
            {
                Dictionary <string, object> attributes = new Dictionary <string, object>()
                {
                    {
                        "PDMS_ID",
                        (object)(IfcLabel)this.Reference
                    }
                };
                IfcTools.AddProperties((IIfcObject)plate, "PDMS Common", attributes);
            }
            elements.Add((IIfcProduct)plate);
            return((IIfcElement)plate);
        }
Esempio n. 2
0
 public IXbimGeometryObject Moved(IXbimGeometryObject geometryObject, IIfcAxis2Placement3D placement)
 {
     using (new Tracer(LogHelper.CurrentFunctionName(), this._logger, geometryObject))
     {
         return(_engine.Moved(geometryObject, placement));
     }
 }
Esempio n. 3
0
        public IIfcElement CreateCylinder(
            ref List <IIfcProduct> elements,
            double height,
            double radius,
            Guid guid)
        {
            IfcAxis2Placement          beamLocation           = new IfcAxis2Placement(IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(this.Position.get_X(), this.Position.get_Y(), this.Position.get_Z()), this.DirZ, this.DirY));
            IIfcAxis2Placement2D       axis2Placement2D       = IfcTools.CreateAxis2Placement2D(IfcTools.CreatePoint(0.0, 0.0), IfcTools.CreateDirection(1.0, 0.0));
            IIfcAxis2Placement3D       axis2Placement3D       = IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(0.0, 0.0, -height / 2.0), IfcTools.CreateDirection(0.0, 0.0, 1.0), IfcTools.CreateDirection(0.0, -1.0, 0.0));
            IIfcProductDefinitionShape productDefinitionShape = IfcTools.IfcDatabase.CreateIfcProductDefinitionShape((IfcLabel)null, (IfcText)null, new List <IIfcRepresentation>()
            {
                IfcTools.CreateShapeRepresentation((IIfcRepresentationItem)IfcTools.CreateExtrudedAreaSolid((IIfcProfileDef)IfcTools.IfcDatabase.CreateIfcCircleProfileDef(new IfcProfileTypeEnum?(IfcProfileTypeEnum.IFC_AREA), (IfcLabel)string.Empty, axis2Placement2D, (IfcPositiveLengthMeasure)radius), axis2Placement3D, IfcTools.CreateDirection(0.0, 0.0, 1.0), (IfcPositiveLengthMeasure)height), "Body", "SweptSolid")
            });
            IIfcBeam beam = IfcTools.CreateBeam(beamLocation, (IIfcProductRepresentation)productDefinitionShape, guid);

            IfcTools.AddQuantities((IIfcObject)beam);
            IfcTools.AddColorToElement((IIfcElement)beam, "yellow");
            IfcTools.AddMaterialToElement(new List <IIfcRoot>()
            {
                (IIfcRoot)beam
            }, "Undefined");
            if (!string.IsNullOrEmpty(this.Reference))
            {
                Dictionary <string, object> attributes = new Dictionary <string, object>()
                {
                    {
                        "PDMS_ID",
                        (object)(IfcLabel)this.Reference
                    }
                };
                IfcTools.AddProperties((IIfcObject)beam, "PDMS Common", attributes);
            }
            elements.Add((IIfcProduct)beam);
            return((IIfcElement)beam);
        }
Esempio n. 4
0
        public IIfcRevolvedAreaSolid CreateSolid(
            IIfcProfileDef profile,
            double radius,
            double angle)
        {
            IIfcAxis1Placement   ifcAxis1Placement = IfcTools.IfcDatabase.CreateIfcAxis1Placement(IfcTools.CreatePoint(radius, 0.0, 0.0), IfcTools.CreateDirection(0.0, 1.0, 0.0));
            IIfcAxis2Placement3D axis2Placement3D  = IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(this.Position.get_X(), this.Position.get_Y(), this.Position.get_Z()), this.DirY, this.DirX);

            return(IfcTools.CreateRevolvedAreaSolid(profile, axis2Placement3D, ifcAxis1Placement, (IfcPlaneAngleMeasure)angle));
        }
        public static XbimMatrix3D ToMatrix3D(IIfcAxis2Placement3D ax)
        {
            var origin = ToXbimPoint3D(ax.Location);
            var zAxis  = ax.Axis == null ? new XbimVector3D(0, 0, 1) : ToXbimVector3D(ax.Axis).Normalized();
            var xAxis  = ax.RefDirection == null ? new XbimVector3D(1, 0, 0) : ToXbimVector3D(ax.RefDirection).Normalized();
            var yAxis  = zAxis.CrossProduct(xAxis);

            return(new XbimMatrix3D(xAxis.X, xAxis.Y, xAxis.Z, 0, yAxis.X, yAxis.Y, yAxis.Z, 0,
                                    zAxis.X, zAxis.Y, zAxis.Z, 0, origin.X, origin.Y, origin.Z, 1));
        }
Esempio n. 6
0
        public IIfcBeam CreateStraight(
            ref List <IIfcProduct> elements,
            IIfcProfileDef profile,
            double length,
            Guid guid)
        {
            IfcAxis2Placement          beamLocation           = new IfcAxis2Placement(IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(this.Position.get_X(), this.Position.get_Y(), this.Position.get_Z()), this.DirZ, this.DirX));
            IIfcAxis2Placement3D       axis2Placement3D       = IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(0.0, 0.0, 0.0), IfcTools.CreateDirection(0.0, 0.0, 1.0), IfcTools.CreateDirection(1.0, 0.0, 0.0));
            IIfcProductDefinitionShape productDefinitionShape = IfcTools.IfcDatabase.CreateIfcProductDefinitionShape((IfcLabel)null, (IfcText)null, new List <IIfcRepresentation>()
            {
                IfcTools.CreateShapeRepresentation((IIfcRepresentationItem)IfcTools.CreateExtrudedAreaSolid(profile, axis2Placement3D, IfcTools.CreateDirection(0.0, 0.0, 1.0), (IfcPositiveLengthMeasure)length), "Body", "SweptSolid")
            });

            return(IfcTools.CreateBeam(beamLocation, (IIfcProductRepresentation)productDefinitionShape, guid));
        }
Esempio n. 7
0
 public static XbimMatrix3D ToMatrix3D(this IIfcAxis2Placement3D axis3)
 {
     if (axis3.RefDirection != null && axis3.Axis != null)
     {
         var za = new XbimVector3D(axis3.Axis.X, axis3.Axis.Y, axis3.Axis.Z);
         za = za.Normalized();
         var xa = new XbimVector3D(axis3.RefDirection.X, axis3.RefDirection.Y, axis3.RefDirection.Z);
         xa = xa.Normalized();
         XbimVector3D ya = XbimVector3D.CrossProduct(za, xa);
         ya = ya.Normalized();
         return(new XbimMatrix3D(xa.X, xa.Y, xa.Z, 0, ya.X, ya.Y, ya.Z, 0, za.X, za.Y, za.Z, 0, axis3.Location.X,
                                 axis3.Location.Y, axis3.Location.Z, 1));
     }
     return(new XbimMatrix3D(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, axis3.Location.X, axis3.Location.Y,
                             axis3.Location.Z, 1));
 }
Esempio n. 8
0
        public IIfcBeam CreateCurve(
            ref List <IIfcProduct> elements,
            IIfcProfileDef profile,
            double radius,
            double angle,
            Guid guid)
        {
            IfcAxis2Placement          beamLocation           = new IfcAxis2Placement(IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(this.Position.get_X(), this.Position.get_Y(), this.Position.get_Z()), this.DirX, this.DirZ));
            IIfcAxis2Placement3D       axis2Placement3D       = IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(0.0, 0.0, 0.0), IfcTools.CreateDirection(1.0, 0.0, 0.0), IfcTools.CreateDirection(0.0, 1.0, 0.0));
            IIfcProductDefinitionShape productDefinitionShape = IfcTools.IfcDatabase.CreateIfcProductDefinitionShape((IfcLabel)null, (IfcText)null, new List <IIfcRepresentation>()
            {
                IfcTools.CreateShapeRepresentation((IIfcRepresentationItem)IfcTools.CreateCurvedBeam(profile, axis2Placement3D, IfcTools.IfcDatabase.CreateIfcAxis1Placement(IfcTools.CreatePoint(0.0, 0.0, 0.0), IfcTools.CreateDirection(1.0, 0.0, 0.0)), (IfcPlaneAngleMeasure)angle), "Body", "SweptSolid")
            });

            return(IfcTools.CreateBeam(beamLocation, (IIfcProductRepresentation)productDefinitionShape, guid));
        }
Esempio n. 9
0
        public IIfcElement CreateSlopedCylinder(
            ref List <IIfcProduct> elements,
            double height,
            double radius,
            double botX,
            double botY,
            double topX,
            double topY,
            Guid guid)
        {
            double                     num1                   = Math.Max(radius * Math.Tan(Math.Abs(botX * Math.PI / 180.0)), radius * Math.Tan(Math.Abs(botY * Math.PI / 180.0)));
            double                     num2                   = Math.Max(radius * Math.Tan(Math.Abs(topX * Math.PI / 180.0)), radius * Math.Tan(Math.Abs(topY * Math.PI / 180.0)));
            IfcAxis2Placement          beamLocation           = new IfcAxis2Placement(IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(this.Position.get_X(), this.Position.get_Y(), this.Position.get_Z()), this.DirZ, this.DirY));
            IIfcAxis2Placement2D       axis2Placement2D       = IfcTools.CreateAxis2Placement2D(IfcTools.CreatePoint(0.0, 0.0), IfcTools.CreateDirection(1.0, 0.0));
            IIfcAxis2Placement3D       axis2Placement3D       = IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(0.0, 0.0, -height / 2.0 - num1), IfcTools.CreateDirection(0.0, 0.0, 1.0), IfcTools.CreateDirection(1.0, 0.0, 0.0));
            IIfcExtrudedAreaSolid      extrudedAreaSolid      = IfcTools.CreateExtrudedAreaSolid((IIfcProfileDef)IfcTools.IfcDatabase.CreateIfcCircleProfileDef(new IfcProfileTypeEnum?(IfcProfileTypeEnum.IFC_AREA), (IfcLabel)string.Empty, axis2Placement2D, (IfcPositiveLengthMeasure)radius), axis2Placement3D, IfcTools.CreateDirection(0.0, 0.0, 1.0), (IfcPositiveLengthMeasure)(height + num1 + num2));
            IIfcBooleanClippingResult  booleanClippingResult1 = (IIfcBooleanClippingResult)null;
            IIfcBooleanClippingResult  booleanClippingResult2 = (IIfcBooleanClippingResult)null;
            IIfcProductDefinitionShape productDefinitionShape = IfcTools.IfcDatabase.CreateIfcProductDefinitionShape((IfcLabel)null, (IfcText)null, new List <IIfcRepresentation>()
            {
                booleanClippingResult2 == null ? (booleanClippingResult1 == null ? IfcTools.CreateShapeRepresentation((IIfcRepresentationItem)extrudedAreaSolid, "Body", "SweptSolid") : IfcTools.CreateShapeRepresentation((IIfcRepresentationItem)booleanClippingResult1, "Body", "Clipping")) : IfcTools.CreateShapeRepresentation((IIfcRepresentationItem)booleanClippingResult2, "Body", "Clipping")
            });
            IIfcBeam beam = IfcTools.CreateBeam(beamLocation, (IIfcProductRepresentation)productDefinitionShape, guid);

            IfcTools.AddQuantities((IIfcObject)beam);
            IfcTools.AddColorToElement((IIfcElement)beam, "green");
            IfcTools.AddMaterialToElement(new List <IIfcRoot>()
            {
                (IIfcRoot)beam
            }, "Undefined");
            if (!string.IsNullOrEmpty(this.Reference))
            {
                Dictionary <string, object> attributes = new Dictionary <string, object>()
                {
                    {
                        "PDMS_ID",
                        (object)(IfcLabel)this.Reference
                    }
                };
                IfcTools.AddProperties((IIfcObject)beam, "PDMS Common", attributes);
            }
            elements.Add((IIfcProduct)beam);
            return((IIfcElement)beam);
        }
Esempio n. 10
0
        public IIfcElement CreateRevolution(
            ref List <IIfcProduct> elements,
            List <Point> points,
            List <double> chamfers,
            double angle,
            Guid guid)
        {
            IIfcProfileDef             profile                = IfcTools.CreateProfile(points, chamfers, "REVO");
            IfcAxis2Placement          beamLocation           = new IfcAxis2Placement(IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(this.Position.get_X(), this.Position.get_Y(), this.Position.get_Z()), this.DirY, this.DirX));
            IIfcAxis2Placement3D       axis2Placement3D       = IfcTools.CreateAxis2Placement3D(IfcTools.CreatePoint(0.0, 0.0, 0.0), IfcTools.CreateDirection(0.0, 1.0, 0.0), IfcTools.CreateDirection(1.0, 0.0, 0.0));
            IIfcProductDefinitionShape productDefinitionShape = IfcTools.IfcDatabase.CreateIfcProductDefinitionShape((IfcLabel)null, (IfcText)null, new List <IIfcRepresentation>()
            {
                IfcTools.CreateShapeRepresentation((IIfcRepresentationItem)IfcTools.CreateCurvedBeam(profile, axis2Placement3D, IfcTools.IfcDatabase.CreateIfcAxis1Placement(IfcTools.CreatePoint(0.0, 0.0, 0.0), IfcTools.CreateDirection(1.0, 0.0, 0.0)), (IfcPlaneAngleMeasure)angle), "Body", "SweptSolid")
            });
            IIfcBeam beam = IfcTools.CreateBeam(beamLocation, (IIfcProductRepresentation)productDefinitionShape, guid);

            IfcTools.AddQuantities((IIfcObject)beam);
            IfcTools.AddColorToElement((IIfcElement)beam, "beige");
            IfcTools.AddMaterialToElement(new List <IIfcRoot>()
            {
                (IIfcRoot)beam
            }, "Undefined");
            if (!string.IsNullOrEmpty(this.Reference))
            {
                Dictionary <string, object> attributes = new Dictionary <string, object>()
                {
                    {
                        "PDMS_ID",
                        (object)(IfcLabel)this.Reference
                    }
                };
                IfcTools.AddProperties((IIfcObject)beam, "PDMS Common", attributes);
            }
            elements.Add((IIfcProduct)beam);
            return((IIfcElement)beam);
        }
Esempio n. 11
0
        public IfcLocationData(string path)
        {
            using (IfcStore model = IfcStore.Open(path))
            {
                if (model.SchemaVersion == XbimSchemaVersion.Ifc2X3)
                {
                    Schema            = "Ifc 2x3";
                    SchemaIsSupported = true;
                }
                else if (model.SchemaVersion == XbimSchemaVersion.Ifc4)
                {
                    Schema            = "Ifc4";
                    SchemaIsSupported = false;
                    return;
                }
                else
                {
                    Schema            = model.SchemaVersion.ToString();
                    SchemaIsSupported = false;
                    return;
                }
                IIfcProject project             = model.Instances.FirstOrDefault <IIfcProject>();
                string      applicationFullname = project.OwnerHistory.OwningApplication.ApplicationFullName;
                if (applicationFullname == null)
                {
                    AuthoringTool = "N/A";
                }
                else
                {
                    AuthoringTool = project.OwnerHistory.OwningApplication.ApplicationFullName;
                }


                IIfcSIUnit lengtUnit = project.UnitsInContext.Units.FirstOrDefault <IIfcSIUnit>(q => q.UnitType == IfcUnitEnum.LENGTHUNIT);
                LengthUnit = lengtUnit.FullName;

                IIfcSite site = model.Instances.FirstOrDefault <IIfcSite>();
                if (site.RefElevation.HasValue)
                {
                    refElevation = site.RefElevation.Value;
                }
                else
                {
                    refElevation = double.NaN;
                }
                IIfcLocalPlacement   placement      = site.ObjectPlacement as IIfcLocalPlacement;
                IIfcAxis2Placement3D axis2Placement = placement.RelativePlacement as IIfcAxis2Placement3D;
                double x     = axis2Placement.RefDirection.DirectionRatios.GetAt(0);
                double y     = axis2Placement.RefDirection.DirectionRatios.GetAt(1);
                double angle = 360 - Math.Atan2(y, x) * 180 / Math.PI;
                if (angle.Equals(360))
                {
                    angle = 0;
                }
                Orientation = angle;

                EW        = axis2Placement.Location.Coordinates.GetAt(0);
                NS        = axis2Placement.Location.Coordinates.GetAt(1);
                elevation = axis2Placement.Location.Coordinates.GetAt(2);
            }
        }
Esempio n. 12
0
 public IXbimGeometryObject Create(IIfcGeometricRepresentationItem ifcRepresentation, IIfcAxis2Placement3D objectLocation, ILogger logger)
 {
     try
     {
         using (new Tracer(LogHelper.CurrentFunctionName(), this._logger, ifcRepresentation))
         {
             return(_engine.Create(ifcRepresentation, objectLocation, logger));
         }
     }
     catch (Exception e)
     {
         (logger ?? _logger).LogError("EE001: Failed to create geometry #{0} of type {1}, {2}", ifcRepresentation.EntityLabel, ifcRepresentation.GetType().Name, e.Message);
         return(null);
     }
 }
Esempio n. 13
0
 public IXbimGeometryObject Moved(IXbimGeometryObject geometryObject, IIfcAxis2Placement3D placement)
 {
     return(_engine.Moved(geometryObject, placement));
 }
Esempio n. 14
0
 public IXbimGeometryObject Create(IIfcGeometricRepresentationItem ifcRepresentation, IIfcAxis2Placement3D objectLocation)
 {
     try
     {
         return(_engine.Create(ifcRepresentation, objectLocation));
     }
     catch (AccessViolationException e)
     {
         Logger.ErrorFormat("EE001: Failed to create geometry #{0} of type {1}, {2]", ifcRepresentation.EntityLabel, ifcRepresentation.GetType().Name, e.Message);
         return(null);
     }
 }