Exemple #1
0
        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";
            }
        }
Exemple #2
0
		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";
			}
		}
Exemple #3
0
        internal static IfcCircleProfileDef CircleProfileCreate(IfcStore model, double radius)
        {
            IfcCircleProfileDef cirProf = model.Instances.New <IfcCircleProfileDef>();

            cirProf.ProfileType = IfcProfileTypeEnum.AREA;
            cirProf.Radius      = radius;

            return(cirProf);
        }
        /// <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 IfcCircleProfileDef a, IfcProfileDef b)
        {
            IfcCircleProfileDef p = b as IfcCircleProfileDef;

            if (p == null)
            {
                return(false);           //different types are not the same
            }
            return(a.Radius == p.Radius && a.Position.GeometricEquals(p.Position));
        }
 BbBbNamedCircleProfile(double radius)
 {
     this.radius = radius;
     ifcCircleProfileDef = new IfcCircleProfileDef
     {
         ProfileType = IfcProfileTypeEnum.AREA,
         //ProfileName = Name,
         Position = BbHeaderSetting.Setting3D.Position2D.IfcAxis2Placement2D,
         Radius = radius,
     };
 }
Exemple #6
0
 BbBbNamedCircleProfile(double radius)
 {
     this.radius         = radius;
     ifcCircleProfileDef = new IfcCircleProfileDef
     {
         ProfileType = IfcProfileTypeEnum.AREA,
         //ProfileName = Name,
         Position = BbHeaderSetting.Setting3D.Position2D.IfcAxis2Placement2D,
         Radius   = radius,
     };
 }
Exemple #7
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";
        }
        static void Main(string[] args)
        {
            //Sample Data https://www.tmr.qld.gov.au/-/media/busind/techstdpubs/Geotechnical/Geotech-Borehole-Logging/Geotechnical-Borehole-Logging.pdf?la=en
            //http://creativecommons.org/licenses/by/3.0/au/
            // © State of Queensland(Department of Transport and Main Roads) 2016

            // Suggested enhancements to test :
            //		Nominate Status and Reference Number
            //		Add Geolocation
            //		Use linear placement for statum layers
            //		Capture Auger, Casing, Wash Boring and Core drilling extents
            //		Add stratum data Impact Strength, Defect Spacing, Additional Data and Test Results, Sample Tests

            DatabaseIfc db = new DatabaseIfc(ReleaseVersion.IFC4X3);

            db.Factory.Options.AngleUnitsInRadians = false;

            IfcSite    site    = new IfcSite(db, "Coombabah Creek Abutment");
            IfcProject project = new IfcProject(site, "FG6280", IfcUnitAssignment.Length.Metre)
            {
                LongName = "Gold Coast Light Rail(GCLR) Stage 2"
            };

            project.Description = "http://creativecommons.org/licenses/by/3.0/au/ © State of Queensland(Department of Transport and Main Roads) 2016";

            IfcAxis2Placement3D placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0.99));
            IfcLocalPlacement   boreHolePlacement = new IfcLocalPlacement(site.ObjectPlacement, placement);
            IfcBorehole         borehole          = new IfcBorehole(site, boreHolePlacement, null);

            borehole.Name        = "BH-CC-01";
            borehole.Description = "Sample borehole data published at  https://www.tmr.qld.gov.au/-/media/busind/techstdpubs/Geotechnical/Geotech-Borehole-Logging/Geotechnical-Borehole-Logging.pdf?la=en";

            Pset_BoreholeCommon pset_BoreholeCommon = new Pset_BoreholeCommon(borehole);

            pset_BoreholeCommon.GroundwaterDepth = -5;             //Not identified in borehole log
            //new Pset_Uncertainty(borehole) { Basis = PEnum_UncertaintyBasis.MEASUREMENT };
            Pset_GeotechnicalAssemblyCommon psetGeotechnicalAssemblyCommon = new Pset_GeotechnicalAssemblyCommon(borehole);

            psetGeotechnicalAssemblyCommon.Purpose = PEnum_StrataAssemblyPurpose.GEOLOGICAL;

            //Should some of these properties be standard?
            //Should actors such as drilling company be IfcActor etc

            List <IfcProperty> tmrBoreholeProperties = new List <IfcProperty>();

            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Driller", new IfcIdentifier("North Coast Drilling")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "LoggedBy", new IfcIdentifier("D.Colborne/J.Armstrong")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "ReviewedBy", new IfcIdentifier("S.Foley")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Plunge", new IfcPlaneAngleMeasure(90)));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Date Started", new IfcDate(new DateTime(2015, 09, 10))));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Date Completed", new IfcDate(new DateTime(2015, 09, 11))));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Reference No", new IfcIdentifier("H12327")));
            tmrBoreholeProperties.Add(new IfcPropertySingleValue(db, "Job No", new IfcIdentifier("498/04375")));
            new IfcPropertySet(borehole, "TMR_Borehole", tmrBoreholeProperties);

            IfcCircleProfileDef boreProfile = new IfcCircleProfileDef(db, "BoreHole", 0.05);

            IfcMaterial siltyClayTopsoil = new IfcMaterial(db, "Silty Clay (TopSoil)");

            siltyClayTopsoil.Description = "Dark grey, moist.";

            placement = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -0.1));
            IfcLocalPlacement         localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            IfcExtrudedAreaSolid      extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 0.1);
            IfcProductDefinitionShape shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));

            //gg Toolkit uses nesting rather than aggregating for stratums
            IfcSolidStratum solidStratum = new IfcSolidStratum(borehole, localPlacement, shape);

            solidStratum.SetMaterial(siltyClayTopsoil);

            IfcClassification soilClassification = new IfcClassification(db, "Soil Descriptions");

            soilClassification.Description = "Description and Classification of Soils for Geotechnical Purposes: Refer to AS1726 - 1993(Appendix A).";

            IfcMaterial siltyClayEstuarine = new IfcMaterial(db, "Silty CLAY (Estuarine)");

            siltyClayEstuarine.Description = "Dark grey, moist, soft.";
            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -1.2));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 1.1);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(siltyClayEstuarine);
            IfcClassificationReference soilClassificationCI = new IfcClassificationReference(soilClassification)
            {
                Identification = "CI",
                Description    = "Inorganic clays of low to medium plasticity, gravelly clays, sandy clays, silty clays, lean clays"
            };

            soilClassificationCI.Associate(solidStratum);
