use of cbit.vcell.solvers.MeshDisplayAdapter in project vcell by virtualcell.
the class PDEDataViewer method createDataValueSurfaceViewer.
/**
* Insert the method's description here.
* Creation date: (9/25/2005 1:53:00 PM)
*/
private DataValueSurfaceViewer createDataValueSurfaceViewer(ClientTaskStatusSupport clientTaskStatusSupport) throws ImageException, UserCancelException {
// try{
// if(fieldDataValueSurfaceViewer == null){
// Surfaces
CartesianMesh cartesianMesh = getPdeDataContext().getCartesianMesh();
if (cartesianMesh.getMembraneElements() == null || cartesianMesh.getMembraneElements().length == 0 || cartesianMesh.isChomboMesh()) {
// return fieldDataValueSurfaceViewer;
return getDataValueSurfaceViewer();
}
meshRegionSurfaces = new MeshDisplayAdapter(cartesianMesh).generateMeshRegionSurfaces(clientTaskStatusSupport);
SurfaceCollection surfaceCollection = meshRegionSurfaces.getSurfaceCollection();
// SurfaceNames
final String[] surfaceNames = new String[meshRegionSurfaces.getSurfaceCollection().getSurfaceCount()];
for (int i = 0; i < meshRegionSurfaces.getSurfaceCollection().getSurfaceCount(); i++) {
// Get the first element, any will do, all have same inside/outside volumeIndex
MembraneElement me = cartesianMesh.getMembraneElements()[meshRegionSurfaces.getMembraneIndexForPolygon(i, 0)];
if (getSimulationModelInfo() != null) {
surfaceNames[i] = getSimulationModelInfo().getMembraneName(cartesianMesh.getSubVolumeFromVolumeIndex(me.getInsideVolumeIndex()), cartesianMesh.getSubVolumeFromVolumeIndex(me.getOutsideVolumeIndex()), false);
} else {
surfaceNames[i] = i + "";
}
}
// SurfaceAreas
final Double[] surfaceAreas = new Double[meshRegionSurfaces.getSurfaceCollection().getSurfaceCount()];
for (int i = 0; i < meshRegionSurfaces.getSurfaceCollection().getSurfaceCount(); i++) {
surfaceAreas[i] = new Double(cartesianMesh.getRegionMembraneSurfaceAreaFromMembraneIndex(meshRegionSurfaces.getMembraneIndexForPolygon(i, 0)));
}
// DataValueSurfaceViewer fieldDataValueSurfaceViewer0 = new DataValueSurfaceViewer();
TaubinSmoothing taubinSmoothing = new TaubinSmoothingWrong();
TaubinSmoothingSpecification taubinSpec = TaubinSmoothingSpecification.getInstance(.3);
taubinSmoothing.smooth(surfaceCollection, taubinSpec);
getDataValueSurfaceViewer().init(meshRegionSurfaces.getSurfaceCollection(), cartesianMesh.getOrigin(), cartesianMesh.getExtent(), surfaceNames, surfaceAreas, cartesianMesh.getGeometryDimension());
return getDataValueSurfaceViewer();
// }
// }catch(UserCancelException e){
// throw e;
// }catch(Exception e){
// PopupGenerator.showErrorDialog(PDEDataViewer.this, e.getMessage(), e);
// }
// return fieldDataValueSurfaceViewer;
}
use of cbit.vcell.solvers.MeshDisplayAdapter in project vcell by virtualcell.
the class PDEOffscreenRenderer method getPixelsRGB.
/**
* Insert the method's description here.
* Creation date: (3/1/2001 11:54:44 PM)
* @return int[]
*/
public int[] getPixelsRGB(int imageScale, int membrScale, int meshMode, int volVarMembrOutlineThickness) {
if (getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.VOLUME) || getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.POSTPROCESSING)) {
CartesianMesh mesh = getServerPDEDataContext().getCartesianMesh();
MeshDisplayAdapter meshDisplayAdapter = new MeshDisplayAdapter(mesh);
BufferedImage bufferedImage = getScaledRGBVolume(mesh, meshMode, imageScale, false);
//
if (!getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.POSTPROCESSING) && volVarMembrOutlineThickness > 0) {
cbit.vcell.geometry.CurveRenderer curveRenderer = new cbit.vcell.geometry.CurveRenderer(getDisplayAdapterService());
curveRenderer.setNormalAxis(getNormalAxis());
org.vcell.util.Origin origin = mesh.getOrigin();
org.vcell.util.Extent extent = mesh.getExtent();
curveRenderer.setWorldOrigin(new org.vcell.util.Coordinate(origin.getX(), origin.getY(), origin.getZ()));
Coordinate pixeldelta = getPixelDelta(extent, mesh, meshMode, imageScale);
curveRenderer.setWorldDelta(new org.vcell.util.Coordinate(pixeldelta.getX(), pixeldelta.getY(), pixeldelta.getZ()));
Hashtable<SampledCurve, int[]> curvesAndMembraneIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(getNormalAxis(), getSlice());
if (curvesAndMembraneIndexes != null) {
Curve[] curves = (Curve[]) org.vcell.util.BeanUtils.getArray(curvesAndMembraneIndexes.keys(), Curve.class);
for (int i = 0; curves != null && i < curves.length; i++) {
curveRenderer.addCurve(curves[i]);
curveRenderer.renderPropertySegmentColors(curves[i], null);
curveRenderer.renderPropertyLineWidthMultiplier(curves[i], volVarMembrOutlineThickness);
}
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
// must be false or could get more than 256 colors
curveRenderer.setAntialias(false);
curveRenderer.draw(g);
}
}
return ((DataBufferInt) bufferedImage.getData().getDataBuffer()).getData();
} else if (getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.MEMBRANE)) {
CartesianMesh mesh = getServerPDEDataContext().getCartesianMesh();
MeshDisplayAdapter meshDisplayAdapter = new MeshDisplayAdapter(mesh);
BufferedImage bufferedImage = getScaledRGBVolume(mesh, meshMode, imageScale, true);
//
// apply curve renderer
//
cbit.vcell.geometry.CurveRenderer curveRenderer = new cbit.vcell.geometry.CurveRenderer(getDisplayAdapterService());
curveRenderer.setNormalAxis(getNormalAxis());
org.vcell.util.Origin origin = mesh.getOrigin();
org.vcell.util.Extent extent = mesh.getExtent();
curveRenderer.setWorldOrigin(new org.vcell.util.Coordinate(origin.getX(), origin.getY(), origin.getZ()));
Coordinate pixeldelta = getPixelDelta(extent, mesh, meshMode, imageScale);
curveRenderer.setWorldDelta(new org.vcell.util.Coordinate(pixeldelta.getX(), pixeldelta.getY(), pixeldelta.getZ()));
Hashtable<SampledCurve, int[]> curvesAndMembraneIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(getNormalAxis(), getSlice());
if (curvesAndMembraneIndexes != null) {
Curve[] curves = (Curve[]) org.vcell.util.BeanUtils.getArray(curvesAndMembraneIndexes.keys(), Curve.class);
for (int i = 0; curves != null && i < curves.length; i++) {
curveRenderer.addCurve(curves[i]);
curveRenderer.renderPropertySegmentColors(curves[i], getCurveColors(curvesAndMembraneIndexes, curves[i], meshDisplayAdapter));
curveRenderer.renderPropertyLineWidthMultiplier(curves[i], membrScale);
}
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
curveRenderer.setAntialias(false);
curveRenderer.draw(g);
}
return ((DataBufferInt) bufferedImage.getData().getDataBuffer()).getData();
} else {
throw new RuntimeException("unsupported VariableType " + getServerPDEDataContext().getDataIdentifier().getVariableType());
}
}
Aggregations