Search in sources :

Example 6 with Vector3f

use of org.bimserver.models.geometry.Vector3f in project BIMserver by opensourceBIM.

the class TestGeometry method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Get the low level interface
        LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
        // Create a new project
        SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Look for a deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
        // Checkin file
        long start = System.nanoTime();
        bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
        // bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, Paths.get("D:\\Dropbox\\Shared\\IFC files\\ArenA 2014\\3D IFC\\arena.ifc"));
        long end = System.nanoTime();
        System.out.println(((end - start) / 1000000) + " ms");
        // Refresh project
        project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
        int nrTriangles = 0;
        // Load model without lazy loading (complete model at once)
        IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), true, true, true);
        Assert.assertNotNull(model.getModelMetaData().getMinBounds());
        Assert.assertNotNull(model.getModelMetaData().getMaxBounds());
        for (IfcProduct ifcProduct : model.getAllWithSubTypes(IfcProduct.class)) {
            GeometryInfo geometryInfo = ifcProduct.getGeometry();
            if (geometryInfo != null) {
                Vector3f minBounds = geometryInfo.getMinBounds();
                Vector3f maxBounds = geometryInfo.getMinBounds();
                Assert.assertNotNull(minBounds);
                Assert.assertNotNull(maxBounds);
                nrTriangles += geometryInfo.getPrimitiveCount();
            }
        }
        Assert.assertEquals(45260, nrTriangles);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SProject(org.bimserver.interfaces.objects.SProject) URL(java.net.URL) Vector3f(org.bimserver.models.geometry.Vector3f) GeometryInfo(org.bimserver.models.geometry.GeometryInfo) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) IfcProduct(org.bimserver.models.ifc2x3tc1.IfcProduct) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) Test(org.junit.Test)

Example 7 with Vector3f

use of org.bimserver.models.geometry.Vector3f in project BIMserver by opensourceBIM.

the class OfflineGeometryGenerator method createVector3f.

private Vector3f createVector3f(PackageMetaData packageMetaData, IfcModelInterface model, double defaultValue) throws BimserverDatabaseException, IfcModelInterfaceException {
    Vector3f vector3f = null;
    vector3f = GeometryFactory.eINSTANCE.createVector3f();
    vector3f.setX(defaultValue);
    vector3f.setY(defaultValue);
    vector3f.setZ(defaultValue);
    return vector3f;
}
Also used : Vector3f(org.bimserver.models.geometry.Vector3f)

Example 8 with Vector3f

use of org.bimserver.models.geometry.Vector3f in project BIMserver by opensourceBIM.

the class GeometryGenerator method processExtendsUntranslated.

private void processExtendsUntranslated(GeometryInfo geometryInfo, float[] vertices, int index, GenerateGeometryResult generateGeometryResult2) throws BimserverDatabaseException {
    double x = vertices[index];
    double y = vertices[index + 1];
    double z = vertices[index + 2];
    Vector3f minBounds = geometryInfo.getMinBoundsUntranslated();
    Vector3f maxBounds = geometryInfo.getMaxBoundsUntranslated();
    minBounds.setX(Math.min(x, (double) minBounds.getX()));
    minBounds.setY(Math.min(y, (double) minBounds.getY()));
    minBounds.setZ(Math.min(z, (double) minBounds.getZ()));
    maxBounds.setX(Math.max(x, (double) maxBounds.getX()));
    maxBounds.setY(Math.max(y, (double) maxBounds.getY()));
    maxBounds.setZ(Math.max(z, (double) maxBounds.getZ()));
}
Also used : Vector3f(org.bimserver.models.geometry.Vector3f)

Aggregations

Vector3f (org.bimserver.models.geometry.Vector3f)8 GeometryInfo (org.bimserver.models.geometry.GeometryInfo)2 URL (java.net.URL)1 IdEObject (org.bimserver.emf.IdEObject)1 IfcModelInterface (org.bimserver.emf.IfcModelInterface)1 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)1 SProject (org.bimserver.interfaces.objects.SProject)1 GeometryData (org.bimserver.models.geometry.GeometryData)1 IfcProduct (org.bimserver.models.ifc2x3tc1.IfcProduct)1 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)1 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)1 LowLevelInterface (org.bimserver.shared.interfaces.LowLevelInterface)1 EClass (org.eclipse.emf.ecore.EClass)1 Test (org.junit.Test)1