public static XbimMatrix3D ToMatrix3D(this IfcAxis2Placement2D axis2, ConcurrentDictionary <int, Object> maps = null)
        {
            object transform;

            if (maps != null && maps.TryGetValue(axis2.EntityLabel, out transform)) //already converted it just return cached
            {
                return((XbimMatrix3D)transform);
            }
            if (axis2.RefDirection != null)
            {
                XbimVector3D v = axis2.RefDirection.XbimVector3D();
                v         = v.Normalized();
                transform = new XbimMatrix3D(v.X, v.Y, 0, 0, v.Y, v.X, 0, 0, 0, 0, 1, 0, axis2.Location.X, axis2.Location.Y, 0, 1);
            }
            else
            {
                transform = new XbimMatrix3D(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, axis2.Location.X, axis2.Location.Y,
                                             axis2.Location.Z, 1);
            }
            if (maps != null)
            {
                maps.TryAdd(axis2.EntityLabel, transform);
            }
            return((XbimMatrix3D)transform);
        }
        private void InitWCS()
        {
            using (var txn = this._model.BeginTransaction("Initialise WCS"))
            {
                var context3D = this._model.Instances.OfType <IfcGeometricRepresentationContext>()
                                .Where(c => c.CoordinateSpaceDimension == 3)
                                .FirstOrDefault();
                if (context3D.WorldCoordinateSystem is IfcAxis2Placement3D wcs)
                {
                    WCS              = wcs;
                    Origin3D         = wcs.Location;
                    AxisZ3D          = toolkit_factory.MakeDirection(_model, 0, 0, 1);
                    wcs.Axis         = AxisZ3D;
                    AxisX3D          = toolkit_factory.MakeDirection(_model, 1, 0, 0);
                    wcs.RefDirection = AxisX3D;
                    AxisY3D          = toolkit_factory.MakeDirection(_model, 0, 1, 0);
                }

                var context2D = this._model.Instances.OfType <IfcGeometricRepresentationContext>()
                                .Where(c => c.CoordinateSpaceDimension == 2)
                                .FirstOrDefault();
                if (context2D.WorldCoordinateSystem is IfcAxis2Placement2D wcs2d)
                {
                    WCS2D              = wcs2d;
                    Origin2D           = wcs2d.Location;
                    AxisX2D            = toolkit_factory.MakeDirection(_model, 1, 0);
                    wcs2d.RefDirection = AxisX2D;
                    AxisY2D            = toolkit_factory.MakeDirection(_model, 0, 1);
                }

                txn.Commit();
            }
        }
Esempio n. 3
0
        // BbPosition2D ()
        //    :this(BbCoordinate2D.Origin2D)
        //{
        //}

        // BbPosition2D (BbCoordinate2D coordinate2D)
        //    :this(coordinate2D, BbDirection2D.RefDirection2D)
        //{
        //}

        BbPosition2D(BbCoordinate2D coordinate2D,
                     BbDirection2D refDirection)
        {
            ifcAxis2Placement2D = new IfcAxis2Placement2D {
                Location     = coordinate2D.IfcCartesianPoint,
                RefDirection = refDirection.IfcDirection,
            };
        }
Esempio n. 4
0
        private static Transform ToTransform(this IfcAxis2Placement2D cs)
        {
            var d = cs.RefDirection.ToVector3();
            var z = Vector3.ZAxis;
            var o = cs.Location.ToVector3();

            return(new Transform(o, d, z));
        }
 static public IfcAxis2Placement2D Create(this IfcAxis2Placement2D ax, IfcCartesianPoint centre, IfcDirection xAxisDirection)
 {
     return(ax.Model.Instances.New <IfcAxis2Placement2D>(a =>
     {
         a.RefDirection = xAxisDirection;
         a.Location = centre;
     }));
 }
