Search in sources :

Example 1 with CoordinateIndex

use of org.vcell.util.CoordinateIndex in project vcell by virtualcell.

the class PDEDataViewer method getFillROI.

private BitSet getFillROI(SpatialSelectionVolume spatialSelectionVolume) {
    if (spatialSelectionVolume.getCurveSelectionInfo().getCurve() instanceof SinglePoint) {
        return null;
    }
    BitSet fillROI = null;
    SSHelper ssHelper = spatialSelectionVolume.getIndexSamples(0, 1);
    if (ssHelper != null && ssHelper.getSampledIndexes()[0] == ssHelper.getSampledIndexes()[ssHelper.getSampledIndexes().length - 1]) {
        Point projMin = null;
        Point projMax = null;
        Point[] projVolCI = new Point[ssHelper.getSampledIndexes().length];
        for (int i = 0; i < ssHelper.getSampledIndexes().length; i++) {
            CoordinateIndex vCI = getPdeDataContext().getCartesianMesh().getCoordinateIndexFromVolumeIndex(ssHelper.getSampledIndexes()[i]);
            int normalAxis = getPDEDataContextPanel1().getNormalAxis();
            projVolCI[i] = new Point((int) Coordinate.convertAxisFromStandardXYZToNormal(vCI.x, vCI.y, vCI.z, Coordinate.X_AXIS, normalAxis), (int) Coordinate.convertAxisFromStandardXYZToNormal(vCI.x, vCI.y, vCI.z, Coordinate.Y_AXIS, normalAxis));
            if (i == 0) {
                projMin = new Point(projVolCI[i]);
                projMax = new Point(projMin);
            } else {
                if (projVolCI[i].x < projMin.x) {
                    projMin.x = projVolCI[i].x;
                }
                if (projVolCI[i].y < projMin.y) {
                    projMin.y = projVolCI[i].y;
                }
                if (projVolCI[i].x > projMax.x) {
                    projMax.x = projVolCI[i].x;
                }
                if (projVolCI[i].y > projMax.y) {
                    projMax.y = projVolCI[i].y;
                }
            }
        }
        // System.out.println(projMin+" "+projMax);
        int UNMARKED = 0;
        int BOUNDARY_MARK = 1;
        // Create work area
        int[][] markers = new int[projMax.y - projMin.y + 1][projMax.x - projMin.x + 1];
        Vector<Vector<Point>> allSeedsV = new Vector<Vector<Point>>();
        allSeedsV.add(null);
        allSeedsV.add(null);
        // Mark boundary
        for (int i = 0; i < projVolCI.length; i++) {
            markers[projVolCI[i].y - projMin.y][projVolCI[i].x - projMin.x] = BOUNDARY_MARK;
        }
        // Create seeds around boundary
        for (int i = 0; i < projVolCI.length; i++) {
            if (projVolCI[i].x - 1 >= projMin.x) {
                int currentMark = markers[projVolCI[i].y - projMin.y][projVolCI[i].x - projMin.x - 1];
                if (currentMark == UNMARKED) {
                    Vector<Point> newSeedV = new Vector<Point>();
                    newSeedV.add(new Point(projVolCI[i].x - 1, projVolCI[i].y));
                    markers[projVolCI[i].y - projMin.y][projVolCI[i].x - projMin.x - 1] = allSeedsV.size();
                    allSeedsV.add(newSeedV);
                }
            }
            if (projVolCI[i].x + 1 <= projMax.x) {
                int currentMark = markers[projVolCI[i].y - projMin.y][projVolCI[i].x - projMin.x + 1];
                if (currentMark == UNMARKED) {
                    Vector<Point> newSeedV = new Vector<Point>();
                    newSeedV.add(new Point(projVolCI[i].x + 1, projVolCI[i].y));
                    markers[projVolCI[i].y - projMin.y][projVolCI[i].x - projMin.x + 1] = allSeedsV.size();
                    allSeedsV.add(newSeedV);
                }
            }
            if (projVolCI[i].y - 1 >= projMin.y) {
                int currentMark = markers[projVolCI[i].y - projMin.y - 1][projVolCI[i].x - projMin.x];
                if (currentMark == UNMARKED) {
                    Vector<Point> newSeedV = new Vector<Point>();
                    newSeedV.add(new Point(projVolCI[i].x, projVolCI[i].y - 1));
                    markers[projVolCI[i].y - projMin.y - 1][projVolCI[i].x - projMin.x] = allSeedsV.size();
                    allSeedsV.add(newSeedV);
                }
            }
            if (projVolCI[i].y + 1 <= projMax.y) {
                int currentMark = markers[projVolCI[i].y - projMin.y + 1][projVolCI[i].x - projMin.x];
                if (currentMark == UNMARKED) {
                    Vector<Point> newSeedV = new Vector<Point>();
                    newSeedV.add(new Point(projVolCI[i].x, projVolCI[i].y + 1));
                    markers[projVolCI[i].y - projMin.y + 1][projVolCI[i].x - projMin.x] = allSeedsV.size();
                    allSeedsV.add(newSeedV);
                }
            }
        }
        // Grow seeds
        for (int i = 2; i < allSeedsV.size(); i++) {
            while (allSeedsV.elementAt(i) != null && allSeedsV.elementAt(i).size() > 0) {
                Point currentPoint = allSeedsV.elementAt(i).remove(0);
                if (currentPoint.x - 1 >= projMin.x) {
                    int currentMark = markers[currentPoint.y - projMin.y][currentPoint.x - projMin.x - 1];
                    if (currentMark == UNMARKED) {
                        allSeedsV.elementAt(i).add(new Point(currentPoint.x - 1, currentPoint.y));
                        markers[currentPoint.y - projMin.y][currentPoint.x - projMin.x - 1] = i;
                    } else if (currentMark != BOUNDARY_MARK && currentMark != i) {
                        for (int j = 0; j < allSeedsV.elementAt(currentMark).size(); j++) {
                            if (!allSeedsV.elementAt(i).contains(allSeedsV.elementAt(currentMark).elementAt(j))) {
                                allSeedsV.elementAt(i).add(allSeedsV.elementAt(currentMark).elementAt(j));
                                markers[allSeedsV.elementAt(currentMark).elementAt(j).y - projMin.y][allSeedsV.elementAt(currentMark).elementAt(j).x - projMin.x] = i;
                            }
                        }
                        allSeedsV.setElementAt(null, currentMark);
                    }
                }
                if (currentPoint.x + 1 <= projMax.x) {
                    int currentMark = markers[currentPoint.y - projMin.y][currentPoint.x - projMin.x + 1];
                    if (currentMark == UNMARKED) {
                        allSeedsV.elementAt(i).add(new Point(currentPoint.x + 1, currentPoint.y));
                        markers[currentPoint.y - projMin.y][currentPoint.x - projMin.x + 1] = i;
                    } else if (currentMark != BOUNDARY_MARK && currentMark != i) {
                        for (int j = 0; j < allSeedsV.elementAt(currentMark).size(); j++) {
                            if (!allSeedsV.elementAt(i).contains(allSeedsV.elementAt(currentMark).elementAt(j))) {
                                allSeedsV.elementAt(i).add(allSeedsV.elementAt(currentMark).elementAt(j));
                                markers[allSeedsV.elementAt(currentMark).elementAt(j).y - projMin.y][allSeedsV.elementAt(currentMark).elementAt(j).x - projMin.x] = i;
                            }
                        }
                        allSeedsV.setElementAt(null, currentMark);
                    }
                }
                if (currentPoint.y - 1 >= projMin.y) {
                    int currentMark = markers[currentPoint.y - projMin.y - 1][currentPoint.x - projMin.x];
                    if (currentMark == UNMARKED) {
                        allSeedsV.elementAt(i).add(new Point(currentPoint.x, currentPoint.y - 1));
                        markers[currentPoint.y - projMin.y - 1][currentPoint.x - projMin.x] = i;
                    } else if (currentMark != BOUNDARY_MARK && currentMark != i) {
                        for (int j = 0; j < allSeedsV.elementAt(currentMark).size(); j++) {
                            if (!allSeedsV.elementAt(i).contains(allSeedsV.elementAt(currentMark).elementAt(j))) {
                                allSeedsV.elementAt(i).add(allSeedsV.elementAt(currentMark).elementAt(j));
                                markers[allSeedsV.elementAt(currentMark).elementAt(j).y - projMin.y][allSeedsV.elementAt(currentMark).elementAt(j).x - projMin.x] = i;
                            }
                        }
                        allSeedsV.setElementAt(null, currentMark);
                    }
                }
                if (currentPoint.y + 1 <= projMax.y) {
                    int currentMark = markers[currentPoint.y - projMin.y + 1][currentPoint.x - projMin.x];
                    if (currentMark == UNMARKED) {
                        allSeedsV.elementAt(i).add(new Point(currentPoint.x, currentPoint.y + 1));
                        markers[currentPoint.y - projMin.y + 1][currentPoint.x - projMin.x] = i;
                    } else if (currentMark != BOUNDARY_MARK && currentMark != i) {
                        for (int j = 0; j < allSeedsV.elementAt(currentMark).size(); j++) {
                            if (!allSeedsV.elementAt(i).contains(allSeedsV.elementAt(currentMark).elementAt(j))) {
                                allSeedsV.elementAt(i).add(allSeedsV.elementAt(currentMark).elementAt(j));
                                markers[allSeedsV.elementAt(currentMark).elementAt(j).y - projMin.y][allSeedsV.elementAt(currentMark).elementAt(j).x - projMin.x] = i;
                            }
                        }
                        allSeedsV.setElementAt(null, currentMark);
                    }
                }
            }
            allSeedsV.setElementAt(null, i);
        }
        int[] encodeEdge = new int[allSeedsV.size()];
        for (int i = 0; i < encodeEdge.length; i++) {
            encodeEdge[i] = i;
        }
        int c = 0;
        while (true) {
            if (c < markers.length) {
                encodeEdge[markers[c][0]] = UNMARKED;
                encodeEdge[markers[c][markers[0].length - 1]] = UNMARKED;
            }
            if (c < markers[0].length) {
                encodeEdge[markers[0][c]] = UNMARKED;
                encodeEdge[markers[markers.length - 1][c]] = UNMARKED;
            }
            c++;
            if (c >= markers.length && c >= markers[0].length) {
                break;
            }
        }
        // boundary
        encodeEdge[1] = 1;
        // System.out.println("Distinct Areas");
        // for (int i = 0; i < markers.length; i++) {
        // for (int j = 0; j < markers[i].length; j++) {
        // System.out.print((encodeEdge[markers[i][j]] < 10?"0":"")+encodeEdge[markers[i][j]]+" ");
        // }
        // System.out.println();
        // }
        // Make BitSet
        fillROI = new BitSet(getPdeDataContext().getDataValues().length);
        CoordinateIndex coordinateIndex = new CoordinateIndex();
        for (int y = 0; y < markers.length; y++) {
            for (int x = 0; x < markers[y].length; x++) {
                if (encodeEdge[markers[y][x]] != UNMARKED) {
                    coordinateIndex.x = projMin.x + x;
                    coordinateIndex.y = projMin.y + y;
                    coordinateIndex.z = getPDEDataContextPanel1().getSlice();
                    Coordinate.convertCoordinateIndexFromNormalToStandardXYZ(coordinateIndex, getPDEDataContextPanel1().getNormalAxis());
                    // System.out.println(coordinateIndex);
                    int volIndex = getPdeDataContext().getCartesianMesh().getVolumeIndex(coordinateIndex);
                    fillROI.set(volIndex);
                }
            }
        }
    }
    return fillROI;
}
Also used : SinglePoint(cbit.vcell.geometry.SinglePoint) BitSet(java.util.BitSet) SSHelper(cbit.vcell.simdata.SpatialSelection.SSHelper) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint) CoordinateIndex(org.vcell.util.CoordinateIndex) Vector(java.util.Vector) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint)

