Search in sources :

Example 1 with SVector3f

use of org.bimserver.interfaces.objects.SVector3f in project BIMserver by opensourceBIM.

the class Region method toSBounds.

public SBounds toSBounds() {
    SBounds sBounds = new SBounds();
    SVector3f min = new SVector3f();
    SVector3f max = new SVector3f();
    min.setX(this.min[0]);
    min.setY(this.min[1]);
    min.setZ(this.min[2]);
    max.setX(this.max[0]);
    max.setY(this.max[1]);
    max.setZ(this.max[2]);
    sBounds.setMin(min);
    sBounds.setMax(max);
    return sBounds;
}
Also used : SBounds(org.bimserver.interfaces.objects.SBounds) SVector3f(org.bimserver.interfaces.objects.SVector3f)

Example 2 with SVector3f

use of org.bimserver.interfaces.objects.SVector3f in project BIMserver by opensourceBIM.

the class TestSetWrappedIntegerGeometry method test.

@Test
public void test() {
    try {
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        bimServerClient.getSettingsInterface().setCacheOutputFiles(false);
        LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        SDeserializerPluginConfiguration suggestedDeserializerForExtension = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
        bimServerClient.checkinSync(newProject.getOid(), "initial", suggestedDeserializerForExtension.getOid(), false, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/revit_quantities.ifc"));
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1 (Streaming)");
        bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test1.ifc"));
        IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, false);
        long tid = lowLevelInterface.startTransaction(newProject.getOid());
        IfcPropertySingleValue ifcPropertySingleValue = model.getAll(IfcPropertySingleValue.class).iterator().next();
        bimServerClient.getLowLevelInterface().setWrappedLongAttribute(tid, ifcPropertySingleValue.getOid(), "NominalValue", "IfcInteger", 12345L);
        long roid = lowLevelInterface.commitTransaction(tid, "v2", false);
        IfcModelInterface newModel = bimServerClient.getModel(newProject, roid, true, false, true);
        SVector3f minBounds = newModel.getModelMetaData().getMinBounds();
        SVector3f maxBounds = newModel.getModelMetaData().getMaxBounds();
        org.junit.Assert.assertNotNull(minBounds);
        org.junit.Assert.assertNotNull(maxBounds);
        bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test2.ifc"));
        bimServerClient.download(roid, serializer.getOid(), Paths.get("test3.ifc"));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SVector3f(org.bimserver.interfaces.objects.SVector3f) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) URL(java.net.URL) Test(org.junit.Test)

Example 3 with SVector3f

use of org.bimserver.interfaces.objects.SVector3f in project BIMserver by opensourceBIM.

the class ServiceImpl method getTotalUntransformedBounds.

@Override
public SBounds getTotalUntransformedBounds(Set<Long> roids) throws ServerException, UserException {
    // TODO duplicate code with getTotalBounds
    try (DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY)) {
        double[] totalMin = new double[] { Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE };
        double[] totalMax = new double[] { -Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE };
        for (Long roid : roids) {
            Revision revision = session.get(roid, OldQuery.getDefault());
            Bounds bounds = revision.getBoundsUntransformedMm();
            if (bounds.getMin().getX() == Double.MAX_VALUE || bounds.getMin().getY() == Double.MAX_VALUE || bounds.getMin().getZ() == Double.MAX_VALUE || bounds.getMax().getX() == -Double.MAX_VALUE || bounds.getMax().getY() == -Double.MAX_VALUE || bounds.getMax().getZ() == -Double.MAX_VALUE) {
                // Probably no objects or weird error, let's skip this one
                continue;
            }
            Vector3f min = bounds.getMin();
            Vector3f max = bounds.getMax();
            if (min.getX() < totalMin[0]) {
                totalMin[0] = min.getX();
            }
            if (min.getY() < totalMin[1]) {
                totalMin[1] = min.getY();
            }
            if (min.getZ() < totalMin[2]) {
                totalMin[2] = min.getZ();
            }
            if (max.getX() > totalMax[0]) {
                totalMax[0] = max.getX();
            }
            if (max.getY() > totalMax[1]) {
                totalMax[1] = max.getY();
            }
            if (max.getZ() > totalMax[2]) {
                totalMax[2] = max.getZ();
            }
        }
        SBounds sBounds = new SBounds();
        SVector3f sMin = new SVector3f();
        SVector3f sMax = new SVector3f();
        sBounds.setMin(sMin);
        sBounds.setMax(sMax);
        sMin.setX(totalMin[0]);
        sMin.setY(totalMin[1]);
        sMin.setZ(totalMin[2]);
        sMax.setX(totalMax[0]);
        sMax.setY(totalMax[1]);
        sMax.setZ(totalMax[2]);
        return sBounds;
    } catch (Exception e) {
        return handleException(e);
    }
}
Also used : SBounds(org.bimserver.interfaces.objects.SBounds) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) SRevision(org.bimserver.interfaces.objects.SRevision) Revision(org.bimserver.models.store.Revision) CheckinRevision(org.bimserver.models.store.CheckinRevision) SExtendedDataAddedToRevision(org.bimserver.interfaces.objects.SExtendedDataAddedToRevision) DatabaseSession(org.bimserver.database.DatabaseSession) Bounds(org.bimserver.models.geometry.Bounds) SBounds(org.bimserver.interfaces.objects.SBounds) SVector3f(org.bimserver.interfaces.objects.SVector3f) Vector3f(org.bimserver.models.geometry.Vector3f) SVector3f(org.bimserver.interfaces.objects.SVector3f) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 4 with SVector3f

