Search in sources :

Example 1 with VolumeGeometricRegion

use of cbit.vcell.geometry.surface.VolumeGeometricRegion in project vcell by virtualcell.

the class ClientRequestManager method createMathModel.

/**
 * Insert the method's description here. Creation date: (5/24/2004 12:22:11 PM)
 *
 * @param windowID java.lang.String
 */
private MathModel createMathModel(String name, Geometry geometry) {
    MathModel mathModel = new MathModel(null);
    MathDescription mathDesc = mathModel.getMathDescription();
    try {
        mathDesc.setGeometry(geometry);
        if (geometry.getDimension() == 0) {
            mathDesc.addSubDomain(new CompartmentSubDomain("Compartment", CompartmentSubDomain.NON_SPATIAL_PRIORITY));
        } else {
            try {
                if (geometry.getDimension() > 0 && geometry.getGeometrySurfaceDescription().getGeometricRegions() == null) {
                    geometry.getGeometrySurfaceDescription().updateAll();
                }
            } catch (ImageException e) {
                e.printStackTrace(System.out);
                throw new RuntimeException("Geometric surface generation error: \n" + e.getMessage());
            } catch (GeometryException e) {
                e.printStackTrace(System.out);
                throw new RuntimeException("Geometric surface generation error: \n" + e.getMessage());
            }
            SubVolume[] subVolumes = geometry.getGeometrySpec().getSubVolumes();
            for (int i = 0; i < subVolumes.length; i++) {
                mathDesc.addSubDomain(new CompartmentSubDomain(subVolumes[i].getName(), subVolumes[i].getHandle()));
            }
            // 
            // add only those MembraneSubDomains corresponding to surfaces that acutally
            // exist in geometry.
            // 
            GeometricRegion[] regions = geometry.getGeometrySurfaceDescription().getGeometricRegions();
            for (int i = 0; i < regions.length; i++) {
                if (regions[i] instanceof SurfaceGeometricRegion) {
                    SurfaceGeometricRegion surfaceRegion = (SurfaceGeometricRegion) regions[i];
                    SubVolume subVolume1 = ((VolumeGeometricRegion) surfaceRegion.getAdjacentGeometricRegions()[0]).getSubVolume();
                    SubVolume subVolume2 = ((VolumeGeometricRegion) surfaceRegion.getAdjacentGeometricRegions()[1]).getSubVolume();
                    CompartmentSubDomain compartment1 = mathDesc.getCompartmentSubDomain(subVolume1.getName());
                    CompartmentSubDomain compartment2 = mathDesc.getCompartmentSubDomain(subVolume2.getName());
                    MembraneSubDomain membraneSubDomain = mathDesc.getMembraneSubDomain(compartment1, compartment2);
                    if (membraneSubDomain == null) {
                        SurfaceClass surfaceClass = geometry.getGeometrySurfaceDescription().getSurfaceClass(subVolume1, subVolume2);
                        membraneSubDomain = new MembraneSubDomain(compartment1, compartment2, surfaceClass.getName());
                        mathDesc.addSubDomain(membraneSubDomain);
                    }
                }
            }
        }
        mathDesc.isValid();
        mathModel.setName(name);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
    return mathModel;
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) ImageException(cbit.image.ImageException) SetMathDescription(cbit.vcell.client.task.SetMathDescription) MathDescription(cbit.vcell.math.MathDescription) SurfaceClass(cbit.vcell.geometry.SurfaceClass) GeometryException(cbit.vcell.geometry.GeometryException) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) ProgrammingException(org.vcell.util.ProgrammingException) MatrixException(cbit.vcell.matrix.MatrixException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) MappingException(cbit.vcell.mapping.MappingException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) ModelException(cbit.vcell.model.ModelException) DataFormatException(java.util.zip.DataFormatException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) UserCancelException(org.vcell.util.UserCancelException) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) SubVolume(cbit.vcell.geometry.SubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion)

Example 2 with VolumeGeometricRegion

use of cbit.vcell.geometry.surface.VolumeGeometricRegion in project vcell by virtualcell.

the class GeomDbDriver method getSurfaceDescription.

