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);
}
}
Aggregations