Esempio n. 6
0
        public static Plane getPlaneFromPosition(IfcPlacement pos)
        {
            Point3D org = getPoint3DFromIfcCartesianPoint(pos.Location);

            Vector3D xAxis = null, yAxis = null, zAxis = null;

            if (pos is IfcAxis1Placement)
            {
                throw new Exception("IfcAxis1Placement");
            }
            else if (pos is IfcAxis2Placement2D)
            {
                IfcAxis2Placement2D pos2D = (IfcAxis2Placement2D)pos;

                if (pos2D.RefDirection != null)
                {
                    xAxis = new Vector3D(pos2D.RefDirection.DirectionRatioX, pos2D.RefDirection.DirectionRatioY, pos2D.RefDirection.DirectionRatioZ);
                }
                else
                {
                    xAxis = new Vector3D(1, 0, 0);
                }

                yAxis = Vector3D.Cross(Plane.XY.AxisZ, xAxis);
            }
            else if (pos is IfcAxis2Placement3D)
            {
                IfcAxis2Placement3D pos3D = (IfcAxis2Placement3D)pos;

                if (pos3D.RefDirection != null)
                {
                    xAxis = new Vector3D(pos3D.RefDirection.DirectionRatioX, pos3D.RefDirection.DirectionRatioY, pos3D.RefDirection.DirectionRatioZ);
                }
                else
                {
                    xAxis = new Vector3D(1, 0, 0);
                }

                if (pos3D.Axis != null)
                {
                    zAxis = new Vector3D(pos3D.Axis.DirectionRatioX, pos3D.Axis.DirectionRatioY, pos3D.Axis.DirectionRatioZ);
                }
                else
                {
                    zAxis = new Vector3D(0, 0, 1);
                }

                if (xAxis.IsZero)    //rivedere
                {
                    xAxis = new Vector3D(1, 0, 0);
                }

                yAxis = Vector3D.Cross(zAxis, xAxis);
            }
            return(new Plane(org, xAxis, yAxis));
        }
Esempio n. 7
0
        static public IfcAxis2Placement2D Create(this IfcAxis2Placement2D ax, IfcCartesianPoint centre, IfcDirection xAxisDirection)
        {
            IfcAxis2Placement2D ax2 = new IfcAxis2Placement2D()
            {
                RefDirection = xAxisDirection,
                Location     = centre
            };

            return(ax2);
        }
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcAxis2Placement2D a, IfcAxis2Placement2D b)
        {
            if (a.Equals(b))
            {
                return(true);
            }
            double precision = b.Model.ModelFactors.Precision;

            return(a.P[0].IsEqual(b.P[0], precision) &&
                   a.P[1].IsEqual(b.P[1], precision) &&
                   a.Location.GeometricEquals(b.Location));
        }
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 2:
                _position = (IfcAxis2Placement2D)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Esempio n. 10
0
        public override void IfcParse(int propIndex, IPropertyValue value)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
                base.IfcParse(propIndex, value);
                break;

            case 2:
                _position = (IfcAxis2Placement2D)value.EntityVal;
                break;

            default:
                this.HandleUnexpectedAttribute(propIndex, value); break;
            }
        }
Esempio n. 11
0
        public static XbimMatrix3D ToMatrix3D(this IfcAxis2Placement placement)
        {
            IfcAxis2Placement3D ax3 = placement as IfcAxis2Placement3D;
            IfcAxis2Placement2D ax2 = placement as IfcAxis2Placement2D;

            if (ax3 != null)
            {
                return(ax3.ToMatrix3D());
            }
            else if (ax2 != null)
            {
                return(ax2.ToMatrix3D());
            }
            else
            {
                return(XbimMatrix3D.Identity);
            }
        }
        public PlacementAxis2D(IfcStore model, CartesianPoint2D location, DirectionVector2D refAxis)
        {
            this.location = location;
            this.refAxis  = refAxis;

            IfcAxis2Placement2D result = model.Instances.OfType <IfcAxis2Placement2D>().Where(p => p.Location == location.IfcPoint && p.RefDirection.Equals(refAxis.IfcDirection)).FirstOrDefault();

            if (result == null)
            {
                ifcAxis2Placement2D = model.Instances.New <IfcAxis2Placement2D>(p =>
                {
                    p.Location     = location.IfcPoint;
                    p.RefDirection = refAxis.IfcDirection;
                });
            }

            else
            {
                ifcAxis2Placement2D = result;
            }
        }
