use of org.vcell.vis.vismesh.thrift.VisMesh in project vcell by virtualcell.
the class CartesianMeshVtkFileWriter method writeEmptyMeshFiles.
public File[] writeEmptyMeshFiles(VCellSimFiles vcellFiles, File destinationDirectory, ProgressListener progressListener) throws IOException, MathException {
if (destinationDirectory == null || !destinationDirectory.isDirectory()) {
throw new RuntimeException("destinationDirectory '" + destinationDirectory + " not valid");
}
//
// read the simplified cartesian mesh
//
CartesianMeshFileReader reader = new CartesianMeshFileReader();
CartesianMesh mesh = reader.readFromFiles(vcellFiles);
//
// for each volume domain in mesh, extract the associated VisMesh
//
List<String> volumeDomainNames = mesh.getVolumeDomainNames();
HashMap<String, VisMesh> domainMeshMap = new HashMap<String, VisMesh>();
for (String volumeDomainName : volumeDomainNames) {
CartesianMeshMapping meshMapping = new CartesianMeshMapping();
VisMesh visMesh = meshMapping.fromMeshData(mesh, volumeDomainName, true);
domainMeshMap.put(volumeDomainName, visMesh);
}
//
// for each membrane domain in mesh, extract the associated VisMesh
//
List<String> membraneDomainNames = mesh.getMembraneDomainNames();
for (String membraneDomainName : membraneDomainNames) {
CartesianMeshMapping meshMapping = new CartesianMeshMapping();
VisMesh visMesh = meshMapping.fromMeshData(mesh, membraneDomainName, false);
domainMeshMap.put(membraneDomainName, visMesh);
}
ArrayList<String> allDomainNames = new ArrayList<String>();
allDomainNames.addAll(volumeDomainNames);
allDomainNames.addAll(membraneDomainNames);
int numFiles = vcellFiles.getTimes().size() * allDomainNames.size();
ArrayList<File> files = new ArrayList<File>();
int filesProcessed = 0;
for (final String domainName : allDomainNames) {
//
// find the globalIndexes for each domain element - use this to extract the domain-only data.
//
VisMesh visMesh = domainMeshMap.get(domainName);
File vtuFile = getVtuMeshFileName(vcellFiles, domainName);
File fvIndexDataFileName = getFiniteVolumeIndexDataFileName(vcellFiles, domainName);
VtkService.getInstance().writeFiniteVolumeSmoothedVtkGridAndIndexData(visMesh, domainName, vtuFile, fvIndexDataFileName);
files.add(vtuFile);
filesProcessed++;
if (progressListener != null) {
progressListener.progress(((double) filesProcessed) / numFiles);
}
}
return files.toArray(new File[0]);
}
use of org.vcell.vis.vismesh.thrift.VisMesh in project vcell by virtualcell.
the class DebugWriteProblem method main.
/**
* @param args
*/
public static void main(String[] args) {
try {
VisMesh visMesh = new VisMesh(3, new Vect3D(0, 0, 0), new Vect3D(3, 1, 1));
VisPoint[] points0 = new VisPoint[] { new VisPoint(0, 0, 0), new VisPoint(1, 0, 0), new VisPoint(0, 1, 0), new VisPoint(0, 0, 1) };
visMesh.addToPoints(points0[0]);
visMesh.addToPoints(points0[1]);
visMesh.addToPoints(points0[2]);
visMesh.addToPoints(points0[3]);
List<PolyhedronFace> faces0 = Arrays.asList(new PolyhedronFace(Arrays.asList(0, 1, 3)), new PolyhedronFace(Arrays.asList(0, 3, 2)), new PolyhedronFace(Arrays.asList(0, 2, 1)), new PolyhedronFace(Arrays.asList(1, 3, 2)));
int level = 0;
int boxNumber = 0;
int boxIndex = 0;
int fraction = 0;
VisIrregularPolyhedron genPolyhedra0 = new VisIrregularPolyhedron(faces0);
genPolyhedra0.setChomboVolumeIndex(new ChomboVolumeIndex(level, boxNumber, boxIndex, fraction));
visMesh.addToIrregularPolyhedra(genPolyhedra0);
// VisPoint[] points1 = new VisPoint[] {
// new VisPoint(2+0, 0, 0),
// new VisPoint(2+1, 0, 0),
// new VisPoint(2+0, 1, 0),
// new VisPoint(2+0, 0, 1)
// };
//
// visMesh.addPoint(points1[0]);
// visMesh.addPoint(points1[1]);
// visMesh.addPoint(points1[2]);
// visMesh.addPoint(points1[3]);
//
// vtkUnstructuredGrid vtkgrid = VtkGridUtils.getVolumeVtkGrid(visMesh);
// String filenameASCII = "testASCII.vtk";
// String filenameBinary = "testBinary.vtk";
// VtkGridUtils.writeXML(vtkgrid, filenameASCII, true);
// VtkGridUtils.writeXML(vtkgrid, filenameBinary, false);
// vtkgrid = VtkGridUtils.read(filenameBinary);
// vtkgrid.BuildLinks();
// SimpleVTKViewer simpleViewer = new SimpleVTKViewer();
// String[] varNames = visDomain.getVisMeshData().getVarNames();
// simpleViewer.showGrid(vtkgrid, varNames[0], varNames[1]);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
Aggregations