use of org.vcell.vis.io.VtuFileContainer in project vcell by virtualcell.
the class CartesianMeshVtkFileWriter method getEmptyVtuMeshFiles.
public VtuFileContainer getEmptyVtuMeshFiles(VCellSimFiles vcellFiles, File destinationDirectory) throws IOException, MathException, DataAccessException {
//
// read the simplified cartesian mesh
//
CartesianMeshFileReader reader = new CartesianMeshFileReader();
CartesianMesh mesh = reader.readFromFiles(vcellFiles);
//
// for each domain in cartesian mesh, get the mesh file
//
ArrayList<String> domains = new ArrayList<String>();
domains.addAll(mesh.getVolumeDomainNames());
domains.addAll(mesh.getMembraneDomainNames());
boolean bMeshFileMissing = false;
ArrayList<File> meshFiles = new ArrayList<File>();
for (String domainName : domains) {
File file = getVtuMeshFileName(vcellFiles, domainName);
meshFiles.add(file);
if (!file.exists()) {
bMeshFileMissing = true;
}
}
if (bMeshFileMissing) {
writeEmptyMeshFiles(vcellFiles, destinationDirectory, null);
}
VtuFileContainer vtuFileContainer = new VtuFileContainer();
for (int i = 0; i < domains.size(); i++) {
byte[] vtuMeshFileContents = FileUtils.readByteArrayFromFile(meshFiles.get(i));
vtuFileContainer.addVtuMesh(new VtuFileContainer.VtuMesh(domains.get(i), 0.0, vtuMeshFileContents));
}
return vtuFileContainer;
}
use of org.vcell.vis.io.VtuFileContainer in project vcell by virtualcell.
the class VCellProxyHandler method downloadEmptyVtuFileContainer.
private VtuFileContainer downloadEmptyVtuFileContainer(SimulationDataSetRef simulationDataSetRef, int timeIndex) throws ThriftDataAccessException {
try {
VtkManager vtkManager = vcellClientDataService.getVtkManager(simulationDataSetRef);
VtuFileContainer vtuFileContainer = vtkManager.getEmptyVtuMeshFiles(timeIndex);
return vtuFileContainer;
} catch (Exception e) {
e.printStackTrace();
throw new ThriftDataAccessException("failed to get data for simulation " + simulationDataSetRef + ": " + e.getMessage());
}
}
use of org.vcell.vis.io.VtuFileContainer in project vcell by virtualcell.
the class DataSetControllerImpl method getEmptyVtuMeshFiles.
public VtuFileContainer getEmptyVtuMeshFiles(ComsolSimFiles comsolSimFiles, VCDataIdentifier vcdataID, int timeIndex) throws DataAccessException {
try {
if (timeIndex > 0) {
throw new RuntimeException("only time index 0 supported for comsol vtk mesh files");
}
ComsolVtkFileWriter comsolVTKFileWriter = new ComsolVtkFileWriter();
File primaryDirectory = getPrimaryUserDir(vcdataID.getOwner(), false);
VtuFileContainer vtuFiles = comsolVTKFileWriter.getEmptyVtuMeshFiles(comsolSimFiles, primaryDirectory);
return vtuFiles;
} catch (Exception e) {
lg.error(e.getMessage(), e);
throw new DataAccessException("failed to retrieve VTK files: " + e.getMessage(), e);
}
}
use of org.vcell.vis.io.VtuFileContainer in project vcell by virtualcell.
the class VCellProxyHandler method getEmptyMeshFile.
private File getEmptyMeshFile(SimulationDataSetRef simulationDataSetRef, String domainName, int timeIndex) throws ThriftDataAccessException {
if (!simulationDataSetRef.isTimeVaryingMesh) {
timeIndex = 0;
}
File vtuEmptyMeshFile;
try {
vtuEmptyMeshFile = getEmptyMeshFileLocation(simulationDataSetRef, domainName, timeIndex);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
throw new ThriftDataAccessException("failed to find data location: " + e1.getMessage());
}
System.out.println("looking for file: " + vtuEmptyMeshFile);
//
if (!vtuEmptyMeshFile.exists()) {
try {
VtuFileContainer vtuFileContainer = downloadEmptyVtuFileContainer(simulationDataSetRef, timeIndex);
for (VtuFileContainer.VtuMesh mesh : vtuFileContainer.getVtuMeshes()) {
FileUtils.writeByteArrayToFile(mesh.vtuMeshContents, getEmptyMeshFileLocation(simulationDataSetRef, mesh.domainName, timeIndex));
}
if (!vtuEmptyMeshFile.exists()) {
System.out.println("after export, couldn't find requested empty mesh file " + vtuEmptyMeshFile);
throw new ThriftDataAccessException("after export, couldn't find empty requested mesh file " + vtuEmptyMeshFile);
}
System.out.println("vtuData file exists, " + vtuEmptyMeshFile);
} catch (IOException e) {
e.printStackTrace();
System.out.println("failed to export entire dataset: " + e.getMessage());
throw new ThriftDataAccessException("failed to export entire dataset: " + e.getMessage());
}
}
return vtuEmptyMeshFile;
}
use of org.vcell.vis.io.VtuFileContainer in project vcell by virtualcell.
the class DataSetControllerImpl method getEmptyVtuMeshFiles.
public VtuFileContainer getEmptyVtuMeshFiles(MovingBoundarySimFiles movingBoundarySimFiles, VCDataIdentifier vcdataID, int timeIndex) throws DataAccessException {
try {
MovingBoundaryVtkFileWriter movingBoundaryVtkFileWriter = new MovingBoundaryVtkFileWriter();
File primaryDirectory = PropertyLoader.getRequiredDirectory(PropertyLoader.primarySimDataDirInternalProperty);
VtuFileContainer vtuFiles = movingBoundaryVtkFileWriter.getEmptyVtuMeshFiles(movingBoundarySimFiles, timeIndex, primaryDirectory);
return vtuFiles;
} catch (Exception e) {
lg.error(e.getMessage(), e);
throw new DataAccessException("failed to retrieve VTK files: " + e.getMessage(), e);
}
}
Aggregations