use of org.bimserver.ifc.step.serializer.Ifc2x3tc1StepSerializer in project BIMserver by opensourceBIM.
the class TestBigModelEmfRemote method test.
@Test
public void test() {
boolean doreuse = true;
boolean useLowLevelCalls = false;
try (BimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
BimServerClientInterface bimServerClient = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
IfcModelInterface model = null;
if (useLowLevelCalls) {
model = bimServerClient.newModel(newProject, true);
} else {
model = new BasicIfcModel(bimServerClient.getMetaDataManager().getPackageMetaData("ifc2x3tc1"), null);
}
RichIfcModel richIfcModel = new RichIfcModel(model, !useLowLevelCalls);
IfcBuilding ifcBuilding = richIfcModel.createDefaultProjectStructure(0, 0, 0);
IfcRelAggregates buildingAggregation = richIfcModel.create(IfcRelAggregates.class);
buildingAggregation.setRelatingObject(ifcBuilding);
for (int i = 1; i <= 200; i++) {
IfcBuildingStorey ifcBuildingStorey = richIfcModel.create(IfcBuildingStorey.class);
ifcBuildingStorey.setName("Storey " + i);
ifcBuildingStorey.setCompositionType(IfcElementCompositionEnum.ELEMENT);
ifcBuildingStorey.setElevation(3000 * i);
IfcLocalPlacement storeyPlacement = richIfcModel.create(IfcLocalPlacement.class);
storeyPlacement.setRelativePlacement(richIfcModel.createBasicPosition(0, 0, i * 3000));
ifcBuildingStorey.setObjectPlacement(storeyPlacement);
buildingAggregation.getRelatedObjects().add(ifcBuildingStorey);
IfcRelAggregates storeyAggregation = richIfcModel.create(IfcRelAggregates.class);
storeyAggregation.setRelatingObject(ifcBuildingStorey);
for (int x = 1; x <= 40; x++) {
for (int y = 1; y <= 40; y++) {
createSpace(richIfcModel, richIfcModel.getDefaultRepresentationContext(), storeyPlacement, storeyAggregation, x, y, doreuse);
}
}
}
long roid = -1;
if (useLowLevelCalls) {
roid = model.commit("Initial model");
} else {
Serializer serializer = new Ifc2x3tc1StepSerializer(null);
serializer.init(model, null, true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
serializer.writeToOutputStream(baos, null);
java.nio.file.Files.write(Paths.get("tmp.ifc"), baos.toByteArray());
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
SLongCheckinActionState checkinSync = bimServerClient.checkinSync(newProject.getOid(), "New", deserializer.getOid(), false, baos.size(), "newfile", new ByteArrayInputStream(baos.toByteArray()));
roid = checkinSync.getRoid();
}
SSerializerPluginConfiguration serializerByContentType = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1 (Streaming)");
bimServerClient.download(roid, serializerByContentType.getOid(), new FileOutputStream(new File("created.ifc")));
} catch (Throwable e) {
e.printStackTrace();
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
Aggregations