use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.
the class MeshDisplayAdapter method getCurvesAndMembraneIndexes.
/**
* Insert the method's description here.
* Creation date: (8/30/00 5:52:19 PM)
* @return cbit.vcell.geometry.SampledCurve[]
* @param normalAxis int
*/
public Hashtable<SampledCurve, int[]> getCurvesAndMembraneIndexes(int normalAxis, int slice) {
Hashtable<SampledCurve, int[]> curvesAndValues = null;
if (mesh.isChomboMesh()) {
curvesAndValues = constructChomboCurves(normalAxis, slice);
} else {
//
// Finds individual curves given a normalAxis and slice
// Also associates membrane indexes with each curve segment
//
MembraneElement[] membraneElements = mesh.getMembraneElements();
if (membraneElements == null) {
return null;
}
if (mesh.isMembraneConnectivityOK() == false) {
System.out.println("CartesianMesh.getCurvesFromMembranes(), MESH ERROR: membrane connectivity is bad");
// throw new RuntimeException("membrane connectivity bad");
}
boolean[] bMembraneElementChecked = new boolean[membraneElements.length];
for (int c = 0; c < membraneElements.length; c += 1) {
bMembraneElementChecked[c] = false;
}
SampledCurve newCurve = null;
// Stores (Integer) membrane indexes corresponding to each segment of curve
Vector<Integer> resolvedMembraneIndexes = null;
int c = 0;
while (true) {
for (; c < membraneElements.length; c += 1) {
if (bMembraneElementChecked[c] == false && isMembraneElementVisible(membraneElements[c], normalAxis, slice)) {
newCurve = new SampledCurve();
resolvedMembraneIndexes = new Vector<Integer>();
ConstructCurveHelper pendingCCH = null;
ConstructCurveHelper currentCCH = new ConstructCurveHelper(membraneElements[c], newCurve, membraneElements[c], null, false, bMembraneElementChecked, normalAxis, slice, resolvedMembraneIndexes);
while (true) {
ConstructCurveHelper[] currentCCHArr = constructCurve(currentCCH);
if (currentCCHArr == null) {
if (pendingCCH == null) {
break;
} else {
currentCCH = pendingCCH;
pendingCCH = null;
}
} else if (currentCCHArr.length == 1) {
currentCCH = currentCCHArr[0];
} else if (currentCCHArr.length == 2) {
if (pendingCCH != null) {
throw new RuntimeException("MeshDisplayAdapter.getCurvesAndMembraneIndexes Error -- Only 1 Pending CurveConstructionHelper allowed.");
}
currentCCH = currentCCHArr[0];
pendingCCH = currentCCHArr[1];
}
}
break;
}
}
if (newCurve == null) {
break;
}
if (curvesAndValues == null) {
curvesAndValues = new Hashtable<SampledCurve, int[]>();
}
// convert Vector to int[]
int[] rmi = new int[resolvedMembraneIndexes.size()];
for (int i = 0; i < resolvedMembraneIndexes.size(); i += 1) {
rmi[i] = ((Integer) (resolvedMembraneIndexes.elementAt(i))).intValue();
}
curvesAndValues.put(newCurve, rmi);
newCurve = null;
}
}
return curvesAndValues;
}
use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.
the class SpatialSelectionVolume method sampleSymmetric.
/**
* Insert the method's description here.
* Creation date: (10/5/2004 7:19:49 AM)
*/
private SSHelper sampleSymmetric() throws Exception {
//
if (!isSymmetric()) {
return null;
}
SampledCurve ssCurve = getCurveSelectionInfo().getCurve().getSampledCurve();
Vector pointsV = ssCurve.getControlPointsVector();
if (pointsV.size() < 2) {
return null;
}
final int INDEX_SPACE_INCR = 100;
int[] indexes = new int[INDEX_SPACE_INCR];
int indexCounter = 0;
Vector snappedV = new Vector();
CoordinateIndex lastCI = null;
for (int i = 0; i < pointsV.size(); i += 1) {
if (i > 0) {
CoordinateIndex c1 = getMesh().getCoordinateIndexFromFractionalIndex(getMesh().getFractionalCoordinateIndex((Coordinate) pointsV.elementAt(i - 1)));
CoordinateIndex c2 = getMesh().getCoordinateIndexFromFractionalIndex(getMesh().getFractionalCoordinateIndex((Coordinate) pointsV.elementAt(i)));
int dx = c2.x - c1.x;
if (dx != 0) {
dx /= Math.abs(dx);
}
int dy = c2.y - c1.y;
if (dy != 0) {
dy /= Math.abs(dy);
}
int dz = c2.z - c1.z;
if (dz != 0) {
dz /= Math.abs(dz);
}
while (true) {
if (!c1.compareEqual(lastCI)) {
if (indexCounter == indexes.length) {
// Make more space
int[] temp = new int[indexes.length + INDEX_SPACE_INCR];
System.arraycopy(indexes, 0, temp, 0, indexes.length);
indexes = temp;
}
indexes[indexCounter] = getConvertedIndexFromCI(c1);
snappedV.add(getMesh().getCoordinate(c1));
indexCounter += 1;
}
if (c1.compareEqual(c2)) {
break;
}
c1.x += dx;
c1.y += dy;
c1.z += dz;
// sanity check to prevent infinite loop, this shouldn't happen
if (c1.x < 0 || c1.y < 0 || c1.z < 0 || c1.x >= getMesh().getSizeX() || c1.y >= getMesh().getSizeY() || c1.z >= getMesh().getSizeZ()) {
throw new Exception(this.getClass().getName() + ".sampleSymmetric failed");
}
}
;
lastCI = c2;
}
}
if (indexCounter > 0) {
return makeSSHelper(indexes, indexCounter, snappedV, false);
}
return null;
}
use of cbit.vcell.geometry.SampledCurve in project vcell by virtualcell.
the class SpatialSelectionVolume method isSymmetric.
/**
* Insert the method's description here.
* Creation date: (10/3/2004 12:54:59 PM)
* @return boolean
*/
private boolean isSymmetric() {
if (!(getCurveSelectionInfo().getCurve() instanceof SampledCurve)) {
return false;
}
SampledCurve ssCurve = getCurveSelectionInfo().getCurve().getSampledCurve();
Vector pointsV = ssCurve.getControlPointsVector();
if (pointsV.size() == 1) {
return true;
}
for (int i = 0; i < pointsV.size(); i += 1) {
if (i > 0) {
CoordinateIndex c1 = getMesh().getCoordinateIndexFromFractionalIndex(getMesh().getFractionalCoordinateIndex((Coordinate) pointsV.elementAt(i - 1)));
CoordinateIndex c2 = getMesh().getCoordinateIndexFromFractionalIndex(getMesh().getFractionalCoordinateIndex((Coordinate) pointsV.elementAt(i)));
int dx = Math.abs(c1.x - c2.x);
int dy = Math.abs(c1.y - c2.y);
int dz = Math.abs(c1.z - c2.z);
int symCount = 0;
if (dx != 0 && dy != 0 && dx != dy) {
symCount += 1;
}
if (dx != 0 && dz != 0 && dx != dz) {
symCount += 1;
}
if (dy != 0 && dz != 0 && dy != dz) {
symCount += 1;
}
if (symCount != 0) {
return false;
}
}
}
return true;
}
Aggregations