Search in sources :

Example 1 with SBounds

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

the class DumpUnits method main.

public static void main(String[] args) {
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) {
            List<SProjectSmall> allRelatedProjects = client.getServiceInterface().getAllRelatedProjects(31588353L);
            for (SProjectSmall projectSmall : allRelatedProjects) {
                if (projectSmall.getLastRevisionId() != -1 && projectSmall.getNrSubProjects() == 0) {
                    SProject project = client.getServiceInterface().getProjectByPoid(projectSmall.getOid());
                    System.out.println(project.getName());
                    SBounds bounds = client.getServiceInterface().getModelBounds(project.getLastRevisionId());
                    if (bounds != null) {
                        System.out.println(bounds.getMin().getX() + ", " + bounds.getMin().getY() + ", " + bounds.getMin().getZ() + " --- " + bounds.getMax().getX() + ", " + bounds.getMax().getY() + ", " + bounds.getMax().getZ());
                        ClientIfcModel model = client.getModel(project, project.getLastRevisionId(), false, false);
                        System.out.println(IfcUtils.getLengthUnitPrefix(model));
                    }
                }
            }
        }
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : SBounds(org.bimserver.interfaces.objects.SBounds) ClientIfcModel(org.bimserver.client.ClientIfcModel) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SProjectSmall(org.bimserver.interfaces.objects.SProjectSmall) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) BimServerClient(org.bimserver.client.BimServerClient) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException)

Example 2 with SBounds

use of org.bimserver.interfaces.objects.SBounds 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 3 with SBounds

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

the class ServiceImpl method getModelBoundsUntransformed.

@Override
public SBounds getModelBoundsUntransformed(Long roid) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        Revision revision = session.get(roid, OldQuery.getDefault());
        ConcreteRevision lastConcreteRevision = revision.getLastConcreteRevision();
        Bounds bounds = lastConcreteRevision.getBoundsUntransformed();
        Vector3f min = bounds.getMin();
        Vector3f max = bounds.getMax();
        if (lastConcreteRevision.getMultiplierToMm() != 1f) {
            min.setX(min.getX() * lastConcreteRevision.getMultiplierToMm());
            min.setY(min.getY() * lastConcreteRevision.getMultiplierToMm());
            min.setZ(min.getZ() * lastConcreteRevision.getMultiplierToMm());
            max.setX(max.getX() * lastConcreteRevision.getMultiplierToMm());
            max.setY(max.getY() * lastConcreteRevision.getMultiplierToMm());
            max.setZ(max.getZ() * lastConcreteRevision.getMultiplierToMm());
        }
        return getBimServer().getSConverter().convertToSObject(bounds);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : 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) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) 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) 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 SBounds

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

the class ServiceImpl method getModelBoundsUntransformedForConcreteRevision.

@Override
public SBounds getModelBoundsUntransformedForConcreteRevision(Long croid) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        ConcreteRevision concreteRevision = session.get(croid, OldQuery.getDefault());
        Bounds bounds = concreteRevision.getBoundsUntransformed();
        Vector3f min = bounds.getMin();
        Vector3f max = bounds.getMax();
        if (concreteRevision.getMultiplierToMm() != 1f) {
            min.setX(min.getX() * concreteRevision.getMultiplierToMm());
            min.setY(min.getY() * concreteRevision.getMultiplierToMm());
            min.setZ(min.getZ() * concreteRevision.getMultiplierToMm());
            max.setX(max.getX() * concreteRevision.getMultiplierToMm());
            max.setY(max.getY() * concreteRevision.getMultiplierToMm());
            max.setZ(max.getZ() * concreteRevision.getMultiplierToMm());
        }
        return getBimServer().getSConverter().convertToSObject(bounds);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : ConcreteRevision(org.bimserver.models.store.ConcreteRevision) 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) 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 5 with SBounds

use of org.bimserver.interfaces.objects.SBounds 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)

Aggregations

SBounds (org.bimserver.interfaces.objects.SBounds)11 SVector3f (org.bimserver.interfaces.objects.SVector3f)8 IOException (java.io.IOException)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 MalformedURLException (java.net.MalformedURLException)7 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)7 MessagingException (javax.mail.MessagingException)7 AddressException (javax.mail.internet.AddressException)7 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)7 DatabaseSession (org.bimserver.database.DatabaseSession)7 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)7 Bounds (org.bimserver.models.geometry.Bounds)7 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)7 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)7 SerializerException (org.bimserver.plugins.serializers.SerializerException)7 PluginException (org.bimserver.shared.exceptions.PluginException)7 ServerException (org.bimserver.shared.exceptions.ServerException)7 ServiceException (org.bimserver.shared.exceptions.ServiceException)7 UserException (org.bimserver.shared.exceptions.UserException)7 BcfException (org.opensourcebim.bcf.BcfException)7