Esempio n. 13
0
 public IfcUShapeProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __Depth, IfcPositiveLengthMeasure __FlangeWidth, IfcPositiveLengthMeasure __WebThickness, IfcPositiveLengthMeasure __FlangeThickness, IfcPositiveLengthMeasure?__FilletRadius, IfcPositiveLengthMeasure?__EdgeRadius, IfcPlaneAngleMeasure?__FlangeSlope, IfcPositiveLengthMeasure?__CentreOfGravityInX)
     : base(__ProfileType, __ProfileName, __Position)
 {
     this._Depth              = __Depth;
     this._FlangeWidth        = __FlangeWidth;
     this._WebThickness       = __WebThickness;
     this._FlangeThickness    = __FlangeThickness;
     this._FilletRadius       = __FilletRadius;
     this._EdgeRadius         = __EdgeRadius;
     this._FlangeSlope        = __FlangeSlope;
     this._CentreOfGravityInX = __CentreOfGravityInX;
 }
 public IfcCraneRailFShapeProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __OverallHeight, IfcPositiveLengthMeasure __HeadWidth, IfcPositiveLengthMeasure?__Radius, IfcPositiveLengthMeasure __HeadDepth2, IfcPositiveLengthMeasure __HeadDepth3, IfcPositiveLengthMeasure __WebThickness, IfcPositiveLengthMeasure __BaseDepth1, IfcPositiveLengthMeasure __BaseDepth2, IfcPositiveLengthMeasure?__CentreOfGravityInY)
     : base(__ProfileType, __ProfileName, __Position)
 {
     this._OverallHeight      = __OverallHeight;
     this._HeadWidth          = __HeadWidth;
     this._Radius             = __Radius;
     this._HeadDepth2         = __HeadDepth2;
     this._HeadDepth3         = __HeadDepth3;
     this._WebThickness       = __WebThickness;
     this._BaseDepth1         = __BaseDepth1;
     this._BaseDepth2         = __BaseDepth2;
     this._CentreOfGravityInY = __CentreOfGravityInY;
 }
Esempio n. 15
0
 public IfcIShapeProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __OverallWidth, IfcPositiveLengthMeasure __OverallDepth, IfcPositiveLengthMeasure __WebThickness, IfcPositiveLengthMeasure __FlangeThickness, IfcPositiveLengthMeasure?__FilletRadius)
     : base(__ProfileType, __ProfileName, __Position)
 {
     this._OverallWidth    = __OverallWidth;
     this._OverallDepth    = __OverallDepth;
     this._WebThickness    = __WebThickness;
     this._FlangeThickness = __FlangeThickness;
     this._FilletRadius    = __FilletRadius;
 }
Esempio n. 16
0
 public IfcCircleHollowProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __Radius, IfcPositiveLengthMeasure __WallThickness)
     : base(__ProfileType, __ProfileName, __Position, __Radius)
 {
     this._WallThickness = __WallThickness;
 }
Esempio n. 17
0
 public IfcCircleProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __Radius)
     : base(__ProfileType, __ProfileName, __Position)
 {
     this._Radius = __Radius;
 }
 public IfcRectangleHollowProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __XDim, IfcPositiveLengthMeasure __YDim, IfcPositiveLengthMeasure __WallThickness, IfcNonNegativeLengthMeasure?__InnerFilletRadius, IfcNonNegativeLengthMeasure?__OuterFilletRadius)
     : base(__ProfileType, __ProfileName, __Position, __XDim, __YDim)
 {
     this._WallThickness     = __WallThickness;
     this._InnerFilletRadius = __InnerFilletRadius;
     this._OuterFilletRadius = __OuterFilletRadius;
 }
