public void IfcPolygonalBoundedHalfspace_Test() { using (var m = new MemoryModel(new Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("")) { var polygonalBoundedHalfspace = m.Instances.New <IfcPolygonalBoundedHalfSpace>(); polygonalBoundedHalfspace.AgreementFlag = false; var plane = m.Instances.New <IfcPlane>(); plane.Position = m.Instances.New <IfcAxis2Placement3D>(); plane.Position.Location = m.Instances.New <IfcCartesianPoint>(c => c.SetXYZ(0, 0, 0)); polygonalBoundedHalfspace.BaseSurface = plane; //create the polygonal bound var polyLine = m.Instances.New <IfcPolyline>(); polyLine.Points.Add(m.Instances.New <IfcCartesianPoint>(c => c.SetXY(0, 2.5))); polyLine.Points.Add(m.Instances.New <IfcCartesianPoint>(c => c.SetXY(5, 2.5))); polyLine.Points.Add(m.Instances.New <IfcCartesianPoint>(c => c.SetXY(5, -2.5))); polyLine.Points.Add(m.Instances.New <IfcCartesianPoint>(c => c.SetXY(0, -2.5))); polyLine.Points.Add(m.Instances.New <IfcCartesianPoint>(c => c.SetXY(0, 2.5))); polygonalBoundedHalfspace.PolygonalBoundary = polyLine; var basePos = m.Instances.New <IfcAxis2Placement3D>(); basePos.Location = m.Instances.New <IfcCartesianPoint>(c => c.SetXYZ(0, 0, 0)); polygonalBoundedHalfspace.Position = basePos; //make an extrusion var profile = IfcModelBuilder.MakeRectangleProfileDef(m, 20, 10); var extrude = IfcModelBuilder.MakeExtrudedAreaSolid(m, profile, 40); var solid = geomEngine.CreateSolid(extrude, logger); var halfSpaceSolid = geomEngine.CreateSolid(polygonalBoundedHalfspace, logger); var cut = solid.Cut(halfSpaceSolid, 1e-5); Assert.IsTrue(cut.Count > 0); Assert.IsTrue(Math.Abs((solid.Volume) - cut.First.Volume - 1000) < 1e-5); //reverse halfspace agreement polygonalBoundedHalfspace.AgreementFlag = true; halfSpaceSolid = geomEngine.CreateSolid(polygonalBoundedHalfspace, logger); cut = solid.Cut(halfSpaceSolid, 1e-5); Assert.IsTrue(Math.Abs(solid.Volume - cut.First.Volume) < 1e-5); //move the plane up plane.Position.Location.Z = 20; halfSpaceSolid = geomEngine.CreateSolid(polygonalBoundedHalfspace, logger); cut = solid.Cut(halfSpaceSolid, 1e-5); Assert.IsTrue(Math.Abs(solid.Volume - cut.First.Volume - 500) < 1e-5); //some realistic data polyLine.Points[0].SetXY(0, 0); polyLine.Points[1].SetXY(0, 2850); polyLine.Points[2].SetXY(-350, 2850); polyLine.Points[3].SetXY(-350, 0); polyLine.Points[4].SetXY(0, 0); plane.Position.Location.SetXYZ(-5240.7742616303667, -33052.9790707385, 0.0); plane.Position.Axis = m.Instances.New <IfcDirection>(d => d.SetXYZ(0, -1, 0)); plane.Position.RefDirection = m.Instances.New <IfcDirection>(d => d.SetXYZ(1, 0, 0)); basePos.Location.SetXYZ(-5240.7742616303667, -33052.9790707385, 0); basePos.Axis = plane.Position.Axis; basePos.RefDirection = plane.Position.RefDirection; halfSpaceSolid = geomEngine.CreateSolid(polygonalBoundedHalfspace, logger); profile.XDim = 350; profile.YDim = 125; profile.Position.Location.SetXY(-5415.7742616303676, -32932.529070738507); extrude.Depth = 2850; solid = geomEngine.CreateSolid(extrude, logger); cut = solid.Cut(halfSpaceSolid, 1e-5); //everything should be cut Assert.IsTrue(cut.Count == 0); } } }