예제 #1
0
        public static IfcProductDefinitionShape CreateExtruded(IfcRepresentationContext representationContext,
            IfcProfileDef ifcProfileDef, IfcAxis2Placement3D placement3D, IfcDirection direction, double depth)
        {
            var extruded = new IfcExtrudedAreaSolid
                               {
                                   SweptArea = ifcProfileDef,
                                   Position =  placement3D,
                                   ExtrudedDirection = direction ,
                                   Depth = depth,
                               };

            var shaperep = new IfcShapeRepresentation
                               {
                                   ContextOfItems = representationContext,
                                   RepresentationIdentifier = "Body",
                                   RepresentationType = "SweptSolid",
                                   Items = new List<IfcRepresentationItem>(),
                               };
            shaperep.Items.Add(extruded);

            var ifcShape = new IfcProductDefinitionShape
                               {
                                   // Name=
                                   // Description =
                                   Representations = new List<IfcRepresentation>(),
                               };
            ifcShape.Representations.Add(shaperep);

            return ifcShape;
        }
예제 #2
0
        /// <summary>
        /// Convert a wall to an IfcWallStandardCase
        /// </summary>
        /// <param name="wall"></param>
        /// <param name="context"></param>
        /// <param name="doc"></param>
        /// <returns></returns>
        private static IfcWallStandardCase ToIfcWallStandardCase(this Wall wall, IfcRepresentationContext context, Document doc)
        {
            var sweptArea        = wall.CenterLine.Thicken(wall.Thickness()).ToIfcArbitraryClosedProfileDef(doc);
            var extrudeDirection = Vector3.ZAxis.ToIfcDirection();

            // We don't use the Wall's transform for positioning, because
            // our walls have a transform that lays the wall "flat". Just
            // use a identity transform.
            var position = new Transform().ToIfcAxis2Placement3D(doc);
            var repItem  = new IfcExtrudedAreaSolid(sweptArea, position,
                                                    extrudeDirection, new IfcPositiveLengthMeasure(wall.Height));
            var rep = new IfcShapeRepresentation(context, "Body", "SweptSolid", new List <IfcRepresentationItem> {
                repItem
            });
            var productRep = new IfcProductDefinitionShape(new List <IfcRepresentation> {
                rep
            });
            var id             = IfcGuid.ToIfcGuid(Guid.NewGuid());
            var localPlacement = new Transform().ToIfcLocalPlacement(doc);
            var ifcWall        = new IfcWallStandardCase(new IfcGloballyUniqueId(id),
                                                         null, wall.Name, null, null, localPlacement, productRep, null);

            doc.AddEntity(sweptArea);
            doc.AddEntity(extrudeDirection);
            doc.AddEntity(position);
            doc.AddEntity(repItem);
            doc.AddEntity(rep);
            doc.AddEntity(localPlacement);
            doc.AddEntity(productRep);
            doc.AddEntity(ifcWall);

            return(ifcWall);
        }
예제 #3
0
        public BbExtrudedGeometry(
			BbProfile profile,
			BbPosition3D position3D,
			BbDirection3D direction3D,
			double depth
			)
        {
            _ifcExtrudedAreaSolid = new IfcExtrudedAreaSolid{
                SweptArea = profile.IfcProfileDef,
                Position = position3D.IfcAxis2Placement3D,
                ExtrudedDirection = direction3D.IfcDirection,
                Depth = depth,
            };

            _ifcShapeRepresentation = new IfcShapeRepresentation
            {
                ContextOfItems = BbHeaderSetting.Setting3D.GeometricRepresentationContext,
                RepresentationIdentifier = "Body",
                RepresentationType = "SweptSolid",
                Items = new List<IfcRepresentationItem>(),
            };
            _ifcShapeRepresentation.Items.Add(_ifcExtrudedAreaSolid);

            _ifcProductDefinitionShape = new IfcProductDefinitionShape
            {
                // Name=
                // Description =
                Representations = new List<IfcRepresentation>(),
            };
            _ifcProductDefinitionShape.Representations.Add(_ifcShapeRepresentation);
        }
예제 #4
0
파일: Slab.cs 프로젝트: mccune/IfcScript
		internal static void GenerateData(STPModelData md, IfcBuilding building,bool openings)
		{
			IfcMaterial concrete = new IfcMaterial(md, "Concrete", "", "");
			int thickness = 200;
			IfcMaterialLayer materialLayer = new IfcMaterialLayer(md, concrete, thickness, false, "Core", "", "", 0);
			string name = thickness + "mm Concrete";
			IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet( materialLayer, name, "");
			materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq";
			md.NextObjectRecord = 300;
			IfcSlabType slabType = new IfcSlabType(name, materialLayerSet, IfcSlabTypeEnum.FLOOR) { GlobalId = "0RSW$KKbzCZ9QaSm3GoEan" };
			slabType.ObjectTypeOf.GlobalId = "3wwDcmW5T3HfafURQewdD0";
			PolyCurve polycurve = new PolyCurve();
			polycurve.Append(new Line(0, 0, 0, 1000, 0, 0));
			polycurve.Append(new Arc(new Point3d(1000, 0, 0), new Point3d(1400, 2000, 0), new Point3d(1000, 4000, 0)));
			polycurve.Append(new Line(1000, 4000, 0, 0, 4000, 0));
			polycurve.Append(new Arc(new Point3d(0, 4000, 0), new Point3d(-400, 2000, 0), new Point3d(0, 0, 0)));
			IfcSlabStandardCase slabStandardCase = new IfcSlabStandardCase(building, slabType, polycurve, -200, true, null) { GlobalId = "1wAj$J2Az2V8wnBiVYd3bU" };
			slabStandardCase.Material.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w";
			if (openings)
			{
				IfcCircleProfileDef cpd = new IfcCircleProfileDef(md, "100DIA", 50);
				IfcExtrudedAreaSolid eas = new IfcExtrudedAreaSolid(cpd,new IfcAxis2Placement3D(md,new Plane(new Point3d(100,300,-200),Vector3d.XAxis,Vector3d.YAxis)),new IfcDirection(md,0,0,1),thickness);
				IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, null, eas) { GlobalId = "15RSTHd8nFVQWMRE7og7sd", Name = "Opening" };
				opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO";
				IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(md, "RecessRectangle", 500, 1000);
				eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(500, 1000, -50), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), 50);
				IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, eas, IfcOpeningElementTypeEnum.RECESS) { GlobalId = "0w93HZ19H2D99zbAVNb4o2", Name = "Recess" };
				recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM";
			}
		}
예제 #5
0
        public static IfcProductDefinitionShape CreateExtruded(IfcRepresentationContext representationContext,
                                                               IfcProfileDef ifcProfileDef, IfcAxis2Placement3D placement3D, IfcDirection direction, double depth)
        {
            var extruded = new IfcExtrudedAreaSolid
            {
                SweptArea         = ifcProfileDef,
                Position          = placement3D,
                ExtrudedDirection = direction,
                Depth             = depth,
            };

            var shaperep = new IfcShapeRepresentation
            {
                ContextOfItems           = representationContext,
                RepresentationIdentifier = "Body",
                RepresentationType       = "SweptSolid",
                Items = new List <IfcRepresentationItem>(),
            };

            shaperep.Items.Add(extruded);

            var ifcShape = new IfcProductDefinitionShape
            {
                // Name=
                // Description =
                Representations = new List <IfcRepresentation>(),
            };

            ifcShape.Representations.Add(shaperep);

            return(ifcShape);
        }
예제 #6
0
        private IfcBeam GenerateIPE200(DatabaseIfc db, IfcBuilding building, bool tessellated)
        {
            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);

                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);
        }
