Search in sources :

Example 1 with IfcBuildingStorey

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

the class TestGetUuid method test.

@Test
public void test() throws Exception {
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) {
            SServerInfo serverInfo = client.getAdminInterface().getServerInfo();
            System.out.println(serverInfo.getServerState());
            System.out.println(serverInfo.getUuid());
            SProject project = client.getServiceInterface().addProject(RandomStringUtils.randomAlphanumeric(10), "ifc2x3tc1");
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            Path path = Paths.get("../../TestFiles/TestData/data/AC11-Institute-Var-2-IFC.ifc");
            client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, new CheckinProgressHandler() {

                @Override
                public void progress(String title, int progress) {
                    System.out.println(title + ": " + progress);
                }
            });
            project = client.getServiceInterface().getProjectByPoid(project.getOid());
            ClientIfcModel model = client.getModel(project, project.getLastRevisionId(), true, true);
            for (IfcBuildingStorey ifcBuildingStorey : model.getAll(IfcBuildingStorey.class)) {
                System.out.println(ifcBuildingStorey.getUuid() + ":" + ifcBuildingStorey.getRid());
            }
            System.out.println("Length unit: " + IfcUtils.getLengthUnitPrefix(model));
            IfcProject ifcProject = model.getAll(IfcProject.class).iterator().next();
            ifcProject.setName(ifcProject.getName() + " updated");
            long newRoid = model.commit("commit message");
            model = client.getModel(project, newRoid, true, true);
            ifcProject = model.getAll(IfcProject.class).iterator().next();
            System.out.println(ifcProject.getName());
        }
    }
    Thread.sleep(1000);
}
Also used : Path(java.nio.file.Path) IfcProject(org.bimserver.models.ifc2x3tc1.IfcProject) ClientIfcModel(org.bimserver.client.ClientIfcModel) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SProject(org.bimserver.interfaces.objects.SProject) BimServerClient(org.bimserver.client.BimServerClient) SServerInfo(org.bimserver.interfaces.objects.SServerInfo) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler) IfcBuildingStorey(org.bimserver.models.ifc2x3tc1.IfcBuildingStorey) Test(org.junit.Test)

Example 2 with IfcBuildingStorey

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

the class Scaler method scale.

