コード例 #1
0
        public void ConvertIfcCircleHollowProfileToBRepTest()
        {
            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.MakeCircleHollowProfileDef(m, 1000, 500), 3000);
                    var solid = _xbimGeometryCreator.CreateSolid(block);

                    var brep = _xbimGeometryCreator.CreateFacetedBrep(m, solid);

                    shape.Items.Add(brep);

                    var solid2 = _xbimGeometryCreator.CreateSolidSet(brep); //round trip it

                    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(solid2.Count == 1, "Expected one solid");
                    IfcCsgTests.GeneralTest(solid2.First);

                    Assert.IsTrue(brep.Outer.CfsFaces.Count == solid2.First.Faces.Count, "Number of faces in round tripped solid is not the same");
                }
            }
        }