public void SectionWithInnerWireTest() { using (var m = new MemoryModel(new Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("")) { var csgTree = m.Instances.New <IfcCsgSolid>(); var bresult = m.Instances.New <IfcBooleanResult>(); var cylinderInner = IfcModelBuilder.MakeRightCircularCylinder(m, 10, 20); var cylinderOuter = IfcModelBuilder.MakeRightCircularCylinder(m, 20, 20); bresult.FirstOperand = cylinderOuter; bresult.SecondOperand = cylinderInner; bresult.Operator = IfcBooleanOperator.DIFFERENCE; csgTree.TreeRootExpression = bresult; var solid = geomEngine.CreateSolidSet(csgTree, logger).FirstOrDefault(); var plane = IfcModelBuilder.MakePlane(m, new XbimPoint3D(cylinderInner.Position.Location.X + 1, cylinderInner.Position.Location.Y, cylinderInner.Position.Location.Z), new XbimVector3D(0, 0, 1), new XbimVector3D(0, 1, 0)); var cutPlane = geomEngine.CreateFace(plane, logger); var section = solid.Section(cutPlane, m.ModelFactors.PrecisionBoolean); Assert.IsTrue(section.First != null, "Result should be a face"); Assert.IsTrue(section.First.OuterBound.Edges.Count == 1, "1 edge is required for this section of a cylinder"); Assert.IsTrue(section.First.InnerBounds.Count == 1, "1 inner wire is required for this section of a cylinder"); } } }
public void BooleanIntersectSolidTest() { using (var m = new MemoryModel(new Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("")) { var cylinder = IfcModelBuilder.MakeRightCircularCylinder(m, 10, 20); var sphere = IfcModelBuilder.MakeSphere(m, 15); var a = geomEngine.CreateSolid(sphere, logger); var b = geomEngine.CreateSolid(cylinder, logger); var solidSet = a.Intersection(b, m.ModelFactors.PrecisionBoolean); Assert.IsTrue(solidSet.Count == 1, "intersecting these two solids should return a single solid"); IsSolidTest(solidSet.First); } } }
public void CutTwoCylindersTest() { using (var m = new MemoryModel(new Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("")) { var cylinderInner = IfcModelBuilder.MakeRightCircularCylinder(m, 10, 20); var cylinderOuter = IfcModelBuilder.MakeRightCircularCylinder(m, 20, 20); var logger = loggerFactory.CreateLogger <IfcBooleanTests>(); var outer = geomEngine.CreateSolid(cylinderOuter, logger); var inner = geomEngine.CreateSolid(cylinderInner, logger); var solidSet = outer.Cut(inner, m.ModelFactors.PrecisionBoolean); Assert.IsTrue(solidSet.Count == 1, "Cutting these two solids should return a single solid"); IsSolidTest(solidSet.First); txn.Commit(); } } }
public void IfcRightCircularCylinderTest() { using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { const double h = 2; const double r = 0.5; var cylinder = IfcModelBuilder.MakeRightCircularCylinder(m, r, h); var solid = geomEngine.CreateSolid(cylinder); Assert.IsTrue(solid.Faces.Count == 3, "3 faces are required of a cylinder"); Assert.IsTrue(solid.Vertices.Count == 2, "2 vertices are required of a cylinder"); var meshRec = new MeshHelper(); geomEngine.Mesh(meshRec, solid, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance * 10); Assert.IsTrue(meshRec.FaceCount == 3, "3 mesh faces are required of a cylinder"); Assert.IsTrue(meshRec.PointCount == 106, "106 mesh points are required of a cylinder"); txn.Commit(); } } }
public void IfcCsgIntersectionTest() { using (var m = new MemoryModel(new Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("")) { var csgTree = m.Instances.New <IfcCsgSolid>(); var bresult = m.Instances.New <IfcBooleanResult>(); var cylinder = IfcModelBuilder.MakeRightCircularCylinder(m, 10, 20); var sphere = IfcModelBuilder.MakeSphere(m, 15); bresult.FirstOperand = cylinder; bresult.SecondOperand = sphere; bresult.Operator = IfcBooleanOperator.INTERSECTION; csgTree.TreeRootExpression = bresult; var solid = geomEngine.CreateSolidSet(csgTree, logger).FirstOrDefault(); Assert.IsTrue(solid.Faces.Count == 3, "3 faces are required of this csg solid"); Assert.IsTrue(solid.Vertices.Count == 3, "3 vertices are required of this csg solid"); } } }
public void SectionOfCylinderTest() { using (var m = new MemoryModel(new Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("")) { var cylinder = IfcModelBuilder.MakeRightCircularCylinder(m, 20, 20); var solid = geomEngine.CreateSolid(cylinder, logger); var plane = IfcModelBuilder.MakePlane(m, new XbimPoint3D(cylinder.Position.Location.X + 1, cylinder.Position.Location.Y, cylinder.Position.Location.Z), new XbimVector3D(0, -1, 0), new XbimVector3D(1, 0, 0)); var cutPlane = geomEngine.CreateFace(plane, logger); var section = solid.Section(cutPlane, m.ModelFactors.PrecisionBoolean); Assert.IsTrue(section.First != null, "Result should be a face"); Assert.IsTrue(section.First.OuterBound.Edges.Count == 4, "4 edges are required for this section of a cylinder"); //repeat with section through cylinder plane = IfcModelBuilder.MakePlane(m, new XbimPoint3D(cylinder.Position.Location.X + 1, cylinder.Position.Location.Y, cylinder.Position.Location.Z), new XbimVector3D(0, 0, 1), new XbimVector3D(0, 1, 0)); cutPlane = geomEngine.CreateFace(plane, logger); section = solid.Section(cutPlane, m.ModelFactors.PrecisionBoolean); Assert.IsTrue(section.First != null, "Result should be a face"); Assert.IsTrue(section.First.OuterBound.Edges.Count == 1, "1 edge is required for this section of a cylinder"); Assert.IsTrue(section.First.InnerBounds.Count == 0, "0 inner wires are required for this section of a cylinder"); } } }