Search in sources :

Example 16 with VCPixelClass

use of cbit.image.VCPixelClass in project vcell by virtualcell.

the class GeomDbDriver method getImageRegionsForVCImage.

/**
 * This method was created in VisualAge.
 * @param vcImage cbit.image.VCImage
 */
private void getImageRegionsForVCImage(QueryHashtable dbc, Connection con, VCImage vcImage) throws SQLException, DataAccessException {
    String sql;
    sql = " SELECT *" + // 
    " FROM " + imageRegionTable.getTableName() + // 
    " WHERE " + imageRegionTable.imageRef + " = " + vcImage.getVersion().getVersionKey() + " ORDER BY " + imageRegionTable.id;
    // 
    // System.out.println(sql);
    // 
    // Connection con = conFact.getConnection();
    Statement stmt = con.createStatement();
    try {
        ResultSet rset = stmt.executeQuery(sql);
        // 
        // get vcPixelClass objects and give them to vcImage
        // 
        Vector<VCPixelClass> vcpcVector = new Vector<VCPixelClass>();
        while (rset.next()) {
            KeyValue vcpcKey = new KeyValue(rset.getBigDecimal(imageRegionTable.id.toString()));
            // 
            // try to get PixelClass from object cache
            // 
            VCPixelClass vcpc = (VCPixelClass) dbc.get(vcpcKey);
            if (vcpc == null) {
                String vcpcName = rset.getString(imageRegionTable.regionName.toString());
                int vcpcPixVal = new Integer(rset.getInt(imageRegionTable.pixelValue.toString())).intValue();
                vcpc = new VCPixelClass(vcpcKey, vcpcName, vcpcPixVal);
                // 
                // put the ImageRegion in the object cache
                // 
                dbc.put(vcpcKey, vcpc);
            }
            vcpcVector.addElement(vcpc);
        }
        VCPixelClass[] vcPixelClasses = (VCPixelClass[]) BeanUtils.getArray(vcpcVector, VCPixelClass.class);
        vcImage.setPixelClasses(vcPixelClasses);
        if (vcImage instanceof VCImageCompressed) {
            // Fix out of memory error when a BioModel has many apps with large geometries
            ((VCImageCompressed) vcImage).nullifyUncompressedPixels();
        }
    } catch (PropertyVetoException e) {
        throw new DataAccessException(e.getMessage());
    } finally {
        // Release resources include resultset
        stmt.close();
    }
}
Also used : VCPixelClass(cbit.image.VCPixelClass) KeyValue(org.vcell.util.document.KeyValue) Statement(java.sql.Statement) VCImageCompressed(cbit.image.VCImageCompressed) PropertyVetoException(java.beans.PropertyVetoException) ResultSet(java.sql.ResultSet) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException)

Example 17 with VCPixelClass

use of cbit.image.VCPixelClass in project vcell by virtualcell.

the class ImageRegionTable method getVCPixelClass.

/**
 * This method was created in VisualAge.
 * @return Model
 * @param rset ResultSet
 * @param log SessionLog
 */
public VCPixelClass getVCPixelClass(ResultSet rset, SessionLog log) throws SQLException {
    KeyValue key = new KeyValue(rset.getBigDecimal(id.toString()));
    String rName = rset.getString(regionName.toString());
    int pixValue = rset.getInt(pixelValue.toString());
    VCPixelClass vcPixelClass = new VCPixelClass(key, rName, pixValue);
    return vcPixelClass;
}
Also used : VCPixelClass(cbit.image.VCPixelClass) KeyValue(org.vcell.util.document.KeyValue)

Aggregations

VCPixelClass (cbit.image.VCPixelClass)17 VCImage (cbit.image.VCImage)7 KeyValue (org.vcell.util.document.KeyValue)7 SubVolume (cbit.vcell.geometry.SubVolume)6 PropertyVetoException (java.beans.PropertyVetoException)6 ImageException (cbit.image.ImageException)4 Geometry (cbit.vcell.geometry.Geometry)4 ArrayList (java.util.ArrayList)4 Vector (java.util.Vector)4 DataAccessException (org.vcell.util.DataAccessException)4 VCImageCompressed (cbit.image.VCImageCompressed)3 VCImageUncompressed (cbit.image.VCImageUncompressed)3 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)3 GeometryException (cbit.vcell.geometry.GeometryException)3 GeometrySpec (cbit.vcell.geometry.GeometrySpec)3 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)3 IOException (java.io.IOException)3 Extent (org.vcell.util.Extent)3 ISize (org.vcell.util.ISize)3 Origin (org.vcell.util.Origin)3