예제 #7
0
파일: Slab.cs 프로젝트: tsiddikee/IfcScript
        internal static void GenerateData(STPModelData md, IfcBuilding building, bool openings)
        {
            IfcMaterial         concrete         = new IfcMaterial(md, "Concrete", "", "");
            int                 thickness        = 200;
            IfcMaterialLayer    materialLayer    = new IfcMaterialLayer(md, concrete, thickness, false, "Core", "", "", 0);
            string              name             = thickness + "mm Concrete";
            IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(md, materialLayer, name, "");

            materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq";
            md.NextObjectRecord = 300;
            IfcSlabType slabType = new IfcSlabType(md, new IfcElemTypeParams("0RSW$KKbzCZ9QaSm3GoEan", name, "", "", ""), materialLayerSet, null, IfcSlabTypeEnum.FLOOR);

            slabType.ObjectTypeOf.GlobalId = "3wwDcmW5T3HfafURQewdD0";
            PolyCurve polycurve = new PolyCurve();

            polycurve.Append(new Line(0, 0, 0, 1000, 0, 0));
            polycurve.Append(new Arc(new Point3d(1000, 0, 0), new Point3d(1400, 2000, 0), new Point3d(1000, 4000, 0)));
            polycurve.Append(new Line(1000, 4000, 0, 0, 4000, 0));
            polycurve.Append(new Arc(new Point3d(0, 4000, 0), new Point3d(-400, 2000, 0), new Point3d(0, 0, 0)));
            IfcSlabStandardCase slabStandardCase = new IfcSlabStandardCase(building, new IfcElemParams("1wAj$J2Az2V8wnBiVYd3bU", "", "", "", ""), slabType, polycurve, -200, true, null);

            slabStandardCase.Material.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w";
            if (openings)
            {
                IfcCircleProfileDef    cpd     = new IfcCircleProfileDef(md, IfcProfileTypeEnum.AREA, "100DIA", null, 50);
                IfcExtrudedAreaSolid   eas     = new IfcExtrudedAreaSolid(cpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(100, 300, -200), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), thickness);
                IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, new IfcElemParams("15RSTHd8nFVQWMRE7og7sd", "Opening", "", "", ""), null, eas);
                opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO";
                IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(md, IfcProfileTypeEnum.AREA, "RecessRectangle", null, 500, 1000);
                eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(500, 1000, -50), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), 50);
                IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, new IfcElemParams("0w93HZ19H2D99zbAVNb4o2", "Recess", "", "", ""), eas, IfcOpeningElementTypeEnum.RECESS);
                recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM";
            }
        }
예제 #8
0
        protected override void GenerateInstance(IfcBuilding building)
        {
            DatabaseIfc db    = building.Database;
            IfcBlock    block = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), 2000, 800, 800);
            IfcRoundedRectangleProfileDef roundedRectangle  = new IfcRoundedRectangleProfileDef(db, "VoidProfile", 1800, 600, 200);
            IfcExtrudedAreaSolid          extrudedAreaSolid = new IfcExtrudedAreaSolid(roundedRectangle, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 1000, 400, 100)), new IfcDirection(db, 0, 0, 1), 700);
            IfcBooleanResult        booleanResult           = new IfcBooleanResult(IfcBooleanOperator.DIFFERENCE, block, extrudedAreaSolid);
            IfcCsgSolid             csgSolid             = new IfcCsgSolid(booleanResult);
            IfcRepresentationMap    representationMap    = new IfcRepresentationMap(csgSolid);
            IfcMaterial             ceramic              = new IfcMaterial(db, "Ceramic");
            IfcSanitaryTerminalType sanitaryTerminalType = new IfcSanitaryTerminalType(db, "Bath", IfcSanitaryTerminalTypeEnum.BATH)
            {
                MaterialSelect = ceramic
            };

            sanitaryTerminalType.RepresentationMaps.Add(representationMap);
            IfcElement element = sanitaryTerminalType.GenerateMappedItemElement(building, new IfcCartesianTransformationOperator3D(db));

            db.Context.AddDeclared(sanitaryTerminalType);

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            sanitaryTerminalType.GlobalId = "1HarmwaPv3OeJSXpaoPKpg";
            ceramic.Associates.GlobalId   = "0Pkhszwjv1qRMYyCFg9fjB";
            sanitaryTerminalType.ObjectTypeOf.GlobalId = "1lO$X3e3j9lfVMhNy4MzKB";
            element.GlobalId = "3$$o7C03j0KQeLnoj018fc";
        }
예제 #9
0
        public BbExtrudedGeometry(
            BbProfile profile,
            BbPosition3D position3D,
            BbDirection3D direction3D,
            double depth
            )
        {
            _ifcExtrudedAreaSolid = new IfcExtrudedAreaSolid {
                SweptArea         = profile.IfcProfileDef,
                Position          = position3D.IfcAxis2Placement3D,
                ExtrudedDirection = direction3D.IfcDirection,
                Depth             = depth,
            };

            _ifcShapeRepresentation = new IfcShapeRepresentation
            {
                ContextOfItems           = BbHeaderSetting.Setting3D.GeometricRepresentationContext,
                RepresentationIdentifier = "Body",
                RepresentationType       = "SweptSolid",
                Items = new List <IfcRepresentationItem>(),
            };
            _ifcShapeRepresentation.Items.Add(_ifcExtrudedAreaSolid);

            _ifcProductDefinitionShape = new IfcProductDefinitionShape
            {
                // Name=
                // Description =
                Representations = new List <IfcRepresentation>(),
            };
            _ifcProductDefinitionShape.Representations.Add(_ifcShapeRepresentation);
        }
예제 #10
0
        internal static void BodyPlacementSet(this IfcExtrudedAreaSolid areaSolidBody, IfcStore model, double x, double y, double z = 0, Vector3D uv = null)
        {
            areaSolidBody.Position = model.Instances.New <IfcAxis2Placement3D>();
            IfcCartesianPoint location = model.Instances.New <IfcCartesianPoint>();

            location.SetXYZ(x, y, z);
            areaSolidBody.Position.Location = location;
        }
예제 #11
0
        internal static void BodyPlacementSet(this IfcExtrudedAreaSolid areaSolidBody, IfcStore model, IfcCartesianPoint insertionPt)
        {
            areaSolidBody.Position = model.Instances.New <IfcAxis2Placement3D>();
            IfcCartesianPoint location = model.Instances.New <IfcCartesianPoint>();

            location.SetXYZ(insertionPt.X, insertionPt.Y, insertionPt.Z);
            areaSolidBody.Position.Location = location;
        }
        /// <summary>
        /// returns a Hash for the geometric behaviour of this object
        /// </summary>
        /// <param name="solid"></param>
        /// <returns></returns>
        public static int GetGeometryHashCode(this IfcExtrudedAreaSolid solid)
        {
            Func <double, int> f = solid.ModelOf.ModelFactors.GetGeometryDoubleHash;

            return(f(solid.Depth) ^
                   solid.ExtrudedDirection.GetGeometryHashCode() ^
                   solid.Position.GetGeometryHashCode() ^
                   solid.SweptArea.GetGeometryHashCode());
        }
예제 #13
0
        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"
            });
        }
예제 #14
0
        internal static IfcExtrudedAreaSolid ProfileSweptSolidCreate(IfcStore model, double extrusionDepth, IfcProfileDef prof, IfcDirection extrusionDirection)
        {
            IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>();

            body.Depth             = extrusionDepth;
            body.SweptArea         = prof;
            body.ExtrudedDirection = extrusionDirection;

            return(body);
        }
예제 #15
0
        static void Main(string[] args)
        {
            var dbInitial = new DatabaseIfc(ModelView.Ifc4NotAssigned);

            dbInitial.Factory.Options.GenerateOwnerHistory = false;

            var site = new IfcSite(dbInitial, "site")
            {
                Guid = new Guid("aa4019f8-2584-44a1-a132-c17dfff69c41")
            };
            var project = new IfcProject(dbInitial, "GeomRep")
            {
                Guid = new Guid("94d4ddac-9120-4fb9-bea0-7a414ee725d4")
            };

            new IfcRelAggregates(project, new List <IfcObjectDefinition>()
            {
                site
            })
            {
                Guid = new Guid("5e1fd0e5-b005-fe11-501e-5caff01dc1ad")
            };

            IfcAxis2Placement3D placement1       = new IfcAxis2Placement3D(new IfcCartesianPoint(dbInitial, 2, 5, 1));
            IfcLocalPlacement   objectPlacement1 = new IfcLocalPlacement(site.ObjectPlacement, placement1);

            IfcAxis2Placement3D placement2       = new IfcAxis2Placement3D(new IfcCartesianPoint(dbInitial, 14, 5, 1));
            IfcLocalPlacement   objectPlacement2 = new IfcLocalPlacement(site.ObjectPlacement, placement2);


            var profile1 = new IfcRectangleProfileDef(dbInitial, "rectangleProfileDef", 4, 6);
            IfcExtrudedAreaSolid      extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
            IfcProductDefinitionShape shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

            var profile2 = new IfcRectangleProfileDef(dbInitial, "rectangleProfileDef", 5, 8);
            IfcExtrudedAreaSolid      extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 4.1);
            IfcProductDefinitionShape shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));


            var proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
            {
                Name = "Cuboid1",
                Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3b44115bbaa")
            };
            var proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
            {
                Name = "Cuboid2",
                Guid = new Guid("f8e196cb-c7d9-4d53-9885-0f687706727a")
            };


            dbInitial.WriteFile("cube_double.ifc");
        }
