forked from xBimTeam/XbimEssentials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Functionality to open a model from a stream added
Additional index properies added to make all inverse relationships indexed InsertCopy of model changed to retain consistent entity labels from source to target model
- Loading branch information
Steve Lockley
committed
Sep 9, 2015
1 parent
d8c48c7
commit e6a03ee
Showing
65 changed files
with
5,983 additions
and
280 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Xbim.IO; | ||
using System.IO; | ||
using Xbim.XbimExtensions.Interfaces; | ||
|
||
namespace Xbim.Essentials.Tests | ||
{ | ||
[TestClass] | ||
[DeploymentItem(@"TestSourceFiles\")] | ||
public class BasicModelTests | ||
{ | ||
[TestMethod] | ||
public void OpenIfcFile() | ||
{ | ||
using (var model = new XbimModel()) | ||
{ | ||
model.CreateFrom("4walls1floorSite.ifc"); | ||
model.Close(); | ||
} | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void OpenIfcZipFile() | ||
{ | ||
using (var model = new XbimModel()) | ||
{ | ||
model.CreateFrom("4walls1floorSite.ifczip"); | ||
model.Close(); | ||
} | ||
|
||
} | ||
[TestMethod] | ||
public void OpenIfcXmlFile() | ||
{ | ||
using (var model = new XbimModel()) | ||
{ | ||
model.CreateFrom("4walls1floorSite.ifcxml"); | ||
model.Close(); | ||
} | ||
|
||
} | ||
[TestMethod] | ||
public void OpenIfcFileFromStream() | ||
{ | ||
using (var fileStream = new FileStream("4walls1floorSite.ifc", FileMode.Open,FileAccess.Read)) | ||
{ | ||
using (var model = new XbimModel()) | ||
{ | ||
model.CreateFrom(fileStream, XbimStorageType.IFC, "4walls1floorSite.xbim",null,true); | ||
model.Close(); | ||
} | ||
fileStream.Close(); | ||
} | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void OpenIfcZipFileFromStream() | ||
{ | ||
using (var fileStream = new FileStream("4walls1floorSite.ifczip", FileMode.Open, FileAccess.Read)) | ||
{ | ||
using (var model = new XbimModel()) | ||
{ | ||
model.CreateFrom(fileStream, XbimStorageType.IFC, "4walls1floorSite.xbim"); | ||
model.Close(); | ||
} | ||
fileStream.Close(); | ||
} | ||
|
||
} | ||
[TestMethod] | ||
public void OpenIfcXmlFileFromStream() | ||
{ | ||
using (var fileStream = new FileStream("4walls1floorSite.ifcxml", FileMode.Open, FileAccess.Read)) | ||
{ | ||
using (var model = new XbimModel()) | ||
{ | ||
model.CreateFrom(fileStream, XbimStorageType.IFC, "4walls1floorSite.xbim"); | ||
model.Close(); | ||
} | ||
fileStream.Close(); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Xbim.IO; | ||
using Xbim.Ifc2x3.Kernel; | ||
using Xbim.Ifc2x3.GeometryResource; | ||
using System.IO; | ||
|
||
namespace Xbim.Essentials.Tests | ||
{ | ||
[TestClass] | ||
[DeploymentItem(@"TestSourceFiles\")] | ||
public class ModelFilterTest | ||
{ | ||
[TestMethod] | ||
public void CopyAllEntitiesTest() | ||
{ | ||
using (var source = new XbimModel()) | ||
{ | ||
PropertyTranformDelegate propTransform = delegate(IfcMetaProperty prop, object toCopy) | ||
{ | ||
var value = prop.PropertyInfo.GetValue(toCopy, null); | ||
return value; | ||
}; | ||
|
||
|
||
|
||
source.Open("BIM Logo-LetterM.xBIM"); | ||
source.SaveAs("WithGeometry.ifc"); | ||
using (var target = XbimModel.CreateTemporaryModel()) | ||
{ | ||
target.AutoAddOwnerHistory = false; | ||
using (var txn = target.BeginTransaction()) | ||
{ | ||
var copied = new XbimInstanceHandleMap(source, target); | ||
|
||
foreach (var item in source.Instances) | ||
{ | ||
target.InsertCopy(item, copied, txn, propTransform); | ||
} | ||
txn.Commit(); | ||
} | ||
target.SaveAs("WithoutGeometry.ifc"); | ||
} | ||
source.Close(); | ||
//the two files should be the same | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void ExtractIfcGeometryEntitiesTest() | ||
{ | ||
using (var source = new XbimModel()) | ||
{ | ||
PropertyTranformDelegate propTransform = delegate(IfcMetaProperty prop, object toCopy) | ||
{ | ||
|
||
if (typeof(IfcProduct).IsAssignableFrom(toCopy.GetType())) | ||
{ | ||
if (prop.PropertyInfo.Name == "ObjectPlacement" || prop.PropertyInfo.Name == "Representation") | ||
return null; | ||
} | ||
if(typeof(IfcTypeProduct).IsAssignableFrom(toCopy.GetType())) | ||
{ | ||
if (prop.PropertyInfo.Name == "RepresentationMaps" ) | ||
return null; | ||
} | ||
return prop.PropertyInfo.GetValue(toCopy, null);//just pass through the value | ||
}; | ||
|
||
//source.Open("BIM Logo-LetterM.xBIM"); | ||
//source.SaveAs("WithGeometry.ifc"); | ||
string modelName = @"4walls1floorSite"; | ||
string xbimModelName = Path.ChangeExtension(modelName,"xbim"); | ||
|
||
source.CreateFrom( Path.ChangeExtension(modelName,"ifc"), null, null, true); | ||
|
||
using (var target = XbimModel.CreateModel(Path.ChangeExtension(modelName + "_NoGeom", "xbim"))) | ||
{ | ||
target.AutoAddOwnerHistory = false; | ||
using (var txn = target.BeginTransaction()) | ||
{ | ||
var copied = new XbimInstanceHandleMap(source, target); | ||
|
||
foreach (var item in source.Instances.OfType<IfcRoot>()) | ||
{ | ||
target.InsertCopy(item, copied, txn, propTransform, false); | ||
} | ||
txn.Commit(); | ||
} | ||
|
||
target.SaveAs(Path.ChangeExtension(modelName + "_NoGeom", "ifc")); | ||
target.Close(); | ||
|
||
} | ||
|
||
source.Close(); | ||
// XbimModel.Compact(Path.ChangeExtension(modelName + "_NoGeom", "xbim"), Path.ChangeExtension(modelName + "_NoGeom_Compacted", "xbim")); | ||
//the two files should be the same | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.