use of org.vcell.util.document.VCDataIdentifier in project vcell by virtualcell.
the class RasterExporter method makeVTKUnstructuredData_VCell.
public ExportOutput[] makeVTKUnstructuredData_VCell(OutputContext outputContext, final JobRequest jobRequest, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, File tmpDir, FileDataContainerManager fileDataContainerManager) throws Exception {
String simID = exportSpecs.getVCDataIdentifier().getID();
final VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
VariableSpecs variableSpecs = exportSpecs.getVariableSpecs();
TimeSpecs timeSpecs = exportSpecs.getTimeSpecs();
VCellSimFiles vcellFiles = dataServerImpl.getVCellSimFiles(user, vcdID);
CartesianMeshVtkFileWriter cartesianMeshVtkFileWriter = new CartesianMeshVtkFileWriter();
File[] vtkFiles = cartesianMeshVtkFileWriter.writeVtuExportFiles(vcellFiles, tmpDir, new CartesianMeshVtkFileWriter.ProgressListener() {
public void progress(double percentDone) {
exportServiceImpl.fireExportProgress(jobRequest.getJobID(), vcdID, "VTKUNSTR", percentDone);
}
});
Vector<ExportOutput> exportOutV = new Vector<ExportOutput>();
for (File file : vtkFiles) {
String dataID = file.getName().replace(simID.toString(), "");
ExportOutput exportOut = new ExportOutput(true, ".vtu", simID.toString(), dataID, fileDataContainerManager);
fileDataContainerManager.manageExistingTempFile(exportOut.getFileDataContainerID(), file);
exportOutV.add(exportOut);
}
ExportOutput[] exportOutputArr = exportOutV.toArray(new ExportOutput[0]);
return exportOutputArr;
}
use of org.vcell.util.document.VCDataIdentifier 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 org.vcell.util.document.VCDataIdentifier 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;
}
use of org.vcell.util.document.VCDataIdentifier in project vcell by virtualcell.
the class RasterExporter method exportPDEData.
private NrrdInfo[] exportPDEData(OutputContext outputContext, long jobID, User user, DataServerImpl dataServerImpl, VCDataIdentifier vcdID, VariableSpecs variableSpecs, TimeSpecs timeSpecs2, GeometrySpecs geometrySpecs, RasterSpecs rasterSpecs, FileDataContainerManager fileDataContainerManager) throws RemoteException, DataAccessException, IOException {
CartesianMesh mesh = dataServerImpl.getMesh(user, vcdID);
DataProcessingOutputInfo dataProcessingOutputInfo = null;
// check if any of export variables are PostProcess and if so try to get PostProcessOutputInfo
exportServiceImpl.fireExportProgress(jobID, vcdID, "Check PostProcess", 0.0);
DataIdentifier[] dataIdentifiers = dataServerImpl.getDataIdentifiers(outputContext, user, vcdID);
for (int i = 0; i < dataIdentifiers.length; i++) {
for (int j = 0; j < variableSpecs.getVariableNames().length; j++) {
if (variableSpecs.getVariableNames()[j].equals(dataIdentifiers[i].getName()) && VariableType.POSTPROCESSING.equals(dataIdentifiers[i].getVariableType())) {
try {
// we need PostProcessOutputInfo
exportServiceImpl.fireExportProgress(jobID, vcdID, "Read PostProcess", 0.0);
dataProcessingOutputInfo = (DataProcessingOutputInfo) dataServerImpl.doDataOperation(user, new DataOperation.DataProcessingOutputInfoOP(vcdID, false, outputContext));
break;
} catch (Exception e) {
throw new DataAccessException("Export variable '" + variableSpecs.getVariableNames()[j] + "' is PostProcessing type. Error reading PostProcessing data: " + e.getClass().getName() + " " + e.getMessage());
}
}
}
}
long lastUpdateTime = 0;
switch(rasterSpecs.getFormat()) {
case NRRD_SINGLE:
{
switch(geometrySpecs.getModeID()) {
case GEOMETRY_FULL:
{
NrrdInfo nrrdInfo = NRRDHelper.getSizeCheckedNrrdHelper(variableSpecs, mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo).createSingleFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, rasterSpecs, timeSpecs2);
int progressIndex = 1;
int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-snglfull", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
}
}
nrrdInfo = NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
return new NrrdInfo[] { nrrdInfo };
}
case GEOMETRY_SLICE:
{
NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createSingleFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, rasterSpecs, timeSpecs2);
int progressIndex = 1;
int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-snglslice", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
}
}
sliceNrrdInfo = NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
return new NrrdInfo[] { sliceNrrdInfo };
}
default:
{
throw new DataAccessException("NRRD export from slice not yet supported");
}
}
}
case NRRD_BY_TIME:
{
switch(geometrySpecs.getModeID()) {
case GEOMETRY_FULL:
{
NRRDHelper nrrdHelper = NRRDHelper.getSizeCheckedNrrdHelper(variableSpecs, mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo);
Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
int progressIndex = 1;
int progressEnd = (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-timefull", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
NrrdInfo nrrdInfo = nrrdHelper.createTimeFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, timeSpecs2.getAllTimes()[j], rasterSpecs);
nrrdinfoV.add(nrrdInfo);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
}
NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
}
if (nrrdinfoV.size() > 0) {
NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
nrrdinfoV.copyInto(nrrdinfoArr);
return nrrdinfoArr;
}
return null;
}
case GEOMETRY_SLICE:
{
Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
int progressIndex = 1;
int progressEnd = (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-timeslice", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createTimeFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, timeSpecs2.getAllTimes()[j], rasterSpecs);
nrrdinfoV.add(sliceNrrdInfo);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
}
NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
}
if (nrrdinfoV.size() > 0) {
NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
nrrdinfoV.copyInto(nrrdinfoArr);
return nrrdinfoArr;
}
return null;
}
default:
{
throw new DataAccessException("NRRD export from slice not yet supported");
}
}
}
case NRRD_BY_VARIABLE:
{
switch(geometrySpecs.getModeID()) {
case GEOMETRY_FULL:
{
Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
int progressIndex = 1;
int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
NRRDHelper nrrdhelHelper = new NRRDHelper(variableSpecs.getVariableNames()[i], mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo);
NrrdInfo nrrdInfo = nrrdhelHelper.createVariableFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2, rasterSpecs);
nrrdinfoV.add(nrrdInfo);
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-varsfull", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
}
nrrdInfo = NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
}
if (nrrdinfoV.size() > 0) {
NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
nrrdinfoV.copyInto(nrrdinfoArr);
return nrrdinfoArr;
}
return null;
}
case GEOMETRY_SLICE:
{
Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
int progressIndex = 1;
int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createVariableFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2, rasterSpecs);
nrrdinfoV.add(sliceNrrdInfo);
for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-varsfull", jobID, vcdID, progressIndex, progressEnd);
progressIndex++;
double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
}
NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
}
if (nrrdinfoV.size() > 0) {
NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
nrrdinfoV.copyInto(nrrdinfoArr);
return nrrdinfoArr;
}
return null;
}
default:
{
throw new DataAccessException("NRRD export from slice not yet supported");
}
}
}
default:
{
throw new DataAccessException("Multiple NRRD file export not yet supported");
}
}
}
use of org.vcell.util.document.VCDataIdentifier in project vcell by virtualcell.
the class RasterExporter method makeVTKImageData.
public ExportOutput[] makeVTKImageData(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);
Vector<ExportOutput> exportOutV = new Vector<ExportOutput>();
for (int j = timeSpecs.getBeginTimeIndex(); j <= timeSpecs.getEndTimeIndex(); j++) {
exportServiceImpl.fireExportProgress(jobRequest.getJobID(), vcdID, "VTKIMG", (double) (j - timeSpecs.getBeginTimeIndex()) / (double) (timeSpecs.getEndTimeIndex() - timeSpecs.getBeginTimeIndex() + 1));
StringBuffer sb = new StringBuffer();
sb.append("# vtk DataFile Version 2.0" + "\n");
sb.append("Simulation " + vcdID.toString() + "\n");
sb.append("ASCII" + "\n");
sb.append("DATASET STRUCTURED_POINTS" + "\n");
sb.append("DIMENSIONS " + mesh.getSizeX() + " " + mesh.getSizeY() + " " + mesh.getSizeZ() + "\n");
sb.append("SPACING " + mesh.getExtent().getX() + " " + mesh.getExtent().getY() + " " + mesh.getExtent().getZ() + "\n");
sb.append("ORIGIN " + mesh.getOrigin().getX() + " " + mesh.getOrigin().getY() + " " + mesh.getOrigin().getZ() + "\n");
sb.append("POINT_DATA " + mesh.getNumVolumeElements() + "\n");
// write volume region ids
sb.append("SCALARS " + "regionID" + " double 1" + "\n");
sb.append("LOOKUP_TABLE default" + "\n");
int yzSize = mesh.getSizeY() * mesh.getSizeZ();
int index = 0;
for (int yz = 0; yz < yzSize; yz++) {
for (int x = 0; x < mesh.getSizeX(); x++) {
sb.append((x != 0 ? " " : "") + mesh.getVolumeRegionIndex(index));
index++;
}
sb.append("\n");
}
sb.append("\n");
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)) {
sb.append("SCALARS " + variableSpecs.getVariableNames()[k] + " double 1" + "\n");
sb.append("LOOKUP_TABLE default" + "\n");
double[] volumeData = simDataBlock.getData();
index = 0;
for (int yz = 0; yz < yzSize; yz++) {
for (int x = 0; x < mesh.getSizeX(); x++) {
sb.append((x != 0 ? " " : "") + volumeData[index]);
index++;
}
sb.append("\n");
}
ExportOutput exportOut = new ExportOutput(true, ".vtk", simID.toString(), "_vol_" + j, fileDataContainerManager);
fileDataContainerManager.append(exportOut.getFileDataContainerID(), sb.toString());
exportOutV.add(exportOut);
} else {
throw new RuntimeException("VTK Image format only for volume data");
}
}
}
ExportOutput[] exportOutputArr = exportOutV.toArray(new ExportOutput[0]);
return exportOutputArr;
}
Aggregations