예제 #16
0
        internal static IfcColumn createColumn(IfcProduct host, IfcProfileDef profile, IfcCartesianPoint cartesianPoint, string globalId)
        {
            DatabaseIfc               db = host.Database;
            IfcExtrudedAreaSolid      extrudedAreaSolid      = new IfcExtrudedAreaSolid(profile, 5000);
            IfcShapeRepresentation    shapeRepresentation    = new IfcShapeRepresentation(extrudedAreaSolid);
            IfcProductDefinitionShape productDefinitionShape = new IfcProductDefinitionShape(shapeRepresentation);
            IfcLocalPlacement         localPlacement         = createLocalPlacement(host, cartesianPoint, db.Factory.YAxis);
            IfcColumn column = new IfcColumn(host, localPlacement, productDefinitionShape);

            setGlobalId(column, globalId);

            return(column);
        }
예제 #17
0
        private static IfcBeam CreateBeam(XbimModel model, HndzStructuralElement genericProducthndz)
        {
            using (XbimReadWriteTransaction txn = model.BeginTransaction("Create" + genericProducthndz.ToString()))
            {
                IfcBeam genericProductIfc        = model.Instances.New <IfcBeam>();
                IfcExtrudedAreaSolid body        = model.Instances.New <IfcExtrudedAreaSolid>();
                IfcBeamType          elementType = model.Instances.New <IfcBeamType>();
                elementType.PredefinedType = IfcBeamTypeEnum.BEAM;


                if (genericProducthndz.Profile is HndzRectangularProfile)
                {
                    HndzRectangularProfile genericProfilehndz = genericProducthndz.Profile as HndzRectangularProfile;

                    IfcRectangleProfileDef ifcGenericProfile = AssignRectangularProfile(model, genericProducthndz, genericProductIfc, elementType, genericProfilehndz);

                    //model as a swept area solid
                    body.SweptArea = ifcGenericProfile;
                }

                if (genericProducthndz.Profile is HndzISectionProfile)
                {
                    HndzISectionProfile genericProfilehndz = genericProducthndz.Profile as HndzISectionProfile;

                    IfcIShapeProfileDef ifcGenericProfile = AssignIProfile(model, genericProducthndz, genericProductIfc, elementType, genericProfilehndz);


                    //model as a swept area solid
                    body.SweptArea = ifcGenericProfile;
                }
                if (genericProducthndz.Profile is HndzCSectionProfile)
                {
                    HndzCSectionProfile genericProfilehndz = genericProducthndz.Profile as HndzCSectionProfile;
                    IfcCShapeProfileDef ifcGenericProfile  = AssignCsectionProfile(model, genericProducthndz, genericProductIfc, elementType, genericProfilehndz);


                    //model as a swept area solid
                    body.SweptArea = ifcGenericProfile;
                }

                AdjustExtrusion(model, body, genericProducthndz, genericProductIfc);

                if (model.Validate(txn.Modified(), Console.Out) == 0)
                {
                    txn.Commit();
                    return(genericProductIfc);
                }

                return(null);
            }
        }
예제 #18
0
        private IfcSlab CreateIfcLanding(IfcStore model, LinearPath landingPline, double landingThickness)
        {
            //begin a transaction
            using (var trans = model.BeginTransaction("Create Wall"))
            {
                IfcSlab landing = model.Instances.New <IfcSlab>();


                IfcDirection extrusionDir = model.Instances.New <IfcDirection>();
                extrusionDir.SetXYZ(0, 0, -1);

                //Create a Definition shape to hold the geometry of the Stair 3D body
                IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body");


                IfcArbitraryClosedProfileDef stepProfile = IFCHelper.ArbitraryClosedProfileCreate(model, (landingPline.Vertices /*.Select(v => v * 1000)*/).ToList());

                IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, landingThickness, stepProfile, extrusionDir);


                body.BodyPlacementSet(model, 0, 0, 0);

                shape.Items.Add(body);

                //Create a Product Definition and add the model geometry to the wall
                IfcProductDefinitionShape prDefShape = model.Instances.New <IfcProductDefinitionShape>();
                prDefShape.Representations.Add(shape);

                landing.Representation = prDefShape;

                //Create Local axes system and assign it to the column
                IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>();
                location3D.SetXYZ(0, 0, 0);

                //var uvColLongDir = MathHelper.UnitVectorPtFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir);

                IfcDirection localXDir = model.Instances.New <IfcDirection>();
                localXDir.SetXYZ(1, 0, 0);

                IfcDirection localZDir = model.Instances.New <IfcDirection>();
                localZDir.SetXYZ(0, 0, 1);

                IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir);

                //now place the slab into the model
                IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D);
                landing.ObjectPlacement = lp;
                trans.Commit();
                return(landing);
            }
        }
예제 #19
0
        internal static IfcBeam createBeam(IfcProduct host, IfcProfileDef profile, IfcCartesianPoint cartesianPoint, string globalId)
        {
            DatabaseIfc               db                     = host.Database;
            IfcAxis2Placement3D       position               = new IfcAxis2Placement3D(db.Factory.Origin, db.Factory.XAxis, db.Factory.YAxisNegative);
            IfcExtrudedAreaSolid      extrudedAreaSolid      = new IfcExtrudedAreaSolid(profile, position, 5000);
            IfcShapeRepresentation    shapeRepresentation    = new IfcShapeRepresentation(extrudedAreaSolid);
            IfcProductDefinitionShape productDefinitionShape = new IfcProductDefinitionShape(shapeRepresentation);

            IfcLocalPlacement localPlacement = createLocalPlacement(host, cartesianPoint, db.Factory.YAxis);
            IfcBeam           beam           = new IfcBeam(host, localPlacement, productDefinitionShape);

            setGlobalId(beam, globalId);
            return(beam);
        }
예제 #20
0
파일: Bath.cs 프로젝트: mccune/IfcScript
		protected override void GenerateData(STPModelData md, IfcBuilding building)
		{
			IfcBlock block = new IfcBlock(md,Plane.WorldXY,	2000,800,800);
			IfcRoundedRectangleProfileDef roundedRectangle = new IfcRoundedRectangleProfileDef(md, "VoidProfile", 600,1800,200);
			IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(roundedRectangle,new IfcAxis2Placement3D(md,new Plane(new Point3d( 1000,400,100),Vector3d.XAxis,Vector3d.YAxis)),new IfcDirection(md,0,0,1),700);
			IfcBooleanResult booleanResult = new IfcBooleanResult(IfcBooleanOperator.DIFFERENCE, block, extrudedAreaSolid);
			IfcCsgSolid csgSolid = new IfcCsgSolid(booleanResult);
			IfcRepresentationMap representationMap = new IfcRepresentationMap(csgSolid);
			IfcMaterial ceramic = new IfcMaterial(md, "Ceramic", "", "");
			ceramic.Associates.GlobalId = "0Pkhszwjv1qRMYyCFg9fjB";
			IfcSanitaryTerminalType sanitaryTerminalType = new IfcSanitaryTerminalType(md, "Bath", IfcSanitaryTerminalTypeEnum.BATH) { GlobalId = "1HarmwaPv3OeJSXpaoPKpg", MaterialSelect = ceramic, RepresentationMaps = new List<IfcRepresentationMap>() {representationMap } };
			sanitaryTerminalType.ObjectTypeOf.GlobalId = "1lO$X3e3j9lfVMhNy4MzKB";
			IfcElement element = sanitaryTerminalType.GenerateMappedItemElement(building, Plane.WorldXY);
			element.GlobalId = "3$$o7C03j0KQeLnoj018fc";
		}
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcExtrudedAreaSolid a, IfcRepresentationItem b)
        {
            IfcExtrudedAreaSolid eas = b as IfcExtrudedAreaSolid;

            if (eas == null)
            {
                return(false);            //different types are not the same
            }
            double precision = a.ModelOf.ModelFactors.Precision;

            return(Math.Abs(a.Depth - eas.Depth) <= precision &&
                   a.ExtrudedDirection.GeometricEquals(eas.ExtrudedDirection) &&
                   a.Position.GeometricEquals(eas.Position) &&
                   a.SweptArea.GeometricEquals(eas.SweptArea));
        }
