コード例 #1
0
 public void RectangleProfileDefTest()
 {
     using (var m = XbimModel.CreateTemporaryModel())
     {
         using (var txn = m.BeginTransaction())
         {
             var prof = IfcModelBuilder.MakeRectangleProfileDef(m, 20, 30);
             var face = _xbimGeometryCreator.CreateFace(prof);
             Assert.IsTrue(face.Area > 0);
         }
     }
 }
コード例 #2
0
        public void ConvertIfcRectangleProfileToBRepTest()
        {
            using (var m = IfcModelBuilder.CreateandInitModel())
            {
                using (var txn = m.BeginTransaction())
                {
                    //add a shape
                    //Create a Definition shape to hold the geometry
                    var shape = m.Instances.New <IfcShapeRepresentation>();
                    shape.ContextOfItems           = m.IfcProject.ModelContext();
                    shape.RepresentationType       = "Brep";
                    shape.RepresentationIdentifier = "Body";

                    //Create a Product Definition and add the model geometry to the wall
                    var rep = m.Instances.New <IfcProductDefinitionShape>();
                    rep.Representations.Add(shape);
                    var building = m.Instances.OfType <IfcBuilding>().FirstOrDefault();
                    Assert.IsNotNull(building, "Failed to find Building");
                    building.Representation = rep;



                    var block = IfcModelBuilder.MakeExtrudedAreaSolid(m, IfcModelBuilder.MakeRectangleProfileDef(m, 10000, 20000), 30000);
                    var solid = _xbimGeometryCreator.CreateSolid(block);
                    var brep  = _xbimGeometryCreator.CreateFacetedBrep(m, solid);
                    shape.Items.Add(brep);
                    var xrep = _xbimGeometryCreator.CreateSolidSet(brep);

                    txn.Commit();
                    try
                    {
                        //Uncomment below to see the results in Ifc
                        //m.SaveAs("brep.ifc", XbimStorageType.IFC);
                    }
                    catch (Exception)
                    {
                        Assert.IsTrue(false, "Failed to save the results to Ifc");
                    }
                    Assert.IsTrue(xrep.Count == 1, "Expected one solid");
                    Assert.IsTrue(solid.Volume - xrep.First.Volume <= m.ModelFactors.Precision, "Volume of round tripped cylinder is not the same");
                    IfcCsgTests.GeneralTest(xrep.First);
                }
            }
        }