/**
 * Insert the method's description here.
 * Creation date: (7/29/00 2:10:42 PM)
 * @param con java.sql.Connection
 * @param geom cbit.vcell.geometry.Geometry
 */
private void getSurfaceDescription(Connection con, Geometry geom) throws SQLException, DataAccessException {
    // System.out.println(sql);
    Statement stmt = con.createStatement();
    try {
        String sql = null;
        // 
        // read sampleSize and filterFrequency from GeometrySurfaceTable.
        // 
        sql = " SELECT " + geoSurfaceTable.getTableName() + ".* " + " FROM " + geoSurfaceTable.getTableName() + " WHERE " + geoSurfaceTable.geometryRef.getQualifiedColName() + " = " + geom.getVersion().getVersionKey();
        if (lg.isTraceEnabled())
            lg.trace(sql);
        ResultSet rset = stmt.executeQuery(sql);
        if (rset.next()) {
            geoSurfaceTable.populateGeometrySurfaceDescription(rset, geom.getGeometrySurfaceDescription());
            rset.close();
        } else {
            if (lg.isWarnEnabled()) {
                lg.warn("surface description not found for geometry " + geom.getVersion().toString());
            }
            rset.close();
            return;
        }
        // 
        // read volume regions from GeometricRegionTable
        // 
        sql = " SELECT " + geoRegionTable.name.getQualifiedColName() + ", " + geoRegionTable.size.getQualifiedColName() + ", " + geoRegionTable.sizeUnit.getQualifiedColName() + ", " + geoRegionTable.subVolumeRef.getQualifiedColName() + ", " + geoRegionTable.regionID.getQualifiedColName() + " FROM " + geoRegionTable.getTableName() + " WHERE " + geoRegionTable.geometryRef.getQualifiedColName() + " = " + geom.getVersion().getVersionKey() + " AND " + geoRegionTable.type + " = " + GeometricRegionTable.TYPE_VOLUME;
        if (lg.isTraceEnabled())
            lg.trace(sql);
        rset = stmt.executeQuery(sql);
        Vector<GeometricRegion> regionList = new Vector<GeometricRegion>();
        while (rset.next()) {
            VolumeGeometricRegion volumeRegion = geoRegionTable.getVolumeRegion(rset, geom);
            regionList.add(volumeRegion);
        }
        VolumeGeometricRegion[] volumeRegions = (VolumeGeometricRegion[]) BeanUtils.getArray(regionList, VolumeGeometricRegion.class);
        // 
        // read surface regions from GeometricRegionTable
        // 
        sql = " SELECT " + "surfTable." + geoRegionTable.name.getUnqualifiedColName() + ", " + "surfTable." + geoRegionTable.size.getUnqualifiedColName() + ", " + "surfTable." + geoRegionTable.sizeUnit.getUnqualifiedColName() + ", " + "vol1Table.name as " + GeometricRegionTable.VOLUME1_NAME_COLUMN + ", " + "vol2Table.name as " + GeometricRegionTable.VOLUME2_NAME_COLUMN + " " + " FROM " + geoRegionTable.getTableName() + " surfTable, " + geoRegionTable.getTableName() + " vol1Table, " + geoRegionTable.getTableName() + " vol2Table " + " WHERE surfTable." + geoRegionTable.geometryRef.getUnqualifiedColName() + " = " + geom.getVersion().getVersionKey() + " AND vol1Table.id = surfTable." + geoRegionTable.volRegion1.getUnqualifiedColName() + " AND vol2Table.id = surfTable." + geoRegionTable.volRegion2.getUnqualifiedColName() + " AND surfTable." + geoRegionTable.type.getUnqualifiedColName() + " = " + GeometricRegionTable.TYPE_SURFACE;
        if (lg.isTraceEnabled())
            lg.trace(sql);
        rset = stmt.executeQuery(sql);
        while (rset.next()) {
            SurfaceGeometricRegion surfaceRegion = geoRegionTable.getSurfaceRegion(rset, volumeRegions, geom.getUnitSystem());
            regionList.add(surfaceRegion);
        }
        // 
        // set regions onto the geometrySurfaceDescription
        // 
        GeometricRegion[] regions = (GeometricRegion[]) BeanUtils.getArray(regionList, GeometricRegion.class);
        geom.getGeometrySurfaceDescription().setGeometricRegions(regions);
    } catch (Exception e) {
        throw new DataAccessException(e.toString(), e);
    } finally {
        // Release resources include resultset
        stmt.close();
    }
}
Also used : Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) Vector(java.util.Vector) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) PropertyVetoException(java.beans.PropertyVetoException) SQLException(java.sql.SQLException) DependencyException(org.vcell.util.DependencyException) GifParsingException(cbit.image.GifParsingException) RecordChangedException(cbit.sql.RecordChangedException) ImageException(cbit.image.ImageException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) DataAccessException(org.vcell.util.DataAccessException) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion)