Esempio n. 19
0
 public IfcTShapeProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __Depth, IfcPositiveLengthMeasure __FlangeWidth, IfcPositiveLengthMeasure __WebThickness, IfcPositiveLengthMeasure __FlangeThickness, IfcNonNegativeLengthMeasure?__FilletRadius, IfcNonNegativeLengthMeasure?__FlangeEdgeRadius, IfcNonNegativeLengthMeasure?__WebEdgeRadius, IfcPlaneAngleMeasure?__WebSlope, IfcPlaneAngleMeasure?__FlangeSlope)
     : base(__ProfileType, __ProfileName, __Position)
 {
     this.Depth            = __Depth;
     this.FlangeWidth      = __FlangeWidth;
     this.WebThickness     = __WebThickness;
     this.FlangeThickness  = __FlangeThickness;
     this.FilletRadius     = __FilletRadius;
     this.FlangeEdgeRadius = __FlangeEdgeRadius;
     this.WebEdgeRadius    = __WebEdgeRadius;
     this.WebSlope         = __WebSlope;
     this.FlangeSlope      = __FlangeSlope;
 }
        /// <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; });
                            var project = Model.FederatedInstances.OfType <IfcProject>().FirstOrDefault();
                            //Create IfcShapeRepresentation
                            IfcShapeRepresentation ifcShapeRepresentation = Model.Instances.New <IfcShapeRepresentation>(sr =>
                            {
                                sr.ContextOfItems           = project.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
                }
            }
        }
Esempio n. 21
0
 public IfcEllipseProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __SemiAxis1, IfcPositiveLengthMeasure __SemiAxis2)
     : base(__ProfileType, __ProfileName, __Position)
 {
     this._SemiAxis1 = __SemiAxis1;
     this._SemiAxis2 = __SemiAxis2;
 }
