Search in sources :

Example 1 with IfcLocalPlacement

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

the class IfcTools2D method placementToMatrix.

public static double[] placementToMatrix(IfcObjectPlacement objectPlacement) {
    double[] matrix = Matrix.identity();
    if (objectPlacement instanceof IfcLocalPlacement) {
        IfcLocalPlacement ifcLocalPlacement = (IfcLocalPlacement) objectPlacement;
        IfcAxis2Placement relativePlacement = ifcLocalPlacement.getRelativePlacement();
        if (relativePlacement instanceof IfcAxis2Placement3D) {
            IfcAxis2Placement3D ifcAxis2Placement3D = (IfcAxis2Placement3D) relativePlacement;
            matrix = placement3DToMatrix(ifcAxis2Placement3D);
        }
        IfcObjectPlacement relativeTo = ifcLocalPlacement.getPlacementRelTo();
        if (relativeTo != null) {
            double[] baseMatrix = placementToMatrix(relativeTo);
            double[] rhs = matrix;
            matrix = Matrix.identity();
            Matrix.multiplyMM(matrix, 0, baseMatrix, 0, rhs, 0);
        }
    }
    return matrix;
}
Also used : IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement) IfcObjectPlacement(org.bimserver.models.ifc2x3tc1.IfcObjectPlacement) IfcAxis2Placement(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement)

Example 2 with IfcLocalPlacement

use of org.bimserver.models.ifc2x3tc1.IfcLocalPlacement 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 IfcLocalPlacement

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

the class TestBigModelEmfRemote method createFurnishing.

private void createFurnishing(RichIfcModel richIfcModel, IfcRepresentationContext representationContext, int number, IfcSpace ifcSpace, IfcLocalPlacement spacePlacement, boolean doreuse) throws IfcModelInterfaceException {
    IfcFurnishingElement furnishing = richIfcModel.create(IfcFurnishingElement.class);
    furnishing.setName("Furnishing " + number);
    IfcLocalPlacement furnishingPlacement = richIfcModel.create(IfcLocalPlacement.class);
    furnishingPlacement.setPlacementRelTo(spacePlacement);
    IfcAxis2Placement3D furnitureAxisPlacement = richIfcModel.create(IfcAxis2Placement3D.class);
    furnitureAxisPlacement.setLocation(richIfcModel.createIfcCartesianPoint(500, 500, 2));
    furnishingPlacement.setRelativePlacement(furnitureAxisPlacement);
    furnishing.setObjectPlacement(furnishingPlacement);
    IfcProductRepresentation rep = null;
    if (doreuse) {
        if (this.furnishingRep == null) {
            this.furnishingRep = richIfcModel.createRectangularExtrusionProductRepresentation(4000, 4000, 1200);
        }
        rep = this.furnishingRep;
    } else {
        rep = richIfcModel.createRectangularExtrusionProductRepresentation(4000, 4000, 1200);
    }
    furnishing.setRepresentation(rep);
    richIfcModel.addContains(ifcSpace, furnishing);
}
Also used : IfcProductRepresentation(org.bimserver.models.ifc2x3tc1.IfcProductRepresentation) IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)

Example 4 with IfcLocalPlacement

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

the class TestBigModelEmf method createFurnishing.

private void createFurnishing(RichIfcModel richIfcModel, IfcRepresentationContext representationContext, int number, IfcSpace ifcSpace, IfcLocalPlacement spacePlacement) throws IfcModelInterfaceException {
    IfcFurnishingElement furnishing = richIfcModel.create(IfcFurnishingElement.class);
    furnishing.setName("Furnishing " + number);
    IfcLocalPlacement furnishingPlacement = richIfcModel.create(IfcLocalPlacement.class);
    furnishingPlacement.setPlacementRelTo(spacePlacement);
    IfcAxis2Placement3D furnitureAxisPlacement = richIfcModel.create(IfcAxis2Placement3D.class);
    furnitureAxisPlacement.setLocation(richIfcModel.createIfcCartesianPoint(500, 500, 2));
    furnishingPlacement.setRelativePlacement(furnitureAxisPlacement);
    furnishing.setObjectPlacement(furnishingPlacement);
    furnishing.setRepresentation(richIfcModel.createRectangularExtrusionProductRepresentation(4000, 4000, 1200));
    richIfcModel.addContains(ifcSpace, furnishing);
}
Also used : IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)

Example 5 with IfcLocalPlacement

use of org.bimserver.models.ifc2x3tc1.IfcLocalPlacement 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)

Aggregations

IfcLocalPlacement (org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)10 IfcAxis2Placement3D (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D)6 IfcModelInterface (org.bimserver.emf.IfcModelInterface)4 IfcFurnishingElement (org.bimserver.models.ifc2x3tc1.IfcFurnishingElement)4 SProject (org.bimserver.interfaces.objects.SProject)3 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)3 IfcAxis2Placement (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement)3 IfcBuildingStorey (org.bimserver.models.ifc2x3tc1.IfcBuildingStorey)3 IfcCartesianPoint (org.bimserver.models.ifc2x3tc1.IfcCartesianPoint)3 IfcObjectPlacement (org.bimserver.models.ifc2x3tc1.IfcObjectPlacement)3 IfcSpace (org.bimserver.models.ifc2x3tc1.IfcSpace)3 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)3 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)3 Test (org.junit.Test)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)2 IfcBuilding (org.bimserver.models.ifc2x3tc1.IfcBuilding)2 IfcProductRepresentation (org.bimserver.models.ifc2x3tc1.IfcProductRepresentation)2 IfcRelAggregates (org.bimserver.models.ifc2x3tc1.IfcRelAggregates)2