Example 3 with VolumeGeometricRegion

use of cbit.vcell.geometry.surface.VolumeGeometricRegion in project vcell by virtualcell.

the class GeomDbDriver method insertGeometrySurfaceDescriptionSQL.

/**
 * This method was created in VisualAge.
 * @param vcimage cbit.image.VCImage
 * @param userid java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
// default access for this method, to allow retrofitting surfaces to geometries.
void insertGeometrySurfaceDescriptionSQL(InsertHashtable hash, Connection con, Geometry geom, KeyValue geomKey) throws SQLException, cbit.image.ImageException, DataAccessException, ObjectNotFoundException {
    String sql;
    GeometrySurfaceDescription geoSurfaceDescription = geom.getGeometrySurfaceDescription();
    // 
    // store GeometrySurfaceDescription (sampleSize and filterFrequency for now)
    // 
    KeyValue newGeomSurfDescKey = keyFactory.getNewKey(con);
    sql = "INSERT INTO " + geoSurfaceTable.getTableName() + " " + geoSurfaceTable.getSQLColumnList() + " VALUES " + geoSurfaceTable.getSQLValueList(newGeomSurfDescKey, geoSurfaceDescription, geomKey);
    // System.out.println(sql);
    updateCleanSQL(con, sql);
    // 
    // store GeometricRegions
    // 
    GeometricRegion[] regions = geoSurfaceDescription.getGeometricRegions();
    // }
    if (regions == null) {
        throw new DataAccessException("geometry '" + geom.getName() + " didn't have region information");
    }
    // 
    for (int i = 0; i < regions.length; i++) {
        if (regions[i] instanceof VolumeGeometricRegion) {
            VolumeGeometricRegion volumeRegion = (VolumeGeometricRegion) regions[i];
            if (hash.getDatabaseKey(volumeRegion) == null) {
                KeyValue newVolumeRegionKey = keyFactory.getNewKey(con);
                KeyValue subvolumeKey = hash.getDatabaseKey(volumeRegion.getSubVolume());
                sql = "INSERT INTO " + geoRegionTable.getTableName() + " " + geoRegionTable.getSQLColumnList() + " VALUES " + geoRegionTable.getSQLValueList(newVolumeRegionKey, volumeRegion, subvolumeKey, geomKey);
                // System.out.println(sql);
                updateCleanSQL(con, sql);
                hash.put(volumeRegion, newVolumeRegionKey);
            }
        }
    }
    // 
    for (int i = 0; i < regions.length; i++) {
        if (regions[i] instanceof SurfaceGeometricRegion) {
            SurfaceGeometricRegion surfaceRegion = (SurfaceGeometricRegion) regions[i];
            if (hash.getDatabaseKey(surfaceRegion) == null) {
                KeyValue newSurfaceRegionKey = keyFactory.getNewKey(con);
                KeyValue volumeRegion1Key = hash.getDatabaseKey((VolumeGeometricRegion) surfaceRegion.getAdjacentGeometricRegions()[0]);
                KeyValue volumeRegion2Key = hash.getDatabaseKey((VolumeGeometricRegion) surfaceRegion.getAdjacentGeometricRegions()[1]);
                sql = "INSERT INTO " + geoRegionTable.getTableName() + " " + geoRegionTable.getSQLColumnList() + " VALUES " + geoRegionTable.getSQLValueList(newSurfaceRegionKey, surfaceRegion, volumeRegion1Key, volumeRegion2Key, geomKey);
                // System.out.println(sql);
                updateCleanSQL(con, sql);
                hash.put(surfaceRegion, newSurfaceRegionKey);
            }
        }
    }
}
Also used : KeyValue(org.vcell.util.document.KeyValue) GeometrySurfaceDescription(cbit.vcell.geometry.surface.GeometrySurfaceDescription) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) DataAccessException(org.vcell.util.DataAccessException) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion)

Example 4 with VolumeGeometricRegion

use of cbit.vcell.geometry.surface.VolumeGeometricRegion in project vcell by virtualcell.

the class GeometricRegionTable method getVolumeRegion.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.model.ReactionParticipant
 * @param rset java.sql.ResultSet
 */