Esempio n. 22
0
        /// <summary>
        ///   Sets up the default units as SI
        ///   Creates the GeometricRepresentationContext for a Model view, required by Ifc compliance
        /// </summary>
        /// <param name = "ifcProject"></param>
        public static void Initialize(this IfcProject ifcProject, ProjectUnits units)
        {
            IModel model = ifcProject.ModelOf;

            if (units == ProjectUnits.SIUnitsUK)
            {
                IfcUnitAssignment ua = model.Instances.New <IfcUnitAssignment>();
                ua.Units.Add(model.Instances.New <IfcSIUnit>(s =>
                {
                    s.UnitType = IfcUnitEnum.LENGTHUNIT;
                    s.Name     = IfcSIUnitName.METRE;
                    s.Prefix   = IfcSIPrefix.MILLI;
                }));
                ua.Units.Add(model.Instances.New <IfcSIUnit>(s =>
                {
                    s.UnitType = IfcUnitEnum.AREAUNIT;
                    s.Name     = IfcSIUnitName.SQUARE_METRE;
                }));
                ua.Units.Add(model.Instances.New <IfcSIUnit>(s =>
                {
                    s.UnitType = IfcUnitEnum.VOLUMEUNIT;
                    s.Name     = IfcSIUnitName.CUBIC_METRE;
                }));
                ua.Units.Add(model.Instances.New <IfcSIUnit>(s =>
                {
                    s.UnitType = IfcUnitEnum.SOLIDANGLEUNIT;
                    s.Name     = IfcSIUnitName.STERADIAN;
                }));
                ua.Units.Add(model.Instances.New <IfcSIUnit>(s =>
                {
                    s.UnitType = IfcUnitEnum.PLANEANGLEUNIT;
                    s.Name     = IfcSIUnitName.RADIAN;
                }));
                ua.Units.Add(model.Instances.New <IfcSIUnit>(s =>
                {
                    s.UnitType = IfcUnitEnum.MASSUNIT;
                    s.Name     = IfcSIUnitName.GRAM;
                }));
                ua.Units.Add(model.Instances.New <IfcSIUnit>(s =>
                {
                    s.UnitType = IfcUnitEnum.TIMEUNIT;
                    s.Name     = IfcSIUnitName.SECOND;
                }));
                ua.Units.Add(model.Instances.New <IfcSIUnit>(s =>
                {
                    s.UnitType =
                        IfcUnitEnum.THERMODYNAMICTEMPERATUREUNIT;
                    s.Name = IfcSIUnitName.DEGREE_CELSIUS;
                }));
                ua.Units.Add(model.Instances.New <IfcSIUnit>(s =>
                {
                    s.UnitType = IfcUnitEnum.LUMINOUSINTENSITYUNIT;
                    s.Name     = IfcSIUnitName.LUMEN;
                }));
                ifcProject.UnitsInContext = ua;
            }
            //Create the Mandatory Model View
            if (ModelContext(ifcProject) == null)
            {
                IfcCartesianPoint   origin           = model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(0, 0, 0));
                IfcAxis2Placement3D axis3D           = model.Instances.New <IfcAxis2Placement3D>(a => a.Location = origin);
                IfcGeometricRepresentationContext gc = model.Instances.New <IfcGeometricRepresentationContext>(c =>
                {
                    c.
                    ContextType
                        =
                            "Model";
                    c.
                    ContextIdentifier
                        =
                            "Building Model";
                    c.
                    CoordinateSpaceDimension
                        = 3;
                    c.Precision
                        =
                            0.00001;
                    c.
                    WorldCoordinateSystem
                        = axis3D;
                }
                                                                                                               );
                ifcProject.RepresentationContexts.Add(gc);

                IfcCartesianPoint   origin2D         = model.Instances.New <IfcCartesianPoint>(p => p.SetXY(0, 0));
                IfcAxis2Placement2D axis2D           = model.Instances.New <IfcAxis2Placement2D>(a => a.Location = origin2D);
                IfcGeometricRepresentationContext pc = model.Instances.New <IfcGeometricRepresentationContext>(c =>
                {
                    c.
                    ContextType
                        =
                            "Plan";
                    c.
                    ContextIdentifier
                        =
                            "Building Plan View";
                    c.
                    CoordinateSpaceDimension
                        = 2;
                    c.Precision
                        =
                            0.00001;
                    c.
                    WorldCoordinateSystem
                        = axis2D;
                }
                                                                                                               );
                ifcProject.RepresentationContexts.Add(pc);
            }
        }
 /// <summary>
 /// returns a Hash for the geometric behaviour of this object
 /// </summary>
 /// <param name="solid"></param>
 /// <returns></returns>
 public static int GetGeometryHashCode(this IfcAxis2Placement2D ax2)
 {
     return(ax2.Location.GetGeometryHashCode() ^ ax2.RefDirection.GetGeometryHashCode());
 }
Esempio n. 24
0
 public IfcTrapeziumProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __BottomXDim, IfcPositiveLengthMeasure __TopXDim, IfcPositiveLengthMeasure __YDim, IfcLengthMeasure __TopXOffset)
     : base(__ProfileType, __ProfileName, __Position)
 {
     this._BottomXDim = __BottomXDim;
     this._TopXDim    = __TopXDim;
     this._YDim       = __YDim;
     this._TopXOffset = __TopXOffset;
 }