Example 2 with CoordinateIndex

use of org.vcell.util.CoordinateIndex in project vcell by virtualcell.

the class ImageContainer method getCoordinateIndexFromDisplay.

/**
 * This method was created by a SmartGuide.
 * @return int
 * @param x int
 * @param y int
 */
public CoordinateIndex getCoordinateIndexFromDisplay(int x, int y) throws Exception {
    if (!bValid)
        throw new Exception("image not valid, display data not availlable");
    int i, j, k;
    switch(getNormalAxis()) {
        case X_AXIS:
            {
                i = getSlice();
                j = Math.max(0, Math.min(x, getSizeY()));
                k = Math.max(0, Math.min(y, getSizeZ()));
                break;
            }
        case Y_AXIS:
            {
                i = Math.max(0, Math.min(y, getSizeX()));
                j = getSlice();
                k = Math.max(0, Math.min(x, getSizeZ()));
                break;
            }
        case Z_AXIS:
            {
                i = Math.max(0, Math.min(x, getSizeX()));
                j = Math.max(0, Math.min(y, getSizeY()));
                k = getSlice();
                break;
            }
        default:
            {
                throw new Exception("bad axis");
            }
    }
    CoordinateIndex ci = new CoordinateIndex();
    ci.x = i;
    ci.y = j;
    ci.z = k;
    return ci;
}
Also used : CoordinateIndex(org.vcell.util.CoordinateIndex) Point(java.awt.Point)

