private static IfcTrimmedCurve ToIfcTrimmedCurve(this Line line, Document doc) { var start = line.Start.ToIfcCartesianPoint(); var end = line.End.ToIfcCartesianPoint(); var dir = line.Direction().ToIfcVector(doc); var ifcLine = new IfcLine(start, dir); var trim1 = new IfcTrimmingSelect(start); var trim2 = new IfcTrimmingSelect(end); var tc = new IfcTrimmedCurve(ifcLine, new List <IfcTrimmingSelect> { trim1 }, new List <IfcTrimmingSelect> { trim2 }, true, IfcTrimmingPreference.CARTESIAN); doc.AddEntity(start); doc.AddEntity(end); doc.AddEntity(dir); doc.AddEntity(ifcLine); return(tc); }
static void Main(string[] args) { var ut_name = "Alignment-TUMAdsk-1"; var db = new DatabaseIfc(ModelView.Ifc4X3NotAssigned); db.Factory.Options.GenerateOwnerHistory = false; var site = new IfcSite(db, "site"); var project = new IfcProject(db, ut_name) { Name = ut_name, Description = "sample for a single horizontal line segment - geometry + semantic part" }; new IfcRelAggregates(project, new List <IfcObjectDefinition>() { site }); // alignment var alignment = new IfcAlignment(site); alignment.AddComment("Entry point for alignment container"); var horiz = new IfcAlignmentHorizontal(alignment); horiz.AddComment("groups all horizontal segments using an IfcRelNests rel"); var pt1 = new IfcCartesianPoint(db, 3, 1, 0); var semanticPartOfTheSegment = new IfcAlignmentHorizontalSegment( pt1, 0, 0, 0, 56.4, IfcAlignmentHorizontalSegmentTypeEnum.LINE); semanticPartOfTheSegment.AddComment("Semantic part of the line segment"); var semanticSegment1 = new IfcAlignmentSegment(horiz, semanticPartOfTheSegment); semanticSegment1.AddComment("link semantic segment with horizontal alignment container"); // build geometric part var line = new IfcLine(pt1, new IfcVector(new IfcDirection(db, 0, 0), 1)); line.AddComment("line geometry"); var curveSeg = new IfcCurveSegment(IfcTransitionCode.CONTINUOUS, new IfcAxis1Placement(pt1), new IfcNonNegativeLengthMeasure(0), new IfcNonNegativeLengthMeasure(56.4), line); curveSeg.AddComment("Trim the entire line"); var shapeRep = new IfcShapeRepresentation(curveSeg, ShapeRepresentationType.Curve2D); IfcProductDefinitionShape shape1 = new IfcProductDefinitionShape(shapeRep) { Name = "Horizontal alignment geom rep" }; shape1.AddComment("link the geometric rep of a line to the representation of the horizontal segment"); horiz.Representation = shape1; db.WriteFile(ut_name + ".ifc"); }
protected override void GenerateInstance(IfcBuilding building) { DatabaseIfc database = building.Database; double angFactor = database.Factory.Options.AngleUnitsInRadians ? 1 : 180 / Math.PI; building.Comments.Add("These profile curves are intentionally expressed in a more complicated manner than possible to test parameterization"); IfcMaterial material = new IfcMaterial(database, "Steel"); //-IfcBSplineCurve //- IfcCompositeCurve //- IfcCompositeCurveSegment //- IfcIndexedPolyCurve //- IfcTrimmedCurve //- IfcPCurve ? double root2 = Math.Sqrt(2), root2div2 = Math.Sqrt(2) / 2.0, root3 = Math.Sqrt(3), root3div2 = Math.Sqrt(3) / 2.0; List <IfcCompositeCurveSegment> segments = new List <IfcCompositeCurveSegment>(); IfcLine line = new IfcLine(new IfcCartesianPoint(database, -1000, 1000), new IfcVector(new IfcDirection(database, 1, -1), 1000 * Math.Sqrt(2))); IfcTrimmedCurve trimmedCurve = new IfcTrimmedCurve(line, new IfcTrimmingSelect((root2 - 1) / root2), new IfcTrimmingSelect(1 + (1 / root2)), true, IfcTrimmingPreference.PARAMETER); segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve)); IfcCircle circle = new IfcCircle(database, 1000); trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(7.0 / 4 * Math.PI * angFactor), new IfcTrimmingSelect(3.0 / 4 * Math.PI * angFactor), true, IfcTrimmingPreference.PARAMETER); segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve)); string name = "SemiCircle"; IfcArbitraryClosedProfileDef profile = new IfcArbitraryClosedProfileDef(name, new IfcCompositeCurve(segments)); IfcMaterialProfileSet materialProfileSet = new IfcMaterialProfileSet(name, new IfcMaterialProfile(name, material, profile)); IfcColumnType columnType = new IfcColumnType(name, materialProfileSet, IfcColumnTypeEnum.COLUMN); database.Context.AddDeclared(columnType); IfcColumnStandardCase column = new IfcColumnStandardCase(building, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.MID), new IfcAxis2Placement3D(new IfcCartesianPoint(database, 0, 0, 0)), 2000) { Name = name, RelatingType = columnType }; //Unique ids assigned to generate constant IfcScript sample files, remove otherwise columnType.GlobalId = "24mq0gwVr7bgEMXPmo$TrF"; column.GlobalId = "0RGc8lepr7BRF_EtHrWJ45"; columnType.ObjectTypeOf.GlobalId = "0devdSRyf3uBEQbSqWTDjo"; columnType.MaterialSelect.Associates.GlobalId = "1gdVo5TjPETPZlW8HSRupM"; column.MaterialSelect.Associates.GlobalId = "35z8gDFbb6gvrCOz$24tUJ"; database.NextObjectRecord = 100; circle = new IfcCircle(new IfcAxis2Placement2D(new IfcCartesianPoint(database, 0, 1000)) { RefDirection = new IfcDirection(database, -1, 0) }, root3 * 1000); segments = new List <IfcCompositeCurveSegment>(); trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(Math.PI / 3 * angFactor), new IfcTrimmingSelect(2 * Math.PI / 3 * angFactor), true, IfcTrimmingPreference.PARAMETER); segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve)); circle = new IfcCircle(new IfcAxis2Placement2D(new IfcCartesianPoint(database, -1000 * root3div2, -500)) { RefDirection = new IfcDirection(database, 0, -1) }, root3 * 1000); trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(Math.PI / 2 * angFactor), new IfcTrimmingSelect(5 * Math.PI / 6 * angFactor), true, IfcTrimmingPreference.PARAMETER); segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve)); circle = new IfcCircle(new IfcAxis2Placement2D(new IfcCartesianPoint(database, 1000 * root3div2, -500)) { RefDirection = new IfcDirection(database, 0, 1) }, root3 * 1000); trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(Math.PI / 6 * angFactor), new IfcTrimmingSelect(Math.PI / 2 * angFactor), true, IfcTrimmingPreference.PARAMETER); segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve)); name = "CurviLinearTriangle"; profile = new IfcArbitraryClosedProfileDef(name, new IfcCompositeCurve(segments)); materialProfileSet = new IfcMaterialProfileSet(name, new IfcMaterialProfile(name, material, profile)); columnType = new IfcColumnType(name, materialProfileSet, IfcColumnTypeEnum.COLUMN); database.Context.AddDeclared(columnType); column = new IfcColumnStandardCase(building, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.MID), new IfcAxis2Placement3D(new IfcCartesianPoint(database, 2500, 0, 0)), 2000) { Name = name, RelatingType = columnType }; //Unique ids assigned to generate constant IfcScript sample files, remove otherwise columnType.GlobalId = "3N_qc_BjX1hvEgwfRvVcb_"; column.GlobalId = "0bmIILAwj8$PLHK1jcmad0"; columnType.ObjectTypeOf.GlobalId = "3tGocD1N51oOvSvHbJI_qD"; columnType.MaterialSelect.Associates.GlobalId = "1M5oofzjD3IOM43brXW6wT"; column.MaterialSelect.Associates.GlobalId = "0gnTzVmkbE9hPsJDxOUOL3"; database.NextObjectRecord = 150; IfcEllipse ellipse = new IfcEllipse(new IfcAxis2Placement2D(database), 1000, 500); segments = new List <IfcCompositeCurveSegment>(); trimmedCurve = new IfcTrimmedCurve(ellipse, new IfcTrimmingSelect(0), new IfcTrimmingSelect(Math.PI / 4 * angFactor), true, IfcTrimmingPreference.PARAMETER); segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve)); double x = root2div2, y = 0.5 * root2div2, len = Math.Sqrt(0.5 + Math.Pow(y, 2)); line = new IfcLine(new IfcCartesianPoint(database, 0, 0), new IfcVector(new IfcDirection(database, x / len, y / len), 1)); trimmedCurve = new IfcTrimmedCurve(line, new IfcTrimmingSelect(0), new IfcTrimmingSelect(len * 1000), false, IfcTrimmingPreference.PARAMETER); segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve)); line = new IfcLine(new IfcCartesianPoint(database, 0, 0), new IfcVector(new IfcDirection(database, 1, 0), 1)); trimmedCurve = new IfcTrimmedCurve(line, new IfcTrimmingSelect(0), new IfcTrimmingSelect(1000), true, IfcTrimmingPreference.PARAMETER); segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve)); name = "PartialEllipse"; profile = new IfcArbitraryClosedProfileDef(name, new IfcCompositeCurve(segments)); materialProfileSet = new IfcMaterialProfileSet(name, new IfcMaterialProfile(name, material, profile)); columnType = new IfcColumnType(name, materialProfileSet, IfcColumnTypeEnum.COLUMN); database.Context.AddDeclared(columnType); column = new IfcColumnStandardCase(building, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.MID), new IfcAxis2Placement3D(new IfcCartesianPoint(database, 5000, 0, 0)), 2000) { Name = name, RelatingType = columnType }; //Unique ids assigned to generate constant IfcScript sample files, remove otherwise columnType.GlobalId = "0dtemVu1P2682BcO3CPWAy"; column.GlobalId = "1JCvykjKH71R7_uck4n6hN"; columnType.ObjectTypeOf.GlobalId = "0rNx6sqCH2mOt1cWOT6zSU"; columnType.MaterialSelect.Associates.GlobalId = "2OfhB1Dcz2cAdV$CDh9PHV"; column.MaterialSelect.Associates.GlobalId = "3bTNkVsf9099xrALHA6WhF"; }
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]); }
/// <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"); } }