Esempio n. 25
0
        static void Main(string[] args)
        {
            DatabaseIfc db = new DatabaseIfc(ReleaseVersion.IFC4X3_RC2);

            db.Factory.Options.AngleUnitsInRadians  = false;
            db.Factory.Options.GenerateOwnerHistory = false;
            IfcRailway railway = new IfcRailway(db)
            {
                Name = "Default Railway", GlobalId = "2Iw5TO8gL8cQQMnPMEy58o"
            };
            IfcProject project = new IfcProject(railway, "Default Project", IfcUnitAssignment.Length.Metre)
            {
                GlobalId = "2VgFtp_1zCO98zJG_O3kln"
            };

            db.Factory.Options.GenerateOwnerHistory = true;
            project.OwnerHistory = db.Factory.OwnerHistoryAdded;
            db.Factory.Options.GenerateOwnerHistory = false;

            IfcGeometricRepresentationSubContext axisSubContext = db.Factory.SubContext(IfcGeometricRepresentationSubContext.SubContextIdentifier.Axis);

            IfcAlignment alignment = new IfcAlignment(railway)
            {
                Name = "TfNSW Alignment", GlobalId = "1F78QPlVv6N9AnnF$LSkp$"
            };
            IfcCartesianPoint alignmentOrigin = new IfcCartesianPoint(db, 0, 0, 0);

            //IfcCartesianPoint alignmentOrigin = new IfcCartesianPoint(db, 1000, 2000, 3000);
            alignment.ObjectPlacement = new IfcLocalPlacement(new IfcAxis2Placement3D(alignmentOrigin));

            double            lineLength = 100;
            IfcCartesianPoint point1     = new IfcCartesianPoint(db, -lineLength, 0);
            IfcCartesianPoint point2     = new IfcCartesianPoint(db, 0, 0);

            double xc               = 99.89734;
            double radius           = 500;
            double transitionLength = 100;

            double d          = -0.75 * Math.Sqrt(3) * xc / radius;
            double ang1       = (Math.Acos(-0.75 * Math.Sqrt(3) * xc / radius) * 180 / Math.PI / 3) + 240;
            double thiRadians = Math.Asin(2 / Math.Sqrt(3) * Math.Cos(ang1 * Math.PI / 180));
            double thi        = thiRadians * 180 / Math.PI;

            double m  = Math.Tan(thiRadians) / (3 * xc * xc);
            double yc = m * Math.Pow(xc, 3);

            IfcCartesianPoint point3 = new IfcCartesianPoint(db, xc, yc);

            double            cx        = Math.Sin(thiRadians) * radius;
            double            cy        = Math.Cos(thiRadians) * radius;
            IfcCartesianPoint arcCentre = new IfcCartesianPoint(db, xc - cx, yc + cy);

            double arcLength = 100;
            double arcAngle  = arcLength / radius * 180 / Math.PI;

            List <IfcSegment> compositeSegments = new List <IfcSegment>();

            IfcLine xLine = new IfcLine(db.Factory.Origin2d, new IfcVector(new IfcDirection(db, 1, 0), 1));

            IfcAlignmentHorizontalSegment linearSegment = new IfcAlignmentHorizontalSegment(point1, 0, 0, 0, lineLength, IfcAlignmentHorizontalSegmentTypeEnum.LINE);
            IfcLine         line         = new IfcLine(point1, new IfcVector(db.Factory.XAxis, 1));
            IfcTrimmedCurve trimmedCurve = new IfcTrimmedCurve(line, new IfcTrimmingSelect(0, point1), new IfcTrimmingSelect(lineLength, point2), true, IfcTrimmingPreference.PARAMETER);

            compositeSegments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));

            List <double> coefficientsX = new List <double>()
            {
                0, 1, 0, 0, 0, -0.9 * m * m, 0, 0, 0, 5.175 * Math.Pow(m, 4), 0, 0, 0, -43.1948 * Math.Pow(m, 6), 0, 0, 0, 426.0564 * Math.Pow(m, 8)
            };
            List <double> coefficientsY = new List <double>()
            {
                0, 0, 0, m, 0, 0, 0, -2.7 * Math.Pow(m, 3), 0, 0, 0, 17.955 * Math.Pow(m, 5), 0, 0, 0, -158.258 * Math.Pow(m, 7), 0, 0, 0, 1604.338 * Math.Pow(m, 9)
            };
            IfcSeriesParameterCurve seriesParameterCurve = new IfcSeriesParameterCurve(db.Factory.Origin2dPlace, coefficientsX, coefficientsY);

            IfcAlignmentHorizontalSegment transitionSegment = new IfcAlignmentHorizontalSegment(point2, 0, 0, radius, transitionLength, IfcAlignmentHorizontalSegmentTypeEnum.CUBICSPIRAL);            // { ObjectType = "TfNSW" };

            trimmedCurve = new IfcTrimmedCurve(seriesParameterCurve, new IfcTrimmingSelect(0, point2), new IfcTrimmingSelect(transitionLength, point3), true, IfcTrimmingPreference.PARAMETER);
            compositeSegments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE, true, trimmedCurve));

            IfcAxis2Placement2D circlePlacement = new IfcAxis2Placement2D(arcCentre)
            {
                RefDirection = new IfcDirection(db, Math.Sin(thiRadians), -Math.Cos(thiRadians))
            };
            IfcCircle circle = new IfcCircle(circlePlacement, radius);

            trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(0, point3), new IfcTrimmingSelect(arcLength / radius * 180 / Math.PI), true, IfcTrimmingPreference.PARAMETER);

            IfcAlignmentHorizontalSegment arcSegment = new IfcAlignmentHorizontalSegment(point3, thi, radius, radius, arcLength, IfcAlignmentHorizontalSegmentTypeEnum.CIRCULARARC);

            compositeSegments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE, true, trimmedCurve));

            IfcCompositeCurve alignmentCurve = new IfcCompositeCurve(compositeSegments);

            alignment.Axis = alignmentCurve;

            double startDist = -123;
            IfcAlignmentHorizontal alignmentHorizontal = new IfcAlignmentHorizontal(alignment, linearSegment, transitionSegment, arcSegment)
            {
                StartDistAlong = startDist,
            };

            alignmentHorizontal.GlobalId        = "0sEEGBFgr289x9s$R$T7N9";
            alignmentHorizontal.ObjectPlacement = alignment.ObjectPlacement;
            alignmentHorizontal.Representation  = new IfcProductDefinitionShape(new IfcShapeRepresentation(axisSubContext, alignmentCurve, ShapeRepresentationType.Curve2D));

            IfcAlignmentSegment alignmentSegment = new IfcAlignmentSegment(alignmentHorizontal, transitionSegment);

            alignmentSegment.GlobalId   = "2_crD$eoPDah_QvgsPhXF3";
            alignmentSegment.ObjectType = "TFNSW";
            new IfcPropertySet(alignmentSegment, "TfNSW_Transition", new IfcPropertySingleValue(db, "m", m));

            IfcPointByDistanceExpression verticalDistanceExpression = new IfcPointByDistanceExpression(0, alignmentCurve);
            double startHeight = 25;

            verticalDistanceExpression.OffsetVertical = startHeight;
            IfcAlignmentVerticalSegment verticalSegment = new IfcAlignmentVerticalSegment(db, startDist, lineLength + transitionLength + arcLength, startHeight, 0.01, IfcAlignmentVerticalSegmentTypeEnum.CONSTANTGRADIENT);

            IfcAlignmentVertical alignmentVertical = new IfcAlignmentVertical(alignment, verticalSegment);

            alignmentVertical.GlobalId = "2YR0TUxTv75RC2XxZVmlj8";

            //IfcLinearAxis2Placement verticalAxisPlacement = new IfcLinearAxis2Placement(verticalDistanceExpression);
            //IfcLinearPlacement verticalLinearPlacement = new IfcLinearPlacement(alignmentPlacement, verticalAxisPlacement);
            //alignmentVertical.ObjectPlacement = verticalLinearPlacement;

            //List<IfcCurveSegment> verticalSegments = new List<IfcCurveSegment>();
            //IfcLine linearGradient = new IfcLine(db.Factory.Origin, new IfcVector(new IfcDirection(db, 1, 0, 0.01), 1)); //not right and should it be xy or xz
            //IfcCurveSegment verticalCurveSegment = new IfcCurveSegment(IfcTransitionCode.CONTINUOUS, new IfcAxis2Placement3D(db.Factory.Origin2d), 50, linearGradient);
            //verticalSegments.Add(verticalCurveSegment);
            //IfcAlignmentVerticalSegment verticalSegment = new IfcAlignmentVerticalSegment(alignmentVertical,
            //	verticalLinearPlacement, verticalCurveSegment, 0, 50, startHeight, 0.01,
            //	IfcAlignmentVerticalSegmentTypeEnum.LINE);

            //IfcGradientCurve gradientCurve = new IfcGradientCurve(horizontalCurve, verticalSegments);
            //alignment.Representation = new IfcProductDefinitionShape(new IfcShapeRepresentation(axisSubContext, gradientCurve, ShapeRepresentationType.Curve3D));
            IfcPointByDistanceExpression distanceExpression = new IfcPointByDistanceExpression(150, alignmentCurve);

            distanceExpression.OffsetLateral = 5;
            IfcAxis2PlacementLinear   axis2PlacementLinear   = new IfcAxis2PlacementLinear(distanceExpression);
            IfcLinearPlacement        linearPlacement        = new IfcLinearPlacement(alignment.ObjectPlacement, axis2PlacementLinear);
            IfcExtrudedAreaSolid      extrudedAreaSolid      = new IfcExtrudedAreaSolid(new IfcRectangleProfileDef(db, "", 0.5, 0.5), 5);
            IfcProductDefinitionShape productDefinitionShape = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            IfcPile pile = new IfcPile(railway, linearPlacement, productDefinitionShape);

            new IfcRelPositions(db, alignment, new List <IfcProduct>()
            {
                pile
            });

            // Conceptual 50m span Bridge from chainage -80
            distanceExpression   = new IfcPointByDistanceExpression(-80 - startDist, alignmentCurve);
            axis2PlacementLinear = new IfcAxis2PlacementLinear(distanceExpression);
            IfcCurveSegment curveSegment = new IfcCurveSegment(IfcTransitionCode.CONTINUOUS, axis2PlacementLinear, 50, alignmentCurve);

            productDefinitionShape = new IfcProductDefinitionShape(new IfcShapeRepresentation(axisSubContext, curveSegment, ShapeRepresentationType.Curve2D));
            IfcBridge bridge = new IfcBridge(railway, alignment.ObjectPlacement, productDefinitionShape);

            db.WriteFile(args[0]);
        }
