Search in sources :

Example 1 with IfcAxis2Placement

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

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

the class IfcUtils method getAbsolutePosition.

/**
 * Not finished, does not take into account the directions
 *
 * @param ifcObjectPlacement
 * @return
 * @throws PlacementNotImplementedException
 */
public static double[] getAbsolutePosition(IfcObjectPlacement ifcObjectPlacement) throws PlacementNotImplementedException {
    if (ifcObjectPlacement instanceof IfcGridPlacement) {
        throw new PlacementNotImplementedException("IfcGridPlacement has not been implemented");
    } else if (ifcObjectPlacement instanceof IfcLocalPlacement) {
        IfcLocalPlacement ifcLocalPlacement = (IfcLocalPlacement) ifcObjectPlacement;
        IfcAxis2Placement relativePlacement = ifcLocalPlacement.getRelativePlacement();
        if (relativePlacement instanceof IfcAxis2Placement2D) {
            throw new PlacementNotImplementedException("IfcAxis2Placement2D has not been implemented");
        } else if (relativePlacement instanceof IfcAxis2Placement3D) {
            IfcAxis2Placement3D ifcAxis2Placement3D = (IfcAxis2Placement3D) relativePlacement;
            IfcObjectPlacement placementRelativeTo = ifcLocalPlacement.getPlacementRelTo();
            if (placementRelativeTo == null) {
                IfcCartesianPoint ifcCartesianPoint = ifcAxis2Placement3D.getLocation();
                return new double[] { ifcCartesianPoint.getCoordinates().get(0), ifcCartesianPoint.getCoordinates().get(1), ifcCartesianPoint.getCoordinates().get(2) };
            } else {
                double[] relative = getAbsolutePosition(placementRelativeTo);
                IfcCartesianPoint ifcCartesianPoint = ifcAxis2Placement3D.getLocation();
                return new double[] { relative[0] + ifcCartesianPoint.getCoordinates().get(0), relative[1] + ifcCartesianPoint.getCoordinates().get(1), relative[2] + ifcCartesianPoint.getCoordinates().get(2) };
            }
        }
    }
    return new double[] { 0d, 0d, 0d };
}
Also used : IfcGridPlacement(org.bimserver.models.ifc2x3tc1.IfcGridPlacement) IfcAxis2Placement2D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement2D) IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement) IfcCartesianPoint(org.bimserver.models.ifc2x3tc1.IfcCartesianPoint) IfcObjectPlacement(org.bimserver.models.ifc2x3tc1.IfcObjectPlacement) IfcAxis2Placement(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement)

Example 3 with IfcAxis2Placement

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

the class TestMoveObject method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a new project
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Get the appropriate deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
        // Checkin the file
        bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
        // Refresh project info
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, true);
        for (IfcFurnishingElement ifcFurnishingElement : model.getAllWithSubTypes(IfcFurnishingElement.class)) {
            IfcObjectPlacement objectPlacement = ifcFurnishingElement.getObjectPlacement();
            if (objectPlacement != null && objectPlacement instanceof IfcLocalPlacement) {
                IfcLocalPlacement localPlacement = (IfcLocalPlacement) objectPlacement;
                IfcAxis2Placement relativePlacement = localPlacement.getRelativePlacement();
                if (relativePlacement != null) {
                    if (relativePlacement instanceof IfcAxis2Placement3D) {
                        IfcAxis2Placement3D axis2Placement3D = (IfcAxis2Placement3D) relativePlacement;
                        IfcCartesianPoint location = axis2Placement3D.getLocation();
                        double newValue = location.getCoordinates().get(2) + 50;
                        System.out.println("Changing z value of " + ifcFurnishingElement.getName() + " from " + location.getCoordinates().get(2) + " to " + newValue);
                        location.getCoordinates().set(2, newValue);
                    }
                }
            }
        }
        long newRoid = model.commit("Moved all furniture 50 meters up");
        SSerializerPluginConfiguration ifcSerializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc");
        bimServerClient.download(newRoid, ifcSerializer.getOid(), Paths.get("movedf.ifc"));
    } catch (Throwable e) {
        e.printStackTrace();
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        fail(e.getMessage());
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SProject(org.bimserver.interfaces.objects.SProject) IfcObjectPlacement(org.bimserver.models.ifc2x3tc1.IfcObjectPlacement) URL(java.net.URL) IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement) IfcCartesianPoint(org.bimserver.models.ifc2x3tc1.IfcCartesianPoint) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) IfcAxis2Placement(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement) Test(org.junit.Test)

Aggregations

IfcAxis2Placement (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement)3 IfcAxis2Placement3D (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D)3 IfcLocalPlacement (org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)3 IfcObjectPlacement (org.bimserver.models.ifc2x3tc1.IfcObjectPlacement)3 IfcCartesianPoint (org.bimserver.models.ifc2x3tc1.IfcCartesianPoint)2 URL (java.net.URL)1 IfcModelInterface (org.bimserver.emf.IfcModelInterface)1 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)1 SProject (org.bimserver.interfaces.objects.SProject)1 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)1 IfcAxis2Placement2D (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement2D)1 IfcFurnishingElement (org.bimserver.models.ifc2x3tc1.IfcFurnishingElement)1 IfcGridPlacement (org.bimserver.models.ifc2x3tc1.IfcGridPlacement)1 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)1 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)1 Test (org.junit.Test)1