public void scale(float scale) {
    if (scale != 1.0f) {
        for (long key : ifcModel.keySet()) {
            IdEObject idEObject = (IdEObject) ifcModel.get(key);
            if (idEObject instanceof IfcAsymmetricIShapeProfileDef) {
                setIfcAsymmetricIShapeProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcBlock) {
                setIfcBlock(idEObject, scale);
            } else if (idEObject instanceof IfcBoundingBox) {
                setIfcBoundingBox(idEObject, scale);
            } else if (idEObject instanceof IfcBuilding) {
                setIfcBuilding(idEObject, scale);
            } else if (idEObject instanceof IfcBuildingStorey) {
                setIfcBuildingStorey(idEObject, scale);
            } else if (idEObject instanceof IfcCartesianPoint) {
                setIfcCartesianPoint(idEObject, scale);
            } else if (idEObject instanceof IfcCenterLineProfileDef) {
                setIfcCenterLineProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcChamferEdgeFeature) {
                setIfcChamferEdgeFeature(idEObject, scale);
            } else if (idEObject instanceof IfcCircle) {
                setIfcCircle(idEObject, scale);
            } else if (idEObject instanceof IfcCircleHollowProfileDef) {
                setIfcCircleHollowProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcCircleProfileDef) {
                setIfcCircleProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcCraneRailAShapeProfileDef) {
                setIfcCraneRailAShapeProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcCraneRailFShapeProfileDef) {
                setIfcCraneRailFShapeProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcConnectionPointEccentricity) {
                setIfcConnectionPointEccentricity(idEObject, scale);
            } else if (idEObject instanceof IfcCShapeProfileDef) {
                setIfcCShapeProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcCurveStyleFontPattern) {
                setIfcCurveStyleFontPattern(idEObject, scale);
            } else if (idEObject instanceof IfcDoor) {
                setIfcDoor(idEObject, scale);
            } else if (idEObject instanceof IfcDoorLiningProperties) {
                setIfcDoorLiningProperties(idEObject, scale);
            } else if (idEObject instanceof IfcDoorPanelProperties) {
                setIfcDoorPanelProperties(idEObject, scale);
            } else if (idEObject instanceof IfcEdgeFeature) {
                setIfcEdgeFeature(idEObject, scale);
            } else if (idEObject instanceof IfcEllipse) {
                setIfcEllipse(idEObject, scale);
            } else if (idEObject instanceof IfcEllipseProfileDef) {
                setIfcEllipseProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcExtrudedAreaSolid) {
                setIfcExtrudedAreaSolid(idEObject, scale);
            } else if (idEObject instanceof IfcGeneralProfileProperties) {
                setIfcGeneralProfileProperties(idEObject, scale);
            } else if (idEObject instanceof IfcIShapeProfileDef) {
                setIfcIShapeProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcLightSourcePositional) {
                setIfcLightSourcePositional(idEObject, scale);
            } else if (idEObject instanceof IfcLShapeProfileDef) {
                setIfcLShapeProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcMaterialLayer) {
                setIfcMaterialLayer(idEObject, scale);
            } else if (idEObject instanceof IfcMaterialLayerSetUsage) {
                setIfcMaterialLayerSetUsage(idEObject, scale);
            } else if (idEObject instanceof IfcMechanicalConcreteMaterialProperties) {
                setIfcMechanicalConcreteMaterialProperties(idEObject, scale);
            } else if (idEObject instanceof IfcMechanicalFastener) {
                setIfcMechanicalFastener(idEObject, scale);
            } else if (idEObject instanceof IfcOffsetCurve2D) {
                setIfcOffsetCurve2D(idEObject, scale);
            } else if (idEObject instanceof IfcOffsetCurve3D) {
                setIfcOffsetCurve3D(idEObject, scale);
            } else if (idEObject instanceof IfcPermeableCoveringProperties) {
                setIfcPermeableCoveringProperties(idEObject, scale);
            } else if (idEObject instanceof IfcPlanarExtent) {
                setIfcPlanarExtent(idEObject, scale);
            } else if (idEObject instanceof IfcQuantityLength) {
                setIfcQuantityLength(idEObject, scale);
            } else if (idEObject instanceof IfcRectangleHollowProfileDef) {
                setIfcRectangleHollowProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcRectangleProfileDef) {
                setIfcRectangleProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcRectangularPyramid) {
                setIfcRectangularPyramid(idEObject, scale);
            } else if (idEObject instanceof IfcReinforcementBarProperties) {
                setIfcReinforcementBarProperties(idEObject, scale);
            } else if (idEObject instanceof IfcReinforcingBar) {
                setIfcReinforcingBar(idEObject, scale);
            } else if (idEObject instanceof IfcReinforcingMesh) {
                setIfcReinforcingMesh(idEObject, scale);
            } else if (idEObject instanceof IfcRelConnectsStructuralMember) {
                setIfcRelConnectsStructuralMember(idEObject, scale);
            } else if (idEObject instanceof IfcRibPlateProfileProperties) {
                setIfcRibPlateProfileProperties(idEObject, scale);
            } else if (idEObject instanceof IfcRightCircularCone) {
                setIfcRightCircularCone(idEObject, scale);
            } else if (idEObject instanceof IfcRightCircularCylinder) {
                setIfcRightCircularCylinder(idEObject, scale);
            } else if (idEObject instanceof IfcRoundedEdgeFeature) {
                setIfcRoundedEdgeFeature(idEObject, scale);
            } else if (idEObject instanceof IfcRoundedRectangleProfileDef) {
                setIfcRoundedRectangleProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcSectionReinforcementProperties) {
                setIfcSectionReinforcementProperties(idEObject, scale);
            } else if (idEObject instanceof IfcSite) {
                setIfcSite(idEObject, scale);
            } else if (idEObject instanceof IfcSlippageConnectionCondition) {
                setIfcSlippageConnectionCondition(idEObject, scale);
            } else if (idEObject instanceof IfcSpace) {
                setIfcSpace(idEObject, scale);
            } else if (idEObject instanceof IfcSphere) {
                setIfcSphere(idEObject, scale);
            } else if (idEObject instanceof IfcStairFlight) {
                setIfcStairFlight(idEObject, scale);
            } else if (idEObject instanceof IfcStructuralLoadSingleDisplacement) {
                setIfcStructuralLoadSingleDisplacement(idEObject, scale);
            } else if (idEObject instanceof IfcStructuralProfileProperties) {
                setIfcStructuralProfileProperties(idEObject, scale);
            } else if (idEObject instanceof IfcStructuralSurfaceMember) {
                setIfcStructuralSurfaceMember(idEObject, scale);
            } else if (idEObject instanceof IfcStructuralSurfaceMemberVarying) {
                setIfcStructuralSurfaceMemberVarying(idEObject, scale);
            } else if (idEObject instanceof IfcSurfaceOfLinearExtrusion) {
                setIfcSurfaceOfLinearExtrusion(idEObject, scale);
            } else if (idEObject instanceof IfcSweptDiskSolid) {
                setIfcSweptDiskSolid(idEObject, scale);
            } else if (idEObject instanceof IfcTendon) {
                setIfcTendon(idEObject, scale);
            } else if (idEObject instanceof IfcTextStyleWithBoxCharacteristics) {
                setIfcTextStyleWithBoxCharacteristics(idEObject, scale);
            } else if (idEObject instanceof IfcTrapeziumProfileDef) {
                setIfcTrapeziumProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcTShapeProfileDef) {
                setIfcTShapeProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcUShapeProfileDef) {
                setIfcUShapeProfileDef(idEObject, scale);
            } else if (idEObject instanceof IfcVector) {
                setIfcVector(idEObject, scale);
            } else if (idEObject instanceof IfcVirtualGridIntersection) {
                setIfcVirtualGridIntersection(idEObject, scale);
            } else if (idEObject instanceof IfcWindow) {
                setIfcWindow(idEObject, scale);
            } else if (idEObject instanceof IfcWindowLiningProperties) {
                setIfcWindowLiningProperties(idEObject, scale);
            } else if (idEObject instanceof IfcWindowPanelProperties) {
                setIfcWindowPanelProperties(idEObject, scale);
            } else if (idEObject instanceof IfcZShapeProfileDef) {
                setIfcZShapeProfileDef(idEObject, scale);
            }
            setDoubleAsStringValues(idEObject);
        }
    }
}
Also used : IfcCenterLineProfileDef(org.bimserver.models.ifc2x3tc1.IfcCenterLineProfileDef) IfcCircleHollowProfileDef(org.bimserver.models.ifc2x3tc1.IfcCircleHollowProfileDef) IfcQuantityLength(org.bimserver.models.ifc2x3tc1.IfcQuantityLength) IfcStructuralSurfaceMember(org.bimserver.models.ifc2x3tc1.IfcStructuralSurfaceMember) IfcReinforcementBarProperties(org.bimserver.models.ifc2x3tc1.IfcReinforcementBarProperties) IfcStairFlight(org.bimserver.models.ifc2x3tc1.IfcStairFlight) IfcRibPlateProfileProperties(org.bimserver.models.ifc2x3tc1.IfcRibPlateProfileProperties) IfcUShapeProfileDef(org.bimserver.models.ifc2x3tc1.IfcUShapeProfileDef) IfcCraneRailAShapeProfileDef(org.bimserver.models.ifc2x3tc1.IfcCraneRailAShapeProfileDef) IfcRectangleHollowProfileDef(org.bimserver.models.ifc2x3tc1.IfcRectangleHollowProfileDef) IfcStructuralSurfaceMemberVarying(org.bimserver.models.ifc2x3tc1.IfcStructuralSurfaceMemberVarying) IfcMaterialLayer(org.bimserver.models.ifc2x3tc1.IfcMaterialLayer) IfcCraneRailFShapeProfileDef(org.bimserver.models.ifc2x3tc1.IfcCraneRailFShapeProfileDef) IfcRightCircularCylinder(org.bimserver.models.ifc2x3tc1.IfcRightCircularCylinder) IfcExtrudedAreaSolid(org.bimserver.models.ifc2x3tc1.IfcExtrudedAreaSolid) IfcBuilding(org.bimserver.models.ifc2x3tc1.IfcBuilding) IfcCircle(org.bimserver.models.ifc2x3tc1.IfcCircle) IfcSurfaceOfLinearExtrusion(org.bimserver.models.ifc2x3tc1.IfcSurfaceOfLinearExtrusion) IfcCShapeProfileDef(org.bimserver.models.ifc2x3tc1.IfcCShapeProfileDef) IfcTextStyleWithBoxCharacteristics(org.bimserver.models.ifc2x3tc1.IfcTextStyleWithBoxCharacteristics) IdEObject(org.bimserver.emf.IdEObject) IfcRightCircularCone(org.bimserver.models.ifc2x3tc1.IfcRightCircularCone) IfcWindowPanelProperties(org.bimserver.models.ifc2x3tc1.IfcWindowPanelProperties) IfcLightSourcePositional(org.bimserver.models.ifc2x3tc1.IfcLightSourcePositional) IfcConnectionPointEccentricity(org.bimserver.models.ifc2x3tc1.IfcConnectionPointEccentricity) IfcRectangularPyramid(org.bimserver.models.ifc2x3tc1.IfcRectangularPyramid) IfcTendon(org.bimserver.models.ifc2x3tc1.IfcTendon) IfcReinforcingMesh(org.bimserver.models.ifc2x3tc1.IfcReinforcingMesh) IfcCircleProfileDef(org.bimserver.models.ifc2x3tc1.IfcCircleProfileDef) IfcZShapeProfileDef(org.bimserver.models.ifc2x3tc1.IfcZShapeProfileDef) IfcEllipseProfileDef(org.bimserver.models.ifc2x3tc1.IfcEllipseProfileDef) IfcBoundingBox(org.bimserver.models.ifc2x3tc1.IfcBoundingBox) IfcIShapeProfileDef(org.bimserver.models.ifc2x3tc1.IfcIShapeProfileDef) IfcVirtualGridIntersection(org.bimserver.models.ifc2x3tc1.IfcVirtualGridIntersection) IfcAsymmetricIShapeProfileDef(org.bimserver.models.ifc2x3tc1.IfcAsymmetricIShapeProfileDef) IfcRelConnectsStructuralMember(org.bimserver.models.ifc2x3tc1.IfcRelConnectsStructuralMember) IfcDoorPanelProperties(org.bimserver.models.ifc2x3tc1.IfcDoorPanelProperties) IfcOffsetCurve2D(org.bimserver.models.ifc2x3tc1.IfcOffsetCurve2D) IfcChamferEdgeFeature(org.bimserver.models.ifc2x3tc1.IfcChamferEdgeFeature) IfcMechanicalFastener(org.bimserver.models.ifc2x3tc1.IfcMechanicalFastener) IfcRectangleProfileDef(org.bimserver.models.ifc2x3tc1.IfcRectangleProfileDef) IfcRoundedRectangleProfileDef(org.bimserver.models.ifc2x3tc1.IfcRoundedRectangleProfileDef) IfcSpace(org.bimserver.models.ifc2x3tc1.IfcSpace) IfcBlock(org.bimserver.models.ifc2x3tc1.IfcBlock) IfcLShapeProfileDef(org.bimserver.models.ifc2x3tc1.IfcLShapeProfileDef) IfcTrapeziumProfileDef(org.bimserver.models.ifc2x3tc1.IfcTrapeziumProfileDef) IfcSweptDiskSolid(org.bimserver.models.ifc2x3tc1.IfcSweptDiskSolid) IfcWindowLiningProperties(org.bimserver.models.ifc2x3tc1.IfcWindowLiningProperties) IfcBuildingStorey(org.bimserver.models.ifc2x3tc1.IfcBuildingStorey) IfcDoor(org.bimserver.models.ifc2x3tc1.IfcDoor) IfcDoorLiningProperties(org.bimserver.models.ifc2x3tc1.IfcDoorLiningProperties) IfcMaterialLayerSetUsage(org.bimserver.models.ifc2x3tc1.IfcMaterialLayerSetUsage) IfcTShapeProfileDef(org.bimserver.models.ifc2x3tc1.IfcTShapeProfileDef) IfcCurveStyleFontPattern(org.bimserver.models.ifc2x3tc1.IfcCurveStyleFontPattern) IfcSlippageConnectionCondition(org.bimserver.models.ifc2x3tc1.IfcSlippageConnectionCondition) IfcSite(org.bimserver.models.ifc2x3tc1.IfcSite) IfcWindow(org.bimserver.models.ifc2x3tc1.IfcWindow) IfcReinforcingBar(org.bimserver.models.ifc2x3tc1.IfcReinforcingBar) IfcEdgeFeature(org.bimserver.models.ifc2x3tc1.IfcEdgeFeature) IfcGeneralProfileProperties(org.bimserver.models.ifc2x3tc1.IfcGeneralProfileProperties) IfcPermeableCoveringProperties(org.bimserver.models.ifc2x3tc1.IfcPermeableCoveringProperties) IfcRoundedEdgeFeature(org.bimserver.models.ifc2x3tc1.IfcRoundedEdgeFeature) IfcVector(org.bimserver.models.ifc2x3tc1.IfcVector) IfcStructuralProfileProperties(org.bimserver.models.ifc2x3tc1.IfcStructuralProfileProperties) IfcOffsetCurve3D(org.bimserver.models.ifc2x3tc1.IfcOffsetCurve3D) IfcStructuralLoadSingleDisplacement(org.bimserver.models.ifc2x3tc1.IfcStructuralLoadSingleDisplacement) IfcSphere(org.bimserver.models.ifc2x3tc1.IfcSphere) IfcPlanarExtent(org.bimserver.models.ifc2x3tc1.IfcPlanarExtent) IfcCartesianPoint(org.bimserver.models.ifc2x3tc1.IfcCartesianPoint) IfcMechanicalConcreteMaterialProperties(org.bimserver.models.ifc2x3tc1.IfcMechanicalConcreteMaterialProperties) IfcEllipse(org.bimserver.models.ifc2x3tc1.IfcEllipse) IfcSectionReinforcementProperties(org.bimserver.models.ifc2x3tc1.IfcSectionReinforcementProperties)