Esempio n. 26
0
 protected IfcParameterizedProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position)
     : base(__ProfileType, __ProfileName)
 {
     this.Position = __Position;
 }
Esempio n. 27
0
 public IfcLShapeProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __Depth, IfcPositiveLengthMeasure?__Width, IfcPositiveLengthMeasure __Thickness, IfcNonNegativeLengthMeasure?__FilletRadius, IfcNonNegativeLengthMeasure?__EdgeRadius, IfcPlaneAngleMeasure?__LegSlope)
     : base(__ProfileType, __ProfileName, __Position)
 {
     this._Depth        = __Depth;
     this._Width        = __Width;
     this._Thickness    = __Thickness;
     this._FilletRadius = __FilletRadius;
     this._EdgeRadius   = __EdgeRadius;
     this._LegSlope     = __LegSlope;
 }
Esempio n. 28
0
 public IfcRoundedRectangleProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __XDim, IfcPositiveLengthMeasure __YDim, IfcPositiveLengthMeasure __RoundingRadius)
     : base(__ProfileType, __ProfileName, __Position, __XDim, __YDim)
 {
     this._RoundingRadius = __RoundingRadius;
 }
Esempio n. 29
0
 public IfcRectangleProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __XDim, IfcPositiveLengthMeasure __YDim)
     : base(__ProfileType, __ProfileName, __Position)
 {
     this._XDim = __XDim;
     this._YDim = __YDim;
 }
Esempio n. 30
0
 public IfcCShapeProfileDef(IfcProfileTypeEnum __ProfileType, IfcLabel?__ProfileName, IfcAxis2Placement2D __Position, IfcPositiveLengthMeasure __Depth, IfcPositiveLengthMeasure __Width, IfcPositiveLengthMeasure __WallThickness, IfcPositiveLengthMeasure __Girth, IfcNonNegativeLengthMeasure?__InternalFilletRadius)
     : base(__ProfileType, __ProfileName, __Position)
 {
     this._Depth                = __Depth;
     this._Width                = __Width;
     this._WallThickness        = __WallThickness;
     this._Girth                = __Girth;
     this._InternalFilletRadius = __InternalFilletRadius;
 }