Search in sources :

Example 1 with RichIfcModel

use of org.bimserver.utils.RichIfcModel in project BIMserver by opensourceBIM.

the class TestBigModelEmf method test.

@Test
public void test() {
    try {
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        IfcModelInterface model = bimServerClient.newModel(newProject, true);
        RichIfcModel richIfcModel = new RichIfcModel(model);
        IfcBuilding ifcBuilding = richIfcModel.createDefaultProjectStructure();
        IfcRelAggregates buildingAggregation = richIfcModel.create(IfcRelAggregates.class);
        buildingAggregation.setRelatingObject(ifcBuilding);
        for (int i = 1; i <= 10; 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 <= 10; x++) {
                for (int y = 1; y <= 10; y++) {
                    createSpace(richIfcModel, richIfcModel.getDefaultRepresentationContext(), storeyPlacement, storeyAggregation, x, y);
                }
            }
        }
        long roid = model.commit("Initial model");
        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());
    }
}
Also used : RichIfcModel(org.bimserver.utils.RichIfcModel) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SProject(org.bimserver.interfaces.objects.SProject) IfcRelAggregates(org.bimserver.models.ifc2x3tc1.IfcRelAggregates) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement) FileOutputStream(java.io.FileOutputStream) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) IfcBuildingStorey(org.bimserver.models.ifc2x3tc1.IfcBuildingStorey) File(java.io.File) IfcBuilding(org.bimserver.models.ifc2x3tc1.IfcBuilding) Test(org.junit.Test)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IfcModelInterface (org.bimserver.emf.IfcModelInterface)1 SProject (org.bimserver.interfaces.objects.SProject)1 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)1 IfcBuilding (org.bimserver.models.ifc2x3tc1.IfcBuilding)1 IfcBuildingStorey (org.bimserver.models.ifc2x3tc1.IfcBuildingStorey)1 IfcLocalPlacement (org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)1 IfcRelAggregates (org.bimserver.models.ifc2x3tc1.IfcRelAggregates)1 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)1 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)1 RichIfcModel (org.bimserver.utils.RichIfcModel)1 Test (org.junit.Test)1