Example 3 with CoordinateIndex

use of org.vcell.util.CoordinateIndex in project vcell by virtualcell.

the class ImagePlaneManagerPanel method updateInfo.

private void updateInfo(MouseEvent mouseEvent) {
    if (mouseEvent == null) {
        return;
    }
    String infoS = null;
    // }else
    if (mouseEvent.getID() != java.awt.event.MouseEvent.MOUSE_EXITED) {
        Coordinate wc = null;
        boolean bNeedsMembraneCursor = false;
        if (getCurveEditorTool().getTool() == CurveEditorTool.TOOL_ZOOM || getCurveEditorTool().getTool() == CurveEditorTool.TOOL_PAN) {
            infoS = getCurveEditorTool().getToolDescription(getCurveEditorTool().getTool());
            setToolCursor();
        } else if (mouseEvent.getID() != java.awt.event.MouseEvent.MOUSE_ENTERED) {
            lastValidMouseEvent = mouseEvent;
            if (getimagePaneView1().isPointOnImage(mouseEvent.getPoint())) {
                java.awt.geom.Point2D unitP = getimagePaneView1().getImagePointUnitized(mouseEvent.getPoint());
                wc = getImagePlaneManager().getWorldCoordinateFromUnitized2D(unitP.getX(), unitP.getY());
                if (wc != null) {
                    if (getCurveValueProvider() != null) {
                        if (getSourceDataInfo() != null && getSourceDataInfo().isChombo()) {
                            // for chombo, can't use closest curve method, one irregular point has one curve, it can be very far
                            CoordinateIndex ci = getImagePlaneManager().getDataIndexFromUnitized2D(unitP.getX(), unitP.getY());
                            CurveSelectionInfo csiSegment = getCurveValueProvider().findChomboCurveSelectionInfoForPoint(ci);
                            if (csiSegment != null) {
                                String infoTemp = getCurveValueProvider().getCurveValue(csiSegment);
                                if (infoTemp != null) {
                                    infoS = infoTemp;
                                    bNeedsMembraneCursor = true;
                                }
                            }
                        } else {
                            CurveSelectionInfo[] curveCSIArr = getCurveRenderer().getCloseCurveSelectionInfos(wc);
                            if (curveCSIArr != null) {
                                for (int i = 0; i < curveCSIArr.length; i += 1) {
                                    CurveSelectionInfo csiSegment = getCurveRenderer().getClosestSegmentSelectionInfo(wc, curveCSIArr[i].getCurve());
                                    if (csiSegment != null) {
                                        String infoTemp = getCurveValueProvider().getCurveValue(csiSegment);
                                        if (infoTemp != null) {
                                            infoS = infoTemp;
                                            bNeedsMembraneCursor = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (infoS == null && getSourceDataInfo() != null) {
                        CoordinateIndex ci = getImagePlaneManager().getDataIndexFromUnitized2D(unitP.getX(), unitP.getY());
                        int volumeIndex = getSourceDataInfo().calculateWorldIndex(ci);
                        Coordinate quantizedWC = getSourceDataInfo().getWorldCoordinateFromIndex(ci);
                        boolean bUndefined = getSourceDataInfo().isDataNull() || (getDataInfoProvider() != null && !getDataInfoProvider().isDefined(volumeIndex));
                        String xCoordString = NumberUtils.formatNumber(quantizedWC.getX());
                        String yCoordString = NumberUtils.formatNumber(quantizedWC.getY());
                        String zCoordString = NumberUtils.formatNumber(quantizedWC.getZ());
                        infoS = "(" + xCoordString + (getSourceDataInfo().getYSize() > 1 ? "," + yCoordString : "") + (getSourceDataInfo().getZSize() > 1 ? "," + zCoordString : "") + ") " + "[" + volumeIndex + "]" + " [" + ci.x + (getSourceDataInfo().getYSize() > 1 ? "," + ci.y : "") + (getSourceDataInfo().getZSize() > 1 ? "," + ci.z : "") + "] " + (bUndefined ? "Undefined" : getSourceDataInfo().getDataValueAsString(ci.x, ci.y, ci.z));
                        if (getDataInfoProvider() != null) {
                            if (getDataInfoProvider().getPDEDataContext().getCartesianMesh().isChomboMesh()) {
                                if (!bUndefined) {
                                    StructureMetricsEntry structure = ((CartesianMeshChombo) getDataInfoProvider().getPDEDataContext().getCartesianMesh()).getStructureInfo(getDataInfoProvider().getPDEDataContext().getDataIdentifier());
                                    if (structure != null) {
                                        infoS += " || " + structure.getDisplayLabel();
                                    }
                                }
                            } else if (getDataInfoProvider() != null) {
                                infoS += "          ";
                                try {
                                    VolumeDataInfo volumeDataInfo = getDataInfoProvider().getVolumeDataInfo(volumeIndex);
                                    if (volumeDataInfo.subvolumeID0 != null) {
                                        infoS += " \"" + volumeDataInfo.volumeNamePhysiology + "\"" + " (\"" + volumeDataInfo.volumeNameGeometry + "\")";
                                        infoS += " svID=" + volumeDataInfo.subvolumeID0;
                                        infoS += " vrID=" + volumeDataInfo.volumeRegionID;
                                    }
                                } catch (Exception e) {
                                    // This can happen with FieldData viewer
                                    e.printStackTrace();
                                }
                            }
                        }
                        String curveDescr = CurveRenderer.getROIDescriptions(wc, getCurveRenderer());
                        if (curveDescr != null) {
                            infoS += "     " + curveDescr;
                        }
                    }
                    if (infoS == null) {
                        infoS = "Unknown";
                    }
                }
            }
            if (bNeedsMembraneCursor) {
                getimagePaneView1().setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
            } else {
                getimagePaneView1().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                setToolCursor();
            }
        } else {
            lastValidMouseEvent = null;
        }
    } else {
        lastValidMouseEvent = null;
    }
    // if(mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_DRAGGED ||
    // mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_PRESSED ||
    // mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_EXITED ||
    // mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_ENTERED){
    // getInfoJlabel().setText((infoS == null?defaultInfoString:infoS));
    // }
    getimagePaneView1().setToolTipText(infoS == null ? defaultInfoString : infoS);
    // make sure the vertical space for the infoText is sufficient to avoid resizing
    FontMetrics fontMetrics = getInfoJlabel().getGraphics().getFontMetrics();
    getInfoJlabel().setMinimumSize(new Dimension(50, (fontMetrics.getMaxAscent() + fontMetrics.getMaxDescent() + 1)));
    getInfoJlabel().setText((infoS == null ? defaultInfoString : infoS));
}
Also used : VolumeDataInfo(cbit.vcell.simdata.VolumeDataInfo) Coordinate(org.vcell.util.Coordinate) FontMetrics(java.awt.FontMetrics) StructureMetricsEntry(cbit.vcell.solvers.CartesianMeshChombo.StructureMetricsEntry) Dimension(java.awt.Dimension) CoordinateIndex(org.vcell.util.CoordinateIndex) CurveSelectionInfo(cbit.vcell.geometry.CurveSelectionInfo)

Example 4 with CoordinateIndex

use of org.vcell.util.CoordinateIndex in project vcell by virtualcell.

the class ImagePlaneManager method snapWorldCoordinateFace.

/**
 * Insert the method's description here.
 * Creation date: (7/13/2004 4:27:15 PM)
 */
public Coordinate snapWorldCoordinateFace(Coordinate targetC) {
    if (getSourceDataInfo().isCellCentered()) {
        return targetC;
    }
    org.vcell.util.CoordinateIndex centerCI = getSourceDataInfo().getDataIndexFromWorldCoordinate(targetC);
    Coordinate centerCoord = getSourceDataInfo().getWorldCoordinateFromIndex(centerCI);
    double diffX = centerCoord.getX() - targetC.getX();
    double diffY = centerCoord.getY() - targetC.getY();
    double diffZ = centerCoord.getZ() - targetC.getZ();
    if (Math.abs(diffX) >= Math.abs(diffY) && Math.abs(diffX) >= Math.abs(diffZ)) {
        diffY = 0;
        diffZ = 0;
    } else if (Math.abs(diffY) >= Math.abs(diffX) && Math.abs(diffY) >= Math.abs(diffZ)) {
        diffX = 0;
        diffZ = 0;
    } else {
        diffX = 0;
        diffY = 0;
    }
    CoordinateIndex offsetCI = new CoordinateIndex(centerCI.x - (new java.math.BigDecimal(diffX).signum()), centerCI.y - (new java.math.BigDecimal(diffY).signum()), centerCI.z - (new java.math.BigDecimal(diffZ).signum()));
    Coordinate offsetCoord = getSourceDataInfo().getWorldCoordinateFromIndex(offsetCI);
    Coordinate faceCoord = new Coordinate((centerCoord.getX() + offsetCoord.getX()) / 2.0, (centerCoord.getY() + offsetCoord.getY()) / 2.0, (centerCoord.getZ() + offsetCoord.getZ()) / 2.0);
    return faceCoord;
}
Also used : CoordinateIndex(org.vcell.util.CoordinateIndex) Coordinate(org.vcell.util.Coordinate) CoordinateIndex(org.vcell.util.CoordinateIndex)

Example 5 with CoordinateIndex

use of org.vcell.util.CoordinateIndex in project vcell by virtualcell.

the class MathTestingUtilities method resample3DSpatialSimple.

/**
 * Insert the method's description here.
 * Creation date: (10/27/2003 5:07:42 PM)
 * @return double[]
 * @param data double[]
 * @param sourceMesh cbit.vcell.solvers.CartesianMesh
 * @param targetMesh cbit.vcell.solvers.CartesianMesh
 */
public static double[] resample3DSpatialSimple(double[] sourceData, CartesianMesh sourceMesh, CartesianMesh refMesh) {
    if (sourceData.length != sourceMesh.getNumVolumeElements()) {
        throw new RuntimeException("must be volume data, data length doesn't match number of volume elements");
    }
    // for volume samples:
    // 
    // loop through volumeIndexes from refMesh
    // Coordinate refCoordinate = refMesh.getCoordinate(volumeIndex);
    // Coordinate fractionalIndex = sourceMesh.getFractionCoordinateIndex(Coordinate refCoordinate);
    // ....interpolate in z
    // start with integer portion of fractionIndex
    double[] resampledData = new double[refMesh.getSizeX() * refMesh.getSizeY() * refMesh.getSizeZ()];
    for (int i = 0; i < resampledData.length; i++) {
        Coordinate refCoordinate = refMesh.getCoordinateFromVolumeIndex(i);
        Coordinate fractionalIndex = sourceMesh.getFractionalCoordinateIndex(refCoordinate);
        int ceil_x;
        int floor_x;
        int ceil_y;
        int floor_y;
        int ceil_z;
        int floor_z;
        if (fractionalIndex.getX() < 0) {
            floor_x = 0;
            ceil_x = 1;
        } else if (fractionalIndex.getX() > sourceMesh.getSizeX() - 1) {
            floor_x = sourceMesh.getSizeX() - 2;
            ceil_x = sourceMesh.getSizeX() - 1;
        } else {
            ceil_x = (int) Math.ceil(fractionalIndex.getX());
            floor_x = (int) Math.floor(fractionalIndex.getX());
        }
        if (fractionalIndex.getY() < 0) {
            floor_y = 0;
            ceil_y = 1;
        } else if (fractionalIndex.getY() > sourceMesh.getSizeY() - 1) {
            floor_y = sourceMesh.getSizeY() - 2;
            ceil_y = sourceMesh.getSizeY() - 1;
        } else {
            ceil_y = (int) Math.ceil(fractionalIndex.getY());
            floor_y = (int) Math.floor(fractionalIndex.getY());
        }
        if (fractionalIndex.getZ() < 0) {
            floor_z = 0;
            ceil_z = 1;
        } else if (fractionalIndex.getZ() > sourceMesh.getSizeZ() - 1) {
            floor_z = sourceMesh.getSizeZ() - 2;
            ceil_z = sourceMesh.getSizeZ() - 1;
        } else {
            ceil_z = (int) Math.ceil(fractionalIndex.getZ());
            floor_z = (int) Math.floor(fractionalIndex.getZ());
        }
        double fract_x = fractionalIndex.getX() - floor_x;
        double fract_y = fractionalIndex.getY() - floor_y;
        double fract_z = fractionalIndex.getZ() - floor_z;
        CoordinateIndex coord_1 = new CoordinateIndex(floor_x, floor_y, floor_z);
        CoordinateIndex coord_2 = new CoordinateIndex(ceil_x, floor_y, floor_z);
        CoordinateIndex coord_3 = new CoordinateIndex(floor_x, floor_y, ceil_z);
        CoordinateIndex coord_4 = new CoordinateIndex(ceil_x, floor_y, ceil_z);
        CoordinateIndex coord_5 = new CoordinateIndex(floor_x, ceil_y, ceil_z);
        CoordinateIndex coord_6 = new CoordinateIndex(ceil_x, ceil_y, ceil_z);
        CoordinateIndex coord_7 = new CoordinateIndex(floor_x, ceil_y, floor_z);
        CoordinateIndex coord_8 = new CoordinateIndex(ceil_x, ceil_y, floor_z);
        int volIndx1 = sourceMesh.getVolumeIndex(coord_1);
        int volIndx2 = sourceMesh.getVolumeIndex(coord_2);
        int volIndx3 = sourceMesh.getVolumeIndex(coord_3);
        int volIndx4 = sourceMesh.getVolumeIndex(coord_4);
        int volIndx5 = sourceMesh.getVolumeIndex(coord_5);
        int volIndx6 = sourceMesh.getVolumeIndex(coord_6);
        int volIndx7 = sourceMesh.getVolumeIndex(coord_7);
        int volIndx8 = sourceMesh.getVolumeIndex(coord_8);
        double val_a = sourceData[volIndx1] + fract_x * (sourceData[volIndx2] - sourceData[volIndx1]);
        double val_b = sourceData[volIndx3] + fract_x * (sourceData[volIndx4] - sourceData[volIndx3]);
        double val_c = sourceData[volIndx5] + fract_x * (sourceData[volIndx6] - sourceData[volIndx5]);
        double val_d = sourceData[volIndx7] + fract_x * (sourceData[volIndx8] - sourceData[volIndx7]);
        // Interpolate in Y
        double val_e = val_a + fract_y * (val_d - val_a);
        double val_f = val_b + fract_y * (val_c - val_b);
        // Interpolate in Z - final resampledSourceData value
        resampledData[i] = val_e + fract_z * (val_f - val_e);
    }
    return resampledData;
}
Also used : Coordinate(org.vcell.util.Coordinate) CoordinateIndex(org.vcell.util.CoordinateIndex)

Aggregations

CoordinateIndex (org.vcell.util.CoordinateIndex)30 Coordinate (org.vcell.util.Coordinate)15 Point (java.awt.Point)7 SinglePoint (cbit.vcell.geometry.SinglePoint)4 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 Hashtable (java.util.Hashtable)3 Vector (java.util.Vector)3 ISize (org.vcell.util.ISize)3 CurveSelectionInfo (cbit.vcell.geometry.CurveSelectionInfo)2 RegionImage (cbit.vcell.geometry.RegionImage)2 SampledCurve (cbit.vcell.geometry.SampledCurve)2 DataBufferByte (java.awt.image.DataBufferByte)2 StringTokenizer (java.util.StringTokenizer)2 DisplayAdapterService (cbit.image.DisplayAdapterService)1 SourceDataInfo (cbit.image.SourceDataInfo)1 VCImage (cbit.image.VCImage)1 VCImageUncompressed (cbit.image.VCImageUncompressed)1 ImagePlaneManagerPanel (cbit.image.gui.ImagePlaneManagerPanel)1 Plot2D (cbit.plot.Plot2D)1 PlotData (cbit.plot.PlotData)1