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 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();
System.out.println(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;
System.out.println(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;
System.out.println(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) {
e.printStackTrace(System.out);
throw new DataAccessException(e.toString());
} 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) {
System.out.println("Geometry " + geom.getName() + "(" + geom.getVersion() + ") doesn't have region information");
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 SimulationContext method refreshSpatialObjects.
public void refreshSpatialObjects() {
Geometry geometry = getGeometry();
if (geometry != null && geometry.getGeometrySurfaceDescription() != null && geometry.getGeometrySurfaceDescription().getGeometricRegions() != null) {
ArrayList<SpatialObject> unmappedSpatialObjects = new ArrayList<SpatialObject>(Arrays.asList(spatialObjects));
ArrayList<GeometricRegion> mappedRegions = new ArrayList<GeometricRegion>();
//
for (SpatialObject spatialObject : spatialObjects) {
if (spatialObject instanceof VolumeRegionObject) {
VolumeRegionObject volRegionObj = (VolumeRegionObject) spatialObject;
SubVolume existingSubvolume = volRegionObj.getSubVolume();
Integer existingRegionID = volRegionObj.getRegionID();
SubVolume newSubvolume = geometry.getGeometrySpec().getSubVolume(existingSubvolume.getName());
if (newSubvolume != null && geometry.getGeometrySurfaceDescription().getGeometricRegions() != null) {
for (GeometricRegion newRegion : geometry.getGeometrySurfaceDescription().getGeometricRegions(newSubvolume)) {
VolumeGeometricRegion newVolRegion = (VolumeGeometricRegion) newRegion;
if (newVolRegion.getRegionID() == existingRegionID) {
((VolumeRegionObject) spatialObject).setSubVolume(newSubvolume);
mappedRegions.add(newVolRegion);
unmappedSpatialObjects.remove(spatialObject);
}
}
}
}
if (spatialObject instanceof SurfaceRegionObject) {
SurfaceRegionObject surfaceRegionObj = (SurfaceRegionObject) spatialObject;
SubVolume existingInsideSubvolume = surfaceRegionObj.getInsideSubVolume();
SubVolume existingOutsideSubvolume = surfaceRegionObj.getOutsideSubVolume();
Integer existingInsideRegionID = surfaceRegionObj.getInsideRegionID();
Integer existingOutsideRegionID = surfaceRegionObj.getOutsideRegionID();
SubVolume newInsideSubvolume = geometry.getGeometrySpec().getSubVolume(existingInsideSubvolume.getName());
SubVolume newOutsideSubvolume = geometry.getGeometrySpec().getSubVolume(existingOutsideSubvolume.getName());
if (newInsideSubvolume != null && newOutsideSubvolume != null) {
SurfaceClass surfaceClass = geometry.getGeometrySurfaceDescription().getSurfaceClass(newInsideSubvolume, newOutsideSubvolume);
for (GeometricRegion newRegion : geometry.getGeometrySurfaceDescription().getGeometricRegions(surfaceClass)) {
SurfaceGeometricRegion newSurfaceRegion = (SurfaceGeometricRegion) newRegion;
GeometricRegion[] adjacentRegions = newSurfaceRegion.getAdjacentGeometricRegions();
if (adjacentRegions.length == 2 && adjacentRegions[0] instanceof VolumeGeometricRegion && adjacentRegions[1] instanceof VolumeGeometricRegion) {
VolumeGeometricRegion adjVolRegion0 = (VolumeGeometricRegion) adjacentRegions[0];
VolumeGeometricRegion adjVolRegion1 = (VolumeGeometricRegion) adjacentRegions[1];
if (adjVolRegion0.getSubVolume() == newInsideSubvolume && adjVolRegion0.getRegionID() == existingInsideRegionID && adjVolRegion1.getSubVolume() == newOutsideSubvolume && adjVolRegion1.getRegionID() == existingOutsideRegionID) {
surfaceRegionObj.setInsideSubVolume(newInsideSubvolume);
surfaceRegionObj.setOutsideSubVolume(newOutsideSubvolume);
mappedRegions.add(newSurfaceRegion);
unmappedSpatialObjects.remove(spatialObject);
}
if (adjVolRegion0.getSubVolume() == newOutsideSubvolume && adjVolRegion0.getRegionID() == existingOutsideRegionID && adjVolRegion1.getSubVolume() == newInsideSubvolume && adjVolRegion1.getRegionID() == existingInsideRegionID) {
surfaceRegionObj.setInsideSubVolume(newInsideSubvolume);
surfaceRegionObj.setOutsideSubVolume(newOutsideSubvolume);
mappedRegions.add(newSurfaceRegion);
unmappedSpatialObjects.remove(spatialObject);
}
}
}
}
}
}
//
// for geometric regions not represented as spatial objects, add them
//
ArrayList<GeometricRegion> unmappedRegions = new ArrayList<GeometricRegion>(Arrays.asList(geometry.getGeometrySurfaceDescription().getGeometricRegions()));
unmappedRegions.removeAll(mappedRegions);
for (GeometricRegion unmappedRegion : unmappedRegions) {
if (unmappedRegion instanceof VolumeGeometricRegion) {
VolumeGeometricRegion unmappedVolRegion = (VolumeGeometricRegion) unmappedRegion;
try {
VolumeRegionObject vro = new VolumeRegionObject(unmappedVolRegion.getSubVolume(), unmappedVolRegion.getRegionID(), this);
addSpatialObject(vro);
} catch (PropertyVetoException e) {
e.printStackTrace();
}
} else if (unmappedRegion instanceof SurfaceGeometricRegion) {
SurfaceGeometricRegion unmappedSurfRegion = (SurfaceGeometricRegion) unmappedRegion;
GeometricRegion[] adjacentRegions = unmappedSurfRegion.getAdjacentGeometricRegions();
if (adjacentRegions.length == 2 && adjacentRegions[0] instanceof VolumeGeometricRegion && adjacentRegions[1] instanceof VolumeGeometricRegion) {
VolumeGeometricRegion volRegion0 = (VolumeGeometricRegion) adjacentRegions[0];
VolumeGeometricRegion volRegion1 = (VolumeGeometricRegion) adjacentRegions[1];
SubVolume insideSubVolume = volRegion0.getSubVolume();
SubVolume outsideSubVolume = volRegion1.getSubVolume();
int insideRegionID = volRegion0.getRegionID();
int outsideRegionID = volRegion1.getRegionID();
SurfaceClass surfaceClass = geometry.getGeometrySurfaceDescription().getSurfaceClass(insideSubVolume, outsideSubVolume);
try {
addSpatialObject(new SurfaceRegionObject(insideSubVolume, insideRegionID, outsideSubVolume, outsideRegionID, this));
} catch (PropertyVetoException e) {
e.printStackTrace();
}
}
}
}
//
try {
for (SpatialObject unmappedSpatialObject : unmappedSpatialObjects) {
if (unmappedSpatialObject instanceof VolumeRegionObject) {
System.err.println("volume region spatial object '" + unmappedSpatialObject.getName() + "' not found in geometry, delete.");
removeSpatialObject(unmappedSpatialObject);
}
if (unmappedSpatialObject instanceof SurfaceRegionObject) {
System.err.println("surface region spatial object '" + unmappedSpatialObject.getName() + "' not found in geometry, delete.");
removeSpatialObject(unmappedSpatialObject);
}
if (unmappedSpatialObject instanceof PointObject) {
System.err.println("point spatial object '" + unmappedSpatialObject.getName() + "' not found in geometry, this is expected.");
// removeSpatialObject(unmappedSpatialObject);
}
}
} catch (PropertyVetoException e) {
e.printStackTrace();
}
}
}
use of cbit.vcell.geometry.surface.VolumeGeometricRegion in project vcell by virtualcell.
the class SurfaceRegionObject method getSurfaceRegion.
public SurfaceGeometricRegion getSurfaceRegion(Geometry geometry) {
GeometricRegion[] regions = geometry.getGeometrySurfaceDescription().getGeometricRegions();
for (GeometricRegion region : regions) {
if (region instanceof SurfaceGeometricRegion) {
SurfaceGeometricRegion surfaceRegion = (SurfaceGeometricRegion) region;
GeometricRegion[] adjacentRegions = surfaceRegion.getAdjacentGeometricRegions();
if (adjacentRegions.length == 2 && adjacentRegions[0] instanceof VolumeGeometricRegion && adjacentRegions[1] instanceof VolumeGeometricRegion) {
VolumeGeometricRegion adjVolumeRegion0 = (VolumeGeometricRegion) adjacentRegions[0];
VolumeGeometricRegion adjVolumeRegion1 = (VolumeGeometricRegion) adjacentRegions[1];
// match adjacent vol0 with inside and vol1 with outside
if (adjVolumeRegion0.getSubVolume() == insideSubVolume && adjVolumeRegion0.getRegionID() == insideRegionID && adjVolumeRegion1.getSubVolume() == outsideSubVolume && adjVolumeRegion1.getRegionID() == outsideRegionID) {
return surfaceRegion;
}
// match adjacent vol1 with inside and vol0 with outside
if (adjVolumeRegion1.getSubVolume() == insideSubVolume && adjVolumeRegion1.getRegionID() == insideRegionID && adjVolumeRegion0.getSubVolume() == outsideSubVolume && adjVolumeRegion0.getRegionID() == outsideRegionID) {
return surfaceRegion;
}
}
}
}
return null;
}
Aggregations