public void ObjectPlacementTest() { //this test checks that a object is correctly copied and moved //create a box using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { var block = IfcModelBuilder.MakeBlock(m, 50, 10, 10); var solid = _geomEngine.CreateSolid(block); var placement = IfcModelBuilder.MakeLocalPlacement(m); ((IfcAxis2Placement3D)placement.RelativePlacement).Location.X = 100; var bb = solid.BoundingBox; var solidA = _geomEngine.Moved(solid, placement) as IXbimSolid; Assert.IsNotNull(solidA, "Should be the same type as the master"); var displacement = solidA.BoundingBox.Centroid() - solid.BoundingBox.Centroid(); Assert.IsTrue(displacement == new XbimVector3D(100, 0, 0)); var placementRelTo = ((IfcLocalPlacement)placement.PlacementRelTo); var zDir = m.Instances.New <IfcDirection>(d => d.SetXYZ(0, 0, 1)); ((IfcAxis2Placement3D)placementRelTo.RelativePlacement).Axis = zDir; var yDir = m.Instances.New <IfcDirection>(d => d.SetXYZ(0, 1, 0)); ((IfcAxis2Placement3D)placementRelTo.RelativePlacement).RefDirection = yDir; //point in Y ((IfcAxis2Placement3D)placementRelTo.RelativePlacement).Location.X = 2000; var solidB = _geomEngine.Moved(solid, placement) as IXbimSolid; displacement = solidB.BoundingBox.Centroid() - solid.BoundingBox.Centroid(); var meshbuilder = new MeshHelper(); _geomEngine.Mesh(meshbuilder, solidB, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance); var box = meshbuilder.BoundingBox; Assert.IsTrue(displacement == new XbimVector3D(1970, 120, 0)); } } }
public void ScaleAndCopyTest() { //this test checks that a object is correctly copied and moved //create a box using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { var block = IfcModelBuilder.MakeBlock(m, 10, 10, 10); var solid = _geomEngine.CreateSolid(block); var transform = IfcModelBuilder.MakeCartesianTransformationOperator3D(m); transform.Scale = 2; var solidA = _geomEngine.Transformed(solid, transform); var bb = solid.BoundingBox; var bbA = solidA.BoundingBox; Assert.IsTrue(Math.Abs(bb.Volume - 1000) < 1e-9, "Bounding box volume is incorrect in original shape"); Assert.IsTrue(Math.Abs(bbA.Volume - 8000) < 1e-9, "Bounding box volume is incorrect in scaled shape"); var transformNonUniform = IfcModelBuilder.MakeCartesianTransformationOperator3DnonUniform(m); transformNonUniform.Scale3 = 100; var solidB = _geomEngine.Transformed(solid, transformNonUniform); Assert.IsTrue(Math.Abs(solidB.BoundingBox.Volume - 100000) < 1e-9, "Bounding box volume is incorrect in non uniform scaled shape"); Assert.IsTrue(Math.Abs(bb.Volume - 1000) < 1e-9, "Bounding box volume of original shape as been changed"); } } }
public void MoveAndCopyTest() { //this test checks that a object is correctly copied and moved //create a box using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { { var block = IfcModelBuilder.MakeBlock(m, 10, 10, 10); var solid = _geomEngine.CreateSolid(block); var ax3D = IfcModelBuilder.MakeAxis2Placement3D(m); ax3D.Location.Y = 100; var solidA = _geomEngine.Moved(solid, ax3D) as IXbimSolid; Assert.IsNotNull(solidA, "Should be the same type as the master"); Assert.IsTrue(Math.Abs(solidA.Volume - solid.Volume) < 1e-9, "Volume has changed"); var displacement = solidA.BoundingBox.Centroid() - solid.BoundingBox.Centroid(); Assert.IsTrue(displacement == new XbimVector3D(0, 100, 0)); var bbA = solidA.BoundingBox; var solidB = _geomEngine.Moved(solid, ax3D); Assert.IsTrue(bbA.Centroid() - solidB.BoundingBox.Centroid() == new XbimVector3D(0, 0, 0)); } } } }
public void SectionOfBlockTest() { using (var m = new MemoryModel(new Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("")) { var block = IfcModelBuilder.MakeBlock(m, 10, 15, 20); var solid = geomEngine.CreateSolid(block, logger); var plane = IfcModelBuilder.MakePlane(m, new XbimPoint3D(block.Position.Location.X + 5, block.Position.Location.Y, block.Position.Location.Z), new XbimVector3D(-1, 0, 0), new XbimVector3D(0, 1, 0)); var cutPlane = geomEngine.CreateFace(plane, logger); var section = solid.Section(cutPlane, m.ModelFactors.PrecisionBoolean); if (section.First == null) { Assert.IsTrue(section.First != null, "Result should be a single face"); Assert.IsTrue(section.First.OuterBound.Edges.Count == 4, "4 edges are required of a section of a block"); } } } }
public void IfcBlockTest() { using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { var block = IfcModelBuilder.MakeBlock(m, 10, 15, 20); var solid = geomEngine.CreateSolid(block); Assert.IsTrue(solid.Faces.Count == 6, "6 faces are required of a block"); Assert.IsTrue(solid.Vertices.Count == 8, "8 vertices are required of a block"); var meshRec = new MeshHelper(); geomEngine.Mesh(meshRec, solid, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance * 10); Assert.IsTrue(meshRec.FaceCount == 6, "6 mesh faces are required of a block"); Assert.IsTrue(meshRec.PointCount == 24, "24 mesh points are required of a block"); txn.Commit(); } } }
public void GridPlacementTest() { //this test checks that a object is correctly copied and moved //create a box using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { var block = IfcModelBuilder.MakeBlock(m, 10, 10, 10); var solid = _geomEngine.CreateSolid(block); var grid = IfcModelBuilder.MakeGrid(m, 3, 100); var gridPlacement = m.Instances.New <IfcGridPlacement>(); gridPlacement.PlacementLocation = m.Instances.New <IfcVirtualGridIntersection>(); gridPlacement.PlacementLocation.IntersectingAxes.Add(grid.UAxes.Last()); gridPlacement.PlacementLocation.IntersectingAxes.Add(grid.VAxes.Last()); var solidA = _geomEngine.Moved(solid, gridPlacement) as IXbimSolid; Assert.IsNotNull(solidA, "Should be the same type as the master"); var displacement = solidA.BoundingBox.Centroid() - solid.BoundingBox.Centroid(); Assert.IsTrue(displacement == new XbimVector3D(200, 200, 0)); } } }
public void BooleanCutSolidWithVoidPlanarTest() { using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Populate")) { var block1 = IfcModelBuilder.MakeBlock(m, 20, 20, 20); var block2 = IfcModelBuilder.MakeBlock(m, 5, 5, 5); block2.Position.Location.X += 10; block2.Position.Location.Y += 10; block2.Position.Location.Z += 10; var b1 = geomEngine.CreateSolid(block1); var b2 = geomEngine.CreateSolid(block2); var result = b1.Cut(b2, m.ModelFactors.PrecisionBoolean); Assert.IsTrue(result.Count == 1, "Cutting of these two solids should return two solids"); foreach (var solid in result) { HelperFunctions.IsValidSolid(solid); } txn.Commit(); } } }