#warning Should soil classification be assigned to soil or to stratum?

            IfcMaterial clayeySANDEstuarine = new IfcMaterial(db, "Clayey SAND (Estuarine)");
            clayeySANDEstuarine.Description = "Dark grey, wet, very loose.";
            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -6.4));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 5.2);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(clayeySANDEstuarine);
            solidStratum.Description = "Fine to medium grained. Shell fragments throughout.";

            IfcClassificationReference soilClassificationSC = new IfcClassificationReference(soilClassification)
            {
                Identification = "SC",
                Description    = "Clayey sands, sandclay mixtures"
            };
            soilClassificationSC.Associate(solidStratum);

            IfcMaterial METAGREYWACKEdcf = new IfcMaterial(db, "METAGREYWACKE (DCf)");

            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -6.8));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 0.4);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(METAGREYWACKEdcf);
            solidStratum.Description = "XW: Recovered as orange brown to grey, moist, very stiff, Silty CLAY.";

            IfcClassification rockClassification = new IfcClassification(db, "Rock Descriptions");
            rockClassification.Description = "Refer to AS1726-1993 (Appendix A3.3) for the description and classification of rock material composition";


            IfcClassificationReference rockClassificationXW = new IfcClassificationReference(rockClassification)
            {
                Identification = "XW",
                Description    = "Rock is weathered to such an extent that it has 'soil' properties, i.e. it either disintegrates or can be remoulded in water, but substance fabric and rock structure still recognisable."
            };
            rockClassificationXW.Associate(solidStratum);

            placement         = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, -12.7));
            localPlacement    = new IfcLocalPlacement(boreHolePlacement, placement);
            extrudedAreaSolid = new IfcExtrudedAreaSolid(boreProfile, 5.9);
            shape             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            solidStratum      = new IfcSolidStratum(borehole, localPlacement, shape);
            solidStratum.SetMaterial(METAGREYWACKEdcf);
            solidStratum.Description = "SW: Dark grey, fine to medium grained, indistinctly foliated, high to very high strength.";
            IfcClassificationReference rockClassificationSW = new IfcClassificationReference(rockClassification)
            {
                Identification = "SW",
                Description    = "Rock is slightly discoloured but shows little or no change of strength from fresh rock."
            };
            rockClassificationSW.Associate(solidStratum);


            System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
            saveFileDialog.Filter = "IFC BIM Data (*.ifc,*.ifcxml,*.ifcjson,*.ifczip)|*.ifc;*.ifcxml;*.ifcjson;*.ifczip";;
            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                db.WriteFile(saveFileDialog.FileName);
            }
        }
        /// <summary>
        /// returns a Hash for the geometric behaviour of this object
        /// </summary>
        /// <param name="solid"></param>
        /// <returns></returns>
        public static int GetGeometryHashCode(this IfcCircleProfileDef profile)
        {
            var model = profile.ModelOf;

            return(model.ModelFactors.GetGeometryDoubleHash(profile.Radius) ^ profile.Position.GetGeometryHashCode());
        }
        internal static DatabaseIfc Generate(ModelView mvd, string path)
        {
            DatabaseIfc db = new DatabaseIfc(true, mvd);
            //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", 200);
            IfcSpace          space          = new IfcSpace(buildingStorey, null)
            {
                Name = "TestSpace"
            };

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

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

            IfcLocalPlacement storeyLocalPlacement = buildingStorey.ObjectPlacement 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);

            IfcBeamType beamType = new IfcBeamType(db, "TestBeamType", IfcBeamTypeEnum.BEAM);

            beamType.MaterialSelect = materialProfileSet;

            int beamXPosition = 1000, beamYposition = 0, beamXSpacing = 1000;
            int columnXPosition = -1000, columnYposition = 0, columnYSpacing = 1000;
            IfcCartesianPoint cartesianPoint = new IfcCartesianPoint(db, beamXPosition += beamXSpacing, beamYposition, 0);
            IfcBeam           beam           = createBeam(buildingStorey, arbitraryClosedProfileDef, cartesianPoint, "16KYUrH45BNwdHw8Y$ia8f");

            beam.setRelatingType(beamType);
            //IfcRelDefinesByType

            IfcProfileDef columnProfile = arbitraryClosedProfileDef;

            if (mvd != ModelView.Ifc4Reference)
            {
                columnProfile = new IfcIShapeProfileDef(db, "IShapeProfileDef", 500, 300, 15, 20)
                {
                    FilletRadius = 10
                }
            }
            ;

            IfcColumnType columnType = new IfcColumnType(db, "TestColumnType", IfcColumnTypeEnum.COLUMN);

            cartesianPoint = new IfcCartesianPoint(db, columnXPosition, columnYposition += columnYSpacing, 0);
            //IfcGeometricRepresentationSubContext
            IfcColumn column = createColumn(buildingStorey, columnProfile, cartesianPoint, "2jS8dBukzApveBm5m9QrBf");

            column.setRelatingType(columnType);

            if (mvd != ModelView.Ifc4Reference)
            {
                IfcCircleProfileDef circleProfileDef = circleProfileDef = new IfcCircleProfileDef(db, "TestCircleProfile", 350);
                cartesianPoint = new IfcCartesianPoint(db, columnXPosition, columnYposition += columnYSpacing, 0);
                createColumn(buildingStorey, circleProfileDef, cartesianPoint, "");

                IfcRectangleProfileDef rectangleProfileDef = new IfcRectangleProfileDef(db, "TestRectangle", 400, 600);
                cartesianPoint = new IfcCartesianPoint(db, beamXPosition += beamXSpacing, beamYposition, 0);
                createBeam(buildingStorey, rectangleProfileDef, cartesianPoint, "");

                IfcRectangleHollowProfileDef rectangleHollowProfileDef = new IfcRectangleHollowProfileDef(db, "TestRectangleHollow", 400, 600, 12);
                cartesianPoint = new IfcCartesianPoint(db, beamXPosition += beamXSpacing, beamYposition, 0);
                createBeam(buildingStorey, rectangleHollowProfileDef, cartesianPoint, "");
            }

            IfcProfileDef memberProfile = arbitraryClosedProfileDef;

            if (mvd != ModelView.Ifc4Reference)
            {
                memberProfile = new IfcCircleHollowProfileDef(db, "TestCircleHollowProfile", 75, 9);
            }
            cartesianPoint = new IfcCartesianPoint(db, -1000, -1000, 0);
            IfcProductDefinitionShape productDefinitionShape = new IfcProductDefinitionShape(new IfcShapeRepresentation(new IfcExtrudedAreaSolid(memberProfile, 2000)));
            IfcMember member = new IfcMember(buildingStorey, createLocalPlacement(buildingStorey, cartesianPoint, db.Factory.YAxisNegative), productDefinitionShape);

            //	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
            //IfcCivilElement
            //IfcCivilElementType
            //IfcClassification
            //IfcClassificationReference
            //IfcClosedShell
            //IfcCoil
            //IfcCoilType
            //IfcColourRgbList
            //IfcColourSpecification
            //IfcColumnStandardCase  NOT RV
            //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
            //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
            //IfcMemberStandardCase  NOT RV
            //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
            //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, mvd.ToString() + ".ifc"));
            return(db);
        }
        /// <summary>
        /// You can give the name of the TestCase -> to build only them
        /// </summary>
        /// <param name="args">Testcases to expoert</param>
        /// <help> Testcases: Spatial_simple\n
        /// Railway_spatial\n Spatial_01\nPlacement_Local"\nGeomRepresentation_01\n
        /// \nGeomRepresentation_02\nGeomRepresentation_03\nGeomRepresentation_04
        /// \nLocalPlacement_01\nLinearPlacement_02
        ///
        /// </help>
        static void Main(string[] args)
        {
            //Var declaration

            string folder       = "Unittest";
            var    testcasename = new List <string>();

            testcasename.Add("Spatial_simple");
            testcasename.Add("Railway_spatial");
            testcasename.Add("Spatial_01");
            testcasename.Add("Placement_Local");
            testcasename.Add("GeomRepresentation_01");
            testcasename.Add("GeomRepresentation_02");
            testcasename.Add("GeomRepresentation_03");
            testcasename.Add("GeomRepresentation_04");
            //testcasename.Add("GeomRepresentation_05");
            testcasename.Add("LocalPlacement_01");
            testcasename.Add("LinearPlacement_02");
            System.IO.Directory.CreateDirectory(".\\" + folder);


            //Help handling + single selection
            if (args.Length != 0)
            {
                //Help handling
                if (args.First().Equals("-?"))
                {
                    foreach (var i in testcasename)
                    {
                        Console.WriteLine(i);
                    }
                    return;
                }

                //Select only selected ones
                testcasename = new List <string>();
                foreach (var i in args)
                {
                    testcasename.Add(i);
                }
            }


            foreach (var proname in testcasename)
            {
                var db = new DatabaseIfc(ModelView.Ifc4NotAssigned);
                db.Factory.Options.GenerateOwnerHistory = false;

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

                new IfcRelAggregates(project, new List <IfcObjectDefinition>()
                {
                    site
                })
                {
                    Guid = new Guid("5e1fd0e5-b005-fe11-501e-5caff01dc1ad")
                };
                //Some placements
                IfcAxis2Placement3D placement1       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 2, 5, 1));
                IfcLocalPlacement   objectPlacement1 = new IfcLocalPlacement(site.ObjectPlacement, placement1);
                IfcAxis2Placement3D placement2       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 10, 5, 1));
                IfcLocalPlacement   objectPlacement2 = new IfcLocalPlacement(site.ObjectPlacement, placement2);
                IfcAxis2Placement3D placement3       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 15, 3, 6));
                IfcLocalPlacement   objectPlacement3 = new IfcLocalPlacement(site.ObjectPlacement, placement3);
                IfcAxis2Placement3D placement4       = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 5, 8, 3));
                IfcLocalPlacement   objectPlacement4 = new IfcLocalPlacement(site.ObjectPlacement, placement4);
                IfcAxis2Placement3D originaxis2place = new IfcAxis2Placement3D(db.Factory.Origin);
                IfcLocalPlacement   origionobjplace  = new IfcLocalPlacement(site.ObjectPlacement, originaxis2place);


                //Select the Testcases and fill them into the container
                switch (proname)
                {
                case "Spatial_simple":
                    //initial File
                    IfcBuilding building1 = new IfcBuilding(db, "building1")
                    {
                        Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3b44115bb42")
                    };
                    building1.ObjectPlacement = objectPlacement1;


                    IfcBuilding building2 = new IfcBuilding(db, "building2")
                    {
                        Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3b441151337")
                    };
                    building2.ObjectPlacement = objectPlacement2;

                    //Write inital File
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //continue with the updated version


                    IfcBuilding building3 = new IfcBuilding(db, "building3")
                    {
                        Guid            = new Guid("fbc7f4b2-177d-4875-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement3
                    };
                    break;

                case "Railway_spatial":
                    //initial
                    IfcSpatialZone spazone1 = new IfcSpatialZone(db, "Spatialzone1")
                    {
                        Guid            = new Guid("42c7f4b2-177d-4875-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement1
                    };

                    IfcSpatialZone spazone2 = new IfcSpatialZone(db, "Spatialzone2")
                    {
                        Guid            = new Guid("42c7f4b2-1337-4875-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement2
                    };
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    IfcSpatialZone spazone3 = new IfcSpatialZone(db, "Spatialzone3")
                    {
                        Guid            = new Guid("42c7f4b2-1337-4422-88bb-d3b441153531"),
                        ObjectPlacement = objectPlacement3
                    };
                    IfcSpatialZone spazone4 = new IfcSpatialZone(db, "Spatialzone4")
                    {
                        Guid            = new Guid("42c7f4b2-1337-4875-4242-d3b441153531"),
                        ObjectPlacement = objectPlacement4
                    };

                    break;

                case "Spatial_01":
                    //creating building and add parts to it
                    building1 = new IfcBuilding(db, "building1")
                    {
                        Guid            = new Guid("fbc7f4b2-177d-4875-88bb-d3b44115bb42"),
                        ObjectPlacement = objectPlacement1
                    };

                    IfcBuildingStorey buildingsto1 = new IfcBuildingStorey(building1, "Level1", 0)
                    {
                        Guid            = new Guid("42c74222-1337-4875-4242-d3b441153531"),
                        ObjectPlacement = objectPlacement2
                    };

                    building1.IsDecomposedBy.First().Guid = new Guid("42abcd22-1337-4875-4242-abcd41153531");

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

                    IfcWall wall = new IfcWall(buildingsto1, objectPlacement3, shape1)
                    {
                        Guid = new Guid("42aa4222-1337-aaaa-4242-d3aa41153531"),
                        Name = "Wall1"
                    };
                    wall.ContainedInStructure.Guid = new Guid("42c74222-1337-4875-4242-d3b44abcd531");


                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //update
                    IfcBuildingStorey buildingsto2 = new IfcBuildingStorey(building1, "Level2", 0)
                    {
                        Guid            = new Guid("42c74222-1337-4875-4242-bbbb41153531"),
                        ObjectPlacement = objectPlacement4
                    };
                    // Reassign Wall to Storey2
                    wall.ContainedInStructure.RelatingStructure = buildingsto2;

                    break;

                case "Placement_Local":
                    //Initial set
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    //Wall at origin
                    IfcWall wall2 = new IfcWall(site, origionobjplace, shape1)
                    {
                        Guid = new Guid("42aa4222-1337-aaaa-4242-d3aa41153531"),
                        Name = "Wall1"
                    };
                    wall2.ContainedInStructure.Guid = new Guid("42cab222-1337-4875-4242-d3b44abcd531");

                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    IfcAxis2Placement3D wallaxisplace = new IfcAxis2Placement3D(new IfcCartesianPoint(db, 2, 3, 0));
                    wall2.ObjectPlacement = new IfcLocalPlacement(site.ObjectPlacement, wallaxisplace);


                    break;

                case "GeomRepresentation_01":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    IfcRectangleProfileDef    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    IfcExtrudedAreaSolid      extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    IfcProductDefinitionShape shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));


                    var proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbc7f4b2-177d-4875-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3b44abcd531");

                    var proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f8e196cb-c7d9-4d53-9885-0f687706abcd")
                    };
                    proxy2.ContainedInStructure.Guid = new Guid("42cab222-1337-4875-4242-00004abcd531");


                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");
                    //Update


                    proxy2.Representation = shape1;
                    shape2.Dispose(true);     //Remove orphaned entries


                    break;

                case "GeomRepresentation_02":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbcba4b2-1c7d-4875-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3b00abcd531");
                    proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f821963b-c7d9-4d53-9885-0f87cd6abcda")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3414abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    extrudedAreaSolid2.Depth = 3;
                    break;

                case "GeomRepresentation_03":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid_extrudedArea",
                        Guid = new Guid("fbcba4b2-1c7d-0000-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("00011222-1337-4875-4242-d1114abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update
                    profile1.Dispose(false);     // Remove profile
                    var profile3 = new IfcCircleProfileDef(db, "CylinderProfileDef", 4);
                    extrudedAreaSolid1.SweptArea = profile3;
                    proxy1.Name = "Cylinder_extrudedArea";



                    break;

                case "GeomRepresentation_04":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid_extrudedArea",
                        Guid = new Guid("fbcba4b2-1c7d-0000-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("00011222-1337-4875-4242-d1114abcd531");

                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update

                    var points = new List <IfcCartesianPoint>();
                    points.Add(new IfcCartesianPoint(db, -2, -3, 0));
                    points.Add(new IfcCartesianPoint(db, -2, 3, 0));
                    points.Add(new IfcCartesianPoint(db, 2, 3, 0));
                    points.Add(new IfcCartesianPoint(db, 2, -3, 0));
                    points.Add(new IfcCartesianPoint(db, -2, -3, 1.35));
                    points.Add(new IfcCartesianPoint(db, -2, 3, 1.35));
                    points.Add(new IfcCartesianPoint(db, 2, 3, 1.35));
                    points.Add(new IfcCartesianPoint(db, 2, -3, 1.35));

                    var polyloop = new List <IfcPolyLoop>();
                    polyloop.Add(new IfcPolyLoop(points[0], points[1], points[2], points[3]));
                    polyloop.Add(new IfcPolyLoop(points[0], points[4], points[5], points[1]));
                    polyloop.Add(new IfcPolyLoop(points[0], points[4], points[7], points[3]));
                    polyloop.Add(new IfcPolyLoop(points[4], points[5], points[6], points[7]));
                    polyloop.Add(new IfcPolyLoop(points[1], points[5], points[6], points[2]));
                    polyloop.Add(new IfcPolyLoop(points[3], points[7], points[6], points[2]));

                    var faceouter = new List <IfcFaceOuterBound>();
                    foreach (var i in polyloop)
                    {
                        faceouter.Add(new IfcFaceOuterBound(i, true));
                    }

                    var face = new List <IfcFace>();
                    foreach (var j in faceouter)
                    {
                        face.Add(new IfcFace(j));
                    }

                    var closedshell = new IfcClosedShell(face);
                    var brep        = new IfcFacetedBrep(closedshell);

                    shape2 = new IfcProductDefinitionShape(new IfcShapeRepresentation(brep));
                    proxy1.Representation = shape2;
                    break;

                case "GeomRepresentation_05":
                    var points1 = new List <IfcCartesianPoint>();
                    points1.Add(new IfcCartesianPoint(db, -2, -3, 0));
                    points1.Add(new IfcCartesianPoint(db, -2, 3, 0));
                    points1.Add(new IfcCartesianPoint(db, 2, 3, 0));
                    points1.Add(new IfcCartesianPoint(db, 2, -3, 0));
                    var points2 = new List <IfcCartesianPoint>();
                    points2.Add(new IfcCartesianPoint(db, -2, -3, 1.35));
                    points2.Add(new IfcCartesianPoint(db, -2, 3, 1.35));
                    points2.Add(new IfcCartesianPoint(db, 2, 3, 1.35));
                    points2.Add(new IfcCartesianPoint(db, 2, -3, 1.35));

                    polyloop = new List <IfcPolyLoop>();
                    polyloop.Add(new IfcPolyLoop(points1));
                    polyloop.Add(new IfcPolyLoop(points2));


                    break;


                case "LocalPlacement_01":
                    //init
                    profile1           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid1 = new IfcExtrudedAreaSolid(profile1, 1.35);
                    shape1             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid1));

                    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));

                    proxy1 = new IfcBuildingElementProxy(site, objectPlacement1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbcba4b2-1c7d-4815-88bb-d3abed15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab222-1337-4875-4242-d3b00abcd531");
                    proxy2 = new IfcBuildingElementProxy(site, objectPlacement2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f821963b-c7d9-4d53-9825-0f87cd6abcda")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ab242-1337-4875-4242-d3414abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //update
                    var point1 = new IfcCartesianPoint(db, 2, 2, 2);
                    placement1.Location = point1;


                    break;

                case "LinearPlacement_02":

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

                    profile2           = new IfcRectangleProfileDef(db, "rectangleProfileDef", 4, 6);
                    extrudedAreaSolid2 = new IfcExtrudedAreaSolid(profile2, 1.35);
                    shape2             = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid2));


                    IfcLine line1 = new IfcLine(new IfcCartesianPoint(db, 1, 1, 1)
                                                , new IfcVector(new IfcDirection(db, 1, 1), 20));

                    IfcLine line2 = new IfcLine(new IfcCartesianPoint(db, 1, -1, -1)
                                                , new IfcVector(new IfcDirection(db, -1, 1), 20));

                    var alignment1 = new IfcAlignment(site, line1)
                    {
                        Name = "Alignment1",
                        Guid = new Guid("fbcba4b2-1cdd-48d5-88bb-d3aced15bbaa")
                    };
                    var alignment2 = new IfcAlignment(site, line2)
                    {
                        Name = "Alignment2",
                        Guid = new Guid("f111a4b2-1c7d-4815-88bb-d3aced15bbaa")
                    };

                    var distn1 = new IfcPointByDistanceExpression(4, line1);
                    var distn2 = new IfcPointByDistanceExpression(2, line2);

                    //Deprecated but should be right for IFC4
                    var linearplace1 = new IfcLinearPlacement(line1, distn1)
                    {
                        Orientation = new IfcOrientationExpression(new IfcDirection(db, 0.5, 0.24),
                                                                   new IfcDirection(db, -0.24, 0.5))
                    };
                    var linearplace2 = new IfcLinearPlacement(line2, distn2)
                    {
                        Orientation = new IfcOrientationExpression(new IfcDirection(db, 0.75, 0.24),
                                                                   new IfcDirection(db, -0.24, 0.66))
                    };

                    proxy1 = new IfcBuildingElementProxy(site, linearplace1, shape1)
                    {
                        Name = "Cuboid1",
                        Guid = new Guid("fbcba4b2-1c7d-4815-88bb-d3aced15bbaa")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000cc222-1337-4875-4242-d3b00abcd531");
                    proxy2 = new IfcBuildingElementProxy(site, linearplace2, shape2)
                    {
                        Name = "Cuboid2",
                        Guid = new Guid("f821963b-c7d9-4d53-98a5-0f8ccd6abcda")
                    };
                    proxy1.ContainedInStructure.Guid = new Guid("000ccc42-1337-4875-4242-d3414abcd531");
                    db.WriteFile(".\\" + folder + "\\Initial_" + proname + ".ifc");
                    db.WriteXmlFile(".\\" + folder + "\\Initial_" + proname + ".ifcxml");

                    //Update

                    IfcLine line3 = new IfcLine(new IfcCartesianPoint(db, 0, 1, 0)
                                                , new IfcVector(new IfcDirection(db, 0, 5, 2), 15));
                    var distn3 = new IfcPointByDistanceExpression(4, line3);

                    linearplace1.PlacementMeasuredAlong = line3;
                    linearplace1.Distance = distn3;


                    break;


                default:
                    //exit
                    return;
                }

                db.WriteFile(".\\" + folder + "\\Update_" + proname + ".ifc");
                db.WriteXmlFile(".\\" + folder + "\\Update_" + proname + ".ifcxml");
            }
        }
        public static double GetPerimeter(this IfcProfileDef Profile, bool addPerimetersOfVoids = true)
        {
            // Inheritance tree of IfcProfileDef:
            //
            //- IfcArbitraryClosedProfileDef
            //  - IfcArbitraryProfileDefWithVoids
            //- IfcArbitraryOpenProfileDef
            //  - IfcCenterLineProfileDef
            //- IfcParameterizedProfileDef  (abstract)
            //  - IfcIShapeProfileDef
            //    - IfcAsymmetricIShapeProfileDef
            //  - IfcCircleProfileDef
            //    - IfcCircleHollowProfileDef
            //  - IfcCraneRailAShapeProfileDef (Throw)
            //  - IfcCraneRailFShapeProfileDef (Throw)
            //  - IfcCShapeProfileDef
            //  - IfcEllipseProfileDef
            //  - IfcLShapeProfileDef (Throw)
            //  - IfcRectangleProfileDef
            //    - IfcRectangleHollowProfileDef
            //    - IfcRoundedRectangleProfileDef
            //  - IfcTrapeziumProfileDef
            //  - IfcTShapeProfileDef (Throw)
            //  - IfcUShapeProfileDef (Throw)
            //  - IfcZShapeProfileDef (Throw)
            //- IfcCompositeProfileDef
            if (Profile is IfcArbitraryProfileDefWithVoids)
            {
                throw new NotImplementedException("IfcArbitraryProfileDefWithVoids Perimeter is not implemented");
            }
            else if (Profile is IfcArbitraryClosedProfileDef)
            {
                throw new NotImplementedException("IfcArbitraryClosedProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcRoundedRectangleProfileDef)
            {
                IfcRoundedRectangleProfileDef p = Profile as IfcRoundedRectangleProfileDef;
                return(RoundedRecPerimeter(p.XDim, p.YDim, p.RoundingRadius));
            }
            else if (Profile is IfcRectangleHollowProfileDef)
            {
                IfcRectangleHollowProfileDef p = Profile as IfcRectangleHollowProfileDef;

                // outer 2P
                double outerFillet = 0;
                if (p.OuterFilletRadius.HasValue)
                {
                    outerFillet = p.OuterFilletRadius.Value;
                }
                double outer = RoundedRecPerimeter(p.XDim, p.YDim, outerFillet);

                if (!addPerimetersOfVoids)
                {
                    return(outer);
                }
                // inner 2P
                double innerFillet = 0;
                if (p.InnerFilletRadius.HasValue)
                {
                    innerFillet = p.InnerFilletRadius.Value;
                }
                double inner = RoundedRecPerimeter(p.XDim - 2 * p.WallThickness, p.YDim - 2 * p.WallThickness, innerFillet);

                // value
                return(outer + inner);
            }
            else if (Profile is IfcRectangleProfileDef)
            {
                IfcRectangleProfileDef p = Profile as IfcRectangleProfileDef;
                return(2 * (p.XDim + p.YDim));
            }
            else if (Profile is IfcCircleHollowProfileDef)
            {
                IfcCircleHollowProfileDef p = Profile as IfcCircleHollowProfileDef;
                double outer = 2 * Math.PI * p.Radius;
                if (!addPerimetersOfVoids)
                {
                    return(outer);
                }

                double inner = 2 * Math.PI * (p.Radius - p.WallThickness);

                return(outer - inner);
            }
            else if (Profile is IfcCircleProfileDef)
            {
                IfcCircleProfileDef p = Profile as IfcCircleProfileDef;
                return(2 * Math.PI * p.Radius);
            }
            else if (Profile is IfcCraneRailAShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcCraneRailAShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcCraneRailFShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcCraneRailFShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcCShapeProfileDef)
            {
                IfcCShapeProfileDef p = Profile as IfcCShapeProfileDef;

                double raIn = 0;
                if (p.InternalFilletRadius.HasValue)
                {
                    raIn = p.InternalFilletRadius.Value;
                }
                double raOut = raIn + p.WallThickness;

                return
                    (2 * Math.PI * raIn +        // internal fillet
                     2 * Math.PI * raOut +       // external fillet
                     4 * (p.Girth - raOut) +     // girt extension
                     2 * p.WallThickness +       // girt closures
                     4 * (p.Width - 2 * raOut) + // top and bottom connections
                     2 * (p.Depth - 2 * raOut)); // left connections
            }
            else if (Profile is IfcEllipseProfileDef)
            {
                IfcEllipseProfileDef p = Profile as IfcEllipseProfileDef;
                // http://www.mathsisfun.com/geometry/ellipse-perimeter.html
                // Ramanujan  approx 3
                double h = Math.Pow((p.SemiAxis1 - p.SemiAxis2), 2) / Math.Pow((p.SemiAxis1 + p.SemiAxis2), 2);
                return
                    (Math.PI * (p.SemiAxis1 + p.SemiAxis2) * (1 + 3 * h / (10 + Math.Sqrt(4 - 3 * h))));
            }
            else if (Profile is IfcLShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcLShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcTrapeziumProfileDef)
            {
                IfcTrapeziumProfileDef p = Profile as IfcTrapeziumProfileDef;
                double diag1             = pita(p.YDim, p.TopXOffset);
                double diag2             = pita(p.YDim, p.BottomXDim - p.TopXOffset - p.TopXDim);
                return(p.BottomXDim + p.TopXDim + diag1 + diag2);
            }
            else if (Profile is IfcTShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcTShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcUShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcUShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcZShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcZShapeProfileDef Perimeter is not implemented");
            }
            else if (Profile is IfcAsymmetricIShapeProfileDef) // needs to be tested before IfcIShapeProfileDef
            {
                throw new NotImplementedException("IfcAsymmetricIShapeProfileDef Perimeter is not implemented");
                // IfcAsymmetricIShapeProfileDef p = Profile as IfcAsymmetricIShapeProfileDef;
            }
            else if (Profile is IfcIShapeProfileDef)
            {
                throw new NotImplementedException("IfcAsymmetricIShapeProfileDef Perimeter is not implemented");
                // IfcIShapeProfileDef p = Profile as IfcIShapeProfileDef;
            }
            else if (Profile is IfcArbitraryOpenProfileDef)
            {
                return(0);
            }
            return(double.NaN);
        }
        public static double GetArea(this IfcProfileDef Profile)
        {
            // Inheritance tree of IfcProfileDef:
            //
            //- IfcArbitraryClosedProfileDef (Throw)
            //  - IfcArbitraryProfileDefWithVoids (Throw)
            //- IfcArbitraryOpenProfileDef (x)
            //  - IfcCenterLineProfileDef (x)
            //- IfcParameterizedProfileDef  (abstract)
            //  - IfcIShapeProfileDef (x)
            //    - IfcAsymmetricIShapeProfileDef (x)
            //  - IfcCircleProfileDef (x)
            //    - IfcCircleHollowProfileDef (x)
            //  - IfcCraneRailAShapeProfileDef (Throw)
            //  - IfcCraneRailFShapeProfileDef (Throw)
            //  - IfcCShapeProfileDef (x)
            //  - IfcEllipseProfileDef (x)
            //  - IfcLShapeProfileDef (Throw)
            //  - IfcRectangleProfileDef (x)
            //    - IfcRectangleHollowProfileDef (x)
            //    - IfcRoundedRectangleProfileDef (x)
            //  - IfcTrapeziumProfileDef (x)
            //  - IfcTShapeProfileDef (Throw)
            //  - IfcUShapeProfileDef (Throw)
            //  - IfcZShapeProfileDef (Throw)
            //- IfcCompositeProfileDef
            if (Profile is IfcArbitraryProfileDefWithVoids)
            {
                throw new NotImplementedException("IfcArbitraryProfileDefWithVoids Area is not implemented");
            }
            else if (Profile is IfcArbitraryClosedProfileDef)
            {
                throw new NotImplementedException("IfcArbitraryClosedProfileDef Area is not implemented");
            }
            else if (Profile is IfcRoundedRectangleProfileDef)
            {
                IfcRoundedRectangleProfileDef p = Profile as IfcRoundedRectangleProfileDef;
                return((p.XDim * p.YDim) - (4 * ConcaveRightAngleFilletArea(p.RoundingRadius)));
            }
            else if (Profile is IfcRectangleHollowProfileDef)
            {
                IfcRectangleHollowProfileDef p = Profile as IfcRectangleHollowProfileDef;

                // outer area
                double outerFillet = 0;
                if (p.OuterFilletRadius.HasValue)
                {
                    outerFillet = p.OuterFilletRadius.Value;
                }
                double outer = (p.XDim * p.YDim) - (4 * ConcaveRightAngleFilletArea(outerFillet));
                // inner area
                double innerFillet = 0;
                if (p.InnerFilletRadius.HasValue)
                {
                    innerFillet = p.InnerFilletRadius.Value;
                }
                double inner = ((p.XDim - 2 * p.WallThickness) * (p.YDim - 2 * p.WallThickness))
                               - (4 * ConcaveRightAngleFilletArea(innerFillet));

                return(outer - inner);
            }
            else if (Profile is IfcRectangleProfileDef)
            {
                IfcRectangleProfileDef p = Profile as IfcRectangleProfileDef;
                return(p.XDim * p.YDim);
            }
            else if (Profile is IfcCircleHollowProfileDef)
            {
                IfcCircleHollowProfileDef p = Profile as IfcCircleHollowProfileDef;
                double outer = Math.PI * Math.Pow(p.Radius, 2);
                double inner = Math.PI * Math.Pow(p.Radius - p.WallThickness, 2);
                return(outer - inner);
            }
            else if (Profile is IfcCircleProfileDef)
            {
                IfcCircleProfileDef p = Profile as IfcCircleProfileDef;
                return(Math.PI * Math.Pow(p.Radius, 2));
            }
            else if (Profile is IfcCraneRailAShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcCraneRailAShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcCraneRailFShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcCraneRailFShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcCShapeProfileDef)
            {
                IfcCShapeProfileDef p = Profile as IfcCShapeProfileDef;

                // inner area
                double innerFillet = 0;
                if (p.InternalFilletRadius.HasValue)
                {
                    innerFillet = p.InternalFilletRadius.Value;
                }
                double inner = ((p.Width - 2 * p.WallThickness) * (p.Depth - 2 * p.WallThickness))
                               - (4 * ConcaveRightAngleFilletArea(innerFillet));

                // outer area
                double outerFillet = innerFillet + p.WallThickness;
                double outer       = (p.Width * p.Depth) - (4 * ConcaveRightAngleFilletArea(outerFillet));

                double girthSideVoid = (p.Depth - 2 * p.Girth) * p.WallThickness;

                //     closed loop area - missing part between girths
                return((outer - inner) - girthSideVoid);
            }
            else if (Profile is IfcEllipseProfileDef)
            {
                IfcEllipseProfileDef p = Profile as IfcEllipseProfileDef;
                return(Math.PI * p.SemiAxis1 * p.SemiAxis2);
            }
            else if (Profile is IfcLShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcLShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcTrapeziumProfileDef)
            {
                IfcTrapeziumProfileDef p = Profile as IfcTrapeziumProfileDef;
                return((p.BottomXDim + p.TopXDim) * p.YDim / 2);
            }
            else if (Profile is IfcTShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcTShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcUShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcUShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcZShapeProfileDef)
            {
                // geometry is not clear
                throw new NotImplementedException("IfcZShapeProfileDef Area is not implemented");
            }
            else if (Profile is IfcAsymmetricIShapeProfileDef) // needs to be tested before IfcIShapeProfileDef
            {
                IfcAsymmetricIShapeProfileDef p = Profile as IfcAsymmetricIShapeProfileDef;
                // bottom flange
                double bottomflange = p.OverallWidth * p.FlangeThickness;
                // bottom flange
                double TopFlangeThickness = p.FlangeThickness; // if not specified differently
                if (p.TopFlangeThickness.HasValue)
                {
                    TopFlangeThickness = p.TopFlangeThickness.Value;
                }
                double topFlange = p.TopFlangeWidth * TopFlangeThickness;
                // core
                double core = (p.OverallDepth - p.FlangeThickness - TopFlangeThickness) * p.WebThickness;

                double bottomfillets = 0;
                double topFillets    = 0;
                if (p.FilletRadius.HasValue)
                {
                    bottomfillets = 2 * ConcaveRightAngleFilletArea(p.FilletRadius.Value);
                    topFillets    = bottomfillets;
                }
                if (p.TopFlangeFilletRadius.HasValue)
                {
                    topFillets = 2 * ConcaveRightAngleFilletArea(p.TopFlangeFilletRadius.Value);
                }
                return(bottomflange + topFlange + core + bottomfillets + topFillets);
            }
            else if (Profile is IfcIShapeProfileDef)
            {
                IfcIShapeProfileDef p = Profile as IfcIShapeProfileDef;
                double flanges        = p.OverallWidth * p.FlangeThickness * 2; // top and bottom flanges
                double core           = (p.OverallDepth - (p.FlangeThickness * 2)) * p.WebThickness;
                double fillets        = 0;
                if (p.FilletRadius.HasValue && p.FilletRadius.Value > 0)
                {
                    fillets = 4 * ConcaveRightAngleFilletArea(p.FilletRadius.Value);
                }
                return(flanges + core + fillets);
            }
            else if (Profile is IfcArbitraryOpenProfileDef)
            {
                return(0);
            }
            return(double.NaN);
        }
Exemple #14
0
        public static devDept.Eyeshot.Entities.Region getRegionFromIfcProfileDef(IfcProfileDef ipd, ViewportLayout viewportLayout1)
        {
            devDept.Eyeshot.Entities.Region region = null;

            if (ipd is IfcCircleProfileDef)
            {
                IfcCircleProfileDef crProfDef = (IfcCircleProfileDef)ipd;

                region = new CircularRegion(crProfDef.Radius);
            }
            else if (ipd is IfcIShapeProfileDef) // IfcIShapeProfileDef and all derived from
            {
                IfcIShapeProfileDef shProfDef = (IfcIShapeProfileDef)ipd;
                double     halfWidth          = shProfDef.OverallWidth / 2;
                double     halfDepth          = shProfDef.OverallDepth / 2;
                LinearPath lp = new LinearPath(Plane.XY,
                                               new Point2D(-halfWidth, -halfDepth),
                                               new Point2D(halfWidth, -halfDepth),
                                               new Point2D(halfWidth, -halfDepth + shProfDef.FlangeThickness),
                                               new Point2D(shProfDef.WebThickness / 2, -halfDepth + shProfDef.FlangeThickness),
                                               new Point2D(shProfDef.WebThickness / 2, +halfDepth - shProfDef.FlangeThickness),
                                               new Point2D(halfWidth, +halfDepth - shProfDef.FlangeThickness),
                                               new Point2D(halfWidth, halfDepth),
                                               new Point2D(-halfWidth, halfDepth),
                                               new Point2D(-halfWidth, halfDepth - shProfDef.FlangeThickness),
                                               new Point2D(-shProfDef.WebThickness / 2, halfDepth - shProfDef.FlangeThickness),
                                               new Point2D(-shProfDef.WebThickness / 2, -halfDepth + shProfDef.FlangeThickness),
                                               new Point2D(-halfWidth, -halfDepth + shProfDef.FlangeThickness),
                                               new Point2D(-halfWidth, -halfDepth)
                                               );

                region = new devDept.Eyeshot.Entities.Region(lp);
            }
            else if (ipd is IfcRectangleProfileDef)
            {
                IfcRectangleProfileDef recProfDef = (IfcRectangleProfileDef)ipd;

                region = new RectangularRegion(recProfDef.XDim, recProfDef.YDim, true);
            }
            else if (ipd is IfcArbitraryClosedProfileDef)
            {
                IfcArbitraryClosedProfileDef arProfDef = (IfcArbitraryClosedProfileDef)ipd;

                ICurve cc = getICurveFromIfcCurve(arProfDef.OuterCurve);

                if (cc != null)
                {
                    //foreach(Entity xx in cc.CurveList)
                    //    viewportLayout1.Entities.Add((Entity)xx.Clone(), 1);

                    //viewportLayout1.Entities.Add((Entity)cc.Clone(), 2);

                    region = new devDept.Eyeshot.Entities.Region(cc);
                }
            }
            else
            {
                if (!debug.Contains("IfcProfileDef not supported: " + ipd.KeyWord))
                {
                    debug += "IfcProfileDef not supported: " + ipd.KeyWord + "\n";
                }
            }
            if (ipd is IfcParameterizedProfileDef)
            {
                IfcParameterizedProfileDef parProfDef = (IfcParameterizedProfileDef)ipd;

                if (parProfDef.Position != null && region != null)
                {
                    Plane plane = getPlaneFromPosition(parProfDef.Position);

                    Align3D algn = new Align3D(Plane.XY, plane);

                    region.TransformBy(algn);

                    //region.Translate(parProfDef.Position.Location.Coordinates.Item1, parProfDef.Position.Location.Coordinates.Item2, parProfDef.Position.Location.Coordinates.Item3);
                }
            }
            return(region);
        }