use of cbit.vcell.simdata.SimDataBlock in project vcell by virtualcell.
the class PDEDataViewerPostProcess method createPostProcessPDEDataContext.
public static PostProcessDataPDEDataContext createPostProcessPDEDataContext(final ClientPDEDataContext parentPDEDataContext) throws Exception {
final DataOperationResults.DataProcessingOutputInfo dataProcessingOutputInfo = (DataOperationResults.DataProcessingOutputInfo) parentPDEDataContext.doDataOperation(new DataOperation.DataProcessingOutputInfoOP(parentPDEDataContext.getVCDataIdentifier(), false, parentPDEDataContext.getDataManager().getOutputContext()));
if (dataProcessingOutputInfo == null) {
return null;
}
DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {
@Override
public DataSetController getDataSetController() throws DataAccessException {
return new DataSetController() {
// DataIdentifier[] dataIdentifiers;
@Override
public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
throw new DataAccessException("Not implemented");
}
@Override
public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataManager().getTimeSeriesValues(timeSeriesJobSpec);
DataOperation.DataProcessingOutputTimeSeriesOP dataProcessingOutputTimeSeriesOP = new DataOperation.DataProcessingOutputTimeSeriesOP(vcdataID, timeSeriesJobSpec, outputContext, getDataSetTimes(vcdataID));
DataOperationResults.DataProcessingOutputTimeSeriesValues dataopDataProcessingOutputTimeSeriesValues = (DataOperationResults.DataProcessingOutputTimeSeriesValues) parentPDEDataContext.doDataOperation(dataProcessingOutputTimeSeriesOP);
return dataopDataProcessingOutputTimeSeriesValues.getTimeSeriesJobResults();
}
@Override
public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataManager().getSimDataBlock(varName, time);
DataOperationResults.DataProcessingOutputDataValues dataProcessingOutputValues = (DataOperationResults.DataProcessingOutputDataValues) parentPDEDataContext.doDataOperation(new DataOperation.DataProcessingOutputDataValuesOP(vcdataID, varName, TimePointHelper.createSingleTimeTimePointHelper(time), DataIndexHelper.createAllDataIndexesDataIndexHelper(), outputContext, null));
PDEDataInfo pdeDataInfo = new PDEDataInfo(vcdataID.getOwner(), vcdataID.getID(), varName, time, Long.MIN_VALUE);
SimDataBlock simDataBlock = new SimDataBlock(pdeDataInfo, dataProcessingOutputValues.getDataValues()[0], VariableType.POSTPROCESSING);
return simDataBlock;
}
@Override
public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return false;
}
@Override
public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// throw new DataAccessException("PostProcessData mesh not available at this level");
return null;
}
@Override
public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
throw new DataAccessException("Remote getLineScan method should not be called for PostProcess");
}
@Override
public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return outputContext.getOutputFunctions();
}
@Override
public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return dataProcessingOutputInfo.getVariableTimePoints();
}
@Override
public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataIdentifiers();
ArrayList<DataIdentifier> postProcessDataIDs = new ArrayList<DataIdentifier>();
if (outputContext != null && outputContext.getOutputFunctions() != null) {
for (int i = 0; i < outputContext.getOutputFunctions().length; i++) {
if (outputContext.getOutputFunctions()[i].isPostProcessFunction()) {
postProcessDataIDs.add(new DataIdentifier(outputContext.getOutputFunctions()[i].getName(), VariableType.POSTPROCESSING, null, false, outputContext.getOutputFunctions()[i].getDisplayName()));
}
}
}
// get 'state' variables
for (int i = 0; i < dataProcessingOutputInfo.getVariableNames().length; i++) {
if (dataProcessingOutputInfo.getPostProcessDataType(dataProcessingOutputInfo.getVariableNames()[i]).equals(PostProcessDataType.image)) {
DataIdentifier dataIdentifier = new DataIdentifier(dataProcessingOutputInfo.getVariableNames()[i], VariableType.POSTPROCESSING, null, false, dataProcessingOutputInfo.getVariableNames()[i]);
postProcessDataIDs.add(dataIdentifier);
}
}
if (postProcessDataIDs.size() > 0) {
return postProcessDataIDs.toArray(new DataIdentifier[0]);
}
return null;
}
@Override
public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return parentPDEDataContext.doDataOperation(dataOperation);
}
@Override
public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public double[] getVtuMeshData(OutputContext outputContext, VCDataIdentifier vcdataID, VtuVarInfo var, double time) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public VtuVarInfo[] getVtuVarInfos(OutputContext outputContext, VCDataIdentifier vcDataIdentifier) {
// TODO Auto-generated method stub
return null;
}
@Override
public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
};
}
};
VCDataManager postProcessVCDataManager = new VCDataManager(dataSetControllerProvider);
PDEDataManager postProcessPDEDataManager = new PDEDataManager(((ClientPDEDataContext) parentPDEDataContext).getDataManager().getOutputContext(), postProcessVCDataManager, parentPDEDataContext.getVCDataIdentifier());
PostProcessDataPDEDataContext postProcessDataPDEDataContext = new PostProcessDataPDEDataContext(postProcessPDEDataManager);
return postProcessDataPDEDataContext;
}
use of cbit.vcell.simdata.SimDataBlock in project vcell by virtualcell.
the class SmoldynFileWriter method writeDataProcessor.
private void writeDataProcessor() throws DataAccessException, IOException, MathException, DivideByZeroException, ExpressionException {
Simulation simulation = simTask.getSimulation();
DataProcessingInstructions dpi = simulation.getDataProcessingInstructions();
if (dpi == null) {
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " begin " + DataProcessingInstructions.ROI_TIME_SERIES);
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " end");
} else {
FieldDataIdentifierSpec fdis = dpi.getSampleImageFieldData(simulation.getVersion().getOwner());
if (fdis == null) {
throw new DataAccessException("Can't find sample image in data processing instructions");
}
File userDirectory = outputFile.getParentFile();
String secondarySimDataDir = PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirInternalProperty, null);
DataSetControllerImpl dsci = new DataSetControllerImpl(null, userDirectory.getParentFile(), secondarySimDataDir == null ? null : new File(secondarySimDataDir));
CartesianMesh origMesh = dsci.getMesh(fdis.getExternalDataIdentifier());
SimDataBlock simDataBlock = dsci.getSimDataBlock(null, fdis.getExternalDataIdentifier(), fdis.getFieldFuncArgs().getVariableName(), fdis.getFieldFuncArgs().getTime().evaluateConstant());
VariableType varType = fdis.getFieldFuncArgs().getVariableType();
VariableType dataVarType = simDataBlock.getVariableType();
if (!varType.equals(VariableType.UNKNOWN) && !varType.equals(dataVarType)) {
throw new IllegalArgumentException("field function variable type (" + varType.getTypeName() + ") doesn't match real variable type (" + dataVarType.getTypeName() + ")");
}
double[] origData = simDataBlock.getData();
String filename = SimulationJob.createSimulationJobID(Simulation.createSimulationID(simulation.getKey()), simTask.getSimulationJob().getJobIndex()) + SimulationData.getDefaultFieldDataFileNameForSimulation(fdis.getFieldFuncArgs());
File fdatFile = new File(userDirectory, filename);
DataSet.writeNew(fdatFile, new String[] { fdis.getFieldFuncArgs().getVariableName() }, new VariableType[] { simDataBlock.getVariableType() }, new ISize(origMesh.getSizeX(), origMesh.getSizeY(), origMesh.getSizeZ()), new double[][] { origData });
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " begin " + dpi.getScriptName());
StringTokenizer st = new StringTokenizer(dpi.getScriptInput(), "\n\r");
while (st.hasMoreTokens()) {
String str = st.nextToken();
if (str.trim().length() > 0) {
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " " + str);
}
}
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " SampleImageFile " + fdis.getFieldFuncArgs().getVariableName() + " " + fdis.getFieldFuncArgs().getTime().infix() + " " + fdatFile);
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " end");
}
}
use of cbit.vcell.simdata.SimDataBlock in project vcell by virtualcell.
the class RasterExporter method makeUCDData.
public ExportOutput[] makeUCDData(OutputContext outputContext, JobRequest jobRequest, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, FileDataContainerManager fileDataContainerManager) throws Exception {
String simID = exportSpecs.getVCDataIdentifier().getID();
VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
VariableSpecs variableSpecs = exportSpecs.getVariableSpecs();
TimeSpecs timeSpecs = exportSpecs.getTimeSpecs();
cbit.vcell.solvers.CartesianMesh mesh = dataServerImpl.getMesh(user, vcdID);
CartesianMesh.UCDInfo ucdInfo = mesh.getUCDInfo();
CartesianMesh.UCDInfo ucdInfoReduced = ucdInfo.removeNonMembraneGridNodes();
Vector<ExportOutput> exportOutV = new Vector<ExportOutput>();
// for (int i = 0; i < variableSpecs.getVariableNames().length; i++){
for (int j = timeSpecs.getBeginTimeIndex(); j <= timeSpecs.getEndTimeIndex(); j++) {
exportServiceImpl.fireExportProgress(jobRequest.getJobID(), vcdID, "UCD", (double) (j - timeSpecs.getBeginTimeIndex()) / (double) (timeSpecs.getEndTimeIndex() - timeSpecs.getBeginTimeIndex() + 1));
// String fileID = simID + "_Full_" + formatTime(timeSpecs.getAllTimes()[j]) + "time_" + variableSpecs.getVariableNames().length + "vars";
// File datafile = new File(tempDir, fileID + "_data.ucd");
// FileWriter fileWriter = new FileWriter(datafile);
Vector<double[]> volumeDataV = new Vector<double[]>();
Vector<String> volumeDataNameV = new Vector<String>();
Vector<String> volumeDataUnitV = new Vector<String>();
Vector<double[]> membraneDataV = new Vector<double[]>();
Vector<String> membraneDataNameV = new Vector<String>();
Vector<String> membraneDataUnitV = new Vector<String>();
for (int k = 0; k < variableSpecs.getVariableNames().length; k++) {
SimDataBlock simDataBlock = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[k], timeSpecs.getAllTimes()[j]);
if (simDataBlock.getVariableType().equals(VariableType.VOLUME)) {
volumeDataNameV.add(variableSpecs.getVariableNames()[k]);
volumeDataUnitV.add("unknown");
volumeDataV.add(simDataBlock.getData());
} else {
membraneDataNameV.add(variableSpecs.getVariableNames()[k]);
membraneDataUnitV.add("unknown");
membraneDataV.add(simDataBlock.getData());
}
}
if (volumeDataV.size() > 0) {
StringWriter stringWriter = new StringWriter();
AVS_UCD_Exporter.writeUCDVolGeomAndData(ucdInfo, volumeDataNameV.toArray(new String[0]), volumeDataUnitV.toArray(new String[0]), volumeDataV.toArray(new double[0][]), stringWriter);
ExportOutput exportOut = new ExportOutput(true, ".ucd", simID.toString(), "_vol_" + j, fileDataContainerManager);
fileDataContainerManager.append(exportOut.getFileDataContainerID(), stringWriter.toString());
exportOutV.add(exportOut);
}
if (membraneDataV.size() > 0) {
StringWriter stringWriter = new StringWriter();
AVS_UCD_Exporter.writeUCDMembGeomAndData(ucdInfoReduced, /*ucdInfo*/
membraneDataNameV.toArray(new String[0]), membraneDataUnitV.toArray(new String[0]), membraneDataV.toArray(new double[0][]), stringWriter);
ExportOutput exportOut = new ExportOutput(true, ".ucd", simID.toString(), "_memb_" + j, fileDataContainerManager);
fileDataContainerManager.append(exportOut.getFileDataContainerID(), stringWriter.toString());
exportOutV.add(exportOut);
}
// AVS_UCD_Exporter.writeUCD(mesh,
// (volumeDataNameV.size() == 0?null:volumeDataNameV.toArray(new String[0])),
// (volumeDataUnitV.size() == 0?null:volumeDataUnitV.toArray(new String[0])),
// (volumeDataV.size() == 0?null:volumeDataV.toArray(new double[0][])),
//
// (membraneDataNameV.size() == 0?null:membraneDataNameV.toArray(new String[0])),
// (membraneDataUnitV.size() == 0?null:membraneDataUnitV.toArray(new String[0])),
// (membraneDataV.size() == 0?null:membraneDataV.toArray(new double[0][])),
// stringWriter);
// ExportOutput exportOut = new ExportOutput(true,".ucd",simID.toString(),fileID,stringWriter.toString().getBytes());
// exportOutV.add(exportOut);
}
// }
ExportOutput[] exportOutputArr = exportOutV.toArray(new ExportOutput[0]);
return exportOutputArr;
// String fileID = simID + "_Full_" + NUM_TIMES + "times_" + variableSpecs.getVariableNames().length + "vars";
// File datafile = new File(tempDir, fileID + "_data.nrrd");
// nrrdInfo.setDatafile(datafile.getName());
// DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(datafile)));
// try {
// for (int i = 0; i < variableSpecs.getVariableNames().length; i++){
// for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++){
// double[] data = dataServerImpl.getSimDataBlock(user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
// for (int k = 0; k < data.length; k++){
// out.writeDouble(data[k]);
// }
// }
// }
// } catch (IOException exc) {
// throw new DataAccessException(exc.toString());
// } finally {
// out.close();
// }
}
use of cbit.vcell.simdata.SimDataBlock in project vcell by virtualcell.
the class RasterExporter method makeVTKUnstructuredData.
public ExportOutput[] makeVTKUnstructuredData(OutputContext outputContext, JobRequest jobRequest, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, FileDataContainerManager fileDataContainerManager) throws Exception {
String simID = exportSpecs.getVCDataIdentifier().getID();
VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
VariableSpecs variableSpecs = exportSpecs.getVariableSpecs();
TimeSpecs timeSpecs = exportSpecs.getTimeSpecs();
cbit.vcell.solvers.CartesianMesh mesh = dataServerImpl.getMesh(user, vcdID);
CartesianMesh.UCDInfo ucdInfo = mesh.getUCDInfo();
CartesianMesh.UCDInfo ucdInfoReduced = ucdInfo.removeNonMembraneGridNodes();
Vector<ExportOutput> exportOutV = new Vector<ExportOutput>();
// for (int i = 0; i < variableSpecs.getVariableNames().length; i++){
for (int j = timeSpecs.getBeginTimeIndex(); j <= timeSpecs.getEndTimeIndex(); j++) {
exportServiceImpl.fireExportProgress(jobRequest.getJobID(), vcdID, "VTKUNSTR", (double) (j - timeSpecs.getBeginTimeIndex()) / (double) (timeSpecs.getEndTimeIndex() - timeSpecs.getBeginTimeIndex() + 1));
// String fileID = simID + "_Full_" + formatTime(timeSpecs.getAllTimes()[j]) + "time_" + variableSpecs.getVariableNames().length + "vars";
// File datafile = new File(tempDir, fileID + "_data.ucd");
// FileWriter fileWriter = new FileWriter(datafile);
Vector<double[]> volumeDataV = new Vector<double[]>();
Vector<String> volumeDataNameV = new Vector<String>();
Vector<String> volumeDataUnitV = new Vector<String>();
Vector<double[]> membraneDataV = new Vector<double[]>();
Vector<String> membraneDataNameV = new Vector<String>();
Vector<String> membraneDataUnitV = new Vector<String>();
for (int k = 0; k < variableSpecs.getVariableNames().length; k++) {
SimDataBlock simDataBlock = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[k], timeSpecs.getAllTimes()[j]);
if (simDataBlock.getVariableType().equals(VariableType.VOLUME)) {
volumeDataNameV.add(variableSpecs.getVariableNames()[k]);
volumeDataUnitV.add("unknown");
volumeDataV.add(simDataBlock.getData());
} else {
membraneDataNameV.add(variableSpecs.getVariableNames()[k]);
membraneDataUnitV.add("unknown");
membraneDataV.add(simDataBlock.getData());
}
}
if (volumeDataV.size() > 0) {
int[] regionIDs = new int[mesh.getNumVolumeElements()];
for (int i = 0; i < regionIDs.length; i++) {
regionIDs[i] = mesh.getVolumeRegionIndex(i);
}
StringWriter stringWriter = new StringWriter();
writeVTKUnstructuredHeader(ucdInfo, vcdID, stringWriter);
int CELL_INFO_COUNT = 1 + 4 + (ucdInfo.getNumVolumeNodesZ() > 1 ? 4 : 0);
stringWriter.write("CELLS " + ucdInfo.getNumVolumeCells() + " " + (ucdInfo.getNumVolumeCells() * CELL_INFO_COUNT) + "\n");
stringWriter.write(ucdInfo.getVolumeCellsString(true));
writeVTKCellTypes(ucdInfo, ucdInfo.getNumVolumeCells(), (ucdInfo.getNumVolumeNodesZ() > 1 ? VTK_HEXAHEDRON : VTK_QUAD), stringWriter);
writeVTKCellData(volumeDataV.toArray(new double[0][]), regionIDs, volumeDataNameV.toArray(new String[0]), stringWriter);
// AVS_UCD_Exporter.writeUCDVolume(
// ucdInfo,
// volumeDataNameV.toArray(new String[0]),
// volumeDataUnitV.toArray(new String[0]),
// volumeDataV.toArray(new double[0][]),
// stringWriter);
ExportOutput exportOut = new ExportOutput(true, ".vtk", simID.toString(), "vol_" + j, fileDataContainerManager);
fileDataContainerManager.append(exportOut.getFileDataContainerID(), stringWriter.toString());
exportOutV.add(exportOut);
}
if (membraneDataV.size() > 0) {
int[] regionIDs = new int[mesh.getNumMembraneElements()];
for (int i = 0; i < regionIDs.length; i++) {
regionIDs[i] = mesh.getMembraneRegionIndex(i);
}
StringWriter stringWriter = new StringWriter();
writeVTKUnstructuredHeader(ucdInfoReduced, /*ucdInfo*/
vcdID, stringWriter);
int MEMBR_INFO_COUNT = 1 + 2 + (ucdInfo.getNumVolumeNodesZ() > 1 ? 2 : 0);
stringWriter.write("CELLS " + ucdInfoReduced.getNumMembraneCells() + " " + (ucdInfoReduced.getNumMembraneCells() * MEMBR_INFO_COUNT) + "\n");
stringWriter.write(ucdInfoReduced.getMembraneCellsString(0, true));
writeVTKCellTypes(ucdInfoReduced, /*ucdInfo*/
ucdInfoReduced.getNumMembraneCells(), (ucdInfo.getNumVolumeNodesZ() > 1 ? VTK_QUAD : VTK_LINE), stringWriter);
writeVTKCellData(membraneDataV.toArray(new double[0][]), regionIDs, membraneDataNameV.toArray(new String[0]), stringWriter);
// AVS_UCD_Exporter.writeUCDMembrane(
// ucdInfo,
// membraneDataNameV.toArray(new String[0]),
// membraneDataUnitV.toArray(new String[0]),
// membraneDataV.toArray(new double[0][]),
// stringWriter);
ExportOutput exportOut = new ExportOutput(true, ".vtk", simID.toString(), "memb_" + j, fileDataContainerManager);
fileDataContainerManager.append(exportOut.getFileDataContainerID(), stringWriter.toString());
exportOutV.add(exportOut);
}
// AVS_UCD_Exporter.writeUCD(mesh,
// (volumeDataNameV.size() == 0?null:volumeDataNameV.toArray(new String[0])),
// (volumeDataUnitV.size() == 0?null:volumeDataUnitV.toArray(new String[0])),
// (volumeDataV.size() == 0?null:volumeDataV.toArray(new double[0][])),
//
// (membraneDataNameV.size() == 0?null:membraneDataNameV.toArray(new String[0])),
// (membraneDataUnitV.size() == 0?null:membraneDataUnitV.toArray(new String[0])),
// (membraneDataV.size() == 0?null:membraneDataV.toArray(new double[0][])),
// stringWriter);
// ExportOutput exportOut = new ExportOutput(true,".ucd",simID.toString(),fileID,stringWriter.toString().getBytes());
// exportOutV.add(exportOut);
}
// }
ExportOutput[] exportOutputArr = exportOutV.toArray(new ExportOutput[0]);
return exportOutputArr;
// String fileID = simID + "_Full_" + NUM_TIMES + "times_" + variableSpecs.getVariableNames().length + "vars";
// File datafile = new File(tempDir, fileID + "_data.nrrd");
// nrrdInfo.setDatafile(datafile.getName());
// DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(datafile)));
// try {
// for (int i = 0; i < variableSpecs.getVariableNames().length; i++){
// for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++){
// double[] data = dataServerImpl.getSimDataBlock(user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
// for (int k = 0; k < data.length; k++){
// out.writeDouble(data[k]);
// }
// }
// }
// } catch (IOException exc) {
// throw new DataAccessException(exc.toString());
// } finally {
// out.close();
// }
}
use of cbit.vcell.simdata.SimDataBlock in project vcell by virtualcell.
the class RasterExporter method makePLYWithTexData.
public ExportOutput[] makePLYWithTexData(OutputContext outputContext, JobRequest jobRequest, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, FileDataContainerManager fileDataContainerManager) throws Exception {
String simID = exportSpecs.getVCDataIdentifier().getID();
VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
cbit.vcell.solvers.CartesianMesh mesh = dataServerImpl.getMesh(user, vcdID);
TimeSpecs timeSpecs = exportSpecs.getTimeSpecs();
VariableSpecs variableSpecs = exportSpecs.getVariableSpecs();
Vector<ExportOutput> exportOutV = new Vector<ExportOutput>();
RegionImage regionImage = MeshDisplayAdapter.generateRegionImage(mesh, null);
PLYSpecs plySpecs = (PLYSpecs) exportSpecs.getFormatSpecificSpecs();
DisplayPreferences[] displayPreferences = plySpecs.getDisplayPreferences();
// BitSet bInDomain = null;
// String variableName = variableSpecs.getVariableNames()[0];
// Domain varDomain = null;
// DataIdentifier[] dataIdentifiers = dataServerImpl.getDataIdentifiers(outputContext, user, vcdID);
// for (int i = 0; i < dataIdentifiers.length; i++) {
// //dataIdentifier.getDomain();
// if(dataIdentifiers[i].getName().equals(variableName)){
// varDomain = dataIdentifiers[i].getDomain();
// break;
// }
// }
// MembraneElement membraneElement = mesh.getMembraneElements()[faceIndex];
// String memSubdomainName = (varDomain==null?null:mesh.getMembraneSubdomainNamefromMemIndex(faceIndex));
// boolean bInDomain = (varDomain==null?true:varDomain.getName().equals(memSubdomainName));
DisplayAdapterService das = new DisplayAdapterService();
StringWriter stringWriter = new StringWriter();
PolyTexHelper imgResults = writeStanfordPolygonTex(regionImage, stringWriter, /*,bInDomain*/
mesh);
// mesh
ExportOutput exportOut = new ExportOutput(true, ".ply", simID.toString(), "_memb", fileDataContainerManager);
fileDataContainerManager.append(exportOut.getFileDataContainerID(), stringWriter.toString());
exportOutV.add(exportOut);
// special neighbor annotation image
ExportOutput textImagetOut0 = new ExportOutput(true, ".png", simID.toString(), "_membAnnot", fileDataContainerManager);
fileDataContainerManager.append(textImagetOut0.getFileDataContainerID(), imgResults.specialNeighborImage);
exportOutV.add(textImagetOut0);
for (int varNameIndex = 0; varNameIndex < variableSpecs.getVariableNames().length; varNameIndex++) {
if (das.fetchColorModel(displayPreferences[varNameIndex].getColorMode()) == null) {
if (displayPreferences[varNameIndex].getColorMode().equals(DisplayAdapterService.GRAY)) {
das.addColorModelForValues(DisplayAdapterService.createGrayColorModel(), DisplayAdapterService.createBlueRedSpecialColors(), displayPreferences[varNameIndex].getColorMode());
} else {
das.addColorModelForValues(DisplayAdapterService.createBlueRedColorModel(), DisplayAdapterService.createGraySpecialColors(), displayPreferences[varNameIndex].getColorMode());
// das.setActiveColorModelID("Contrast");
}
}
// BitSet domainValid = (displayPreferences[varNameIndex]==null?null:(displayPreferences[varNameIndex].getDomainValid()==null?null:displayPreferences[varNameIndex].getDomainValid()));
ExportSpecs.setupDisplayAdapterService(displayPreferences[varNameIndex], das, displayPreferences[varNameIndex].getScaleSettings());
for (int j = timeSpecs.getBeginTimeIndex(); j <= timeSpecs.getEndTimeIndex(); j++) {
BufferedImage image = createTextureImage(imgResults.imageSideSize);
int[] imgBuffer = ((DataBufferInt) (image.getRaster().getDataBuffer())).getData();
Arrays.fill(imgBuffer, Integer.MAX_VALUE);
SimDataBlock simDataBlock = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[varNameIndex], timeSpecs.getAllTimes()[j]);
for (int k = 0; k < imgResults.dataIndexes.length; k++) {
if (imgBuffer[k] != Integer.MAX_VALUE) {
System.out.println("texture pixel used twice");
}
double avgVal = 0;
for (int l = 0; l < imgResults.dataIndexes[k].length; l++) {
avgVal += simDataBlock.getData()[imgResults.dataIndexes[k][l]];
}
imgBuffer[k] = das.getColorFromValue(avgVal / imgResults.dataIndexes[k].length);
}
byte[] pngImage = flipPNG(image);
ExportOutput textImagetOut = new ExportOutput(true, ".png", simID.toString(), "_memb_" + variableSpecs.getVariableNames()[varNameIndex] + "_" + j, fileDataContainerManager);
fileDataContainerManager.append(textImagetOut.getFileDataContainerID(), pngImage);
exportOutV.add(textImagetOut);
}
}
ExportOutput[] exportOutputArr = exportOutV.toArray(new ExportOutput[0]);
return exportOutputArr;
}
Aggregations