Search in sources :

Example 11 with SampledCurve

use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.

the class MeshDisplayAdapter method getCurvesFromContours.

/**
 * Insert the method's description here.
 * Creation date: (11/9/2000 4:36:26 PM)
 * @return java.util.Hashtable
 * @param normalAxis int
 * @param slice int
 * @param countourValues double[]
 */
public Hashtable<SampledCurve, Vector<Double>> getCurvesFromContours(double[] countourValues) {
    ContourElement[] contourElements = mesh.getContourElements();
    if (contourElements == null) {
        return null;
    }
    if (countourValues != null && countourValues.length != contourElements.length) {
        throw new RuntimeException("countourValues.length != contourElements.length");
    }
    Hashtable<SampledCurve, Vector<Double>> curvesAndValues = new Hashtable<SampledCurve, Vector<Double>>();
    SampledCurve newCurve = null;
    Vector<Double> resolvedContourValues = null;
    for (int c = 0; c < contourElements.length; c += 1) {
        if (contourElements[c].isBegin()) {
            newCurve = new SampledCurve();
            resolvedContourValues = new Vector<Double>();
        }
        newCurve.appendControlPoint(contourElements[c].getBeginCoordinate());
        if (countourValues != null) {
            resolvedContourValues.addElement(new Double(countourValues[c]));
        }
        if (contourElements[c].isEnd()) {
            newCurve.appendControlPoint(contourElements[c].getEndCoordinate());
            curvesAndValues.put(newCurve, resolvedContourValues);
        }
    }
    return curvesAndValues;
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) Hashtable(java.util.Hashtable) Vector(java.util.Vector)

Example 12 with SampledCurve

use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.

the class PDEDataContextPanel method getCurveValue.

/**
 * Insert the method's description here.
 * Creation date: (3/13/2001 12:53:10 PM)
 * @return java.lang.String
 * @param csi cbit.vcell.geometry.CurveSelectionInfo
 */
