Search in sources :

Example 1 with MeshDisplayAdapter

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;
}
Also used : SurfaceCollection(cbit.vcell.geometry.surface.SurfaceCollection) CartesianMesh(cbit.vcell.solvers.CartesianMesh) TaubinSmoothingWrong(cbit.vcell.geometry.surface.TaubinSmoothingWrong) MeshDisplayAdapter(cbit.vcell.solvers.MeshDisplayAdapter) TaubinSmoothingSpecification(cbit.vcell.geometry.surface.TaubinSmoothingSpecification) TaubinSmoothing(cbit.vcell.geometry.surface.TaubinSmoothing) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint)

Example 2 with MeshDisplayAdapter

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());
    }
}
Also used : Extent(org.vcell.util.Extent) DataBufferInt(java.awt.image.DataBufferInt) BufferedImage(java.awt.image.BufferedImage) MeshDisplayAdapter(cbit.vcell.solvers.MeshDisplayAdapter) SampledCurve(cbit.vcell.geometry.SampledCurve) Hashtable(java.util.Hashtable) Curve(cbit.vcell.geometry.Curve) SampledCurve(cbit.vcell.geometry.SampledCurve) Extent(org.vcell.util.Extent) Graphics2D(java.awt.Graphics2D) Coordinate(org.vcell.util.Coordinate) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Coordinate(org.vcell.util.Coordinate)

Aggregations

CartesianMesh (cbit.vcell.solvers.CartesianMesh)2 MeshDisplayAdapter (cbit.vcell.solvers.MeshDisplayAdapter)2 Curve (cbit.vcell.geometry.Curve)1 SampledCurve (cbit.vcell.geometry.SampledCurve)1 SinglePoint (cbit.vcell.geometry.SinglePoint)1 SurfaceCollection (cbit.vcell.geometry.surface.SurfaceCollection)1 TaubinSmoothing (cbit.vcell.geometry.surface.TaubinSmoothing)1 TaubinSmoothingSpecification (cbit.vcell.geometry.surface.TaubinSmoothingSpecification)1 TaubinSmoothingWrong (cbit.vcell.geometry.surface.TaubinSmoothingWrong)1 Graphics2D (java.awt.Graphics2D)1 Point (java.awt.Point)1 BufferedImage (java.awt.image.BufferedImage)1 DataBufferInt (java.awt.image.DataBufferInt)1 Hashtable (java.util.Hashtable)1 Coordinate (org.vcell.util.Coordinate)1 Extent (org.vcell.util.Extent)1