public VolumeGeometricRegion getVolumeRegion(java.sql.ResultSet rset, cbit.vcell.geometry.Geometry geometry) throws java.sql.SQLException, DataAccessException {
    String _name = rset.getString(this.name.toString());
    double _size = rset.getBigDecimal(this.size.toString()).doubleValue();
    String _sizeUnitSymbol = rset.getString(this.sizeUnit.toString());
    cbit.vcell.units.VCUnitDefinition _sizeUnit = geometry.getUnitSystem().getInstance(_sizeUnitSymbol);
    int _regionID = rset.getInt(this.regionID.toString());
    KeyValue _subvolumeKey = new KeyValue(rset.getBigDecimal(this.subVolumeRef.toString()));
    // 
    // find subvolume with correct key
    // 
    cbit.vcell.geometry.SubVolume _subVolume = null;
    cbit.vcell.geometry.SubVolume[] subvolumes = geometry.getGeometrySpec().getSubVolumes();
    for (int i = 0; i < subvolumes.length; i++) {
        if (subvolumes[i].getKey().compareEqual(_subvolumeKey)) {
            _subVolume = subvolumes[i];
            break;
        }
    }
    VolumeGeometricRegion volumeRegion = new VolumeGeometricRegion(_name, _size, _sizeUnit, _subVolume, _regionID);
    return volumeRegion;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion)

Example 5 with VolumeGeometricRegion

use of cbit.vcell.geometry.surface.VolumeGeometricRegion in project vcell by virtualcell.

the class VolumeRegionObject method gatherIssues.

@Override
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
    if (simulationContext.getGeometry().getGeometrySurfaceDescription() != null && simulationContext.getGeometry().getGeometrySurfaceDescription().getGeometricRegions() != null) {
        GeometricRegion[] regions = simulationContext.getGeometry().getGeometrySurfaceDescription().getGeometricRegions();
        boolean bFound = false;
        for (GeometricRegion region : regions) {
            if (region instanceof VolumeGeometricRegion) {
                VolumeGeometricRegion vr = (VolumeGeometricRegion) region;
                if (getSubVolume() == vr.getSubVolume() && getRegionID() == vr.getRegionID()) {
                    bFound = true;
                    break;
                }
            }
        }
        if (!bFound) {
            issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "geometry missing volume region (subvolume " + subVolume.getName() + " region " + regionID + ")", Issue.Severity.ERROR));
        }
    }
}
Also used : Issue(org.vcell.util.Issue) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion)

Aggregations

VolumeGeometricRegion (cbit.vcell.geometry.surface.VolumeGeometricRegion)23 GeometricRegion (cbit.vcell.geometry.surface.GeometricRegion)21 SurfaceGeometricRegion (cbit.vcell.geometry.surface.SurfaceGeometricRegion)21 SubVolume (cbit.vcell.geometry.SubVolume)11 GeometrySurfaceDescription (cbit.vcell.geometry.surface.GeometrySurfaceDescription)10 ISize (org.vcell.util.ISize)10 SurfaceClass (cbit.vcell.geometry.SurfaceClass)8 ExpressionException (cbit.vcell.parser.ExpressionException)7 PropertyVetoException (java.beans.PropertyVetoException)7 ArrayList (java.util.ArrayList)7 ImageException (cbit.image.ImageException)6 Origin (org.vcell.util.Origin)6 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)5 Geometry (cbit.vcell.geometry.Geometry)5 GeometrySpec (cbit.vcell.geometry.GeometrySpec)5 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)5 RegionInfo (cbit.vcell.geometry.RegionImage.RegionInfo)5 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)5 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)5 Expression (cbit.vcell.parser.Expression)5