public String getCurveValue(CurveSelectionInfo csi) {
    String infoS = null;
    if (csi.getType() == CurveSelectionInfo.TYPE_SEGMENT) {
        if (membranesAndIndexes != null) {
            java.util.Enumeration<SampledCurve> keysEnum = membranesAndIndexes.keys();
            while (keysEnum.hasMoreElements()) {
                Curve curve = (Curve) keysEnum.nextElement();
                if (csi.getCurve() == curve) {
                    int[] membraneIndexes = (int[]) membranesAndIndexes.get(curve);
                    if (meshDisplayAdapter != null) {
                        double[] membraneValues = meshDisplayAdapter.getDataValuesForMembraneIndexes(membraneIndexes, getPdeDataContext().getDataValues(), getPdeDataContext().getDataIdentifier().getVariableType());
                        if (membraneValues != null) {
                            Coordinate segmentWC = getPdeDataContext().getCartesianMesh().getCoordinateFromMembraneIndex(membraneIndexes[csi.getSegment()]);
                            String xCoordString = NumberUtils.formatNumber(segmentWC.getX());
                            String yCoordString = NumberUtils.formatNumber(segmentWC.getY());
                            String zCoordString = NumberUtils.formatNumber(segmentWC.getZ());
                            boolean bDefined = getDataInfoProvider() == null || getDataInfoProvider().isDefined(membraneIndexes[csi.getSegment()]);
                            infoS = "(" + xCoordString + "," + yCoordString + "," + zCoordString + ")  [" + membraneIndexes[csi.getSegment()] + "]  Value = " + (bDefined ? membraneValues[csi.getSegment()] : "Undefined");
                            if (getPdeDataContext().getCartesianMesh() != null && getPdeDataContext().getCartesianMesh().isChomboMesh()) {
                                if (bDefined && getDataInfoProvider() != null) {
                                    StructureMetricsEntry structure = ((CartesianMeshChombo) getDataInfoProvider().getPDEDataContext().getCartesianMesh()).getStructureInfo(getDataInfoProvider().getPDEDataContext().getDataIdentifier());
                                    if (structure != null) {
                                        infoS += " || " + structure.getDisplayLabel();
                                    }
                                }
                            } else {
                                if (getDataInfoProvider() != null) {
                                    MembraneDataInfo membraneDataInfo = getDataInfoProvider().getMembraneDataInfo(membraneIndexes[csi.getSegment()]);
                                    infoS += "          ";
                                    infoS += " \"" + membraneDataInfo.membraneName + "\"";
                                    infoS += " mrID=" + membraneDataInfo.membraneRegionID;
                                }
                                String curveDescr = CurveRenderer.getROIDescriptions(segmentWC, getImagePlaneManagerPanel().getCurveRenderer());
                                if (curveDescr != null) {
                                    infoS += "     " + curveDescr;
                                }
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
    return infoS;
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) Coordinate(org.vcell.util.Coordinate) ControlPointCurve(cbit.vcell.geometry.ControlPointCurve) Curve(cbit.vcell.geometry.Curve) SampledCurve(cbit.vcell.geometry.SampledCurve) CurveSelectionCurve(cbit.vcell.geometry.CurveSelectionCurve) StructureMetricsEntry(cbit.vcell.solvers.CartesianMeshChombo.StructureMetricsEntry) MembraneDataInfo(cbit.vcell.simdata.MembraneDataInfo) CartesianMeshChombo(cbit.vcell.solvers.CartesianMeshChombo)

Example 13 with SampledCurve

use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.

the class PDEDataContextPanel method findChomboCurveSelectionInfoForPoint.

@Override
public CurveSelectionInfo findChomboCurveSelectionInfoForPoint(CoordinateIndex ci) {
    if (getPdeDataContext().getCartesianMesh().isChomboMesh()) {
        CartesianMeshChombo chomboMesh = (CartesianMeshChombo) getPdeDataContext().getCartesianMesh();
        int memIndex = chomboMesh.findMembraneIndexFromVolumeIndex(ci);
        if (memIndex >= 0) {
            for (Entry<SampledCurve, int[]> entry : membranesAndIndexes.entrySet()) {
                SampledCurve sc = entry.getKey();
                int[] memIndexes = entry.getValue();
                for (int idx = 0; idx < memIndexes.length; ++idx) {
                    if (memIndexes[idx] == memIndex) {
                        return new CurveSelectionInfo(sc, CurveSelectionInfo.TYPE_SEGMENT, idx);
                    }
                }
            }
        }
    }
    return null;
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) CurveSelectionInfo(cbit.vcell.geometry.CurveSelectionInfo) CartesianMeshChombo(cbit.vcell.solvers.CartesianMeshChombo) SinglePoint(cbit.vcell.geometry.SinglePoint)

Example 14 with SampledCurve

use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.

the class ImageJHelper method sendMembraneOutline.

private static void sendMembraneOutline(ImageJConnection imageJConnection, Hashtable<SampledCurve, int[]>[] membraneTables) throws Exception {
    if (membraneTables != null) {
        // num slices
        imageJConnection.dos.writeInt(membraneTables.length);
        for (Hashtable<SampledCurve, int[]> membraneTable : membraneTables) {
            // System.out.println();
            if (membraneTable != null) {
                // some slices have no membrane outline
                // num polygons on slice
                imageJConnection.dos.writeInt(membraneTable.size());
                Enumeration<SampledCurve> sliceMembranes = membraneTable.keys();
                while (sliceMembranes.hasMoreElements()) {
                    SampledCurve sampledCurve = sliceMembranes.nextElement();
                    Vector<Coordinate> polygonPoints = sampledCurve.getControlPointsVector();
                    // System.out.println(polygonPoints.size());
                    // num points for polygon
                    imageJConnection.dos.writeInt(polygonPoints.size());
                    // isClosed
                    imageJConnection.dos.writeInt((sampledCurve.isClosed() ? 1 : 0));
                    for (Coordinate coord : polygonPoints) {
                        imageJConnection.dos.writeDouble(coord.getX());
                        imageJConnection.dos.writeDouble(coord.getY());
                        imageJConnection.dos.writeDouble(coord.getZ());
                    }
                }
            } else {
                imageJConnection.dos.writeInt(0);
            }
        }
    } else {
        imageJConnection.dos.writeInt(0);
    }
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) Coordinate(org.vcell.util.Coordinate)

Example 15 with SampledCurve

use of cbit.vcell.geometry.SampledCurve 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

SampledCurve (cbit.vcell.geometry.SampledCurve)18 Coordinate (org.vcell.util.Coordinate)11 SinglePoint (cbit.vcell.geometry.SinglePoint)8 ControlPointCurve (cbit.vcell.geometry.ControlPointCurve)6 Curve (cbit.vcell.geometry.Curve)6 VariableType (cbit.vcell.math.VariableType)5 Vector (java.util.Vector)5 CurveSelectionCurve (cbit.vcell.geometry.CurveSelectionCurve)4 CurveSelectionInfo (cbit.vcell.geometry.CurveSelectionInfo)3 Hashtable (java.util.Hashtable)3 CurveRenderer (cbit.vcell.geometry.CurveRenderer)2 Line (cbit.vcell.geometry.Line)2 Spline (cbit.vcell.geometry.Spline)2 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)2 DataIdentifier (cbit.vcell.simdata.DataIdentifier)2 SpatialSelectionMembrane (cbit.vcell.simdata.SpatialSelectionMembrane)2 SpatialSelectionVolume (cbit.vcell.simdata.SpatialSelectionVolume)2 CartesianMesh (cbit.vcell.solvers.CartesianMesh)2 CartesianMeshChombo (cbit.vcell.solvers.CartesianMeshChombo)2 Element (org.jdom.Element)2