예제 #22
0
        protected override void GenerateData(STPModelData md, IfcBuilding building)
        {
            IfcBlock block = new IfcBlock(md, Plane.WorldXY, 2000, 800, 800);
            IfcRoundedRectangleProfileDef roundedRectangle  = new IfcRoundedRectangleProfileDef(md, IfcProfileTypeEnum.AREA, "VoidProfile", null, 600, 1800, 200);
            IfcExtrudedAreaSolid          extrudedAreaSolid = new IfcExtrudedAreaSolid(roundedRectangle, new IfcAxis2Placement3D(md, new Plane(new Point3d(1000, 400, 100), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), 700);
            IfcBooleanResult     booleanResult     = new IfcBooleanResult(IfcBooleanOperator.DIFFERENCE, block, extrudedAreaSolid);
            IfcCsgSolid          csgSolid          = new IfcCsgSolid(booleanResult);
            IfcRepresentationMap representationMap = new IfcRepresentationMap(csgSolid);
            IfcMaterial          ceramic           = new IfcMaterial(md, "Ceramic", "", "");

            ceramic.Associates.GlobalId = "0Pkhszwjv1qRMYyCFg9fjB";
            IfcSanitaryTerminalType sanitaryTerminalType = new IfcSanitaryTerminalType(md, new IfcElemTypeParams("1HarmwaPv3OeJSXpaoPKpg", "Bath", "", "", ""), ceramic, representationMap, null, IfcSanitaryTerminalTypeEnum.BATH);

            sanitaryTerminalType.ObjectTypeOf.GlobalId = "1lO$X3e3j9lfVMhNy4MzKB";
            sanitaryTerminalType.GenerateMappedItemElement(building, Plane.WorldXY, new IfcElemParams("3$$o7C03j0KQeLnoj018fc", "", "", "", ""));
        }
        public ExtrudedAreaSolid(IfcStore model, double depth, IProfile profile, DirectionVector3D direction, PlacementAxis3D placement)
        {
            this.Model             = model;
            this.depth             = depth;
            this.profile           = profile;
            this.extrudedDirection = direction;
            this.position          = placement;

            ifcExtrusionSolid = model.Instances.New <IfcExtrudedAreaSolid>(e =>
            {
                e.Depth             = depth;
                e.ExtrudedDirection = extrudedDirection.IfcDirection;
                e.Position          = position.IfcAxis2Placement3D;
                e.SweptArea         = profile.ProfileDef;
            });
        }
        private IfcProductRepresentation MakeSweptSolidRepresentation(IfcExtrudedAreaSolid extrusion)
        {
            //Create a Definition shape to hold the geometry
            var shape = TargetRepository.Instances.New <IfcShapeRepresentation>();

            shape.ContextOfItems           = Model3DContext;
            shape.RepresentationType       = "SweptSolid";
            shape.RepresentationIdentifier = "Body";
            shape.Items.Add(extrusion);

            //Create a Product Definition and add the model geometry to the wall
            var rep = TargetRepository.Instances.New <IfcProductDefinitionShape>();

            rep.Representations.Add(shape);
            return(rep);
        }
예제 #25
0
        internal static IfcExtrudedAreaSolid ProfileSweptSolidCreate(IfcStore model, double extrusionDepth, IfcProfileDef prof, IfcDirection extrusionDirection = null)
        {
            IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>();

            body.Depth     = extrusionDepth;
            body.SweptArea = prof;
            if (extrusionDirection != null)
            {
                body.ExtrudedDirection = extrusionDirection;
            }
            else
            {
                body.ExtrudedDirection = model.Instances.New <IfcDirection>(d => d.SetXYZ(0, 0, 1));
            }

            return(body);
        }
예제 #26
0
        static void Generate(TypeIFC type, ReleaseVersion release, string path)
        {
            DatabaseIfc db       = new DatabaseIfc(true, release);
            IfcBuilding building = new IfcBuilding(db, "IfcBuilding")
            {
            };
            IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Millimetre)
            {
            };

            IfcRectangleProfileDef    rect      = new IfcRectangleProfileDef(db, "Rect", 1000, 500);
            IfcExtrudedAreaSolid      extrusion = new IfcExtrudedAreaSolid(rect, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), new IfcDirection(db, 0, 0, 1), 2000);
            IfcProductDefinitionShape rep       = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrusion));

            if (type == TypeIFC.Chiller)
            {
                IfcChiller chiller = new IfcChiller(building, null, rep, null)
                {
                    PredefinedType = IfcChillerTypeEnum.AIRCOOLED
                };
                if (release == ReleaseVersion.IFC2x3)
                {
                    chiller.RelatingType = new IfcChillerType(db, "MyChillerType", IfcChillerTypeEnum.AIRCOOLED);
                }
            }
            else if (type == TypeIFC.AirTerminal)
            {
                IfcAirTerminal terminal = new IfcAirTerminal(building, null, rep, null)
                {
                    PredefinedType = IfcAirTerminalTypeEnum.DIFFUSER
                };
                if (release == ReleaseVersion.IFC2x3)
                {
                    terminal.RelatingType = new IfcAirTerminalType(db, "MyAirTerminalType", IfcAirTerminalTypeEnum.DIFFUSER);
                }
            }
            else
            {
                IfcElectricDistributionPoint point = new IfcElectricDistributionPoint(building, null, rep, null)
                {
                    DistributionPointFunction = IfcElectricDistributionPointFunctionEnum.DISTRIBUTIONBOARD
                };
            }
            db.WriteFile(Path.Combine(path, type.ToString() + " " + release.ToString() + ".ifc"));
        }
예제 #27
0
        internal static IfcExtrudedAreaSolid ToIfcExtrudedAreaSolid(this Extrude extrude, Document doc)
        {
            var position = new Transform().ToIfcAxis2Placement3D(doc);

            var extrudeDepth     = extrude.Height;
            var extrudeProfile   = extrude.Profile.Perimeter.ToIfcArbitraryClosedProfileDef(doc);
            var extrudeDirection = Vector3.ZAxis.ToIfcDirection();;

            var solid = new IfcExtrudedAreaSolid(extrudeProfile, position,
                                                 extrudeDirection, new IfcPositiveLengthMeasure(extrude.Height));

            doc.AddEntity(extrudeProfile);
            doc.AddEntity(extrudeDirection);
            doc.AddEntity(position);
            doc.AddEntity(solid);

            return(solid);
        }
예제 #28
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" }; 
		}
예제 #29
0
        private static IfcExtrudedAreaSolid ToIfcExtrudedAreaSolid(this IExtrude extrude, Transform transform, Document doc)
        {
            var position = new Transform().ToIfcAxis2Placement3D(doc);

            double extrudeDepth = 0.0;
            IfcArbitraryClosedProfileDef extrudeProfile = null;
            IfcDirection extrudeDirection = null;

            extrudeProfile   = extrude.Profile.Perimeter.ToIfcArbitraryClosedProfileDef(doc);
            extrudeDirection = extrude.ExtrudeDirection.ToIfcDirection();
            extrudeDepth     = extrude.ExtrudeDepth;

            var solid = new IfcExtrudedAreaSolid(extrudeProfile, position,
                                                 extrudeDirection, new IfcPositiveLengthMeasure(extrude.ExtrudeDepth));

            doc.AddEntity(extrudeProfile);
            doc.AddEntity(extrudeDirection);
            doc.AddEntity(position);
            doc.AddEntity(solid);

            return(solid);
        }
