public void CreateXbimFacetedSolidFromIfcRectangleHollowProfileDef()
 {
     using (var m = XbimModel.CreateTemporaryModel())
     {
         using (var txn = m.BeginTransaction())
         {
             var profile = IfcModelBuilder.MakeRectangleHollowProfileDef(m, 20, 10, 1);
             var extrude = IfcModelBuilder.MakeExtrudedAreaSolid(m, profile, 40);
             var solid   = XbimGeometryCreator.CreateSolid(extrude);
             var faceted = XbimGeometryCreator.CreateFacetedSolid(solid, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance);
             foreach (var face in faceted.Faces)
             {
                 Assert.IsTrue(face.OuterBound.Edges.Count == 4, "Each face should have four outer edges");
             }
             int hasInnerCount = 0;
             foreach (var face in faceted.Faces)
             {
                 if (face.InnerBounds.Count == 1)
                 {
                     hasInnerCount++;
                     Assert.IsTrue(face.InnerBounds.First.Edges.Count == 4, "Each face should have four inner edges");
                 }
             }
             Assert.IsTrue(hasInnerCount == 2, "There should be two faces with an innerbound");
             Assert.IsTrue(faceted.Shells.Count == 1, "Should only be one shell");
             Assert.IsTrue(faceted.Vertices.Count == faceted.Shells.First.Vertices.Count, "Should be one shell with the same number of vertices");
         }
     }
 }
 public void ReadWriteTriangulationOfPlanarSolidTest()
 {
     using (var m = XbimModel.CreateTemporaryModel())
     {
         using (var txn = m.BeginTransaction())
         {
             var        profile = IfcModelBuilder.MakeRectangleHollowProfileDef(m, 20, 10, 1);
             var        extrude = IfcModelBuilder.MakeExtrudedAreaSolid(m, profile, 40);
             var        solid   = XbimGeometryCreator.CreateSolid(extrude);
             TextWriter tw      = new StringWriter();
             XbimGeometryCreator.WriteTriangulation(tw, solid, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance, 0.5);
             TextReader          tr   = new StringReader(tw.ToString());
             IXbimGeometryObject geom = XbimGeometryCreator.ReadTriangulation(tr);
             var triangulatedSold     = geom as IXbimSolid;
             Assert.IsNotNull(triangulatedSold, "Invalid solid returned");
             Assert.IsTrue(Math.Abs(solid.Volume - triangulatedSold.Volume) < 0.001, "Volume differs");
         }
     }
 }
 public void ConvertXbimSolidFromXbimFacetedSolidPlanarTest()
 {
     using (var m = XbimModel.CreateTemporaryModel())
     {
         using (var txn = m.BeginTransaction())
         {
             var profile = IfcModelBuilder.MakeRectangleHollowProfileDef(m, 20, 10, 1);
             var extrude = IfcModelBuilder.MakeExtrudedAreaSolid(m, profile, 40);
             var solid   = XbimGeometryCreator.CreateSolid(extrude);
             var faceted = XbimGeometryCreator.CreateFacetedSolid(solid, m.ModelFactors.Precision,
                                                                  m.ModelFactors.DeflectionTolerance);
             var solid2 = XbimGeometryCreator.CreateSolid(faceted);
             Assert.IsTrue(solid.Shells.Count == solid2.Shells.Count, "Shell count differs");
             Assert.IsTrue(solid.Faces.Count == solid2.Faces.Count, "Face count differs");
             Assert.IsTrue(solid.Edges.Count == solid2.Edges.Count, "Edge count differs");
             Assert.IsTrue(solid.Vertices.Count == solid2.Vertices.Count, "Vertex count differs");
             Assert.IsTrue(Math.Abs(solid.Volume - solid2.Volume) < 0.001, "Volume differs");
         }
     }
 }