public void ScaleAndCopyTest() { //this test checks that a object is correctly copied and moved //create a box using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { var block = IfcModelBuilder.MakeBlock(m, 10, 10, 10); var solid = _geomEngine.CreateSolid(block); var transform = IfcModelBuilder.MakeCartesianTransformationOperator3D(m); transform.Scale = 2; var solidA = _geomEngine.Transformed(solid, transform); var bb = solid.BoundingBox; var bbA = solidA.BoundingBox; Assert.IsTrue(Math.Abs(bb.Volume - 1000) < 1e-9, "Bounding box volume is incorrect in original shape"); Assert.IsTrue(Math.Abs(bbA.Volume - 8000) < 1e-9, "Bounding box volume is incorrect in scaled shape"); var transformNonUniform = IfcModelBuilder.MakeCartesianTransformationOperator3DnonUniform(m); transformNonUniform.Scale3 = 100; var solidB = _geomEngine.Transformed(solid, transformNonUniform); Assert.IsTrue(Math.Abs(solidB.BoundingBox.Volume - 100000) < 1e-9, "Bounding box volume is incorrect in non uniform scaled shape"); Assert.IsTrue(Math.Abs(bb.Volume - 1000) < 1e-9, "Bounding box volume of original shape as been changed"); } } }
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 ReadPreProcessorTest() { string revitPattern = @"- Exporter\s(\d*.\d*.\d*.\d*)"; string[] files = new[] { @"TestSourceFiles\Axis2PlacementError.ifc", @"TestSourceFiles\4walls1floorSite.ifc", @"TestSourceFiles\SampleHouse4.ifc" }; var surfaceOfLinearExtrusionVersion = new Version(17, 0, 416, 0); foreach (var file in files) { using (var store = MemoryModel.OpenRead(file)) { var matches = Regex.Matches(store.Header.FileName.OriginatingSystem, revitPattern, RegexOptions.IgnoreCase); Assert.IsTrue(matches.Count > 0, "No match found"); Assert.IsTrue(matches[0].Groups.Count == 2, "Should only be two matches"); if (Version.TryParse(matches[0].Groups[1].Value, out Version modelVersion)) { var shouldHaveWorkAround = (modelVersion <= surfaceOfLinearExtrusionVersion); if (shouldHaveWorkAround) { Assert.IsTrue(store.ModelFactors.ApplyWorkAround("#SurfaceOfLinearExtrusion"), "Work around should be implemented"); } else { Assert.IsFalse(store.ModelFactors.ApplyWorkAround("#SurfaceOfLinearExtrusion"), "Work around should not be implemented"); } } } } }
public void CreatingPartialFile() { using (var w = new StringWriter()) { using (var mm = MemoryModel.OpenRead("SmallModelIfc2x3.ifc")) { var extrusion = mm.Instances.FirstOrDefault <IfcExtrudedAreaSolid>(); ModelHelper.WritePartialFile(mm, extrusion, w, new HashSet <int>()); var part = w.ToString(); Assert.IsFalse(string.IsNullOrEmpty(part)); var ef = new EntityFactoryIfc2x3(); using (var insModel = new MemoryModel(ef)) { insModel.InsertCopy(extrusion, new Common.XbimInstanceHandleMap(mm, insModel), null, false, true, true); using (var partModel = new MemoryModel(ef)) { var errs = partModel.LoadStep21Part(part); Assert.IsTrue(errs == 0); Assert.IsTrue(insModel.Instances.Count == partModel.Instances.Count); var ext2 = partModel.Instances.FirstOrDefault <IfcExtrudedAreaSolid>(); Assert.IsTrue(ext2.Depth == extrusion.Depth); Assert.IsTrue(ext2.ExtrudedDirection.X == extrusion.ExtrudedDirection.X); Assert.IsTrue(ext2.ExtrudedDirection.Y == extrusion.ExtrudedDirection.Y); Assert.IsTrue(ext2.ExtrudedDirection.Z == extrusion.ExtrudedDirection.Z); } } } } }
public void IfcDateAndTimeToIfcDateTimeTest() { using (var iModel = new MemoryModel(new Xbim.Ifc2x3.EntityFactory())) { using (var txn = iModel.BeginTransaction("Insert date time")) { var ifc2x3DateAndTime = iModel.Instances.New <IfcDateAndTime>(); var res = ifc2x3DateAndTime.ToISODateTimeString(); Assert.IsTrue(res == "0001-01-01T12:00:00.000"); ifc2x3DateAndTime.DateComponent = iModel.Instances.New <IfcCalendarDate>(); ifc2x3DateAndTime.DateComponent.YearComponent = 2015; ifc2x3DateAndTime.DateComponent.MonthComponent = 11; ifc2x3DateAndTime.DateComponent.DayComponent = 5; ifc2x3DateAndTime.TimeComponent = iModel.Instances.New <IfcLocalTime>(); ifc2x3DateAndTime.TimeComponent.HourComponent = 12; ifc2x3DateAndTime.TimeComponent.MinuteComponent = 11; ifc2x3DateAndTime.TimeComponent.SecondComponent = 32.123456789; res = ifc2x3DateAndTime.ToISODateTimeString(); Assert.IsTrue(res == "2015-11-05T12:11:32.123"); res = ifc2x3DateAndTime.DateComponent.ToISODateTimeString(); Assert.IsTrue(res == "2015-11-05T12:00:00"); res = ifc2x3DateAndTime.TimeComponent.ToISODateTimeString(); Assert.IsTrue(res == "0001-01-01T12:11:32.123"); } } }
/// <summary> /// This constructor only opens an in memory model /// </summary> /// <param name="input"></param> /// <param name="labelFrom"></param> /// <returns></returns> public static CobieModel OpenStep21(Stream input, long streamSize, int labelFrom) { var model = new MemoryModel(new EntityFactory(), labelFrom); model.LoadStep21(input, streamSize); return(new CobieModel(model)); }
private IModel ParseModelFile(string ifcFileName, bool caching, ILogger <BatchProcessor> logger, ReportProgressDelegate progress) { IModel ret = null; if (string.IsNullOrWhiteSpace(ifcFileName)) { return(null); } if (!File.Exists(ifcFileName)) { return(null); } // create a callback for progress var ext = Path.GetExtension(ifcFileName).ToLowerInvariant(); switch (ext) { case ".ifc": case ".ifczip": case ".ifcxml": if (caching) { ret = IfcStore.Open(ifcFileName, null, 0, progress); } else { ret = MemoryModel.OpenRead(ifcFileName, logger, progress); } return(ret); default: logger?.LogError("XbimRegression does not support {0} file format.", ext); return(null); } }
public void CreateSerializeAndDeserialize() { var lat = new List <long> { 45, 12, 79 }; var lon = new List <long> { 2, 23, 80 }; var model = new MemoryModel(new EntityFactoryIfc2x3()); using (var txn = model.BeginTransaction("Site creation")) { var site = model.Instances.New <IfcSite>(); site.RefLatitude = lat; site.RefLongitude = lon; txn.Commit(); } using (var fileStream = new StreamWriter("site.ifc")) { model.SaveAsStep21(fileStream); } model = new MemoryModel(new EntityFactoryIfc2x3()); model.LoadStep21("site.ifc"); var site2 = model.Instances.FirstOrDefault <IfcSite>(); Assert.IsTrue(lat == site2.RefLatitude); Assert.AreEqual((IfcCompoundPlaneAngleMeasure)lon, site2.RefLongitude); }
public void OpenReadIfc2x3XmlFormatTest() { using (var mm = MemoryModel.OpenRead("4walls1floorSite.ifcxml")) { Assert.IsTrue(mm.Instances.Count == 579); } }
public void CreateNew() { var ef2x3 = new Ifc2x3.EntityFactoryIfc2x3(); using (var mm = new MemoryModel(ef2x3)) { using (var txn = mm.BeginTransaction("Simple")) { mm.Instances.New <Ifc2x3.ActorResource.IfcPerson>(); txn.Commit(); Assert.IsTrue(mm.Instances.Count == 1); } } var ef4 = new Ifc4.EntityFactoryIfc4(); using (var mm = new MemoryModel(ef4)) { using (var txn = mm.BeginTransaction("Simple")) { mm.Instances.New <Ifc4.ActorResource.IfcPerson>(); txn.Commit(); Assert.IsTrue(mm.Instances.Count == 1); } } }
public void OpenReadIfc4StepZipFormatTest() { using (var mm = MemoryModel.OpenRead("SmallModelIfc4.ifczip")) { Assert.IsTrue(mm.Instances.Count == 52); } }
public void OpenReadIfc2x3StepFormatTest() { using (var mm = MemoryModel.OpenRead("SmallModelIfc2x3.ifc")) { Assert.IsTrue(mm.Instances.Count == 579); } }
public void OpenReadModelFactorPrecisionTest() { using (var mm = MemoryModel.OpenRead("Axis2PlacementError.ifc")) { Assert.IsTrue(mm.ModelFactors.Precision == 0.01); } }
public void UpdateScore (MemoryModel model) { for (int i = 0; i < model.Players.Length; i++) { scorePanels[i].Show(model.Players[i].score, i, model.PlayerIndex == i); } }
private Dictionary <int, string> GetXmlEntityMap(Stream stream, IModel model) { var result = new Dictionary <int, string>(model.Instances.Count()); var schema = model.Header.FileSchema.Schemas.First(); if (string.Equals(schema, "IFC2X3", StringComparison.OrdinalIgnoreCase)) { log.LogWarning("Only IFC4 models are supported to report XML ids"); return(result); } _dummyModel = new MemoryModel(_factory4); // pass in null logger as this is not critical var xmlReader = new XbimXmlReader4(GetOrCreateXMLEntity, entity => { }, model.Metadata, NullLogger.Instance); xmlReader.Read(stream, _dummyModel); // swap the dictionary foreach (var item in xmlReader.IdMap) { result.Add(item.Value, item.Key); } //purge _read.Clear(); _dummyModel = null; return(result); }
public void CollectionRemoval() { // arrange using (var model = new MemoryModel(new Ifc2x3.EntityFactoryIfc2x3())) using (var txn = model.BeginTransaction("")) { IfcWall wall1 = model.Instances.New <IfcWall>(); IfcWall wall2 = model.Instances.New <IfcWall>(); var propertySet = model.Instances.New <Ifc2x3.Kernel.IfcPropertySet>(); propertySet.HasProperties.Add(model.Instances.New <Ifc2x3.PropertyResource.IfcPropertySingleValue>()); // Changing the type of the rel variable from interface to IfcRelDefinesByProperties solves the issue. IIfcRelDefinesByProperties rel = model.Instances.New <Ifc2x3.Kernel.IfcRelDefinesByProperties>(); rel.RelatingPropertyDefinition = propertySet; rel.RelatedObjects.Add(wall1); rel.RelatedObjects.Add(wall2); // act rel.RelatedObjects.Remove(wall1); // assert failed. Expected: 1, actual: 2 (null, wall2). Assert.AreEqual(1, rel.RelatedObjects.Count); txn.Commit(); } }
public void CreateIfcAlignment() { using (var model = new MemoryModel(ef)) { using (var txn = model.BeginTransaction("Init")) { var a = model.Instances.New <IfcAlignment>(); a.GlobalId = Guid.NewGuid(); a.Name = "Testing alignment"; a.Axis = model.Instances.New <IfcAlignmentCurve>(); txn.Commit(); } using (var w = File.CreateText("xbim_alignment.ifc")) { model.SaveAsStep21(w); w.Close(); } } using (var model = new MemoryModel(ef)) { model.LoadStep21("xbim_alignment.ifc"); var a = model.Instances.FirstOrDefault <IfcAlignment>(); Assert.IsNotNull(a); Assert.IsNotNull(a.Axis); } }
public static void ExpandAttributes() { using (var cobie = new MemoryModel(new EntityFactory())) { using (var txn = cobie.BeginTransaction("Test")) { var component1 = cobie.Instances.New <CobieComponent>(c => c.Name = "Chair A"); var component2 = cobie.Instances.New <CobieComponent>(c => c.Name = "Chair B"); var a1 = cobie.Instances.New <CobieAttribute>(c => { c.Name = "A"; c.Value = new StringValue("Value A"); }); var a2 = cobie.Instances.New <CobieAttribute>(c => { c.Name = "B"; c.Value = new StringValue("Value B"); }); component1.Attributes.AddRange(new[] { a1, a2 }); component2.Attributes.AddRange(new[] { a1, a2 }); Expand(cobie, (CobieComponent c) => c.Attributes); if (component1.Attributes.Any(a => component2.Attributes.Contains(a))) { throw new Exception("Didn't work!"); } } } }
public static IfcBSplineCurveWithKnots MakeBSplineCurveWithKnots(MemoryModel m) { var c = m.Instances.New <IfcBSplineCurveWithKnots>(); c.Degree = 3; var p1 = m.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(240, 192, -84)); var p2 = m.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(0, 275, -84)); var p3 = m.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(-240, 192, -84)); c.ControlPointsList.Add(p1); c.ControlPointsList.Add(p2); c.ControlPointsList.Add(p3); c.ControlPointsList.Add(m.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(0, -108, -84))); c.ControlPointsList.Add(p1); c.ControlPointsList.Add(p2); c.ControlPointsList.Add(p3); c.CurveForm = IfcBSplineCurveForm.UNSPECIFIED; for (int i = 0; i < 11; i++) { c.KnotMultiplicities.Add(1); c.Knots.Add(i - 7.0); } c.ClosedCurve = false; c.SelfIntersect = false; c.KnotSpec = IfcKnotType.UNSPECIFIED; return(c); }
public void Ifc4InterfacesToIfc2X3() { var model = new MemoryModel(new EntityFactory()); model.LoadStep21("4walls1floorSite.ifc", null); var walls = model.Instances.OfType <IIfcWall>().ToList(); Assert.AreEqual(4, walls.Count); foreach (var wall in walls) { Assert.IsNotNull(wall.Name); var properties = wall.IsDefinedBy .Where(r => r.RelatingPropertyDefinition is IIfcPropertySet) .SelectMany(r => ((IIfcPropertySet)r.RelatingPropertyDefinition).HasProperties); foreach (var property in properties) { Assert.IsNotNull(property.Name); var single = property as IIfcPropertySingleValue; if (single != null) { Assert.IsNotNull(single.NominalValue); } } var type = wall.IsTypedBy.Select(r => r.RelatingType).FirstOrDefault(); Assert.IsNotNull(type); } }
public void IfcSphereTest() { using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { const double r = 0.5; var sphere = IfcModelBuilder.MakeSphere(m, r); var solid = geomEngine.CreateSolid(sphere); Assert.IsTrue(solid.Faces.Count == 1, "1 face is required of a sphere"); Assert.IsTrue(solid.Vertices.Count == 2, "2 vertices are required of a sphere"); var meshRec = new MeshHelper(); meshRec.BeginUpdate(); geomEngine.Mesh(meshRec, solid, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance * 10); meshRec.EndUpdate(); Assert.IsTrue(meshRec.FaceCount == 1, "1 mesh face is required of a sphere"); Assert.IsTrue(meshRec.PointCount == 168, "168 mesh points are required of a sphere"); Assert.IsTrue(meshRec.TriangleCount == 306, "306 triangles are required of a sphere"); Assert.IsTrue(meshRec.TriangleCount * 3 == meshRec.TriangleIndicesCount, "Incorrect triangulation"); txn.Commit(); } } }
public void TestingLinqWhere2() { using (var model1 = MemoryModel.OpenRead("email.ifc")) { var telecom = model1.Instances[28] as IIfcTelecomAddress; Assert.IsNotNull(telecom); Assert.IsNotNull(telecom.ElectronicMailAddresses); // the linq queries below should return the same value, // indeed resharper suggest to transform one into the other // but the values returned are different. // // Is this a problem with linq or Essentials? // // the problem goes away if we use "using Xbim.Ifc2x3.Interfaces;" instead of ifc4. // var add = telecom.ElectronicMailAddresses; var enum1 = add.Where(t => !string.IsNullOrWhiteSpace(t.ToString())); var enumFrom1 = enum1.FirstOrDefault(); var ml1 = add.Where(t => !string.IsNullOrWhiteSpace(t.ToString())).FirstOrDefault(); var ml2 = add.FirstOrDefault(t => !string.IsNullOrWhiteSpace(t.ToString())); Assert.AreEqual(ml1, ml2); } }
public void IfcRectangularPyramidTest() { using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { var pyramid = m.Instances.New <IfcRectangularPyramid>(); var p = m.Instances.New <IfcAxis2Placement3D>(); p.Axis = m.Instances.New <IfcDirection>(d => d.SetXYZ(1, 0, 0)); p.Location = m.Instances.New <IfcCartesianPoint>(c => c.SetXYZ(10, 10, 0)); pyramid.Position = p; pyramid.Height = 20; pyramid.XLength = 10; pyramid.YLength = 15; var solid = geomEngine.CreateSolid(pyramid); Assert.IsTrue(solid.Faces.Count == 5, "5 faces are required of a pyramid"); Assert.IsTrue(solid.Vertices.Count == 5, "5 vertices are required of a pyramid"); var meshRec = new MeshHelper(); geomEngine.Mesh(meshRec, solid, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance * 10); Assert.IsTrue(meshRec.FaceCount == 5, "5 mesh faces are required of a pyramid"); Assert.IsTrue(meshRec.PointCount == 16, "16 mesh points are required of a pyramid"); txn.Commit(); } } }
private IModel ParseModelFile(string ifcFileName, bool caching, ILogger <BatchProcessor> logger) { IModel ret = null; if (string.IsNullOrWhiteSpace(ifcFileName)) { return(null); } // create a callback for progress switch (Path.GetExtension(ifcFileName).ToLowerInvariant()) { case ".ifc": case ".ifczip": case ".ifcxml": if (caching) { ret = IfcStore.Open(ifcFileName, null, 0); } else { ret = MemoryModel.OpenRead(ifcFileName, logger); } return(ret); default: throw new NotImplementedException( string.Format("XbimRegression does not support {0} file formats currently", Path.GetExtension(ifcFileName)) ); } }
public void IfcRightCircularConeTest() { using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { var cylinder = m.Instances.New <IfcRightCircularCone>(); var p = m.Instances.New <IfcAxis2Placement3D>(); p.Axis = m.Instances.New <IfcDirection>(d => d.SetXYZ(1, 0, 0)); p.Location = m.Instances.New <IfcCartesianPoint>(c => c.SetXYZ(0, 0, 0)); cylinder.Position = p; cylinder.BottomRadius = 0.5; cylinder.Height = 2; var solid = geomEngine.CreateSolid(cylinder); Assert.IsTrue(solid.Faces.Count == 2, "2 faces are required of a cone"); Assert.IsTrue(solid.Vertices.Count == 2, "2 vertices are required of a cone"); var meshRec = new MeshHelper(); geomEngine.Mesh(meshRec, solid, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance * 10); Assert.IsTrue(meshRec.FaceCount == 2, "2 mesh faces are required of a cone"); Assert.IsTrue(meshRec.PointCount == 55, "55 mesh points are required of a cone"); txn.Commit(); } } }
public void MoveAndCopyTest() { //this test checks that a object is correctly copied and moved //create a box using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { { var block = IfcModelBuilder.MakeBlock(m, 10, 10, 10); var solid = _geomEngine.CreateSolid(block); var ax3D = IfcModelBuilder.MakeAxis2Placement3D(m); ax3D.Location.Y = 100; var solidA = _geomEngine.Moved(solid, ax3D) as IXbimSolid; Assert.IsNotNull(solidA, "Should be the same type as the master"); Assert.IsTrue(Math.Abs(solidA.Volume - solid.Volume) < 1e-9, "Volume has changed"); var displacement = solidA.BoundingBox.Centroid() - solid.BoundingBox.Centroid(); Assert.IsTrue(displacement == new XbimVector3D(0, 100, 0)); var bbA = solidA.BoundingBox; var solidB = _geomEngine.Moved(solid, ax3D); Assert.IsTrue(bbA.Centroid() - solidB.BoundingBox.Centroid() == new XbimVector3D(0, 0, 0)); } } } }
public static void Create(string path, XbimSchemaVersion schema, Action <IModel> creation) { var f = MemoryModel.GetFactory(schema); using (var model = new MemoryModel(f)) { using (var txn = model.BeginTransaction("Creation")) { creation(model); txn.Commit(); } using (var file = File.Create(path)) { if (path.ToLowerInvariant().EndsWith(".ifc")) { model.SaveAsStep21(file); } else if (path.ToLowerInvariant().EndsWith(".ifcxml")) { model.SaveAsXml(file, new System.Xml.XmlWriterSettings { Indent = true, IndentChars = " " }); } else { throw new Exception("Unexpected extension"); } file.Close(); } } }
public void ObjectPlacementTest() { //this test checks that a object is correctly copied and moved //create a box using (var m = new MemoryModel(new Xbim.Ifc4.EntityFactoryIfc4())) { using (var txn = m.BeginTransaction("Test")) { var block = IfcModelBuilder.MakeBlock(m, 50, 10, 10); var solid = _geomEngine.CreateSolid(block); var placement = IfcModelBuilder.MakeLocalPlacement(m); ((IfcAxis2Placement3D)placement.RelativePlacement).Location.X = 100; var bb = solid.BoundingBox; var solidA = _geomEngine.Moved(solid, placement) as IXbimSolid; Assert.IsNotNull(solidA, "Should be the same type as the master"); var displacement = solidA.BoundingBox.Centroid() - solid.BoundingBox.Centroid(); Assert.IsTrue(displacement == new XbimVector3D(100, 0, 0)); var placementRelTo = ((IfcLocalPlacement)placement.PlacementRelTo); var zDir = m.Instances.New <IfcDirection>(d => d.SetXYZ(0, 0, 1)); ((IfcAxis2Placement3D)placementRelTo.RelativePlacement).Axis = zDir; var yDir = m.Instances.New <IfcDirection>(d => d.SetXYZ(0, 1, 0)); ((IfcAxis2Placement3D)placementRelTo.RelativePlacement).RefDirection = yDir; //point in Y ((IfcAxis2Placement3D)placementRelTo.RelativePlacement).Location.X = 2000; var solidB = _geomEngine.Moved(solid, placement) as IXbimSolid; displacement = solidB.BoundingBox.Centroid() - solid.BoundingBox.Centroid(); var meshbuilder = new MeshHelper(); _geomEngine.Mesh(meshbuilder, solidB, m.ModelFactors.Precision, m.ModelFactors.DeflectionTolerance); var box = meshbuilder.BoundingBox; Assert.IsTrue(displacement == new XbimVector3D(1970, 120, 0)); } } }
static ModelFactory() { FileProviders.Add((path) => { return(MemoryModel.OpenRead(path)); }); FileProviders.Add((path) => { // return Esent DB return(Ifc.IfcStore.Open(path, null, 0, (pct, o) => { })); }); FileProviders.Add((path) => { // return Memory DB return(Ifc.IfcStore.Open(path, null, null, (pct, o) => { })); }); ModelProviders.Add((factory) => { return(new MemoryModel(factory)); }); ModelProviders.Add((factory) => { return(EsentModel.CreateTemporaryModel(factory)); }); }
public void SubtractionResultsInClosedWindow() { using (var model = MemoryModel.OpenRead(@"SubtractionResultsInClosedWindow.ifc")) { logger.LogInformation("Running SubtractionResultsInClosedWindow"); var wallBrep = model.Instances[12752] as IIfcFacetedBrep; var wallPlacement = model.Instances[12562] as IIfcLocalPlacement; var wallTransform = wallPlacement.ToMatrix3D(); var openingExtrudeArea = model.Instances[286479] as IIfcExtrudedAreaSolid; var openingPlacement = model.Instances[286487] as IIfcLocalPlacement; var openingTransform = openingPlacement.ToMatrix3D(); var wallSolid = geomEngine.CreateSolidSet(wallBrep, logger).FirstOrDefault(); var transformedWall = wallSolid.Transform(wallTransform) as IXbimSolid; var openingSolid = geomEngine.CreateSolid(openingExtrudeArea, logger); var transformedOpening = openingSolid.Transform(openingTransform) as IXbimSolid; var cutWall = transformedWall.Cut(transformedOpening, model.ModelFactors.Precision, logger).FirstOrDefault(); Assert.IsNotNull(cutWall, "Cut wall should not be null"); // note this faceted brep already has the openings cut out and we are cutting them again so the volume should not change var volDiff = cutWall.Volume - transformedWall.Volume; Assert.IsTrue(Math.Abs(volDiff) < 1e-5); // Assert.IsTrue(er.Entity != null, "No IfcBooleanResult found"); // var solid = geomEngine.CreateSolid(er.Entity, logger); // Assert.IsFalse(solid.Faces.Any(), "This solid should have 0 faces"); } }
public void OpenReadIfc4XmlZipFormatTest() { using (var mm = MemoryModel.OpenRead("HelloWallXml.ifczip")) { Assert.AreEqual(163, mm.Instances.Count); } }