예제 #30
0
        private static IfcBeam ToIfcBeam(this Beam beam, IfcRepresentationContext context, Document doc)
        {
            var sweptArea = beam.ElementType.Profile.Perimeter.ToIfcArbitraryClosedProfileDef(doc);
            var line      = beam.Curve as Line;

            if (line == null)
            {
                throw new Exception("The beam could not be exported to IFC. Only linear beams are currently supported.");
            }

            // We use the Z extrude direction because the direction is
            // relative to the local placement, which is a transform at the
            // beam's end with the Z axis pointing along the direction.

            var extrudeDirection = Vector3.ZAxis.ToIfcDirection();

            var position = new Transform().ToIfcAxis2Placement3D(doc);
            var repItem  = new IfcExtrudedAreaSolid(sweptArea, position,
                                                    extrudeDirection, new IfcPositiveLengthMeasure(beam.Curve.Length()));
            var localPlacement = beam.Curve.TransformAt(0.0).ToIfcLocalPlacement(doc);
            var rep            = new IfcShapeRepresentation(context, "Body", "SweptSolid", new List <IfcRepresentationItem> {
                repItem
            });
            var productRep = new IfcProductDefinitionShape(new List <IfcRepresentation> {
                rep
            });
            var ifcBeam = new IfcBeam(IfcGuid.ToIfcGuid(Guid.NewGuid()), null, null, null, null, localPlacement, productRep, null);

            doc.AddEntity(sweptArea);
            doc.AddEntity(extrudeDirection);
            doc.AddEntity(position);
            doc.AddEntity(repItem);
            doc.AddEntity(rep);
            doc.AddEntity(localPlacement);
            doc.AddEntity(productRep);
            doc.AddEntity(ifcBeam);

            return(ifcBeam);
        }