Example 3 with IfcBuildingStorey

use of org.bimserver.models.ifc2x3tc1.IfcBuildingStorey 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 4 with IfcBuildingStorey

use of org.bimserver.models.ifc2x3tc1.IfcBuildingStorey 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 5 with IfcBuildingStorey

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

the class AddFurniture method main.

public static void main(String[] args) {
    try {
        PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
        DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
        Deserializer deserializer = deserializerPlugin.createDeserializer(null);
        deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
        IfcModelInterface model = DeserializerUtils.readFromFile(deserializer, Paths.get("../TestData/data/AC9R1-Haus-G-H-Ver2-2x3.ifc"));
        deserializer = deserializerPlugin.createDeserializer(null);
        deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
        IfcModelInterface furnishingModel = DeserializerUtils.readFromFile(deserializer, Paths.get("test.ifc"));
        model.fixOids(new IncrementingOidProvider());
        long oid = model.getHighestOid();
        IncrementingOidProvider oidProvider = new IncrementingOidProvider(oid + 1);
        IfcFurnishingElement picknick = (IfcFurnishingElement) furnishingModel.getByName(Ifc2x3tc1Package.eINSTANCE.getIfcFurnishingElement(), "Picknik Bank");
        ModelHelper modelHelper = new ModelHelper(pluginManager.getMetaDataManager(), model);
        IfcProductDefinitionShape representation = (IfcProductDefinitionShape) picknick.getRepresentation();
        IfcRepresentation surfaceModel = null;
        IfcRepresentation boundingBox = null;
        for (IfcRepresentation ifcRepresentation : representation.getRepresentations()) {
            IfcShapeRepresentation ifcShapeRepresentation = (IfcShapeRepresentation) ifcRepresentation;
            if (ifcShapeRepresentation.getRepresentationType().equals("SurfaceModel")) {
                surfaceModel = (IfcRepresentation) modelHelper.copy(ifcShapeRepresentation, false);
            } else if (ifcShapeRepresentation.getRepresentationType().equals("BoundingBox")) {
                boundingBox = (IfcRepresentation) modelHelper.copy(ifcShapeRepresentation, false);
            }
        }
        IfcOwnerHistory ownerHistory = null;
        List<IfcOwnerHistory> all = model.getAll(IfcOwnerHistory.class);
        if (all.size() > 0) {
            ownerHistory = all.get(0);
        }
        for (IfcBuildingStorey ifcBuildingStorey : model.getAll(IfcBuildingStorey.class)) {
            for (IfcRelDecomposes ifcRelDecomposes : ifcBuildingStorey.getIsDecomposedBy()) {
                for (IfcObjectDefinition ifcObjectDefinition : ifcRelDecomposes.getRelatedObjects()) {
                    if (ifcObjectDefinition instanceof IfcSpace) {
                        IfcSpace ifcSpace = (IfcSpace) ifcObjectDefinition;
                        // IfcProductDefinitionShape slabRepr = (IfcProductDefinitionShape) ifcSpace.getRepresentation();
                        // IfcBoundingBox box = null;
                        // for (IfcRepresentation representation2 : slabRepr.getRepresentations()) {
                        // IfcShapeRepresentation shapeRepresentation = (IfcShapeRepresentation)representation2;
                        // if (shapeRepresentation.getRepresentationType().equals("BoundingBox")) {
                        // for (IfcRepresentationItem i2 : shapeRepresentation.getItems()) {
                        // box = (IfcBoundingBox)i2;
                        // }
                        // }
                        // }
                        IfcFurnishingElement newFurnishing = model.create(IfcFurnishingElement.class, oidProvider);
                        IfcRelContainedInSpatialStructure containedInSpatialStructure2 = model.create(IfcRelContainedInSpatialStructure.class, oidProvider);
                        containedInSpatialStructure2.setRelatingStructure(ifcBuildingStorey);
                        containedInSpatialStructure2.getRelatedElements().add(newFurnishing);
                        newFurnishing.setName("Generated");
                        newFurnishing.setGlobalId("TEST");
                        newFurnishing.setOwnerHistory(ownerHistory);
                        IfcProductDefinitionShape definitionShape = model.create(IfcProductDefinitionShape.class, oidProvider);
                        newFurnishing.setRepresentation(definitionShape);
                        definitionShape.getRepresentations().add(boundingBox);
                        definitionShape.getRepresentations().add(surfaceModel);
                        IfcLocalPlacement localPlacement = model.create(IfcLocalPlacement.class, oidProvider);
                        localPlacement.setPlacementRelTo(ifcSpace.getObjectPlacement());
                        IfcAxis2Placement3D axis2Placement3D = model.create(IfcAxis2Placement3D.class, oidProvider);
                        localPlacement.setRelativePlacement(axis2Placement3D);
                        IfcCartesianPoint pos = model.create(IfcCartesianPoint.class, oidProvider);
                        pos.getCoordinates().add(-3d);
                        pos.getCoordinates().add(+0.5d);
                        pos.getCoordinates().add(0d);
                        axis2Placement3D.setLocation(pos);
                        newFurnishing.setObjectPlacement(localPlacement);
                    }
                }
            }
        }
        model.resetExpressIds();
        SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true);
        Serializer serializer = serializerPlugin.createSerializer(null);
        serializer.init(model, null, true);
        SerializerUtils.writeToFile(serializer, Paths.get("withfurn.ifc"));
    } catch (PluginException e) {
        e.printStackTrace();
    } catch (DeserializeException e) {
        e.printStackTrace();
    } catch (IfcModelInterfaceException e) {
        e.printStackTrace();
    } catch (SerializerException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : IfcModelInterface(org.bimserver.emf.IfcModelInterface) IfcObjectDefinition(org.bimserver.models.ifc2x3tc1.IfcObjectDefinition) IfcSpace(org.bimserver.models.ifc2x3tc1.IfcSpace) FileNotFoundException(java.io.FileNotFoundException) IfcOwnerHistory(org.bimserver.models.ifc2x3tc1.IfcOwnerHistory) PluginManager(org.bimserver.plugins.PluginManager) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) IfcProductDefinitionShape(org.bimserver.models.ifc2x3tc1.IfcProductDefinitionShape) IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement) IncrementingOidProvider(org.bimserver.shared.IncrementingOidProvider) IfcShapeRepresentation(org.bimserver.models.ifc2x3tc1.IfcShapeRepresentation) IfcRepresentation(org.bimserver.models.ifc2x3tc1.IfcRepresentation) IfcBuildingStorey(org.bimserver.models.ifc2x3tc1.IfcBuildingStorey) Serializer(org.bimserver.plugins.serializers.Serializer) ModelHelper(org.bimserver.plugins.ModelHelper) IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) IOException(java.io.IOException) SerializerException(org.bimserver.plugins.serializers.SerializerException) IfcRelDecomposes(org.bimserver.models.ifc2x3tc1.IfcRelDecomposes) Deserializer(org.bimserver.plugins.deserializers.Deserializer) IfcCartesianPoint(org.bimserver.models.ifc2x3tc1.IfcCartesianPoint) IfcRelContainedInSpatialStructure(org.bimserver.models.ifc2x3tc1.IfcRelContainedInSpatialStructure)

Aggregations

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