use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class TestGeometry method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Get the low level interface
LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
// Create a new project
SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
// Checkin file
long start = System.nanoTime();
bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, Paths.get("D:\\Dropbox\\Shared\\IFC files\\ArenA 2014\\3D IFC\\arena.ifc"));
long end = System.nanoTime();
System.out.println(((end - start) / 1000000) + " ms");
// Refresh project
project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
int nrTriangles = 0;
// Load model without lazy loading (complete model at once)
IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), true, true, true);
Assert.assertNotNull(model.getModelMetaData().getMinBounds());
Assert.assertNotNull(model.getModelMetaData().getMaxBounds());
for (IfcProduct ifcProduct : model.getAllWithSubTypes(IfcProduct.class)) {
GeometryInfo geometryInfo = ifcProduct.getGeometry();
if (geometryInfo != null) {
Vector3f minBounds = geometryInfo.getMinBounds();
Vector3f maxBounds = geometryInfo.getMinBounds();
Assert.assertNotNull(minBounds);
Assert.assertNotNull(maxBounds);
nrTriangles += geometryInfo.getPrimitiveCount();
}
}
Assert.assertEquals(45260, nrTriangles);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class TestCompare method testIfc2x3tc1Name.
@Test
public void testIfc2x3tc1Name() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a new project
SProject newProject1 = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
SProject newProject2 = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Get the appropriate deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject1.getOid());
SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1");
// Checkin the file
bimServerClient.checkin(newProject1.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/compare_by_guid_rev_1.ifc"));
bimServerClient.checkin(newProject2.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/compare_by_guid_rev_2.ifc"));
newProject1 = bimServerClient.getServiceInterface().getProjectByPoid(newProject1.getOid());
newProject2 = bimServerClient.getServiceInterface().getProjectByPoid(newProject2.getOid());
SModelComparePluginConfiguration defaultModelCompare = bimServerClient.getPluginInterface().getModelCompareByName("Name based");
bimServerClient.getServiceInterface().compare(newProject1.getLastRevisionId(), newProject2.getLastRevisionId(), SCompareType.ALL, defaultModelCompare.getOid());
Long topicId = bimServerClient.getServiceInterface().downloadCompareResults(serializer.getOid(), newProject1.getLastRevisionId(), newProject2.getLastRevisionId(), defaultModelCompare.getOid(), SCompareType.ALL, true);
bimServerClient.saveDownloadData(topicId, Paths.get("tmptestdata/ifc2x3tc1namecompare.ifc"));
} catch (Throwable e) {
e.printStackTrace();
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class ImportLargeProject method main.
public static void main(String[] args) {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
try {
Path baseFolder = Paths.get("C:\\Users\\Ruben de Laat\\Documents\\ttt");
ServiceInterface serviceInterface = client.getServiceInterface();
SProject mainProject = serviceInterface.addProject("Tekla Demo Model", "ifc2x3tc1");
SProject architectural = serviceInterface.addProjectAsSubProject("Architectural", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHouseArchitectural = serviceInterface.addProjectAsSubProject("Tekla House Architectural", architectural.getOid(), "ifc2x3tc1");
SProject structuralSteal = serviceInterface.addProjectAsSubProject("Structural Steal", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHouseStructural = serviceInterface.addProjectAsSubProject("Tekla House Structural", structuralSteal.getOid(), "ifc2x3tc1");
SProject foundation = serviceInterface.addProjectAsSubProject("Foundation", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHouseFoundationFootings = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Footings", foundation.getOid(), "ifc2x3tc1");
SProject teklaHouseFoundationPiles = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Piles", foundation.getOid(), "ifc2x3tc1");
SProject teklaHouseFoundationRebars = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Rebars", foundation.getOid(), "ifc2x3tc1");
SProject teklaHouseFoundationEmbedments = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Embedments", foundation.getOid(), "ifc2x3tc1");
SProject cipConcreteContractor = serviceInterface.addProjectAsSubProject("CIP Concrete Contractor", mainProject.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Tekla House CIP Pours", cipConcreteContractor.getOid(), "ifc2x3tc1");
SProject teklaHouseCIPRebars = serviceInterface.addProjectAsSubProject("Tekla House CIP Rebars", cipConcreteContractor.getOid(), "ifc2x3tc1");
SProject teklaHouseCIPColumns = serviceInterface.addProjectAsSubProject("Tekla House CIP Columns", cipConcreteContractor.getOid(), "ifc2x3tc1");
SProject formWork = serviceInterface.addProjectAsSubProject("Formwork", mainProject.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Column Formwork", formWork.getOid(), "ifc2x3tc1");
SProject precast = serviceInterface.addProjectAsSubProject("Precast", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHousePrecastRebars = serviceInterface.addProjectAsSubProject("Tekla House Precast Rebars", precast.getOid(), "ifc2x3tc1");
SProject teklaHousePrecastConcrete = serviceInterface.addProjectAsSubProject("Tekla House Precast Concrete", precast.getOid(), "ifc2x3tc1");
SProject mep = serviceInterface.addProjectAsSubProject("MEP", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHouseMEPGround = serviceInterface.addProjectAsSubProject("Teklas House MEP, Ground", mep.getOid(), "ifc2x3tc1");
SProject teklaHouseMEP1 = serviceInterface.addProjectAsSubProject("Tekla House MEP, 1st", mep.getOid(), "ifc2x3tc1");
SProject teklaHouseMEP2 = serviceInterface.addProjectAsSubProject("Tekla House MEP, 2nd", mep.getOid(), "ifc2x3tc1");
SProject teklaHouseMEP3 = serviceInterface.addProjectAsSubProject("Tekla House MEP, 3rd", mep.getOid(), "ifc2x3tc1");
SProject teklaHouseMEPRoof = serviceInterface.addProjectAsSubProject("Tekla House MEP, Roof", mep.getOid(), "ifc2x3tc1");
SProject site = serviceInterface.addProjectAsSubProject("Site", mainProject.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Site.skp", site.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Tower crane", site.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Caterpillar", site.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Excavator", site.getOid(), "ifc2x3tc1");
SProject grid = serviceInterface.addProjectAsSubProject("Grid", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHouseGrids = serviceInterface.addProjectAsSubProject("Tekla House Grids", grid.getOid(), "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", grid.getOid());
client.checkin(teklaHouseStructural.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Structural.ifcZIP"));
client.checkin(teklaHouseGrids.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Grids.ifc"));
client.checkin(teklaHouseFoundationFootings.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Footings.ifcZIP"));
client.checkin(teklaHouseFoundationPiles.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Piles.ifcZIP"));
client.checkin(teklaHouseFoundationRebars.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Rebars.ifcZIP"));
client.checkin(teklaHouseFoundationEmbedments.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Embedments.ifcZIP"));
client.checkin(teklaHousePrecastRebars.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Precast Rebars.ifcZIP"));
client.checkin(teklaHousePrecastConcrete.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Precast Concrete.ifcZIP"));
// client.checkin(teklaHouseCIPPours.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder, "Tekla House CIP Pours.ifc"));
client.checkin(teklaHouseCIPRebars.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House CIP Rebars.ifcZIP"));
client.checkin(teklaHouseCIPColumns.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House CIP Columns.ifcZIP"));
client.checkin(teklaHouseArchitectural.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Architectural.ifczip"));
client.checkin(teklaHouseMEPGround.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, Ground.ifc"));
client.checkin(teklaHouseMEP1.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, 1st.ifc"));
client.checkin(teklaHouseMEP2.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, 2nd.ifc"));
client.checkin(teklaHouseMEP3.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, 3rd.ifc"));
client.checkin(teklaHouseMEPRoof.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, Roof.ifc"));
mainProject = serviceInterface.getProjectByPoid(mainProject.getOid());
SSerializerPluginConfiguration serializer = client.getServiceInterface().getSerializerByContentType("application/ifc");
client.download(mainProject.getLastRevisionId(), serializer.getOid(), Paths.get("output.ifc"));
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
e.printStackTrace();
}
}
use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class TestCreateProperties method test.
@Test
public void test() {
try {
// New client
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a project
SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// Refresh project
project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
// Load model without lazy loading (complete model at once)
IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), true, true);
String propertyName = "BooleanProperty";
int nrWindowsFirst = 0;
// Iterate over all projects, there should be 1
for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
nrWindowsFirst++;
createProperty(window, model, propertyName, "Description of property", true);
}
long newRoid = model.commit("Added boolean properties to " + nrWindowsFirst + " windows");
model = bimServerClient.getModel(project, newRoid, true, false);
int foundOke = 0;
int nrWindowsSecond = 0;
Set<Long> counted = new HashSet<Long>();
for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
nrWindowsSecond++;
for (IfcRelDefines ifcRelDefines : window.getIsDefinedBy()) {
if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines;
IfcPropertySetDefinition relatingPropertyDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition();
if (relatingPropertyDefinition instanceof IfcPropertySet) {
IfcPropertySet ifcPropertySet = (IfcPropertySet) relatingPropertyDefinition;
for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) {
if (ifcProperty instanceof IfcPropertySingleValue) {
IfcPropertySingleValue ifcPropertySingleValue = (IfcPropertySingleValue) ifcProperty;
if (ifcPropertySingleValue.getName().equals(propertyName)) {
IfcValue nominalValue = ifcPropertySingleValue.getNominalValue();
if (nominalValue instanceof IfcBoolean) {
if (((IfcBoolean) nominalValue).getWrappedValue() == Tristate.TRUE) {
if (!counted.contains(ifcPropertySingleValue.getOid())) {
foundOke++;
counted.add(ifcPropertySingleValue.getOid());
}
}
}
}
}
}
}
}
}
}
LOGGER.info("Windows first: " + nrWindowsFirst);
LOGGER.info("Windows second: " + nrWindowsSecond);
LOGGER.info("Found Oke: " + foundOke);
if (foundOke != nrWindowsFirst) {
fail(foundOke + " / " + nrWindowsFirst);
}
} catch (Throwable e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class TestReadProperties method test.
@Test
public void test() {
try {
// New client
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a project
SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
// Checkin file
bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// Refresh project
project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
// Load model without lazy loading (complete model at once)
IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), true, false);
// Iterate over all projects, there should be 1
for (IfcProject ifcProject : model.getAllWithSubTypes(IfcProject.class)) {
for (IfcRelDefines ifcRelDefines : ifcProject.getIsDefinedBy()) {
if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines;
IfcPropertySetDefinition relatingPropertyDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition();
if (relatingPropertyDefinition instanceof IfcPropertySet) {
IfcPropertySet ifcPropertySet = (IfcPropertySet) relatingPropertyDefinition;
for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) {
if (ifcProperty instanceof IfcPropertySingleValue) {
IfcPropertySingleValue ifcPropertySingleValue = (IfcPropertySingleValue) ifcProperty;
IfcValue nominalValue = ifcPropertySingleValue.getNominalValue();
String stringValue = "";
if (nominalValue instanceof IfcLabel) {
stringValue = ((IfcLabel) nominalValue).getWrappedValue();
} else if (nominalValue instanceof IfcIdentifier) {
stringValue = ((IfcIdentifier) nominalValue).getWrappedValue();
} else if (nominalValue instanceof IfcAreaMeasure) {
stringValue = "" + ((IfcAreaMeasure) nominalValue).getWrappedValue();
}
if (ifcPropertySingleValue.getName().equals("ConstructionMode")) {
if (!stringValue.equals("Massivbau")) {
fail("Massivbau expected");
}
} else if (ifcPropertySingleValue.getName().equals("BuildingPermitId")) {
if (!stringValue.equals("4711")) {
fail("4711 expected");
}
} else if (ifcPropertySingleValue.getName().equals("GrossAreaPlanned")) {
if (stringValue == null || !stringValue.equals("1000.0")) {
fail("1000. expected");
}
}
System.out.println(ifcPropertySingleValue.getName() + ": " + stringValue);
}
}
}
}
}
}
} catch (Throwable e) {
if (!(e instanceof AssertionError)) {
fail(e.getMessage());
}
}
}
Aggregations