예제 #31
0
        internal static DatabaseIfc Generate(ModelView mdv, string path)
        {
            DatabaseIfc db = new DatabaseIfc(true, mdv);
            //IfcGeometricRepresentationContext
            //IfcCartesianPoint
            //IfcAxis2Placement3D
            //IfcDirection
            //IfcAxis2Placement2D
            //IfcSIUnit
            //IfcLocalPlacement
            IfcSite site = new IfcSite(db, "TestSite");
            //IfcPerson  NOT RV
            //IfcOrganization  NOT RV
            //IfcPersonAndOrganization  NOT RV
            //IfcOwnerHistory  NOT RV
            //fcApplication NOT RV
            //                     IfcProjectLibrary NOT RV Can't have multiple context
            IfcProject project = new IfcProject(site, "TestProject", IfcUnitAssignment.Length.Millimetre)
            {
            };
            //IfcUnitAssignment
            //IfcRelAggregates
            IfcBuilding building = new IfcBuilding(site, "TestBuilding")
            {
            };
            IfcBuildingStorey buildingStorey = new IfcBuildingStorey(building, "TestBuildingStorey", 3000);
            IfcSpace          space          = new IfcSpace(buildingStorey, null, null)
            {
                Name = "TestSpace"
            };

            space.RelatingType = new IfcSpaceType(db, "TestSpaceType", IfcSpaceTypeEnum.INTERNAL);

            IfcZone zone = new IfcZone(buildingStorey, "TestZone", "TestZoneLongName", new List <IfcSpace>()
            {
                space
            });

            IfcLocalPlacement localPlacement = buildingStorey.Placement as IfcLocalPlacement;

            IfcMaterial material = new IfcMaterial(db, "TestMaterial")
            {
                Description = "TestDescription", Category = "TestCategory"
            };
            IfcMaterialProperties materialProperties = new IfcMaterialProperties("TestMaterialProperties", material);

            materialProperties.AddProperty(new IfcPropertySingleValue(db, "MassDensity", new IfcMassDensityMeasure(1)));
            IfcSurfaceStyleShading surfaceStyleShading = new IfcSurfaceStyleShading(new IfcColourRgb(db, 1, 0, 0)
            {
                Name = "Red"
            });
            IfcSurfaceStyle surfaceStyle = new IfcSurfaceStyle(surfaceStyleShading, null, null, null, null);
            IfcMaterialDefinitionRepresentation materialDefinitionRepresentation = new IfcMaterialDefinitionRepresentation(new IfcStyledRepresentation(new IfcStyledItem(surfaceStyle)
            {
                Name = "TestStyledItem"
            }), material);

            IfcIndexedPolyCurve          indexedPolyCurve          = IPE200Curve(db);
            IfcArbitraryClosedProfileDef arbitraryClosedProfileDef = new IfcArbitraryClosedProfileDef("IPE200", indexedPolyCurve);
            IfcMaterialProfile           materialProfile           = new IfcMaterialProfile("TestMaterialProfile", material, arbitraryClosedProfileDef);
            IfcMaterialProfileSet        materialProfileSet        = new IfcMaterialProfileSet("TestMaterialProfileSet", materialProfile);

            IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(arbitraryClosedProfileDef, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0), new IfcDirection(db, 1, 0, 0), new IfcDirection(db, 0, 1, 0)), new IfcDirection(db, 0, 0, 1), 5000);
            IfcBeamType          beamType          = new IfcBeamType(db, "TestBeamType", IfcBeamTypeEnum.BEAM);

            beamType.MaterialSelect = materialProfileSet;
            IfcBeam beam = new IfcBeam(buildingStorey, new IfcLocalPlacement(localPlacement, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 1000, 2000, 0))
            {
                RefDirection = new IfcDirection(db, 0, 1, 0)
            }), new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid)));

            //IfcGeometricRepresentationSubContext
            beam.RelatingType = beamType;
            //IfcRelDefinesByType

            //	if(mdv != ModelView.Ifc4Reference)
            //			IfcActorRole  NOT RV

            //IfcActuator
            //IfcActuatorType
            //IfcAdvancedBrep  NOT RV
            //IfcAdvancedFace   NOT RV
            //IfcAirTerminal
            //IfcAirTerminalBox
            //IfcAirTerminalBoxType
            //IfcAirTerminalType
            //IfcAirToAirHeatRecovery
            //IfcAirToAirHeatRecoveryType
            //IfcAlarm
            //IfcAlarmType
            //IfcArbitraryOpenProfileDef
            //IfcArbitraryProfileDefWithVoids
            //IfcAsymmetricIShapeProfileDef  NOT RV
            //IfcAudioVisualAppliance
            //IfcAudioVisualApplianceType
            //IfcAxis1Placement
            //IfcBeamStandardCase  NOT RV
            //IfcBlock   NOT RV
            //IfcBoiler
            //IfcBoilerType
            //IfcBooleanClippingResult  NOT RV
            //IfcBooleanResult  NOT RV
            //IfcBSplineCurveWithKnots  NOT RV
            //IfcBSplineSurface  NOT RV
            //IfcBSplineSurfaceWithKnots  NOT RV
            //IfcBuildingElementPart
            //IfcBuildingElementPartType
            //IfcBuildingElementProxy
            //IfcBuildingElementProxyType
            //IfcBuildingSystem
            //IfcBurner
            //IfcBurnerType
            //IfcCableCarrierFitting
            //IfcCableCarrierFittingType
            //IfcCableCarrierSegment
            //IfcCableCarrierSegmentType
            //IfcCableFitting
            //IfcCableFittingType
            //IfcCableSegment
            //IfcCableSegmentType
            //IfcCartesianPointList2D
            //IfcCartesianPointList3D
            //IfcCartesianTransformationOperator2D
            //IfcCartesianTransformationOperator2DnonUniform
            //IfcCartesianTransformationOperator3D
            //IfcCartesianTransformationOperator3DnonUniform
            //IfcCenterLineProfileDef
            //IfcChiller
            //IfcChillerType
            //IfcChimney
            //IfcChimneyType
            //IfcCircle
            //IfcCircleHollowProfileDef  NOT RV
            //IfcCircleProfileDef  NOT RV
            //IfcCivilElement
            //IfcCivilElementType
            //IfcClassification
            //IfcClassificationReference
            //IfcClosedShell
            //IfcCoil
            //IfcCoilType
            //IfcColourRgbList
            //IfcColourSpecification
            //IfcColumn
            //IfcColumnStandardCase  NOT RV
            //IfcColumnType
            //IfcCommunicationsAppliance
            //IfcCommunicationsApplianceType
            //IfcComplexProperty
            //IfcCompositeProfileDef  NOT RV
            //IfcCompressor
            //IfcCompressorType
            //IfcCondenser
            //IfcCondenserType
            //IfcConnectedFaceSet  NOT RV
            //IfcConnectionCurveGeometry  NOT RV
            //IfcConnectionVolumeGeometry  NOT RV
            //IfcController
            //IfcControllerType
            //IfcConversionBasedUnit
            //IfcConversionBasedUnitWithOffset
            //IfcCooledBeam
            //IfcCooledBeamType
            //IfcCoolingTower
            //IfcCoolingTowerType
            //IfcCovering
            //IfcCoveringType
            //IfcCsgSolid  NOT RV
            //IfcCShapeProfileDef  NOT RV
            //IfcCurtainWall
            //IfcCurtainWallType
            //IfcCurveStyle
            //IfcCurveStyleFont
            //IfcCurveStyleFontPattern
            //IfcDamper
            //IfcDamperType
            //IfcDerivedProfileDef  NOT RV
            //IfcDerivedUnit
            //IfcDerivedUnitElement
            //IfcDimensionalExponents
            //IfcDiscreteAccessory
            //IfcDiscreteAccessoryType
            //IfcDistributionChamberElement
            //IfcDistributionChamberElementType
            //IfcDistributionCircuit
            //IfcDistributionControlElement
            //IfcDistributionControlElementType
            //IfcDistributionElement
            //IfcDistributionElementType
            //IfcDistributionFlowElement
            //IfcDistributionFlowElementType
            //IfcDistributionPort
            //IfcDistributionSystem
            //IfcDocumentReference
            //IfcDoor
            //IfcDoorLiningProperties
            //IfcDoorPanelProperties
            //IfcDoorStandardCase  NOT RV
            //IfcDoorType
            //IfcDuctFitting
            //IfcDuctFittingType
            //IfcDuctSegment
            //IfcDuctSegmentType
            //IfcDuctSilencer
            //IfcDuctSilencerType
            //IfcEdge	 NOT RV
            //IfcEdgeCurve  NOT RV
            //IfcEdgeLoop  NOT RV
            //IfcElectricAppliance
            //IfcElectricApplianceType
            //IfcElectricDistributionBoard
            //IfcElectricDistributionBoardType
            //IfcElectricFlowStorageDevice
            //IfcElectricFlowStorageDeviceType
            //IfcElectricGenerator
            //IfcElectricGeneratorType
            //IfcElectricMotor
            //IfcElectricMotorType
            //IfcElectricTimeControl
            //IfcElectricTimeControlType
            //IfcElementAssembly
            //IfcElementAssemblyType
            //IfcElementComponent
            //IfcElementComponentType
            //IfcElementQuantity
            //IfcEllipseProfileDef  NOT RV
            //IfcEnergyConversionDevice
            //IfcEnergyConversionDeviceType
            //IfcEngine
            //IfcEngineType
            //IfcEvaporativeCooler
            //IfcEvaporativeCoolerType
            //IfcEvaporator
            //IfcEvaporatorType
            //IfcExtendedProperties
            //IfcExternalInformation
            //IfcExternalReference
            //IfcExtrudedAreaSolidTapered  NOT RV
            //IfcFace  NOT RV
            //IfcFaceBasedSurfaceModel  NOT RV
            //IfcFaceBound  NOT RV
            //IfcFaceOuterBound  NOT RV
            //IfcFaceSurface  NOT RV
            //IfcFacetedBrep  NOT RV
            //IfcFan
            //IfcFanType
            //IfcFastener
            //IfcFastenerType
            //IfcFeatureElement
            //IfcFeatureElementAddition  NOT RV
            //IfcFeatureElementSubtraction
            //IfcFillAreaStyle
            //IfcFillAreaStyleHatching
            //IfcFilter
            //IfcFilterType
            //IfcFireSuppressionTerminal
            //IfcFireSuppressionTerminalType
            //IfcFixedReferenceSweptAreaSolid  NOT RV
            //IfcFlowController
            //IfcFlowControllerType
            //IfcFlowFitting
            //IfcFlowFittingType
            //IfcFlowInstrument
            //IfcFlowInstrumentType
            //IfcFlowMeter
            //IfcFlowMeterType
            //IfcFlowMovingDevice
            //IfcFlowMovingDeviceType
            //IfcFlowSegment
            //IfcFlowSegmentType
            //IfcFlowStorageDevice
            //IfcFlowStorageDeviceType
            //IfcFlowTerminal
            //IfcFlowTerminalType
            //IfcFlowTreatmentDevice
            //IfcFlowTreatmentDeviceType
            //IfcFooting
            //IfcFootingType
            //IfcFurnishingElement
            //IfcFurnishingElementType
            //IfcFurniture
            //IfcFurnitureType
            //IfcGeographicElement
            //IfcGeographicElementType
            //IfcGeometricCurveSet
            //IfcGeometricSet
            //IfcGrid
            //IfcGridAxis
            //IfcGridPlacement  NOT RV
            //IfcGroup
            //IfcHalfSpaceSolid  NOT RV
            //IfcHeatExchanger
            //IfcHeatExchangerType
            //IfcHumidifier
            //IfcHumidifierType
            //IfcIndexedColourMap
            //IfcIndexedTextureMap
            //IfcIndexedTriangleTextureMap
            //IfcInterceptor
            //IfcInterceptorType
            //IfcIShapeProfileDef
            //IfcJunctionBox
            //IfcJunctionBoxType
            //IfcLamp
            //IfcLampType
            //IfcLibraryInformation  NOT RV
            //IfcLibraryReference  NOT RV
            //IfcLightFixture
            //IfcLightFixtureType
            //IfcLine
            //IfcLoop   NOT RV
            //IfcLShapeProfileDef  NOT RV
            //IfcMapConversion
            //IfcMappedItem
            //IfcMaterialConstituent
            //IfcMaterialConstituentSet
            //IfcMaterialLayer
            //IfcMaterialLayerSet
            //IfcMaterialLayerSetUsage  NOT RV
            //IfcMaterialLayerWithOffsets  NOT RV
            //IfcMaterialProfileSetUsage  NOT RV
            //IfcMaterialProfileSetUsageTapering  NOT RV
            //IfcMaterialProfileWithOffsets  NOT RV
            //IfcMaterialUsageDefinition  NOT RV
            //IfcMeasureWithUnit
            //IfcMechanicalFastener
            //IfcMechanicalFastenerType
            //IfcMedicalDevice
            //IfcMedicalDeviceType
            //IfcMember
            //IfcMemberStandardCase  NOT RV
            //IfcMemberType
            //IfcMonetaryUnit
            //IfcMotorConnection
            //IfcMotorConnectionType
            //IfcNamedUnit
            //IfcOpeningElement
            //IfcOpeningStandardCase  NOT RV
            //IfcOpenShell  NOT RV
            //IfcOrientedEdge  NOT RV
            //IfcOutlet
            //IfcOutletType
            //IfcPcurve  NOT RV
            //IfcPhysicalComplexQuantity
            //IfcPhysicalQuantity
            //IfcPhysicalSimpleQuantity
            //IfcPile
            //IfcPileType
            //IfcPipeFitting
            //IfcPipeFittingType
            //IfcPipeSegment
            //IfcPipeSegmentType
            //IfcPlane  NOT RV
            //IfcPlate
            //IfcPlateStandardCase  NOT RV
            //IfcPlateType
            //IfcPoint
            //IfcPolygonalBoundedHalfSpace  NOT RV
            //IfcPolyline  NOT RV
            //IfcPolyLoop  NOT RV
            //IfcPort
            //IfcPostalAddress
            //IfcPreDefinedPropertySet
            //IfcPresentationItem
            //IfcPresentationLayerAssignment
            //IfcPresentationStyle
            //IfcPresentationStyleAssignment
            //IfcProductDefinitionShape
            //IfcProductRepresentation
            //IfcProfileDef
            //IfcProfileProperties
            //IfcProjectedCRS
            //IfcProjectionElement  NOT RV
            //IfcProperty
            //IfcPropertyAbstraction
            //IfcPropertyBoundedValue
            //IfcPropertyDefinition
            //IfcPropertyEnumeratedValue
            //IfcPropertyEnumeration
            //IfcPropertyListValue
            //IfcPropertySet
            //IfcPropertySetTemplate  NOT RV
            //IfcPropertyTableValue
            //IfcPropertyTemplate  NOT RV
            //IfcPropertyTemplateDefinition  NOT RV
            //IfcProtectiveDevice
            //IfcProtectiveDeviceTrippingUnit
            //IfcProtectiveDeviceTrippingUnitType
            //IfcProtectiveDeviceType
            //IfcPump
            //IfcPumpType
            //IfcQuantityArea
            //IfcQuantityCount
            //IfcQuantityLength
            //IfcQuantitySet
            //IfcQuantityTime
            //IfcQuantityVolume
            //IfcQuantityWeight
            //IfcRailing
            //IfcRailingType
            //IfcRamp
            //IfcRampFlight
            //IfcRampFlightType
            //IfcRampType
            //IfcRectangleHollowProfileDef  NOT RV
            //IfcRectangleProfileDef  NOT RV
            //IfcRectangularPyramid  NOT RV
            //IfcReinforcingBar
            //IfcReinforcingBarType
            //IfcReinforcingElement
            //IfcReinforcingElementType
            //IfcReinforcingMesh
            //IfcReinforcingMeshType
            //IfcRelAssignsToGroup
            //IfcRelAssociatesClassification
            //IfcRelAssociatesDocument
            //IfcRelAssociatesLibrary  NOT RV
            //IfcRelAssociatesMaterial
            //IfcRelConnectsElements  NOT RV
            //IfcRelConnectsPathElements  NOT RV
            //IfcRelConnectsPorts
            //IfcRelConnectsWithRealizingElements  NOT RV
            //IfcRelContainedInSpatialStructure
            //IfcRelCoversBldgElements
            //IfcRelDeclares
            //IfcRelDefinesByProperties
            //IfcRelFillsElement
            //IfcRelFlowControlElements  NOT RV
            //IfcRelInterferesElements  NOT RV
            //IfcRelNests
            //IfcRelProjectsElement  NOT RV
            //IfcRelServicesBuildings
            //IfcRelVoidsElement
            //IfcRepresentation
            //IfcRepresentationContext
            //IfcRepresentationItem
            //IfcRepresentationMap
            //IfcRevolvedAreaSolid
            //IfcRevolvedAreaSolidTapered  NOT RV
            //IfcRightCircularCone  NOT RV
            //IfcRightCircularCylinder  NOT RV
            //IfcRoof
            //IfcRoofType
            //IfcRoundedRectangleProfileDef  NOT RV
            //IfcSanitaryTerminal
            //IfcSanitaryTerminalType
            //IfcSensor
            //IfcSensorType
            //IfcShadingDevice
            //IfcShadingDeviceType
            //IfcShapeRepresentation
            //IfcShellBasedSurfaceModel  NOT RV
            //IfcSimplePropertyTemplate  NOT RV
            //IfcSlab
            //IfcSlabElementedCase  NOT RV
            //IfcSlabStandardCase  NOT RV
            //IfcSlabType
            //IfcSolarDevice
            //IfcSolarDeviceType
            //IfcSpaceHeater
            //IfcSpaceHeaterType
            //IfcSpatialZone
            //IfcSpatialZoneType
            //IfcSphere  NOT RV
            //IfcStackTerminal
            //IfcStackTerminalType
            //IfcStair
            //IfcStairFlight
            //IfcStairFlightType
            //IfcStairType
            //IfcStyleModel
            //IfcSurface  NOT RV
            //IfcSurfaceCurveSweptAreaSolid  NOT RV
            //IfcSurfaceOfLinearExtrusion  NOT RV
            //IfcSurfaceOfRevolution  NOT RV
            //IfcSurfaceStyleRendering
            //IfcSurfaceStyleWithTextures surfaceStyleWithTextures = new IfcSurfaceStyleWithTextures(new IfcImageTexture(db,true,true,""));
            //IfcSweptDiskSolid
            //IfcSwitchingDevice
            //IfcSwitchingDeviceType
            //IfcSystemFurnitureElement
            //IfcSystemFurnitureElementType
            //IfcTank
            //IfcTankType
            //IfcTelecomAddress  NOT RV
            //IfcTendon
            //IfcTendonAnchor
            //IfcTendonAnchorType
            //IfcTendonType
            //IfcTessellatedFaceSet
            //IfcTessellatedItem
            //IfcTextureCoordinate
            //IfcTextureVertexList
            //IfcTransformer
            //IfcTransformerType
            //IfcTransportElement
            //IfcTransportElementType
            //IfcTriangulatedFaceSet
            //IfcTrimmedCurve
            //IfcTShapeProfileDef  NOT RV
            //IfcTubeBundle
            //IfcTubeBundleType
            //IfcUnitaryControlElement
            //IfcUnitaryControlElementType
            //IfcUnitaryEquipment
            //IfcUnitaryEquipmentType
            //IfcUShapeProfileDef  NOT RV
            //IfcValve
            //IfcValveType
            //IfcVector
            //IfcVertex  NOT RV
            //IfcVertexPoint  NOT RV
            //IfcVibrationIsolator
            //IfcVibrationIsolatorType
            //IfcVirtualGridIntersection  NOT RV
            //IfcWall
            //IfcWallElementedCase  NOT RV
            //IfcWallStandardCase  NOT RV
            //IfcWallType
            //IfcWasteTerminal
            //IfcWasteTerminalType
            //IfcWindow
            //IfcWindowLiningProperties
            //IfcWindowPanelProperties
            //IfcWindowStandardCase  NOT RV
            //IfcWindowType
            //IfcZShapeProfileDef  NOT RV
            db.WriteFile(Path.Combine(path, mdv.ToString() + ".ifc"));
            return(db);
        }
