private static IfcTrimmedCurve ToIfcTrimmedCurve(this Arc arc, Document doc) { var placement = new Transform().ToIfcAxis2Placement3D(doc); var ifcCircle = new IfcCircle(new IfcAxis2Placement(placement), new IfcPositiveLengthMeasure(arc.Radius)); var trim1 = new IfcTrimmingSelect(arc.StartAngle); var trim2 = new IfcTrimmingSelect(arc.EndAngle); var tc = new IfcTrimmedCurve(ifcCircle, new List <IfcTrimmingSelect> { trim1 }, new List <IfcTrimmingSelect> { trim2 }, true, IfcTrimmingPreference.PARAMETER); doc.AddEntity(placement); doc.AddEntity(ifcCircle); return(tc); }
//transformation function to convert/cast IFC2x3 data to appear as IFC4 private static IIfcTrimmingSelect Trim1ToIfc4(IfcTrimmingSelect member) { if (member == null) { return(null); } switch (member.GetType().Name) { case "IfcCartesianPoint": return(member as IfcCartesianPoint); case "IfcParameterValue": return(new Ifc4.MeasureResource.IfcParameterValue((MeasureResource.IfcParameterValue)member)); default: throw new System.NotSupportedException(); } }
private static IfcTrimmedCurve ToIfcTrimmedCurve(this Arc arc, Document doc) { var t = new Transform(arc.Plane.Origin, arc.Plane.Normal); var placement = t.ToIfcAxis2Placement3D(doc); var ifcCircle = new IfcCircle(new IfcAxis2Placement(placement), new IfcPositiveLengthMeasure(arc.Radius)); var start = arc.Start.ToIfcCartesianPoint(); var end = arc.End.ToIfcCartesianPoint(); var trim1 = new IfcTrimmingSelect(start); var trim2 = new IfcTrimmingSelect(end); var tc = new IfcTrimmedCurve(ifcCircle, new List <IfcTrimmingSelect> { trim1 }, new List <IfcTrimmingSelect> { trim2 }, true, IfcTrimmingPreference.CARTESIAN); doc.AddEntity(start); doc.AddEntity(end); doc.AddEntity(placement); doc.AddEntity(ifcCircle); return(tc); }
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); }
public void ArbitraryClosedProfileDefWithIncorrectPlacementTest() { using (var model = IfcStore.Create(new XbimEditorCredentials(), IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel)) { using (var txn = model.BeginTransaction("Create Column")) { IfcProject project = model.Instances.New <IfcProject>(); project.Initialize(ProjectUnits.SIUnitsUK); project.Name = "Test Project"; IfcColumn col = model.Instances.New <IfcColumn>(); col.Name = "Column With ArbitraryClosedProfileDef"; //Creating IfcArbitraryClosedProfileDef that will contain IfcCompositeCurve IfcArbitraryClosedProfileDef arbClosedProf = model.Instances.New <IfcArbitraryClosedProfileDef>(); //To create IfcArbitraryClosedProfileDef, we'll need to create IfcCompositeCurve //Creating IfcCompositeCurve IfcCompositeCurve myCompCurve = model.Instances.New <IfcCompositeCurve>(); //To Create IfcCompositeCurve, We'll need to create IfcCompositeCurveSegment //create IfcCompositeCurveSegment (polyline) IfcCompositeCurveSegment polylineSeg = model.Instances.New <IfcCompositeCurveSegment>(); //create IfcCompositeCurveSegment (arc) IfcCompositeCurveSegment arcSeg = model.Instances.New <IfcCompositeCurveSegment>(); //Creating IfcPolyline that will be the parent curve for IfcCompositeCurveSegment "polylineSeg" IfcPolyline myPolyline = model.Instances.New <IfcPolyline>(); //Creating Points to build the IfcPolyline IfcCartesianPoint p0 = model.Instances.New <IfcCartesianPoint>(); p0.SetXY(200, 100); IfcCartesianPoint p1 = model.Instances.New <IfcCartesianPoint>(); p1.SetXY(0, 100); IfcCartesianPoint p2 = model.Instances.New <IfcCartesianPoint>(); p2.SetXY(0, 0); IfcCartesianPoint p3 = model.Instances.New <IfcCartesianPoint>(); p3.SetXY(400, 0); IfcCartesianPoint p4 = model.Instances.New <IfcCartesianPoint>(); p4.SetXY(400, 600); IfcCartesianPoint p5 = model.Instances.New <IfcCartesianPoint>(); p5.SetXY(0, 600); IfcCartesianPoint p6 = model.Instances.New <IfcCartesianPoint>(); p6.SetXY(0, 500); IfcCartesianPoint p7 = model.Instances.New <IfcCartesianPoint>(); p7.SetXY(200, 500); //Adding points to the polyline myPolyline.Points.Add(p0); myPolyline.Points.Add(p1); myPolyline.Points.Add(p2); myPolyline.Points.Add(p3); myPolyline.Points.Add(p4); myPolyline.Points.Add(p5); myPolyline.Points.Add(p6); myPolyline.Points.Add(p7); //Assigning myPolyline to the IfcCompositeCurveSegment polylineSeg polylineSeg.ParentCurve = myPolyline; //Creating Arc using IfcTrimmedCurve IfcTrimmedCurve myArc = model.Instances.New <IfcTrimmedCurve>(); //To create IfcTrimmedCurve, We'll need to create IfcCircle and trim it using IfcTrimmingSelect IfcCircle myCirc = model.Instances.New <IfcCircle>(); myCirc.Radius = 213.554; IfcCartesianPoint cP = model.Instances.New <IfcCartesianPoint>(); cP.SetXY(125.1312, 300); //this should really be a 3D point IfcAxis2Placement3D plcmnt = model.Instances.New <IfcAxis2Placement3D>(); plcmnt.Location = cP; plcmnt.RefDirection = model.Instances.New <IfcDirection>(); plcmnt.RefDirection.SetXY(0, 1);//this should eb a 3D axis myCirc.Position = plcmnt; myArc.BasisCurve = myCirc; IfcTrimmingSelect v1 = p7; IfcTrimmingSelect v2 = p0; myArc.Trim1.Add(v1); myArc.Trim2.Add(v2); arcSeg.ParentCurve = myArc; //Adding the created two IfcCompositeCurveSegments to the IfcCompositeCurve myCompCurve.Segments.Add(arcSeg); myCompCurve.Segments.Add(polylineSeg); //Assigning IfcCompositeCurve "myCompCurve" to the IfcArbitraryClosedProfileDef arbClosedProf.OuterCurve = myCompCurve; arbClosedProf.ProfileType = IfcProfileTypeEnum.AREA; //model as a swept area solid IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>(); body.Depth = 2000; body.SweptArea = arbClosedProf; body.ExtrudedDirection = model.Instances.New <IfcDirection>(); body.ExtrudedDirection.SetXYZ(0, 0, 1); txn.Commit(); var solid = _xbimGeometryCreator.CreateSolid(body); Assert.IsTrue((int)solid.Volume == 239345450); } } }