Search in sources :

Example 6 with VtkManager

use of cbit.vcell.simdata.VtkManager in project vcell by virtualcell.

the class VCellProxyHandler method getDataSetFileOfVariableAtTimeIndex.

@Override
public String getDataSetFileOfVariableAtTimeIndex(SimulationDataSetRef simulationDataSetRef, VariableInfo var, int timeIndex) throws ThriftDataAccessException {
    try {
        if (var.isMeshVar) {
            return getEmptyMeshFile(simulationDataSetRef, var.domainName, timeIndex).getAbsolutePath();
        }
        File meshFileForVariableAndTime = getPopulatedMeshFileLocation(simulationDataSetRef, var, timeIndex);
        if (meshFileForVariableAndTime.exists()) {
            return meshFileForVariableAndTime.getAbsolutePath();
        }
        // 
        // get data from server for this variable, domain, time
        // 
        VtkManager vtkManager = vcellClientDataService.getVtkManager(simulationDataSetRef);
        VariableDomain variableDomainType = VariableDomain.VARIABLEDOMAIN_UNKNOWN;
        if (var.variableDomainType == DomainType.MEMBRANE) {
            variableDomainType = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
        } else if (var.variableDomainType == DomainType.VOLUME) {
            variableDomainType = VariableDomain.VARIABLEDOMAIN_VOLUME;
        }
        org.vcell.vis.io.VtuVarInfo.DataType dataType = org.vcell.vis.io.VtuVarInfo.DataType.CellData;
        if (var.isSetDataType() && var.dataType == DataType.CELLDATA) {
            dataType = org.vcell.vis.io.VtuVarInfo.DataType.CellData;
        } else if (var.isSetDataType() && var.dataType == DataType.POINTDATA) {
            dataType = org.vcell.vis.io.VtuVarInfo.DataType.PointData;
        }
        VtuVarInfo vtuVarInfo = new VtuVarInfo(var.getVariableVtuName(), var.getVariableDisplayName(), var.getDomainName(), variableDomainType, var.getExpressionString(), dataType, var.isMeshVar);
        List<Double> times = getTimePoints(simulationDataSetRef);
        double time = (double) times.get(timeIndex);
        double[] data = vtkManager.getVtuMeshData(vtuVarInfo, time);
        // 
        // get empty mesh file for this domain (getEmptyMeshFile() will ensure that the file exists or create it).
        // 
        File emptyMeshFile = getEmptyMeshFile(simulationDataSetRef, var.getDomainName(), timeIndex);
        if (var.getDataType() == DataType.CELLDATA) {
            VisMeshUtils.writeCellDataToVtu(emptyMeshFile, var.getVariableVtuName(), data, meshFileForVariableAndTime);
        } else if (var.getDataType() == DataType.POINTDATA) {
            VisMeshUtils.writePointDataToVtu(emptyMeshFile, var.getVariableVtuName(), data, meshFileForVariableAndTime);
        }
        return meshFileForVariableAndTime.getAbsolutePath();
    } catch (Exception e) {
        e.printStackTrace();
        throw new ThriftDataAccessException("failed to retrieve data file for variable " + var.getVariableVtuName() + " at time index " + timeIndex);
    }
}
Also used : VtuVarInfo(org.vcell.vis.io.VtuVarInfo) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) VtkManager(cbit.vcell.simdata.VtkManager) TException(org.apache.thrift.TException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File)

Aggregations

VtkManager (cbit.vcell.simdata.VtkManager)6 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 DataAccessException (org.vcell.util.DataAccessException)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 TException (org.apache.thrift.TException)3 VtuVarInfo (org.vcell.vis.io.VtuVarInfo)3 ExportServiceImpl (cbit.vcell.export.server.ExportServiceImpl)2 DataSetControllerImpl (cbit.vcell.simdata.DataSetControllerImpl)2 VCDataManager (cbit.vcell.simdata.VCDataManager)2 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)2 User (org.vcell.util.document.User)2 ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)1 LocalVCSimulationDataIdentifier (cbit.vcell.client.ClientSimManager.LocalVCSimulationDataIdentifier)1 LocalDataSetControllerProvider (cbit.vcell.client.LocalDataSetControllerProvider)1 DataViewer (cbit.vcell.client.data.DataViewer)1 DataViewerController (cbit.vcell.client.data.DataViewerController)1 SimulationWorkspaceModelInfo (cbit.vcell.client.data.SimulationWorkspaceModelInfo)1 VCellClientDataServiceImpl (cbit.vcell.client.data.VCellClientDataServiceImpl)1