Search in sources :

Example 6 with GeometryGeneratingException

use of org.bimserver.GeometryGeneratingException in project BIMserver by opensourceBIM.

the class RegenerateGeometryDatabaseAction method execute.

@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
    ProgressListener progressListener = new ProgressListener() {

        @Override
        public void updateProgress(String state, int percentage) {
            setProgress("Generating geometry...", percentage);
        }
    };
    GeometryGenerationReport report = new GeometryGenerationReport();
    report.setOriginalIfcFileName("rerun");
    report.setOriginalIfcFileSize(-1);
    report.setOriginalDeserializer("rerun");
    StreamingGeometryGenerator streamingGeometryGenerator = new StreamingGeometryGenerator(bimServer, progressListener, eoid, report);
    Revision revision = getDatabaseSession().get(roid, OldQuery.getDefault());
    ConcreteRevision concreteRevision = revision.getConcreteRevisions().get(0);
    PackageMetaData packageMetaData = bimServer.getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
    int highestStopId = AbstractDownloadDatabaseAction.findHighestStopRid(concreteRevision.getProject(), concreteRevision);
    QueryContext queryContext = new QueryContext(getDatabaseSession(), packageMetaData, revision.getProject().getId(), revision.getId(), roid, concreteRevision.getOid(), highestStopId);
    try {
        // TODO get the actual amount of products
        GenerateGeometryResult generateGeometry = streamingGeometryGenerator.generateGeometry(uoid, getDatabaseSession(), queryContext, 1000);
        for (Revision other : concreteRevision.getRevisions()) {
            other.setHasGeometry(true);
        }
        concreteRevision.setMultiplierToMm(generateGeometry.getMultiplierToMm());
        concreteRevision.setBounds(generateGeometry.getBounds());
        concreteRevision.setBoundsUntransformed(generateGeometry.getBoundsUntransformed());
        byte[] htmlBytes = report.toHtml().getBytes(Charsets.UTF_8);
        byte[] jsonBytes = report.toJson().toString().getBytes(Charsets.UTF_8);
        storeExtendedData(htmlBytes, "text/html", "html", revision);
        storeExtendedData(jsonBytes, "application/json", "json", revision);
        getDatabaseSession().store(revision);
        getDatabaseSession().store(concreteRevision);
        renderEngineName = streamingGeometryGenerator.getRenderEngineName();
    } catch (GeometryGeneratingException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : GeometryGenerationReport(org.bimserver.geometry.GeometryGenerationReport) Revision(org.bimserver.models.store.Revision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) GenerateGeometryResult(org.bimserver.GenerateGeometryResult) PackageMetaData(org.bimserver.emf.PackageMetaData) StreamingGeometryGenerator(org.bimserver.geometry.StreamingGeometryGenerator) GeometryGeneratingException(org.bimserver.GeometryGeneratingException) QueryContext(org.bimserver.shared.QueryContext)

Aggregations

GeometryGeneratingException (org.bimserver.GeometryGeneratingException)6 OldQuery (org.bimserver.database.OldQuery)5 PackageMetaData (org.bimserver.emf.PackageMetaData)5 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)5 UserException (org.bimserver.shared.exceptions.UserException)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 Revision (org.bimserver.models.store.Revision)4 User (org.bimserver.models.store.User)4 HashMap (java.util.HashMap)3 GenerateGeometryResult (org.bimserver.GenerateGeometryResult)3 IOException (java.io.IOException)2 Date (java.util.Date)2 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)2 QueryException (org.bimserver.database.queries.om.QueryException)2 IdEObject (org.bimserver.emf.IdEObject)2 IfcModelInterface (org.bimserver.emf.IfcModelInterface)2 GeometryGenerationReport (org.bimserver.geometry.GeometryGenerationReport)2 StreamingGeometryGenerator (org.bimserver.geometry.StreamingGeometryGenerator)2 IfcModel (org.bimserver.ifc.IfcModel)2 IfcModelChangeListener (org.bimserver.ifc.IfcModelChangeListener)2