Search in sources :

Example 16 with SampledCurve

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;
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve)

Example 17 with SampledCurve

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;
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) Coordinate(org.vcell.util.Coordinate) CoordinateIndex(org.vcell.util.CoordinateIndex) Vector(java.util.Vector) SinglePoint(cbit.vcell.geometry.SinglePoint)

Example 18 with SampledCurve

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;
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) Coordinate(org.vcell.util.Coordinate) CoordinateIndex(org.vcell.util.CoordinateIndex) Vector(java.util.Vector) SinglePoint(cbit.vcell.geometry.SinglePoint)

Aggregations

SampledCurve (cbit.vcell.geometry.SampledCurve)18 Coordinate (org.vcell.util.Coordinate)11 SinglePoint (cbit.vcell.geometry.SinglePoint)8 ControlPointCurve (cbit.vcell.geometry.ControlPointCurve)6 Curve (cbit.vcell.geometry.Curve)6 VariableType (cbit.vcell.math.VariableType)5 Vector (java.util.Vector)5 CurveSelectionCurve (cbit.vcell.geometry.CurveSelectionCurve)4 CurveSelectionInfo (cbit.vcell.geometry.CurveSelectionInfo)3 Hashtable (java.util.Hashtable)3 CurveRenderer (cbit.vcell.geometry.CurveRenderer)2 Line (cbit.vcell.geometry.Line)2 Spline (cbit.vcell.geometry.Spline)2 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)2 DataIdentifier (cbit.vcell.simdata.DataIdentifier)2 SpatialSelectionMembrane (cbit.vcell.simdata.SpatialSelectionMembrane)2 SpatialSelectionVolume (cbit.vcell.simdata.SpatialSelectionVolume)2 CartesianMesh (cbit.vcell.solvers.CartesianMesh)2 CartesianMeshChombo (cbit.vcell.solvers.CartesianMeshChombo)2 Element (org.jdom.Element)2