use of org.bimserver.interfaces.objects.SVector3f in project BIMserver by opensourceBIM.

the class Bounds method toSBounds.

public SBounds toSBounds() {
    SBounds bounds = new SBounds();
    SVector3f min = new SVector3f();
    min.setX(getMinX());
    min.setY(getMinY());
    min.setZ(getMinZ());
    SVector3f max = new SVector3f();
    max.setX(getMaxX());
    max.setY(getMaxY());
    max.setZ(getMaxZ());
    bounds.setMin(min);
    bounds.setMax(max);
    return bounds;
}
Also used : SBounds(org.bimserver.interfaces.objects.SBounds) SVector3f(org.bimserver.interfaces.objects.SVector3f)

Example 5 with SVector3f

use of org.bimserver.interfaces.objects.SVector3f in project BIMserver by opensourceBIM.

the class ServiceImpl method getTotalBounds.

@Override
public SBounds getTotalBounds(Set<Long> roids) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        double[] totalMin = new double[] { Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE };
        double[] totalMax = new double[] { -Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE };
        for (Long roid : roids) {
            Revision revision = session.get(roid, OldQuery.getDefault());
            Bounds bounds = revision.getBoundsMm();
            if (bounds.getMin().getX() == Double.MAX_VALUE || bounds.getMin().getY() == Double.MAX_VALUE || bounds.getMin().getZ() == Double.MAX_VALUE || bounds.getMax().getX() == -Double.MAX_VALUE || bounds.getMax().getY() == -Double.MAX_VALUE || bounds.getMax().getZ() == -Double.MAX_VALUE) {
                // Probably no objects or weird error, let's skip this one
                continue;
            }
            Vector3f min = bounds.getMin();
            Vector3f max = bounds.getMax();
            // }
            if (min.getX() < totalMin[0]) {
                totalMin[0] = min.getX();
            }
            if (min.getY() < totalMin[1]) {
                totalMin[1] = min.getY();
            }
            if (min.getZ() < totalMin[2]) {
                totalMin[2] = min.getZ();
            }
            if (max.getX() > totalMax[0]) {
                totalMax[0] = max.getX();
            }
            if (max.getY() > totalMax[1]) {
                totalMax[1] = max.getY();
            }
            if (max.getZ() > totalMax[2]) {
                totalMax[2] = max.getZ();
            }
        }
        SBounds sBounds = new SBounds();
        SVector3f sMin = new SVector3f();
        SVector3f sMax = new SVector3f();
        sBounds.setMin(sMin);
        sBounds.setMax(sMax);
        sMin.setX(totalMin[0]);
        sMin.setY(totalMin[1]);
        sMin.setZ(totalMin[2]);
        sMax.setX(totalMax[0]);
        sMax.setY(totalMax[1]);
        sMax.setZ(totalMax[2]);
        return sBounds;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SBounds(org.bimserver.interfaces.objects.SBounds) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) SRevision(org.bimserver.interfaces.objects.SRevision) Revision(org.bimserver.models.store.Revision) CheckinRevision(org.bimserver.models.store.CheckinRevision) SExtendedDataAddedToRevision(org.bimserver.interfaces.objects.SExtendedDataAddedToRevision) DatabaseSession(org.bimserver.database.DatabaseSession) Bounds(org.bimserver.models.geometry.Bounds) SBounds(org.bimserver.interfaces.objects.SBounds) SVector3f(org.bimserver.interfaces.objects.SVector3f) Vector3f(org.bimserver.models.geometry.Vector3f) SVector3f(org.bimserver.interfaces.objects.SVector3f) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Aggregations

SVector3f (org.bimserver.interfaces.objects.SVector3f)5 SBounds (org.bimserver.interfaces.objects.SBounds)4 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)2 MessagingException (javax.mail.MessagingException)2 AddressException (javax.mail.internet.AddressException)2 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)2 DatabaseSession (org.bimserver.database.DatabaseSession)2 SExtendedDataAddedToRevision (org.bimserver.interfaces.objects.SExtendedDataAddedToRevision)2 SRevision (org.bimserver.interfaces.objects.SRevision)2 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)2 Bounds (org.bimserver.models.geometry.Bounds)2 Vector3f (org.bimserver.models.geometry.Vector3f)2 CheckinRevision (org.bimserver.models.store.CheckinRevision)2 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)2 Revision (org.bimserver.models.store.Revision)2 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)2 SerializerException (org.bimserver.plugins.serializers.SerializerException)2