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;
}
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();
}
}
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);
}
}
}
}
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;
}
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));
}
}
}
Aggregations