예제 #32
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);
        }
예제 #33
0
        internal static void GenerateInstance(IfcBuilding building, bool openings)
        {
            DatabaseIfc db       = building.Database;
            IfcMaterial concrete = new IfcMaterial(db, "Concrete")
            {
                Category = "Concrete"
            };
            int thickness = 200;
            IfcMaterialLayer    materialLayer    = new IfcMaterialLayer(concrete, thickness, "Core");
            string              name             = thickness + "mm Concrete";
            IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(materialLayer, name);

            db.NextObjectRecord = 300;
            IfcSlabType slabType = new IfcSlabType(name, materialLayerSet, IfcSlabTypeEnum.FLOOR);

            db.Context.AddDeclared(slabType);
            List <Coord2d> points = new List <Coord2d>()
            {
                new Coord2d(0, 0), new Coord2d(1000, 0), new Coord2d(1400, 2000), new Coord2d(1000, 4000), new Coord2d(0, 4000), new Coord2d(-400, 2000)
            };

            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 IfcArcIndex(5, 6, 1));
            IfcBoundedCurve          boundedCurve  = IfcBoundedCurve.Generate(db, points, segments);
            IfcMaterialLayerSetUsage layerSetUsage = new IfcMaterialLayerSetUsage(materialLayerSet, IfcLayerSetDirectionEnum.AXIS3, IfcDirectionSenseEnum.NEGATIVE, 0);
            IfcSlab slabStandardCase = new IfcSlabStandardCase(building, layerSetUsage, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), new IfcArbitraryClosedProfileDef("Slab Perimeter", boundedCurve))
            {
                RelatingType = slabType
            };

            slabStandardCase.RelatingType = slabType;
            if (openings)
            {
                IfcCircleProfileDef    cpd     = new IfcCircleProfileDef(db, "100DIA", 50);
                IfcExtrudedAreaSolid   eas     = new IfcExtrudedAreaSolid(cpd, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 100, 300, -200)), new IfcDirection(db, 0, 0, 1), thickness);
                IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, null, eas)
                {
                    Name = "Opening"
                };
                IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(db, "RecessRectangle", 500, 1000);
                eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 500, 1000, -50)), new IfcDirection(db, 0, 0, 1), 50);
                IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, null, new IfcProductDefinitionShape(new IfcShapeRepresentation(eas)))
                {
                    Name = "Recess", PredefinedType = IfcOpeningElementTypeEnum.RECESS
                };

                //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
                opening.GlobalId = "15RSTHd8nFVQWMRE7og7sd";
                opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO";
                recess.GlobalId = "0w93HZ19H2D99zbAVNb4o2";
                recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM";
            }

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            slabType.GlobalId                    = "0RSW$KKbzCZ9QaSm3GoEan";
            slabStandardCase.GlobalId            = "1wAj$J2Az2V8wnBiVYd3bU";
            materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq";
            slabType.ObjectTypeOf.GlobalId       = "3wwDcmW5T3HfafURQewdD0";
            slabStandardCase.MaterialSelect.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w";
        }
