Search in sources :

Example 1 with IfcRelAggregates

use of org.bimserver.models.ifc2x3tc1.IfcRelAggregates in project BIMserver by opensourceBIM.

the class RichIfcModel method addDecomposes.

/**
 * Create a decomposes relationship
 *
 * @param parent The object that represents the nest or aggregation
 * @param children The objects being nested or aggregated
 * @throws IfcModelInterfaceException
 */
public void addDecomposes(IfcObjectDefinition parent, IfcObjectDefinition... children) throws IfcModelInterfaceException {
    IfcRelAggregates ifcRelAggregates = this.create(IfcRelAggregates.class);
    ifcRelAggregates.setRelatingObject(parent);
    for (IfcObjectDefinition child : children) {
        ifcRelAggregates.getRelatedObjects().add(child);
    }
}
Also used : IfcRelAggregates(org.bimserver.models.ifc2x3tc1.IfcRelAggregates) IfcObjectDefinition(org.bimserver.models.ifc2x3tc1.IfcObjectDefinition)

Example 2 with IfcRelAggregates

use of org.bimserver.models.ifc2x3tc1.IfcRelAggregates 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());
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) RichIfcModel(org.bimserver.utils.RichIfcModel) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SProject(org.bimserver.interfaces.objects.SProject) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientFactory(org.bimserver.shared.BimServerClientFactory) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) IfcBuildingStorey(org.bimserver.models.ifc2x3tc1.IfcBuildingStorey) IfcBuilding(org.bimserver.models.ifc2x3tc1.IfcBuilding) Serializer(org.bimserver.plugins.serializers.Serializer) Ifc2x3tc1StepSerializer(org.bimserver.ifc.step.serializer.Ifc2x3tc1StepSerializer) SLongCheckinActionState(org.bimserver.interfaces.objects.SLongCheckinActionState) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) Ifc2x3tc1StepSerializer(org.bimserver.ifc.step.serializer.Ifc2x3tc1StepSerializer) IfcRelAggregates(org.bimserver.models.ifc2x3tc1.IfcRelAggregates) ByteArrayInputStream(java.io.ByteArrayInputStream) FileOutputStream(java.io.FileOutputStream) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) File(java.io.File) Test(org.junit.Test)

Example 3 with IfcRelAggregates

use of org.bimserver.models.ifc2x3tc1.IfcRelAggregates 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, false);
        IfcBuilding ifcBuilding = richIfcModel.createDefaultProjectStructure(100000, 0, 0);
        double offsetX = 100000;
        IfcRelAggregates buildingAggregation = richIfcModel.create(IfcRelAggregates.class);
        buildingAggregation.setRelatingObject(ifcBuilding);
        for (int i = 1; i <= 20; 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(offsetX, 0D, i * 3000D));
            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)

Example 4 with IfcRelAggregates

use of org.bimserver.models.ifc2x3tc1.IfcRelAggregates in project BIMserver by opensourceBIM.

the class TestBigModelEmfRemote method createSpace.

private void createSpace(RichIfcModel richIfcModel, IfcRepresentationContext representationContext, IfcLocalPlacement storeyPlacement, IfcRelAggregates storeyAggregation, int x, int y, boolean doreuse) throws IfcModelInterfaceException {
    IfcSpace ifcSpace = richIfcModel.create(IfcSpace.class);
    ifcSpace.setName("Space " + ((y * 10) + x));
    ifcSpace.setCompositionType(IfcElementCompositionEnum.ELEMENT);
    ifcSpace.setInteriorOrExteriorSpace(IfcInternalOrExternalEnum.INTERNAL);
    IfcLocalPlacement spacePlacement = richIfcModel.create(IfcLocalPlacement.class);
    spacePlacement.setPlacementRelTo(storeyPlacement);
    spacePlacement.setRelativePlacement(richIfcModel.createBasicPosition(x * 6000, y * 6000, 0));
    ifcSpace.setObjectPlacement(spacePlacement);
    storeyAggregation.getRelatedObjects().add(ifcSpace);
    IfcProductRepresentation rep = null;
    if (doreuse) {
        if (this.spaceRep == null) {
            this.spaceRep = richIfcModel.createRectangularExtrusionProductRepresentation(5000, 5000, 2000);
        }
        rep = this.spaceRep;
    } else {
        rep = richIfcModel.createRectangularExtrusionProductRepresentation(5000, 5000, 2000);
    }
    ifcSpace.setRepresentation(rep);
    createFurnishing(richIfcModel, representationContext, y, ifcSpace, spacePlacement, doreuse);
}
Also used : IfcProductRepresentation(org.bimserver.models.ifc2x3tc1.IfcProductRepresentation) IfcSpace(org.bimserver.models.ifc2x3tc1.IfcSpace) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)

Example 5 with IfcRelAggregates

use of org.bimserver.models.ifc2x3tc1.IfcRelAggregates in project BIMserver by opensourceBIM.

the class TestBigModelEmf method createSpace.

private void createSpace(RichIfcModel richIfcModel, IfcRepresentationContext representationContext, IfcLocalPlacement storeyPlacement, IfcRelAggregates storeyAggregation, int x, int y) throws IfcModelInterfaceException {
    IfcSpace ifcSpace = richIfcModel.create(IfcSpace.class);
    ifcSpace.setName("Space " + ((y * 10) + x));
    ifcSpace.setCompositionType(IfcElementCompositionEnum.ELEMENT);
    ifcSpace.setInteriorOrExteriorSpace(IfcInternalOrExternalEnum.INTERNAL);
    IfcLocalPlacement spacePlacement = richIfcModel.create(IfcLocalPlacement.class);
    spacePlacement.setPlacementRelTo(storeyPlacement);
    spacePlacement.setRelativePlacement(richIfcModel.createBasicPosition(x * 6000, y * 6000, 0));
    ifcSpace.setObjectPlacement(spacePlacement);
    storeyAggregation.getRelatedObjects().add(ifcSpace);
    ifcSpace.setRepresentation(richIfcModel.createRectangularExtrusionProductRepresentation(5000, 5000, 2000));
    createFurnishing(richIfcModel, representationContext, y, ifcSpace, spacePlacement);
}
Also used : IfcSpace(org.bimserver.models.ifc2x3tc1.IfcSpace) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)

Aggregations

IfcLocalPlacement (org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)4 IfcRelAggregates (org.bimserver.models.ifc2x3tc1.IfcRelAggregates)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IfcModelInterface (org.bimserver.emf.IfcModelInterface)2 SProject (org.bimserver.interfaces.objects.SProject)2 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)2 IfcBuilding (org.bimserver.models.ifc2x3tc1.IfcBuilding)2 IfcBuildingStorey (org.bimserver.models.ifc2x3tc1.IfcBuildingStorey)2 IfcSpace (org.bimserver.models.ifc2x3tc1.IfcSpace)2 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)2 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)2 RichIfcModel (org.bimserver.utils.RichIfcModel)2 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)1 BasicIfcModel (org.bimserver.ifc.BasicIfcModel)1 Ifc2x3tc1StepSerializer (org.bimserver.ifc.step.serializer.Ifc2x3tc1StepSerializer)1 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)1