コード例 #1
0
        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");
                }
            }
        }
コード例 #2
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");
                    }
                }
            }
        }
コード例 #3
0
 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");
         }
     }
 }