示例#1
0
文件: Beam.cs 项目: mccune/IfcScript
		private IfcBeam GenerateIPE200(STPModelData md,IfcBuilding building,bool tessellated)
		{
			 
			if (tessellated)
			{
				List<Point3d> coords = new List<Point3d>() { new Point3d(1000.0, 50.0, -91.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(1000.0, 50.0, -100.0), new Point3d(1000.0, -50.0, -100.0), new Point3d(1000.0, -50.0, -91.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(1000.0, -50.0, 91.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(1000.0, -50.0, 100.0), new Point3d(1000.0, 50.0, 100.0), new Point3d(1000.0, 50.0, 91.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(0.0, 2.8, -79.5), new Point3d(0.0, 50.0, 91.5), new Point3d(0.0, 14.8, 91.5), new Point3d(0.0, 50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(0.0, -50.0, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(0.0, -2.8, -79.5), new Point3d(0.0, -2.8, 79.5), new Point3d(0.0, -50.0, -91.5), new Point3d(0.0, -14.8, -91.5), new Point3d(0.0, -50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(0.0, 50.0, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(0.0, 2.8, -79.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(500.0, 2.8, -79.5), new Point3d(500.0, 14.8, -91.5), new Point3d(0.0, 2.8, -79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(500.0, 2.8, -79.5), new Point3d(500.0, 2.8, 79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(0.0, 14.8, 91.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(500.0, 2.8, 79.5), new Point3d(500.0, 14.8, 91.5), new Point3d(0.0, 14.8, 91.5), new Point3d(0.0, 50.0, 91.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(1000.0, 50.0, 91.5), new Point3d(500.0, 14.8, 91.5), new Point3d(500.0, 50.0, 91.5), new Point3d(0.0, 50.0, 91.5), new Point3d(0.0, 50.0, 100.0), new Point3d(1000.0, 50.0, 91.5), new Point3d(1000.0, 50.0, 100.0), new Point3d(500.0, 50.0, 91.5), new Point3d(500.0, 50.0, 100.0), new Point3d(0.0, 50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(1000.0, 50.0, 100.0), new Point3d(1000.0, -50.0, 100.0), new Point3d(500.0, 50.0, 100.0), new Point3d(500.0, -50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(0.0, -50.0, 91.5), new Point3d(1000.0, -50.0, 100.0), new Point3d(1000.0, -50.0, 91.5), new Point3d(500.0, -50.0, 100.0), new Point3d(500.0, -50.0, 91.5), new Point3d(0.0, -50.0, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(1000.0, -50.0, 91.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(500.0, -50.0, 91.5), new Point3d(500.0, -14.8, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(0.0, -2.8, 79.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(500.0, -14.8, 91.5), new Point3d(500.0, -2.8, 79.5), new Point3d(0.0, -2.8, 79.5), new Point3d(0.0, -2.8, -79.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(500.0, -2.8, 79.5), new Point3d(500.0, -2.8, -79.5), new Point3d(0.0, -2.8, -79.5), new Point3d(0.0, -14.8, -91.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(500.0, -2.8, -79.5), new Point3d(500.0, -14.8, -91.5), new Point3d(0.0, -14.8, -91.5), new Point3d(0.0, -50.0, -91.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(1000.0, -50.0, -91.5), new Point3d(500.0, -14.8, -91.5), new Point3d(500.0, -50.0, -91.5), new Point3d(0.0, -50.0, -91.5), new Point3d(0.0, -50.0, -100.0), new Point3d(1000.0, -50.0, -91.5), new Point3d(1000.0, -50.0, -100.0), new Point3d(500.0, -50.0, -91.5), new Point3d(500.0, -50.0, -100.0), new Point3d(0.0, -50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(1000.0, -50.0, -100.0), new Point3d(1000.0, 50.0, -100.0), new Point3d(500.0, -50.0, -100.0), new Point3d(500.0, 50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(0.0, 50.0, -91.5), new Point3d(1000.0, 50.0, -100.0), new Point3d(1000.0, 50.0, -91.5), new Point3d(500.0, 50.0, -100.0), new Point3d(500.0, 50.0, -91.5), new Point3d(0.0, 50.0, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(1000.0, 50.0, -91.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(500.0, 50.0, -91.5), new Point3d(500.0, 14.8, -91.5) };
				IfcCartesianPointList3D cartesianPointList3D = new IfcCartesianPointList3D(md, coords);
				cartesianPointList3D.Comments.Add("the geometric representation of the beam is provided as a triangulated face set");
				cartesianPointList3D.Comments.Add("the meshing depends on the creating software system");

				List<CoordIndex> coordIndex = new List<CoordIndex>() { new CoordIndex(6, 5, 4), new CoordIndex(15, 8, 6), new CoordIndex(6, 4, 3), new CoordIndex(10, 11, 9), new CoordIndex(16, 10, 7), new CoordIndex(14, 11, 10), new CoordIndex(7, 8, 16), new CoordIndex(6, 2, 15), new CoordIndex(2, 3, 1), new CoordIndex(3, 2, 6), new CoordIndex(10, 16, 14), new CoordIndex(14, 13, 12), new CoordIndex(11, 14, 12), new CoordIndex(8, 15, 16), new CoordIndex(24, 23, 22), new CoordIndex(17, 26, 24), new CoordIndex(22, 21, 20), new CoordIndex(28, 29, 27), new CoordIndex(32, 28, 25), new CoordIndex(30, 29, 28), new CoordIndex(18, 25, 26), new CoordIndex(24, 20, 17), new CoordIndex(20, 21, 19), new CoordIndex(32, 31, 30), new CoordIndex(28, 32, 30), new CoordIndex(33, 34, 37), new CoordIndex(36, 35, 38), new CoordIndex(40, 44, 43), new CoordIndex(41, 43, 44), new CoordIndex(46, 50, 49), new CoordIndex(47, 49, 50), new CoordIndex(56, 55, 51), new CoordIndex(55, 56, 54), new CoordIndex(57, 58, 62), new CoordIndex(60, 59, 61), new CoordIndex(63, 64, 68), new CoordIndex(66, 65, 67), new CoordIndex(69, 70, 74), new CoordIndex(72, 71, 73), new CoordIndex(80, 79, 75), new CoordIndex(79, 80, 78), new CoordIndex(81, 82, 86), new CoordIndex(84, 83, 85), new CoordIndex(88, 92, 91), new CoordIndex(89, 91, 92), new CoordIndex(94, 98, 97), new CoordIndex(95, 97, 98), new CoordIndex(104, 103, 99), new CoordIndex(103, 104, 102), new CoordIndex(105, 106, 110), new CoordIndex(108, 107, 109), new CoordIndex(111, 112, 116), new CoordIndex(114, 113, 115), new CoordIndex(117, 118, 122), new CoordIndex(120, 119, 121), new CoordIndex(128, 127, 123), new CoordIndex(127, 128, 126), new CoordIndex(22, 20, 24), new CoordIndex(32, 25, 18), new CoordIndex(18, 26, 17), new CoordIndex(33, 37, 38), new CoordIndex(36, 38, 37), new CoordIndex(40, 43, 39), new CoordIndex(41, 44, 42), new CoordIndex(46, 49, 45), new CoordIndex(47, 50, 48), new CoordIndex(56, 51, 52), new CoordIndex(55, 54, 53), new CoordIndex(57, 62, 61), new CoordIndex(60, 61, 62), new CoordIndex(63, 68, 67), new CoordIndex(66, 67, 68), new CoordIndex(69, 74, 73), new CoordIndex(72, 73, 74), new CoordIndex(80, 75, 76), new CoordIndex(79, 78, 77), new CoordIndex(81, 86, 85), new CoordIndex(84, 85, 86), new CoordIndex(88, 91, 87), new CoordIndex(89, 92, 90), new CoordIndex(94, 97, 93), new CoordIndex(95, 98, 96), new CoordIndex(104, 99, 100), new CoordIndex(103, 102, 101), new CoordIndex(105, 110, 109), new CoordIndex(108, 109, 110), new CoordIndex(111, 116, 115), new CoordIndex(114, 115, 116), new CoordIndex(117, 122, 121), new CoordIndex(120, 121, 122), new CoordIndex(128, 123, 124), new CoordIndex(127, 126, 125) };
				IfcTriangulatedFaceSet triangulatedFaceSet = new IfcTriangulatedFaceSet(md, cartesianPointList3D, null, true, coordIndex, null);

				return new IfcBeam(building, triangulatedFaceSet) { GlobalId = "0EF5_zZRv0pQPddeofU3KT", Name = "ExampleBeamName",Description = "ExampleBeamDescription",Tag = "Tag" };
			}

			List<Point3d> points = new List<Point3d>() {new Point3d(2.8,-79.5,0),new Point3d(2.8,79.5,0),new Point3d(6.314719,87.985281,0),new Point3d(14.8,91.5,0),new Point3d(50.0,91.5,0),new Point3d(50.0,100.0,0),new Point3d(-50.0,100.0,0),new Point3d(-50.0,91.5,0),new Point3d(-14.8,91.5,0),new Point3d(-6.314719,87.985281,0),new Point3d(-2.8,79.5,0),new Point3d(-2.8,-79.5,0),new Point3d(-6.314719,-87.985281,0),new Point3d(-14.8,-91.5,0),new Point3d(-50.0,-91.5,0),new Point3d(-50.0,-100.0,0),new Point3d(50.0,-100.0,0),new Point3d(50.0,-91.5,0),new Point3d(14.8,-91.5,0),new Point3d(6.314719,-87.985281,0) };
			PolyCurve pc = new PolyCurve();
			pc.Append(new Line(points[0],points[1]));
			pc.Append(new Arc(points[1],points[2],points[3]));
			pc.Append(new Line(points[3],points[4]));
			pc.Append(new Line(points[4],points[5]));
			pc.Append(new Line(points[5],points[6]));
			pc.Append(new Line(points[6],points[7]));
			pc.Append(new Line(points[7],points[8]));
			pc.Append(new Arc(points[8],points[9],points[10]));
			pc.Append(new Line(points[10],points[11]));
			pc.Append(new Arc(points[11],points[12],points[13]));
			pc.Append(new Line(points[13], points[14]));
			pc.Append(new Line(points[14], points[15]));
			pc.Append(new Line(points[15], points[16]));
			pc.Append(new Line(points[16], points[17]));
			pc.Append(new Line(points[17], points[18]));
			pc.Append(new Arc(points[18],points[19],points[0]));
			IfcBoundedCurve boundedCurve = IfcBoundedCurve.ConvertCurve(md, pc);
			IfcArbitraryClosedProfileDef arbitraryClosedProfileDef = new IfcArbitraryClosedProfileDef("IPE200",boundedCurve);
			IfcAxis2Placement3D axis2Placement3D = new IfcAxis2Placement3D(new IfcCartesianPoint(md,0,0,0),new IfcDirection(md,0,1,0),new IfcDirection(md,1,0,0));
			IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(arbitraryClosedProfileDef, axis2Placement3D,new IfcDirection(md,0,0,1),1000);
			return new IfcBeam(building, extrudedAreaSolid) { GlobalId = "0EF5_zZRv0pQPddeofU3KT", Name = "ExampleBeamName",Description = "ExampleBeamDescription", Tag = "Tag" }; 
		}
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 4:
                _position = (IfcAxis2Placement3D)(value.EntityVal);
                return;

            case 5:
                _colourAppearance = (IfcColourRgb)(value.EntityVal);
                return;

            case 6:
                _colourTemperature = value.RealVal;
                return;

            case 7:
                _luminousFlux = value.RealVal;
                return;

            case 8:
                _lightEmissionSource = (IfcLightEmissionSourceEnum)System.Enum.Parse(typeof(IfcLightEmissionSourceEnum), value.EnumVal, true);
                return;

            case 9:
                _lightDistributionDataSource = (IfcLightDistributionDataSourceSelect)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
示例#3
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 4:
                _relatingStructuralMember = (IfcStructuralMember)(value.EntityVal);
                return;

            case 5:
                _relatedStructuralConnection = (IfcStructuralConnection)(value.EntityVal);
                return;

            case 6:
                _appliedCondition = (IfcBoundaryCondition)(value.EntityVal);
                return;

            case 7:
                _additionalConditions = (IfcStructuralConnectionCondition)(value.EntityVal);
                return;

            case 8:
                _supportedLength = value.RealVal;
                return;

            case 9:
                _conditionCoordinateSystem = (IfcAxis2Placement3D)(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
        /// <summary>
        ///   Sets X axis direction of the existing local placement. If it does not exist, exception raises.
        /// </summary>
        /// <param name = "xAxisDirectionX">X coordinate of the X asis direction</param>
        /// <param name = "xAxisDirectionY">Y coordinate of the X asis direction</param>
        /// <param name = "xAxisDirectionZ">Z coordinate of the X asis direction</param>
        public static void SetObjectLocalPlacement_XZdirection(this IfcProduct prod, double xAxisDirectionX,
                                                               double xAxisDirectionY, double xAxisDirectionZ,
                                                               double zAxisDirectionX, double zAxisDirectionY,
                                                               double Z_axisDirection_Z)
        {
            IfcLocalPlacement localPlacement = prod.ObjectPlacement as IfcLocalPlacement;

            if (localPlacement == null)
            {
                throw new Exception("ProductExtensions: Local placement is not defined.");
            }

            IfcAxis2Placement3D placement = localPlacement.RelativePlacement as IfcAxis2Placement3D;

            if (placement == null)
            {
                throw new Exception("ProductExtensions: Local placement is not defined.");
            }

            placement.SetNewDirectionOf_XZ(xAxisDirectionX, xAxisDirectionY, xAxisDirectionZ, zAxisDirectionX,
                                           zAxisDirectionY, Z_axisDirection_Z);
        }
示例#5
0
        /// <summary>
        /// Builds a windows Matrix3D from an ObjectPlacement
        /// Conversion fo c++ function CartesianTransform::ConvertMatrix3D from CartesianTransform.cpp
        /// </summary>
        /// <param name="objPlacement">IfcObjectPlacement object</param>
        /// <returns>Matrix3D</returns>
        protected XbimMatrix3D ConvertMatrix3D(IfcObjectPlacement objPlacement)
        {
            if (objPlacement is IfcLocalPlacement)
            {
                IfcLocalPlacement locPlacement = (IfcLocalPlacement)objPlacement;
                if (locPlacement.RelativePlacement is IfcAxis2Placement3D)
                {
                    IfcAxis2Placement3D axis3D   = (IfcAxis2Placement3D)locPlacement.RelativePlacement;
                    XbimVector3D        ucsXAxis = new XbimVector3D(axis3D.RefDirection.DirectionRatios[0], axis3D.RefDirection.DirectionRatios[1], axis3D.RefDirection.DirectionRatios[2]);
                    XbimVector3D        ucsZAxis = new XbimVector3D(axis3D.Axis.DirectionRatios[0], axis3D.Axis.DirectionRatios[1], axis3D.Axis.DirectionRatios[2]);
                    ucsXAxis.Normalize();
                    ucsZAxis.Normalize();
                    XbimVector3D ucsYAxis = XbimVector3D.CrossProduct(ucsZAxis, ucsXAxis);
                    ucsYAxis.Normalize();
                    XbimPoint3D ucsCentre = axis3D.Location.XbimPoint3D();

                    XbimMatrix3D ucsTowcs = new XbimMatrix3D(ucsXAxis.X, ucsXAxis.Y, ucsXAxis.Z, 0,
                                                             ucsYAxis.X, ucsYAxis.Y, ucsYAxis.Z, 0,
                                                             ucsZAxis.X, ucsZAxis.Y, ucsZAxis.Z, 0,
                                                             ucsCentre.X, ucsCentre.Y, ucsCentre.Z, 1);
                    if (locPlacement.PlacementRelTo != null)
                    {
                        return(XbimMatrix3D.Multiply(ucsTowcs, ConvertMatrix3D(locPlacement.PlacementRelTo)));
                    }
                    else
                    {
                        return(ucsTowcs);
                    }
                }
                else                 //must be 2D
                {
                    throw new NotImplementedException("Support for Placements other than 3D not implemented");
                }
            }
            else             //probably a Grid
            {
                throw new NotImplementedException("Support for Placements other than Local not implemented");
            }
        }
        public PlacementAxis3D(IfcStore model, CartesianPoint3D location, DirectionVector3D axis, DirectionVector3D refAxis)
        {
            this.location = location;
            this.axis     = axis;
            this.refAxis  = refAxis;

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

            if (result == null)
            {
                ifcAxis2Placement3D = model.Instances.New <IfcAxis2Placement3D>(p =>
                {
                    p.Location     = location.IfcPoint;
                    p.Axis         = axis.IfcDirection;
                    p.RefDirection = refAxis.IfcDirection;
                });
            }
            else
            {
                ifcAxis2Placement3D = result;
            }
        }
示例#7
0
        protected override void GenerateInstance(IfcBuilding building)
        {
            DatabaseIfc database = building.Database;
            IfcBeamType beamType = GetParametericIPE200(database);
            IfcMaterialProfileSetUsage materialProfileSetUsage = new IfcMaterialProfileSetUsage(beamType.MaterialSelect as IfcMaterialProfileSet, IfcCardinalPointReference.TOPMID);
            IfcAxis2Placement3D        axis2Placement3d        = new IfcAxis2Placement3D(new IfcCartesianPoint(database, 0, 0, 0), database.Factory.YAxis, database.Factory.XAxisNegative);
            IfcBeamStandardCase        beamStandardCase        = new IfcBeamStandardCase(building, materialProfileSetUsage, axis2Placement3d, 1000)
            {
                Name = "Extrusion", RelatingType = beamType
            };

            axis2Placement3d = new IfcAxis2Placement3D(new IfcCartesianPoint(database, 0, 0, 400), new IfcDirection(database, -0.38461538, 0.92307692, 0), new IfcDirection(database, -0.92307692, -0.38461538, 0));
            IfcBeamStandardCase beamStandardCase2 = new IfcBeamStandardCase(building, materialProfileSetUsage, axis2Placement3d, new Tuple <double, double>(-1300, 0), 0.789582239399523)
            {
                Name = "Revolution", RelatingType = beamType
            };

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            beamStandardCase.GlobalId = "0a_qfeQLDA8e5qT$Do6J_t";
            beamStandardCase.MaterialSelect.Associates.GlobalId = "2uxxMWfA51AAznk5bQJylf";
            beamStandardCase2.GlobalId = "1zqFh80l11VgfEm3ZWh6Xv";
        }
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 8:
                _conditionCoordinateSystem = (IfcAxis2Placement3D)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
示例#9
0
        protected override void GenerateInstance(IfcBuilding building)
        {
            DatabaseIfc           database           = building.Database;
            IfcBeamType           beamType           = GetParametericIPE200(database);
            IfcMaterialProfileSet materialProfileSet = beamType.MaterialSelect as IfcMaterialProfileSet;
            IfcAxis2Placement3D   axis2dPlacement3d  = new IfcAxis2Placement3D(new IfcCartesianPoint(database, 0, 0, 0), database.Factory.YAxis, database.Factory.XAxisNegative);
            IfcBeamStandardCase   beamStandardCase   = new IfcBeamStandardCase(building, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.MID), axis2dPlacement3d, 1000)
            {
                Name = beamType.Name, RelatingType = beamType
            };

            database.NextObjectRecord = 300;
            string name = "CHS219.1x6.3";
            IfcCircleHollowProfileDef chs219x6 = new IfcCircleHollowProfileDef(database, name, 219.1 / 2.0, 6.3);

            materialProfileSet = beamType.MaterialSelect as IfcMaterialProfileSet;
            IfcMaterialProfile materialProfile2 = new IfcMaterialProfile(name, materialProfileSet.MaterialProfiles[0].Material, chs219x6);
            IfcBeamType        beamType2        = new IfcBeamType(name, materialProfile2, IfcBeamTypeEnum.BEAM);

            materialProfileSet = beamType2.MaterialSelect as IfcMaterialProfileSet;
            axis2dPlacement3d  = new IfcAxis2Placement3D(new IfcCartesianPoint(database, 500, 0, 0), database.Factory.YAxis, database.Factory.XAxisNegative);
            IfcBeamStandardCase beamStandardCase2 = new IfcBeamStandardCase(building, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.MID), axis2dPlacement3d, 1000)
            {
                Name = name, RelatingType = beamType2
            };

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            beamType.ObjectTypeOf.GlobalId = "3s_DqAVvb3LguudTShJHVo";
            beamType.MaterialSelect.Associates.GlobalId = "3tlx8qcefDouGWiGFgBV8d";
            beamStandardCase.GlobalId = "0uo2yx7G19uwCu9sIjn6DQ";
            beamStandardCase.MaterialSelect.Associates.GlobalId = "2SL41bR1rCj99SIKuKXeFl";
            beamType2.GlobalId = "3l_OKNTJr4yBOR5rYl6b9w";
            beamType2.ObjectTypeOf.GlobalId = "3LrutsCpn4DPF9Zt4YdIEU";
            beamType2.MaterialSelect.Associates.GlobalId = "14nDe0n1bErgiI78N83Oxd";
            beamStandardCase2.GlobalId = "3_NFDdmqr7mxekvlvcgwa7";
            beamStandardCase2.MaterialSelect.Associates.GlobalId = "1Set5Cyu9BFOWznvoQe1ho";
        }
示例#10
0
        public override void IfcParse(int propIndex, IPropertyValue value)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
                base.IfcParse(propIndex, value);
                break;

            case 5:
                _predefinedType =
                    (IfcAnalysisModelTypeEnum)Enum.Parse(typeof(IfcAnalysisModelTypeEnum), value.EnumVal, true);
                break;

            case 6:
                _orientationOf2DPlane = (IfcAxis2Placement3D)value.EntityVal;
                break;

            case 7:
                if (_loadedBy == null)
                {
                    _loadedBy = new XbimSet <IfcStructuralLoadGroup>(this);
                }
                _loadedBy.Add((IfcStructuralLoadGroup)value.EntityVal);
                break;

            case 8:
                _hasResults = (IfcStructuralResultGroup)value.EntityVal;
                break;

            default:
                this.HandleUnexpectedAttribute(propIndex, value); break;
            }
        }
示例#11
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 5:
                _predefinedType = (IfcAnalysisModelTypeEnum)System.Enum.Parse(typeof(IfcAnalysisModelTypeEnum), value.EnumVal, true);
                return;

            case 6:
                _orientationOf2DPlane = (IfcAxis2Placement3D)(value.EntityVal);
                return;

            case 7:
                _loadedBy.InternalAdd((IfcStructuralLoadGroup)value.EntityVal);
                return;

            case 8:
                _hasResults.InternalAdd((IfcStructuralResultGroup)value.EntityVal);
                return;

            case 9:
                _sharedPlacement = (IfcObjectPlacement)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
示例#12
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
                _placementRelTo = (IfcCurve)(value.EntityVal);
                return;

            case 1:
                _distance = (IfcDistanceExpression)(value.EntityVal);
                return;

            case 2:
                _orientation = (IfcOrientationExpression)(value.EntityVal);
                return;

            case 3:
                _cartesianPosition = (IfcAxis2Placement3D)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
示例#13
0
        private IfcBeam GenerateIPE200(IfcBuilding building, bool tessellated)
        {
            DatabaseIfc db = building.Database;

            if (tessellated)
            {
                List <Tuple <double, double, double> > coords = new List <Tuple <double, double, double> >()
                {
                    new Tuple <double, double, double>(1000.0, 50.0, -91.5), new Tuple <double, double, double>(1000.0, 14.8, -91.5), new Tuple <double, double, double>(1000.0, 50.0, -100.0), new Tuple <double, double, double>(1000.0, -50.0, -100.0), new Tuple <double, double, double>(1000.0, -50.0, -91.5), new Tuple <double, double, double>(1000.0, -14.8, -91.5), new Tuple <double, double, double>(1000.0, -2.8, 79.5), new Tuple <double, double, double>(1000.0, -2.8, -79.5), new Tuple <double, double, double>(1000.0, -50.0, 91.5), new Tuple <double, double, double>(1000.0, -14.8, 91.5), new Tuple <double, double, double>(1000.0, -50.0, 100.0), new Tuple <double, double, double>(1000.0, 50.0, 100.0), new Tuple <double, double, double>(1000.0, 50.0, 91.5), new Tuple <double, double, double>(1000.0, 14.8, 91.5), new Tuple <double, double, double>(1000.0, 2.8, -79.5), new Tuple <double, double, double>(1000.0, 2.8, 79.5), new Tuple <double, double, double>(0.0, 2.8, 79.5), new Tuple <double, double, double>(0.0, 2.8, -79.5), new Tuple <double, double, double>(0.0, 50.0, 91.5), new Tuple <double, double, double>(0.0, 14.8, 91.5), new Tuple <double, double, double>(0.0, 50.0, 100.0), new Tuple <double, double, double>(0.0, -50.0, 100.0), new Tuple <double, double, double>(0.0, -50.0, 91.5), new Tuple <double, double, double>(0.0, -14.8, 91.5), new Tuple <double, double, double>(0.0, -2.8, -79.5), new Tuple <double, double, double>(0.0, -2.8, 79.5), new Tuple <double, double, double>(0.0, -50.0, -91.5), new Tuple <double, double, double>(0.0, -14.8, -91.5), new Tuple <double, double, double>(0.0, -50.0, -100.0), new Tuple <double, double, double>(0.0, 50.0, -100.0), new Tuple <double, double, double>(0.0, 50.0, -91.5), new Tuple <double, double, double>(0.0, 14.8, -91.5), new Tuple <double, double, double>(0.0, 14.8, -91.5), new Tuple <double, double, double>(0.0, 2.8, -79.5), new Tuple <double, double, double>(1000.0, 14.8, -91.5), new Tuple <double, double, double>(1000.0, 2.8, -79.5), new Tuple <double, double, double>(500.0, 2.8, -79.5), new Tuple <double, double, double>(500.0, 14.8, -91.5), new Tuple <double, double, double>(0.0, 2.8, -79.5), new Tuple <double, double, double>(0.0, 2.8, 79.5), new Tuple <double, double, double>(1000.0, 2.8, -79.5), new Tuple <double, double, double>(1000.0, 2.8, 79.5), new Tuple <double, double, double>(500.0, 2.8, -79.5), new Tuple <double, double, double>(500.0, 2.8, 79.5), new Tuple <double, double, double>(0.0, 2.8, 79.5), new Tuple <double, double, double>(0.0, 14.8, 91.5), new Tuple <double, double, double>(1000.0, 2.8, 79.5), new Tuple <double, double, double>(1000.0, 14.8, 91.5), new Tuple <double, double, double>(500.0, 2.8, 79.5), new Tuple <double, double, double>(500.0, 14.8, 91.5), new Tuple <double, double, double>(0.0, 14.8, 91.5), new Tuple <double, double, double>(0.0, 50.0, 91.5), new Tuple <double, double, double>(1000.0, 14.8, 91.5), new Tuple <double, double, double>(1000.0, 50.0, 91.5), new Tuple <double, double, double>(500.0, 14.8, 91.5), new Tuple <double, double, double>(500.0, 50.0, 91.5), new Tuple <double, double, double>(0.0, 50.0, 91.5), new Tuple <double, double, double>(0.0, 50.0, 100.0), new Tuple <double, double, double>(1000.0, 50.0, 91.5), new Tuple <double, double, double>(1000.0, 50.0, 100.0), new Tuple <double, double, double>(500.0, 50.0, 91.5), new Tuple <double, double, double>(500.0, 50.0, 100.0), new Tuple <double, double, double>(0.0, 50.0, 100.0), new Tuple <double, double, double>(0.0, -50.0, 100.0), new Tuple <double, double, double>(1000.0, 50.0, 100.0), new Tuple <double, double, double>(1000.0, -50.0, 100.0), new Tuple <double, double, double>(500.0, 50.0, 100.0), new Tuple <double, double, double>(500.0, -50.0, 100.0), new Tuple <double, double, double>(0.0, -50.0, 100.0), new Tuple <double, double, double>(0.0, -50.0, 91.5), new Tuple <double, double, double>(1000.0, -50.0, 100.0), new Tuple <double, double, double>(1000.0, -50.0, 91.5), new Tuple <double, double, double>(500.0, -50.0, 100.0), new Tuple <double, double, double>(500.0, -50.0, 91.5), new Tuple <double, double, double>(0.0, -50.0, 91.5), new Tuple <double, double, double>(0.0, -14.8, 91.5), new Tuple <double, double, double>(1000.0, -50.0, 91.5), new Tuple <double, double, double>(1000.0, -14.8, 91.5), new Tuple <double, double, double>(500.0, -50.0, 91.5), new Tuple <double, double, double>(500.0, -14.8, 91.5), new Tuple <double, double, double>(0.0, -14.8, 91.5), new Tuple <double, double, double>(0.0, -2.8, 79.5), new Tuple <double, double, double>(1000.0, -14.8, 91.5), new Tuple <double, double, double>(1000.0, -2.8, 79.5), new Tuple <double, double, double>(500.0, -14.8, 91.5), new Tuple <double, double, double>(500.0, -2.8, 79.5), new Tuple <double, double, double>(0.0, -2.8, 79.5), new Tuple <double, double, double>(0.0, -2.8, -79.5), new Tuple <double, double, double>(1000.0, -2.8, 79.5), new Tuple <double, double, double>(1000.0, -2.8, -79.5), new Tuple <double, double, double>(500.0, -2.8, 79.5), new Tuple <double, double, double>(500.0, -2.8, -79.5), new Tuple <double, double, double>(0.0, -2.8, -79.5), new Tuple <double, double, double>(0.0, -14.8, -91.5), new Tuple <double, double, double>(1000.0, -2.8, -79.5), new Tuple <double, double, double>(1000.0, -14.8, -91.5), new Tuple <double, double, double>(500.0, -2.8, -79.5), new Tuple <double, double, double>(500.0, -14.8, -91.5), new Tuple <double, double, double>(0.0, -14.8, -91.5), new Tuple <double, double, double>(0.0, -50.0, -91.5), new Tuple <double, double, double>(1000.0, -14.8, -91.5), new Tuple <double, double, double>(1000.0, -50.0, -91.5), new Tuple <double, double, double>(500.0, -14.8, -91.5), new Tuple <double, double, double>(500.0, -50.0, -91.5), new Tuple <double, double, double>(0.0, -50.0, -91.5), new Tuple <double, double, double>(0.0, -50.0, -100.0), new Tuple <double, double, double>(1000.0, -50.0, -91.5), new Tuple <double, double, double>(1000.0, -50.0, -100.0), new Tuple <double, double, double>(500.0, -50.0, -91.5), new Tuple <double, double, double>(500.0, -50.0, -100.0), new Tuple <double, double, double>(0.0, -50.0, -100.0), new Tuple <double, double, double>(0.0, 50.0, -100.0), new Tuple <double, double, double>(1000.0, -50.0, -100.0), new Tuple <double, double, double>(1000.0, 50.0, -100.0), new Tuple <double, double, double>(500.0, -50.0, -100.0), new Tuple <double, double, double>(500.0, 50.0, -100.0), new Tuple <double, double, double>(0.0, 50.0, -100.0), new Tuple <double, double, double>(0.0, 50.0, -91.5), new Tuple <double, double, double>(1000.0, 50.0, -100.0), new Tuple <double, double, double>(1000.0, 50.0, -91.5), new Tuple <double, double, double>(500.0, 50.0, -100.0), new Tuple <double, double, double>(500.0, 50.0, -91.5), new Tuple <double, double, double>(0.0, 50.0, -91.5), new Tuple <double, double, double>(0.0, 14.8, -91.5), new Tuple <double, double, double>(1000.0, 50.0, -91.5), new Tuple <double, double, double>(1000.0, 14.8, -91.5), new Tuple <double, double, double>(500.0, 50.0, -91.5), new Tuple <double, double, double>(500.0, 14.8, -91.5)
                };
                IfcCartesianPointList3D cartesianPointList3D = new IfcCartesianPointList3D(db, coords);
                cartesianPointList3D.Comments.Add("the geometric representation of the beam is provided as a triangulated face set");
                cartesianPointList3D.Comments.Add("the meshing depends on the creating software system");

                List <CoordIndex> coordIndex = new List <CoordIndex>()
                {
                    new CoordIndex(6, 5, 4), new CoordIndex(15, 8, 6), new CoordIndex(6, 4, 3), new CoordIndex(10, 11, 9), new CoordIndex(16, 10, 7), new CoordIndex(14, 11, 10), new CoordIndex(7, 8, 16), new CoordIndex(6, 2, 15), new CoordIndex(2, 3, 1), new CoordIndex(3, 2, 6), new CoordIndex(10, 16, 14), new CoordIndex(14, 13, 12), new CoordIndex(11, 14, 12), new CoordIndex(8, 15, 16), new CoordIndex(24, 23, 22), new CoordIndex(17, 26, 24), new CoordIndex(22, 21, 20), new CoordIndex(28, 29, 27), new CoordIndex(32, 28, 25), new CoordIndex(30, 29, 28), new CoordIndex(18, 25, 26), new CoordIndex(24, 20, 17), new CoordIndex(20, 21, 19), new CoordIndex(32, 31, 30), new CoordIndex(28, 32, 30), new CoordIndex(33, 34, 37), new CoordIndex(36, 35, 38), new CoordIndex(40, 44, 43), new CoordIndex(41, 43, 44), new CoordIndex(46, 50, 49), new CoordIndex(47, 49, 50), new CoordIndex(56, 55, 51), new CoordIndex(55, 56, 54), new CoordIndex(57, 58, 62), new CoordIndex(60, 59, 61), new CoordIndex(63, 64, 68), new CoordIndex(66, 65, 67), new CoordIndex(69, 70, 74), new CoordIndex(72, 71, 73), new CoordIndex(80, 79, 75), new CoordIndex(79, 80, 78), new CoordIndex(81, 82, 86), new CoordIndex(84, 83, 85), new CoordIndex(88, 92, 91), new CoordIndex(89, 91, 92), new CoordIndex(94, 98, 97), new CoordIndex(95, 97, 98), new CoordIndex(104, 103, 99), new CoordIndex(103, 104, 102), new CoordIndex(105, 106, 110), new CoordIndex(108, 107, 109), new CoordIndex(111, 112, 116), new CoordIndex(114, 113, 115), new CoordIndex(117, 118, 122), new CoordIndex(120, 119, 121), new CoordIndex(128, 127, 123), new CoordIndex(127, 128, 126), new CoordIndex(22, 20, 24), new CoordIndex(32, 25, 18), new CoordIndex(18, 26, 17), new CoordIndex(33, 37, 38), new CoordIndex(36, 38, 37), new CoordIndex(40, 43, 39), new CoordIndex(41, 44, 42), new CoordIndex(46, 49, 45), new CoordIndex(47, 50, 48), new CoordIndex(56, 51, 52), new CoordIndex(55, 54, 53), new CoordIndex(57, 62, 61), new CoordIndex(60, 61, 62), new CoordIndex(63, 68, 67), new CoordIndex(66, 67, 68), new CoordIndex(69, 74, 73), new CoordIndex(72, 73, 74), new CoordIndex(80, 75, 76), new CoordIndex(79, 78, 77), new CoordIndex(81, 86, 85), new CoordIndex(84, 85, 86), new CoordIndex(88, 91, 87), new CoordIndex(89, 92, 90), new CoordIndex(94, 97, 93), new CoordIndex(95, 98, 96), new CoordIndex(104, 99, 100), new CoordIndex(103, 102, 101), new CoordIndex(105, 110, 109), new CoordIndex(108, 109, 110), new CoordIndex(111, 116, 115), new CoordIndex(114, 115, 116), new CoordIndex(117, 122, 121), new CoordIndex(120, 121, 122), new CoordIndex(128, 123, 124), new CoordIndex(127, 126, 125)
                };
                IfcTriangulatedFaceSet triangulatedFaceSet = new IfcTriangulatedFaceSet(cartesianPointList3D, true, coordIndex);

                //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
                return(new IfcBeam(building, null, new IfcProductDefinitionShape(new IfcShapeRepresentation(triangulatedFaceSet)))
                {
                    GlobalId = "0EF5_zZRv0pQPddeofU3KT", Name = "ExampleBeamName", Description = "ExampleBeamDescription", Tag = "Tag"
                });
            }

            List <Coord2d> points = new List <Coord2d>()
            {
                new Coord2d(2.8, -79.5), new Coord2d(2.8, 79.5), new Coord2d(6.314719, 87.985281), new Coord2d(14.8, 91.5), new Coord2d(50.0, 91.5), new Coord2d(50.0, 100.0), new Coord2d(-50.0, 100.0), new Coord2d(-50.0, 91.5), new Coord2d(-14.8, 91.5), new Coord2d(-6.314719, 87.985281), new Coord2d(-2.8, 79.5), new Coord2d(-2.8, -79.5), new Coord2d(-6.314719, -87.985281), new Coord2d(-14.8, -91.5), new Coord2d(-50.0, -91.5), new Coord2d(-50.0, -100.0), new Coord2d(50.0, -100.0), new Coord2d(50.0, -91.5), new Coord2d(14.8, -91.5), new Coord2d(6.314719, -87.985281)
            };
            List <IfcSegmentIndexSelect> segments = new List <IfcSegmentIndexSelect>();

            segments.Add(new IfcLineIndex(1, 2));
            segments.Add(new IfcArcIndex(2, 3, 4));
            segments.Add(new IfcLineIndex(4, 5));
            segments.Add(new IfcLineIndex(5, 6));
            segments.Add(new IfcLineIndex(6, 7));
            segments.Add(new IfcLineIndex(7, 8));
            segments.Add(new IfcLineIndex(8, 9));
            segments.Add(new IfcArcIndex(9, 10, 11));
            segments.Add(new IfcLineIndex(11, 12));
            segments.Add(new IfcArcIndex(12, 13, 14));
            segments.Add(new IfcLineIndex(14, 15));
            segments.Add(new IfcLineIndex(15, 16));
            segments.Add(new IfcLineIndex(16, 17));
            segments.Add(new IfcLineIndex(17, 18));
            segments.Add(new IfcLineIndex(18, 19));
            segments.Add(new IfcArcIndex(19, 20, 1));
            IfcBoundedCurve boundedCurve = IfcBoundedCurve.Generate(db, points, segments);
            IfcArbitraryClosedProfileDef arbitraryClosedProfileDef = new IfcArbitraryClosedProfileDef("IPE200", boundedCurve);
            IfcAxis2Placement3D          axis2Placement3D          = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0), new IfcDirection(db, 0, 1, 0), new IfcDirection(db, 1, 0, 0));
            IfcExtrudedAreaSolid         extrudedAreaSolid         = new IfcExtrudedAreaSolid(arbitraryClosedProfileDef, axis2Placement3D, new IfcDirection(db, 0, 0, 1), 1000);
            IfcBeam beam = new IfcBeam(building, null, new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid)))
            {
                Name = "ExampleBeamName", Description = "ExampleBeamDescription", Tag = "Tag"
            };

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            beam.GlobalId = "0EF5_zZRv0pQPddeofU3KT";

            return(beam);
        }
示例#14
0
 public IfcExtrudedAreaSolid(IfcProfileDef __SweptArea, IfcAxis2Placement3D __Position, IfcDirection __ExtrudedDirection, IfcPositiveLengthMeasure __Depth)
     : base(__SweptArea, __Position)
 {
     this._ExtrudedDirection = __ExtrudedDirection;
     this._Depth             = __Depth;
 }
示例#15
0
 public IfcStructuralAnalysisModel(IfcGloballyUniqueId __GlobalId, IfcOwnerHistory __OwnerHistory, IfcLabel?__Name, IfcText?__Description, IfcLabel?__ObjectType, IfcAnalysisModelTypeEnum __PredefinedType, IfcAxis2Placement3D __OrientationOf2DPlane, IfcStructuralLoadGroup[] __LoadedBy, IfcStructuralResultGroup[] __HasResults)
     : base(__GlobalId, __OwnerHistory, __Name, __Description, __ObjectType)
 {
     this._PredefinedType       = __PredefinedType;
     this._OrientationOf2DPlane = __OrientationOf2DPlane;
     this._LoadedBy             = new HashSet <IfcStructuralLoadGroup>(__LoadedBy);
     this._HasResults           = new HashSet <IfcStructuralResultGroup>(__HasResults);
 }
示例#16
0
 public IfcLinearPlacement(IfcCurve __PlacementRelTo, IfcDistanceExpression __Distance, IfcOrientationExpression __Orientation, IfcAxis2Placement3D __CartesianPosition)
 {
     this.PlacementRelTo    = __PlacementRelTo;
     this.Distance          = __Distance;
     this.Orientation       = __Orientation;
     this.CartesianPosition = __CartesianPosition;
 }
示例#17
0
        public static int Main(string[] args)
        {
            var returnMessage      = (int)ExitCode.Success;
            var outputElements     = new List <JsonIfcElement>();
            var pathSource         = string.Empty;
            var pathDest           = string.Empty;
            var activeComptactJson = true;
            var readVersion        = false;
            var activeFullJson     = false;
            //var SCALE = 1.0;
            var context = new JsonConversionContext();
            JsonProjectIfcElement newProject = null;

            try
            {
                foreach (string arg in args)
                {
                    if (arg.ToLower().Trim() == "--version")
                    {
                        readVersion = true;
                    }
                    if (arg.ToLower().Trim() == "--indented")
                    {
                        activeComptactJson = false;
                    }
                    if (arg.ToLower().Trim() == "--full")
                    {
                        activeFullJson = true;
                    }
                    if (arg.Substring(0, 2) != "--" && pathSource != string.Empty && pathDest == string.Empty)
                    {
                        pathDest = arg;
                    }
                    if (arg.Substring(0, 2) != "--" && pathSource == string.Empty)
                    {
                        pathSource = arg;
                    }
                }

                if (readVersion)
                {
                    var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                    Console.WriteLine($"1. ConvertIfc2Json : {version}{Environment.NewLine}(.Net version {typeof(string).Assembly.ImageRuntimeVersion})");
                    return(returnMessage);
                }



                if (File.Exists(pathSource))
                {
                    if (pathDest == string.Empty)
                    {
                        pathDest = pathSource + ".json";
                    }
                    var        db = new DatabaseIfc();
                    IfcProject project;
                    var        projectId = "";
                    var        sites     = new List <IfcSite>();
                    var        buildings = new List <IfcBuilding>();

                    try
                    {
                        db      = new DatabaseIfc(pathSource);
                        project = db.Project;
                        sites   = project.Extract <IfcSite>();



                        // IFC Project
                        try
                        {
                            if (project.GlobalId != null)
                            {
                                // REVIEW ne semble pas servir
                                //foreach (var unit in project.UnitsInContext.Units)
                                //{
                                //    var u = project.UnitsInContext.Extract<IfcSIUnit>();
                                //    // Console.WriteLine("2." + unit.StepClassName);
                                //}

                                // Computing the json conversion scale from current Geogym project
                                context.SCALE = project.GetJsonConversionScale();
                                projectId     = project.GlobalId;
                            }

                            outputElements.Add(newProject = new JsonProjectIfcElement(project));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("3. Element read error " + ex.Message);
                            returnMessage = (int)ExitCode.UnknownError;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("31. Write file : " + ex.Message);
                        returnMessage = (int)ExitCode.InvalidFile;
                    }

                    // IFC Site
                    foreach (var site in sites)
                    {
                        try
                        {
                            if (site.GlobalId != null)
                            {
                                var newSite = new JsonSiteIfcElement(site, newProject, context);
                                outputElements.Add(newSite);

                                // IFC Building
                                buildings = site.Extract <IfcBuilding>();
                                foreach (var building in buildings)
                                {
                                    var newBuildind = new JsonBuildingIfcElement(building, newSite, context); // REVIEW shouldn't create this unused instance if global id is null
                                    if (building.GlobalId != null)
                                    {
                                        outputElements.Add(newBuildind);
                                    }

                                    // IFC Building Storey // Levels
                                    var buildingStoreys = building.Extract <IfcBuildingStorey>();
                                    foreach (var buildingStorey in buildingStoreys)
                                    {
                                        var storeyElement = new JsonStoreyIfcElement(buildingStorey, newBuildind, context);
                                        outputElements.Add(storeyElement);


                                        // IFC Space // Rooms
                                        var spaces = buildingStorey.Extract <IfcSpace>();

                                        // Check IfcProduct Ids
                                        var productsIds    = new List <string>();
                                        var productCounter = 0;

                                        // IfcProduct
                                        var products = buildingStorey.Extract <IfcProduct>();
                                        foreach (var product in products)
                                        {
                                            try
                                            {
                                                if (product.GlobalId != null)
                                                {
                                                    var newElementProd = new JsonProductIfcElement(product, storeyElement, context);
                                                    var spaceCounter   = 0;

                                                    // Link to the Space
                                                    foreach (var space in spaces)
                                                    {
                                                        try
                                                        {
                                                            // REVIEW = LatestOrDefault
                                                            // IfcSpace
                                                            if (space.GlobalId == product.GlobalId)
                                                            {
                                                                try
                                                                {
                                                                    newElementProd.userData.name = space.LongName;
                                                                }
                                                                catch (NotSupportedException exEncode)
                                                                {
                                                                    newElementProd.userData.name = space.Name;
                                                                    Console.WriteLine("15. Space Name read error (id: " + space.GlobalId + ") " + exEncode.Message); // returnMessage = (int)ExitCode.NodataIsAvailableForEncoding;
                                                                }
                                                                catch (System.Exception ex)
                                                                {
                                                                    Console.WriteLine("29. Space Name LongName read error" + ex.Message);
                                                                }

                                                                newElementProd.userData.pset.Add("number", space.Name);

                                                                // Create boundary
                                                                geoGeometry geom = new geoGeometry();
                                                                IList <IList <IList <double> > > coords = new List <IList <IList <double> > >();
                                                                Dictionary <string, string>      props  = new Dictionary <string, string>();
                                                                string height    = "0.0";
                                                                string elevation = "0.0";


                                                                // Representation
                                                                if (space.Representation.Representations.Count > 0)
                                                                {
                                                                    foreach (IfcRepresentationItem item in space.Representation.Representations[0].Items)
                                                                    {
                                                                        try
                                                                        {
                                                                            if (item.StepClassName == "IfcExtrudedAreaSolid")
                                                                            {
                                                                                IfcExtrudedAreaSolid areaSolid = item as IfcExtrudedAreaSolid;
                                                                                IfcAxis2Placement3D  pos       = areaSolid.Position;
                                                                                Point3D loc = new Point3D(pos.Location.Coordinates[0], pos.Location.Coordinates[1], pos.Location.Coordinates[2]);
                                                                                height    = (areaSolid.Depth / context.SCALE).ToString();
                                                                                elevation = (buildingStorey.Elevation / context.SCALE).ToString();

                                                                                if (areaSolid.SweptArea.StepClassName == "IfcArbitraryClosedProfileDef")
                                                                                { // Polyline
                                                                                    IfcArbitraryClosedProfileDef arbitraryClosedProfiles = areaSolid.SweptArea as IfcArbitraryClosedProfileDef;
                                                                                    IList <IList <double> >      polyExt = new List <IList <double> >();

                                                                                    if (arbitraryClosedProfiles.OuterCurve.StepClassName == "IfcIndexedPolyCurve")
                                                                                    {
                                                                                        IfcIndexedPolyCurve     outerCurve = arbitraryClosedProfiles.OuterCurve as IfcIndexedPolyCurve;
                                                                                        IfcCartesianPointList2D points     = outerCurve.Points as IfcCartesianPointList2D;
                                                                                        foreach (double[] pts in points.CoordList)
                                                                                        {
                                                                                            if (pts.Length >= 2)
                                                                                            {
                                                                                                try
                                                                                                {
                                                                                                    IList <double> xy = new List <double>();
                                                                                                    xy.Add(pts[0] / context.SCALE);
                                                                                                    xy.Add(pts[1] / context.SCALE);
                                                                                                    polyExt.Add(xy);
                                                                                                }
                                                                                                catch (System.Exception exTransf)
                                                                                                {
                                                                                                    Console.WriteLine("6." + exTransf.Message);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        List <IfcPolyline> poly = arbitraryClosedProfiles.OuterCurve.Extract <IfcPolyline>();

                                                                                        if (poly.Count > 0 && poly[0].Points.Count > 0)
                                                                                        {
                                                                                            foreach (IfcCartesianPoint pt in poly[0].Points)
                                                                                            {
                                                                                                if (pt.Coordinates.Count >= 2)
                                                                                                {
                                                                                                    try
                                                                                                    {
                                                                                                        IList <double> xy = new List <double>();
                                                                                                        xy.Add(pt.Coordinates[0] / context.SCALE);
                                                                                                        xy.Add(pt.Coordinates[1] / context.SCALE);
                                                                                                        polyExt.Add(xy);
                                                                                                    }
                                                                                                    catch (System.Exception exTransf)
                                                                                                    {
                                                                                                        Console.WriteLine("7. " + exTransf.Message);
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }


                                                                                    coords.Add(polyExt);

                                                                                    props.Add("location", pos.Location.Coordinates[0] / context.SCALE + "," + pos.Location.Coordinates[1] / context.SCALE + "," + pos.Location.Coordinates[2] / context.SCALE);
                                                                                    if (pos.RefDirection != null)
                                                                                    {
                                                                                        props.Add("refDirection", pos.RefDirection.DirectionRatios[0] + "," + pos.RefDirection.DirectionRatios[1] + "," + pos.RefDirection.DirectionRatios[2]);
                                                                                    }
                                                                                    if (pos.Axis != null)
                                                                                    {
                                                                                        props.Add("axis", pos.Axis.DirectionRatios[0] + "," + pos.Axis.DirectionRatios[1] + "," + pos.Axis.DirectionRatios[2]);
                                                                                    }
                                                                                }
                                                                                else if (areaSolid.SweptArea.StepClassName == "IfcRectangleProfileDef") // Rectangle
                                                                                {
                                                                                    List <IfcRectangleProfileDef> rectangleProfile = areaSolid.SweptArea.Extract <IfcRectangleProfileDef>();

                                                                                    if (rectangleProfile.Count > 0)
                                                                                    {
                                                                                        if (rectangleProfile[0].XDim > 0.0000001 && rectangleProfile[0].YDim > 0.0000001)
                                                                                        {
                                                                                            if (rectangleProfile[0].Position.Location.Coordinates.Count >= 2)
                                                                                            {
                                                                                                try
                                                                                                {
                                                                                                    Point3D lm   = new Point3D(0, 0, 0);
                                                                                                    double  XDim = rectangleProfile[0].XDim / 2;
                                                                                                    double  YDim = rectangleProfile[0].YDim / 2;

                                                                                                    // Left-Bottom
                                                                                                    IList <double> lb  = new List <double>();
                                                                                                    Point3D        lbP = new Point3D(lm.X - XDim, lm.Y - YDim, lm.Z);
                                                                                                    lb.Add(lbP.X / context.SCALE);
                                                                                                    lb.Add(lbP.Y / context.SCALE);
                                                                                                    // right-Bottom
                                                                                                    IList <double> rb  = new List <double>();
                                                                                                    Point3D        rbP = new Point3D(lm.X + XDim, lm.Y - YDim, lm.Z);
                                                                                                    rb.Add(rbP.X / context.SCALE);
                                                                                                    rb.Add(rbP.Y / context.SCALE);
                                                                                                    // right-top
                                                                                                    IList <double> rt  = new List <double>();
                                                                                                    Point3D        rtP = new Point3D(lm.X + XDim, lm.Y + YDim, lm.Z);
                                                                                                    rt.Add(rtP.X / context.SCALE);
                                                                                                    rt.Add(rtP.Y / context.SCALE);
                                                                                                    // left-top
                                                                                                    IList <double> lt  = new List <double>();
                                                                                                    Point3D        ltP = new Point3D(lm.X - XDim, lm.Y + YDim, lm.Z);
                                                                                                    lt.Add(ltP.X / context.SCALE);
                                                                                                    lt.Add(ltP.Y / context.SCALE);

                                                                                                    IList <IList <double> > polyExt = new List <IList <double> >();
                                                                                                    polyExt.Add(lb);
                                                                                                    polyExt.Add(rb);
                                                                                                    polyExt.Add(rt);
                                                                                                    polyExt.Add(lt);
                                                                                                    polyExt.Add(lb);
                                                                                                    coords.Add(polyExt);
                                                                                                    props.Add("location", pos.Location.Coordinates[0] / context.SCALE + "," + pos.Location.Coordinates[1] / context.SCALE + "," + pos.Location.Coordinates[2] / context.SCALE);
                                                                                                    if (pos.RefDirection != null)
                                                                                                    {
                                                                                                        props.Add("refDirection", pos.RefDirection.DirectionRatios[0] + "," + pos.RefDirection.DirectionRatios[1] + "," + pos.RefDirection.DirectionRatios[2]);
                                                                                                    }
                                                                                                    if (pos.Axis != null)
                                                                                                    {
                                                                                                        props.Add("axis", pos.Axis.DirectionRatios[0] + "," + pos.Axis.DirectionRatios[1] + "," + pos.Axis.DirectionRatios[2]);
                                                                                                    }
                                                                                                }
                                                                                                catch (System.Exception exMatrixTransf)
                                                                                                {
                                                                                                    Console.WriteLine("8. " + exMatrixTransf.Message);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                                else if (areaSolid.SweptArea.StepClassName == "IfcArbitraryProfileDefWithVoids") //
                                                                                {
                                                                                    // OuterCurve [IfcCurve]
                                                                                    IfcArbitraryProfileDefWithVoids arbitraryProfileDefWithVoids = areaSolid.SweptArea as IfcArbitraryProfileDefWithVoids;
                                                                                    IfcArbitraryClosedProfileDef    arbitraryClosedProfiles      = areaSolid.SweptArea as IfcArbitraryClosedProfileDef;
                                                                                    IList <IList <double> >         polyExt = new List <IList <double> >();

                                                                                    if (arbitraryProfileDefWithVoids.OuterCurve.StepClassName == "IfcIndexedPolyCurve")
                                                                                    {
                                                                                        IfcIndexedPolyCurve     outerCurve = arbitraryClosedProfiles.OuterCurve as IfcIndexedPolyCurve;
                                                                                        IfcCartesianPointList2D points     = outerCurve.Points as IfcCartesianPointList2D;
                                                                                        foreach (double[] pts in points.CoordList)
                                                                                        {
                                                                                            if (pts.Length >= 2)
                                                                                            {
                                                                                                try
                                                                                                {
                                                                                                    IList <double> xy = new List <double>();
                                                                                                    xy.Add(pts[0] / context.SCALE);
                                                                                                    xy.Add(pts[1] / context.SCALE);
                                                                                                    polyExt.Add(xy);
                                                                                                }
                                                                                                catch (System.Exception exTransf)
                                                                                                {
                                                                                                    Console.WriteLine("9. " + exTransf.Message);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        List <IfcPolyline> poly = arbitraryProfileDefWithVoids.OuterCurve.Extract <IfcPolyline>();

                                                                                        foreach (IfcCartesianPoint pt in poly[0].Points)
                                                                                        {
                                                                                            if (pt.Coordinates.Count >= 2)
                                                                                            {
                                                                                                try
                                                                                                {
                                                                                                    IList <double> xy = new List <double>();
                                                                                                    Point3D        p  = new Point3D(pt.Coordinates[0], pt.Coordinates[1], 0);
                                                                                                    xy.Add(p.X / context.SCALE);
                                                                                                    xy.Add(p.Y / context.SCALE);
                                                                                                    polyExt.Add(xy);
                                                                                                }
                                                                                                catch (System.Exception exTransf)
                                                                                                {
                                                                                                    Console.WriteLine("10. " + exTransf.Message);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }

                                                                                    coords.Add(polyExt);

                                                                                    props.Add("location", pos.Location.Coordinates[0] / context.SCALE + "," + pos.Location.Coordinates[1] / context.SCALE + "," + pos.Location.Coordinates[2] / context.SCALE);
                                                                                    if (pos.RefDirection != null)
                                                                                    {
                                                                                        props.Add("refDirection", pos.RefDirection.DirectionRatios[0] + "," + pos.RefDirection.DirectionRatios[1] + "," + pos.RefDirection.DirectionRatios[2]);
                                                                                    }
                                                                                    if (pos.Axis != null)
                                                                                    {
                                                                                        props.Add("axis", pos.Axis.DirectionRatios[0] + "," + pos.Axis.DirectionRatios[1] + "," + pos.Axis.DirectionRatios[2]);
                                                                                    }
                                                                                }
                                                                            }
                                                                            else if (item.StepClassName == "IfcFacetedBrep-XXX")  // TODO : Fix export 3D Object
                                                                            {                                                     // https://standards.buildingsmart.org/IFC/RELEASE/IFC4_1/FINAL/HTML/schema/ifcgeometricmodelresource/lexical/ifcfacetedbrep.htm
                                                                                List <IfcFacetedBrep> facetedBreps = item.Extract <IfcFacetedBrep>();
                                                                                if (facetedBreps.Count > 0)
                                                                                {
                                                                                    IfcFacetedBrep facetedBrep = facetedBreps[0];
                                                                                    elevation = (buildingStorey.Elevation / context.SCALE).ToString();
                                                                                    if (facetedBrep.Outer.StepClassName == "IfcClosedShell")
                                                                                    {
                                                                                        if (facetedBrep.Outer.CfsFaces.Count > 0) //
                                                                                        {
                                                                                            // CfsFaces[].Bounds[IfcFaceBound].Bound.Polgon[IfcCartesianPoint].Coordinates[3]
                                                                                            // OuterCurve [IfcCurve]
                                                                                            foreach (IfcFace cfsFace in facetedBrep.Outer.CfsFaces)
                                                                                            {
                                                                                                foreach (IfcFaceBound faceBound in cfsFace.Bounds)
                                                                                                {
                                                                                                    IList <IList <double> > polyExt = new List <IList <double> >();
                                                                                                    if (faceBound.Bound.StepClassName == "IfcPolyLoop")
                                                                                                    {
                                                                                                        IfcPolyLoop polyLoop = faceBound.Bound as IfcPolyLoop;
                                                                                                        foreach (IfcCartesianPoint pt in polyLoop.Polygon)
                                                                                                        {
                                                                                                            IList <double> xy = new List <double>();
                                                                                                            xy.Add(pt.Coordinates[0] / context.SCALE); //+ loc.X);
                                                                                                            xy.Add(pt.Coordinates[1] / context.SCALE); // + loc.Y);
                                                                                                            xy.Add(pt.Coordinates[2] / context.SCALE); // + loc.YZ;
                                                                                                            polyExt.Add(xy);
                                                                                                        }
                                                                                                    }

                                                                                                    // ERREUR OBJET 3D
                                                                                                    // TODO : Fix export 3D Object
                                                                                                    // coords.Add(polyExt);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        catch (System.Exception exRepresentationItem)
                                                                        {
                                                                            Console.WriteLine("11. Element read error exRepresentationItem" + exRepresentationItem.Message);
                                                                            returnMessage = (int)ExitCode.UnknownError;
                                                                        }
                                                                    }
                                                                }

                                                                if (coords.Count == 0)
                                                                {
                                                                    // Console.WriteLine("12. " + coords.Count);
                                                                }

                                                                props.Add("height", height);
                                                                props.Add("elevation", elevation);

                                                                geom.type        = "Polygon";
                                                                geom.coordinates = coords;

                                                                newElementProd.boundary            = new geoFeature();
                                                                newElementProd.boundary.type       = "Feature";
                                                                newElementProd.boundary.id         = null;
                                                                newElementProd.boundary.properties = props;
                                                                newElementProd.boundary.geometry   = geom;
                                                            }
                                                            var builingElements = space.Extract <IfcBuildingElementProxy>();
                                                            // IFC Elements
                                                            foreach (var bElement in builingElements)
                                                            {
                                                                IfcRelContainedInSpatialStructure productIds = bElement.ContainedInStructure;
                                                                foreach (IfcProduct pId in productIds.RelatedElements)
                                                                {
                                                                    try
                                                                    {
                                                                        if (pId.GlobalId == product.GlobalId)
                                                                        {
                                                                            newElementProd.userData.spaceId = space.GlobalId;
                                                                        }
                                                                    }
                                                                    catch (System.Exception ex)
                                                                    {
                                                                        Console.WriteLine("13. Element read error" + ex.Message);
                                                                        returnMessage = (int)ExitCode.UnknownError;
                                                                    }
                                                                }
                                                            }
                                                        }

                                                        catch (Exception ex)
                                                        {
                                                            Console.WriteLine("16. Element read error" + ex.Message);
                                                            returnMessage = (int)ExitCode.UnknownError;
                                                        }

                                                        spaceCounter += 1;
                                                    }

                                                    // Add to list
                                                    productsIds.Add(newElementProd.id);

                                                    if (newElementProd.userData.type != "IfcBuildingStorey")
                                                    {
                                                        outputElements.Add(newElementProd);
                                                    }
                                                    else
                                                    {
                                                        // Console.WriteLine("14. Error IfcBuildingStorey");
                                                    }
                                                }
                                            }
                                            catch (NotSupportedException exEncode)
                                            {
                                                Console.WriteLine("28. Name read error (product counter: " + productCounter + ") " + exEncode.Message); // returnMessage = (int)ExitCode.NodataIsAvailableForEncoding;
                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine("29. Element read error" + ex.Message);
                                                returnMessage = (int)ExitCode.UnknownError;
                                            }

                                            productCounter += 1;
                                        }



                                        // IFC Elements

                                        var elements = buildingStorey.Extract <IfcBuildingElementProxy>();
                                        foreach (IfcBuildingElementProxy element in elements
                                                 .Where(element => element.GlobalId != null && !productsIds.Contains(element.GlobalId)))
                                        {
                                            try
                                            {
                                                // Add to list
                                                outputElements.Add(new JsonBuildingElementProxyIfcElement(element, storeyElement, context));
                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine("17. Element read error" + ex.Message);
                                                returnMessage = (int)ExitCode.UnknownError;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("18. Element read error" + ex.Message);
                            returnMessage = (int)ExitCode.UnknownError;
                        }
                    }



                    // Json Settings
                    Newtonsoft.Json.JsonSerializerSettings jsonSettings = new Newtonsoft.Json.JsonSerializerSettings {
                        NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
                    };

                    if (activeComptactJson)
                    {
                        if (activeFullJson)
                        {
                            // Original File
                            string jsonFormat = Newtonsoft.Json.JsonConvert.SerializeObject(db.JSON(), Newtonsoft.Json.Formatting.None, jsonSettings);
                            File.WriteAllText(pathDest, jsonFormat);
                        }
                        else
                        {
                            string jsonFormat = Newtonsoft.Json.JsonConvert.SerializeObject(outputElements, Newtonsoft.Json.Formatting.None, jsonSettings);
                            File.WriteAllText(pathDest, jsonFormat);
                        }
                    }
                    else
                    {
                        if (activeFullJson)
                        {
                            // Original File
                            db.WriteFile(pathDest);
                        }
                        else
                        {
                            string jsonFormat = Newtonsoft.Json.JsonConvert.SerializeObject(outputElements, Newtonsoft.Json.Formatting.Indented, jsonSettings);
                            File.WriteAllText(pathDest, jsonFormat);
                        }
                    }
                }
                else
                {
                    returnMessage = (int)ExitCode.InvalidFilename;
                }
            }
            catch (Exception ioEx)
            {
                Console.WriteLine("19. " + ioEx.Message);
                returnMessage = (int)ExitCode.InvalidFile;
            }

            Console.WriteLine("20. " + pathDest);
            return(returnMessage);
        }
示例#18
0
 public IfcLightSourceGoniometric(IfcLabel?__Name, IfcColourRgb __LightColour, IfcNormalisedRatioMeasure?__AmbientIntensity, IfcNormalisedRatioMeasure?__Intensity, IfcAxis2Placement3D __Position, IfcColourRgb __ColourAppearance, IfcThermodynamicTemperatureMeasure __ColourTemperature, IfcLuminousFluxMeasure __LuminousFlux, IfcLightEmissionSourceEnum __LightEmissionSource, IfcLightDistributionDataSourceSelect __LightDistributionDataSource)
     : base(__Name, __LightColour, __AmbientIntensity, __Intensity)
 {
     this.Position                    = __Position;
     this.ColourAppearance            = __ColourAppearance;
     this.ColourTemperature           = __ColourTemperature;
     this.LuminousFlux                = __LuminousFlux;
     this.LightEmissionSource         = __LightEmissionSource;
     this.LightDistributionDataSource = __LightDistributionDataSource;
 }
示例#19
0
 public IfcSphere(IfcAxis2Placement3D __Position, IfcPositiveLengthMeasure __Radius)
     : base(__Position)
 {
     this.Radius = __Radius;
 }
示例#20
0
 public IfcRightCircularCone(IfcAxis2Placement3D __Position, IfcPositiveLengthMeasure __Height, IfcPositiveLengthMeasure __BottomRadius)
     : base(__Position)
 {
     this._Height       = __Height;
     this._BottomRadius = __BottomRadius;
 }
示例#21
0
 protected IfcCsgPrimitive3D(IfcAxis2Placement3D __Position)
 {
     this.Position = __Position;
 }
示例#22
0
 protected IfcSweptAreaSolid(IfcProfileDef __SweptArea, IfcAxis2Placement3D __Position)
 {
     this.SweptArea = __SweptArea;
     this.Position  = __Position;
 }
        /// <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
                }
            }
        }
 public IfcStructuralPointConnection(IfcGloballyUniqueId __GlobalId, IfcOwnerHistory __OwnerHistory, IfcLabel?__Name, IfcText?__Description, IfcLabel?__ObjectType, IfcObjectPlacement __ObjectPlacement, IfcProductRepresentation __Representation, IfcBoundaryCondition __AppliedCondition, IfcAxis2Placement3D __ConditionCoordinateSystem)
     : base(__GlobalId, __OwnerHistory, __Name, __Description, __ObjectType, __ObjectPlacement, __Representation, __AppliedCondition)
 {
     this.ConditionCoordinateSystem = __ConditionCoordinateSystem;
 }
        /// <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 = ucsAxisX.Normalized();
                    ucsAxisZ = ucsAxisZ.Normalized();

                    //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);
        }
示例#26
0
 public IfcRightCircularCylinder(IfcAxis2Placement3D __Position, IfcPositiveLengthMeasure __Height, IfcPositiveLengthMeasure __Radius)
     : base(__Position)
 {
     this.Height = __Height;
     this.Radius = __Radius;
 }
示例#27
0
 public IfcExtrudedAreaSolidTapered(IfcProfileDef __SweptArea, IfcAxis2Placement3D __Position, IfcDirection __ExtrudedDirection, IfcPositiveLengthMeasure __Depth, IfcProfileDef __EndSweptArea)
     : base(__SweptArea, __Position, __ExtrudedDirection, __Depth)
 {
     this._EndSweptArea = __EndSweptArea;
 }
示例#28
0
 public IfcSweptAreaSolid(IfcProfileDef __SweptArea, IfcAxis2Placement3D __Position)
 {
     this._SweptArea = __SweptArea;
     this._Position  = __Position;
 }
示例#29
0
 public IfcRevolvedAreaSolid(IfcProfileDef __SweptArea, IfcAxis2Placement3D __Position, IfcAxis1Placement __Axis, IfcPlaneAngleMeasure __Angle)
     : base(__SweptArea, __Position)
 {
     this.Axis  = __Axis;
     this.Angle = __Angle;
 }
 public IfcRelConnectsStructuralMember(IfcGloballyUniqueId __GlobalId, IfcOwnerHistory __OwnerHistory, IfcLabel?__Name, IfcText?__Description, IfcStructuralMember __RelatingStructuralMember, IfcStructuralConnection __RelatedStructuralConnection, IfcBoundaryCondition __AppliedCondition, IfcStructuralConnectionCondition __AdditionalConditions, IfcLengthMeasure?__SupportedLength, IfcAxis2Placement3D __ConditionCoordinateSystem)
     : base(__GlobalId, __OwnerHistory, __Name, __Description)
 {
     this._RelatingStructuralMember    = __RelatingStructuralMember;
     this._RelatedStructuralConnection = __RelatedStructuralConnection;
     this._AppliedCondition            = __AppliedCondition;
     this._AdditionalConditions        = __AdditionalConditions;
     this._SupportedLength             = __SupportedLength;
     this._ConditionCoordinateSystem   = __ConditionCoordinateSystem;
 }
示例#31
0
 public IXbimGeometryObject Create(IfcGeometricRepresentationItem ifcRepresentation, IfcAxis2Placement3D 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);
     }
 }