예제 #34
0
        static void Main(string[] args)
        {
            DatabaseIfc db = new DatabaseIfc(ReleaseVersion.IFC4X3_RC2);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            IfcCompositeCurve alignmentCurve = new IfcCompositeCurve(compositeSegments);

            alignment.Axis = alignmentCurve;

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

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

            IfcAlignmentSegment alignmentSegment = new IfcAlignmentSegment(alignmentHorizontal, transitionSegment);

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

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

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

            IfcAlignmentVertical alignmentVertical = new IfcAlignmentVertical(alignment, verticalSegment);

            alignmentVertical.GlobalId = "2YR0TUxTv75RC2XxZVmlj8";

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

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

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

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

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

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

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

            db.WriteFile(args[0]);
        }
예제 #35
0
        internal static List <IfcProduct> ToIfcProducts(this Element e,
                                                        IfcRepresentationContext context,
                                                        Document doc,
                                                        Dictionary <Guid, List <IfcStyleAssignmentSelect> > styleAssignments)
        {
            var products = new List <IfcProduct>();

            IfcProductDefinitionShape shape      = null;
            GeometricElement          geoElement = null;
            Transform trans = null;
            Guid      id    = default(Guid);

            if (e is ElementInstance)
            {
                // If we're using an element instance, get the transform
                // and the id and use those to uniquely position and
                // identify the element.
                var instance = (ElementInstance)e;
                geoElement = instance.BaseDefinition;
                id         = instance.Id;
                trans      = instance.Transform;
            }
            else if (e is GeometricElement)
            {
                // If we've go a geometric element, use its properties as-is.
                geoElement = (GeometricElement)e;
                id         = geoElement.Id;
                trans      = geoElement.Transform;
            }

            geoElement.UpdateRepresentations();

            var localPlacement = trans.ToIfcLocalPlacement(doc);

            doc.AddEntity(localPlacement);

            var geoms = new List <IfcRepresentationItem>();

            if (geoElement is MeshElement)
            {
                var meshEl  = (MeshElement)geoElement;
                var lengths = meshEl.Mesh.Vertices.Select(v => v.Position.ToArray().Select(vi => new IfcLengthMeasure(vi)).ToList()).ToList();
                var pts     = new IfcCartesianPointList3D(lengths);
                doc.AddEntity(pts);
                var indices = meshEl.Mesh.Triangles.Select(t => t.Vertices.Select(vx => new IfcPositiveInteger(vx.Index + 1)).ToList()).ToList();
                var idxs    = new List <List <IfcPositiveInteger> >(indices);
                var geom    = new IfcTriangulatedFaceSet(pts, indices);
                geom.Closed = false;
                doc.AddEntity(geom);
                geoms.Add(geom);
                shape = ToIfcProductDefinitionShape(geoms, "Tessellation", context, doc);
            }
            else
            {
                foreach (var op in geoElement.Representation.SolidOperations)
                {
                    if (op is Sweep)
                    {
                        var sweep = (Sweep)op;

                        // Neither of these entities, which are part of the
                        // IFC4 specification, and which would allow a sweep
                        // along a curve, are supported by many applications
                        // which are supposedly IFC4 compliant (Revit). For
                        // Those applications where these entities appear,
                        // the rotation of the profile is often wrong or
                        // inconsistent.
                        // geom = sweep.ToIfcSurfaceCurveSweptAreaSolid(doc);
                        // geom = sweep.ToIfcFixedReferenceSweptAreaSolid(geoElement.Transform, doc);

                        // Instead, we'll divide the curve and create a set of
                        // linear extrusions instead.
                        Polyline pline;
                        if (sweep.Curve is Line)
                        {
                            pline = sweep.Curve.ToPolyline(1);
                        }
                        else
                        {
                            pline = sweep.Curve.ToPolyline();
                        }
                        foreach (var segment in pline.Segments())
                        {
                            var position         = segment.TransformAt(0.0).ToIfcAxis2Placement3D(doc);
                            var extrudeDepth     = segment.Length();
                            var extrudeProfile   = sweep.Profile.Perimeter.ToIfcArbitraryClosedProfileDef(doc);
                            var extrudeDirection = Vector3.ZAxis.Negate().ToIfcDirection();
                            var geom             = new IfcExtrudedAreaSolid(extrudeProfile, position,
                                                                            extrudeDirection, new IfcPositiveLengthMeasure(extrudeDepth));

                            doc.AddEntity(extrudeProfile);
                            doc.AddEntity(extrudeDirection);
                            doc.AddEntity(position);
                            doc.AddEntity(geom);
                            geoms.Add(geom);
                        }
                    }
                    else if (op is Extrude)
                    {
                        var extrude = (Extrude)op;
                        var geom    = extrude.ToIfcExtrudedAreaSolid(doc);
                        doc.AddEntity(geom);
                        geoms.Add(geom);
                    }
                    else if (op is Lamina)
                    {
                        var lamina = (Lamina)op;
                        var geom   = lamina.ToIfcShellBasedSurfaceModel(doc);
                        doc.AddEntity(geom);
                        geoms.Add(geom);
                    }
                    else
                    {
                        throw new Exception("Only IExtrude, ISweepAlongCurve, and ILamina representations are currently supported.");
                    }
                }
                shape = ToIfcProductDefinitionShape(geoms, "SolidModel", context, doc);
            }
            doc.AddEntity(shape);


            // Can we use IfcMappedItem?
            // https://forums.buildingsmart.org/t/can-tessellation-typed-representation-hold-items-from-another-group/1621
            // var rep = new IfcShapeRepresentation(context, "Body", "Solids", geoms);
            // doc.AddEntity(rep);
            // var axisPt = Vector3.Origin.ToIfcCartesianPoint();
            // doc.AddEntity(axisPt);
            // var axis = new IfcAxis2Placement2D(axisPt);
            // doc.AddEntity(axis);
            // var repMap = new IfcRepresentationMap(new IfcAxis2Placement(axis), rep);
            // doc.AddEntity(repMap);
            // var x = trans.XAxis.ToIfcDirection();
            // var y = trans.YAxis.ToIfcDirection();
            // var z = trans.ZAxis.ToIfcDirection();
            // var origin = trans.Origin.ToIfcCartesianPoint();
            // var cart = new IfcCartesianTransformationOperator3D(x, y, origin, trans.XAxis.Length(), z);
            // doc.AddEntity(x);
            // doc.AddEntity(y);
            // doc.AddEntity(z);
            // doc.AddEntity(origin);
            // doc.AddEntity(cart);
            // var mappedItem = new IfcMappedItem(repMap, cart);
            // doc.AddEntity(mappedItem);
            // var shapeRep= new IfcShapeRepresentation(context, new List<IfcRepresentationItem>(){mappedItem});
            // doc.AddEntity(shapeRep);
            // shape = new IfcProductDefinitionShape(new List<IfcRepresentation>(){shapeRep});
            // doc.AddEntity(shape);

            var product = ConvertElementToIfcProduct(id, geoElement, localPlacement, shape);

            products.Add(product);
            doc.AddEntity(product);

            var ifcOpenings = doc.AllEntities.Where(ent => ent.GetType() == typeof(IfcOpeningElement)).Cast <IfcOpeningElement>();

            // If the element has openings, make opening relationships in
            // the IfcElement.
            if (e is IHasOpenings)
            {
                var openings = (IHasOpenings)e;
                if (openings.Openings.Count > 0)
                {
                    foreach (var o in openings.Openings)
                    {
                        var element = (IfcElement)product;
                        // TODO: Find the opening that we've already created that relates here
                        var opening = ifcOpenings.First(ifcO => ifcO.GlobalId == IfcGuid.ToIfcGuid(o.Id));
                        var voidRel = new IfcRelVoidsElement(IfcGuid.ToIfcGuid(Guid.NewGuid()), element, opening);
                        element.HasOpenings.Add(voidRel);
                        doc.AddEntity(voidRel);
                    }
                }
            }

            foreach (var geom in geoms)
            {
                var styledItem = new IfcStyledItem(geom, styleAssignments[geoElement.Material.Id], null);
                doc.AddEntity(styledItem);
            }

            return(products);
        }