Search in sources :

Example 1 with Bounds

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

the class GeometryGenerator method returnCachedData.

private void returnCachedData(IfcModelInterface model, GeometryCache geometryCache, DatabaseSession databaseSession, int pid, int rid, boolean store) throws BimserverDatabaseException, ObjectAlreadyExistsException, IfcModelInterfaceException {
    EClass productClass = model.getPackageMetaData().getEClass("IfcProduct");
    List<IdEObject> products = model.getAllWithSubTypes(productClass);
    for (IdEObject ifcProduct : products) {
        GeometryCacheEntry geometryCacheEntry = geometryCache.get(ifcProduct.getExpressId());
        if (geometryCacheEntry != null) {
            GeometryData geometryData = databaseSession.create(GeometryPackage.eINSTANCE.getGeometryData(), pid, rid);
            geometryData.setVertices(createBuffer(model, databaseSession, geometryCacheEntry.getVertices(), store, pid, rid));
            geometryData.setNormals(createBuffer(model, databaseSession, geometryCacheEntry.getNormals(), store, pid, rid));
            GeometryInfo geometryInfo = databaseSession.create(GeometryPackage.eINSTANCE.getGeometryInfo(), pid, rid);
            Vector3f min = databaseSession.create(GeometryPackage.eINSTANCE.getVector3f(), pid, rid);
            min.setX(geometryCacheEntry.getGeometryInfo().getBounds().getMin().getX());
            min.setY(geometryCacheEntry.getGeometryInfo().getBounds().getMin().getY());
            min.setZ(geometryCacheEntry.getGeometryInfo().getBounds().getMin().getZ());
            Vector3f max = databaseSession.create(GeometryPackage.eINSTANCE.getVector3f(), pid, rid);
            max.setX(geometryCacheEntry.getGeometryInfo().getBounds().getMax().getX());
            max.setY(geometryCacheEntry.getGeometryInfo().getBounds().getMax().getY());
            max.setZ(geometryCacheEntry.getGeometryInfo().getBounds().getMax().getZ());
            Bounds bounds = GeometryFactory.eINSTANCE.createBounds();
            bounds.setMin(min);
            bounds.setMax(max);
            geometryInfo.setBounds(bounds);
            geometryInfo.setData(geometryData);
            ifcProduct.eSet(ifcProduct.eClass().getEStructuralFeature("geometry"), geometryInfo);
        }
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IdEObject(org.bimserver.emf.IdEObject) Vector3f(org.bimserver.models.geometry.Vector3f) Bounds(org.bimserver.models.geometry.Bounds) GeometryInfo(org.bimserver.models.geometry.GeometryInfo) GeometryData(org.bimserver.models.geometry.GeometryData)

Example 2 with Bounds

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

the class GenerateGeometryResult method getBounds.

public Bounds getBounds() {
    Bounds bounds = GeometryFactory.eINSTANCE.createBounds();
    Vector3f min = GeometryFactory.eINSTANCE.createVector3f();
    min.setX(this.min[0]);
    min.setY(this.min[1]);
    min.setZ(this.min[2]);
    Vector3f max = GeometryFactory.eINSTANCE.createVector3f();
    max.setX(this.max[0]);
    max.setY(this.max[1]);
    max.setZ(this.max[2]);
    bounds.setMin(min);
    bounds.setMax(max);
    return bounds;
}
Also used : Bounds(org.bimserver.models.geometry.Bounds) Vector3f(org.bimserver.models.geometry.Vector3f)

Example 3 with Bounds

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

the class GeometryGenerator method processExtends.

private void processExtends(GeometryInfo geometryInfo, double[] transformationMatrix, DoubleBuffer vertices, int index, GenerateGeometryResult generateGeometryResult) {
    double x = vertices.get(index);
    double y = vertices.get(index + 1);
    double z = vertices.get(index + 2);
    double[] result = new double[4];
    Matrix.multiplyMV(result, 0, transformationMatrix, 0, new double[] { x, y, z, 1 }, 0);
    x = result[0];
    y = result[1];
    z = result[2];
    Bounds bounds = geometryInfo.getBounds();
    bounds.getMin().setX(Math.min(x, bounds.getMin().getX()));
    bounds.getMin().setY(Math.min(y, bounds.getMin().getY()));
    bounds.getMin().setZ(Math.min(z, bounds.getMin().getZ()));
    bounds.getMax().setX(Math.max(x, bounds.getMax().getX()));
    bounds.getMax().setY(Math.max(y, bounds.getMax().getY()));
    bounds.getMax().setZ(Math.max(z, bounds.getMax().getZ()));
    generateGeometryResult.setMinX(Math.min(x, generateGeometryResult.getMinX()));
    generateGeometryResult.setMinY(Math.min(y, generateGeometryResult.getMinY()));
    generateGeometryResult.setMinZ(Math.min(z, generateGeometryResult.getMinZ()));
    generateGeometryResult.setMaxX(Math.max(x, generateGeometryResult.getMaxX()));
    generateGeometryResult.setMaxY(Math.max(y, generateGeometryResult.getMaxY()));
    generateGeometryResult.setMaxZ(Math.max(z, generateGeometryResult.getMaxZ()));
}
Also used : Bounds(org.bimserver.models.geometry.Bounds)

Example 4 with Bounds

use of org.bimserver.models.geometry.Bounds 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 5 with Bounds

use of org.bimserver.models.geometry.Bounds 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)

Aggregations

Bounds (org.bimserver.models.geometry.Bounds)14 Vector3f (org.bimserver.models.geometry.Vector3f)10 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)8 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)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 DatabaseSession (org.bimserver.database.DatabaseSession)7 SBounds (org.bimserver.interfaces.objects.SBounds)7 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)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