Search in sources :

Example 11 with CoordinateIndex

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

the class DisplayImageOp method displayImage.

public void displayImage(final Image image, String title, WindowListener listener) {
    final ImagePlaneManagerPanel imagePanel = new ImagePlaneManagerPanel();
    double[] doublePixels = image.getDoublePixels();
    double minPixel = Double.MAX_VALUE;
    double maxPixel = -Double.MAX_VALUE;
    for (int i = 0; i < doublePixels.length; i++) {
        double pixel = doublePixels[i];
        doublePixels[i] = pixel;
        minPixel = Math.min(minPixel, pixel);
        maxPixel = Math.max(maxPixel, pixel);
    }
    Range newRange = new Range(minPixel, maxPixel);
    SourceDataInfo source = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, doublePixels, image.getExtent(), image.getOrigin(), newRange, 0, image.getNumX(), 1, image.getNumY(), image.getNumX(), image.getNumZ(), image.getNumX() * image.getNumY());
    imagePanel.setDisplayAdapterServicePanelVisible(true);
    imagePanel.setCurveValueProvider(new CurveValueProvider() {

        @Override
        public void curveAdded(Curve curve) {
            System.out.println("called curveAdded(" + curve + "), do nothing for now");
        }

        @Override
        public void curveRemoved(Curve curve) {
            System.out.println("called curveRemoved(" + curve + ")");
        }

        @Override
        public String getCurveValue(CurveSelectionInfo csi) {
            System.out.println("called getCurveValue(CurveSelectionInfo " + csi);
            return null;
        }

        @Override
        public CurveSelectionInfo getInitalCurveSelection(int tool, Coordinate wc) {
            System.out.println("called getInitialCurveSelection(tool=" + tool + ", coord=" + wc + ")");
            return null;
        }

        @Override
        public boolean isAddControlPointOK(int tool, Coordinate wc, Curve addedToThisCurve) {
            System.out.println("called isAddControlPointOK");
            return true;
        }

        @Override
        public boolean providesInitalCurve(int tool, Coordinate wc) {
            System.out.println("called providesInitialCurve(tool=" + tool + " (TOOL_LINE=" + CurveEditorTool.TOOL_LINE + "), coord=" + wc);
            return false;
        }

        @Override
        public void setDescription(Curve curve) {
            System.out.println("called setDescription(" + curve + ")");
            curve.setDescription(CurveValueProvider.DESCRIPTION_VOLUME);
        }

        @Override
        public CurveSelectionInfo findChomboCurveSelectionInfoForPoint(CoordinateIndex ci) {
            System.out.println("called find ChomboCurveSelectionInfoForPoint(coord=" + ci + ")");
            return null;
        }
    });
    DisplayAdapterService das = imagePanel.getDisplayAdapterServicePanel().getDisplayAdapterService();
    das.setValueDomain(null);
    das.addColorModelForValues(DisplayAdapterService.createGrayColorModel(), DisplayAdapterService.createGraySpecialColors(), DisplayAdapterService.GRAY);
    das.addColorModelForValues(DisplayAdapterService.createBlueRedColorModel(), DisplayAdapterService.createBlueRedSpecialColors(), DisplayAdapterService.BLUERED);
    das.setActiveColorModelID(DisplayAdapterService.BLUERED);
    final JFrame jframe = new JFrame();
    jframe.setTitle(title);
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints imageConstraints = new GridBagConstraints();
    imageConstraints.gridx = 0;
    imageConstraints.gridy = 0;
    imageConstraints.weightx = 1.0;
    imageConstraints.weighty = 1.0;
    imageConstraints.fill = GridBagConstraints.BOTH;
    panel.add(imagePanel, imageConstraints);
    JButton plotButton = new JButton("plot");
    plotButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                Curve curve = imagePanel.getCurveRenderer().getSelection().getCurve();
                VariableType variableType = VariableType.VOLUME;
                Curve samplerCurve = curve.getSampledCurve();
                samplerCurve.setDescription(curve.getDescription());
                VCImage vcImage = new VCImageUncompressed(null, new byte[image.getISize().getXYZ()], image.getExtent(), image.getISize().getX(), image.getISize().getY(), image.getISize().getZ());
                int dimension = 1 + (image.getISize().getY() > 0 ? 1 : 0) + (image.getISize().getZ() > 0 ? 1 : 0);
                RegionImage regionImage = new RegionImage(vcImage, dimension, image.getExtent(), image.getOrigin(), RegionImage.NO_SMOOTHING);
                CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(image.getOrigin(), image.getExtent(), image.getISize(), regionImage);
                SpatialSelectionVolume ssVolume = new SpatialSelectionVolume(new CurveSelectionInfo(samplerCurve), variableType, mesh);
                String varName = "var";
                SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[] { new VolVariable(varName, null) };
                PlotData plotData = getLineScan(ssVolume, image, mesh);
                PlotPane plotPane = new PlotPane();
                DataSymbolMetadataResolver resolver = null;
                Plot2D plot2D = new Plot2D(symbolTableEntries, resolver, new String[] { varName }, new PlotData[] { plotData }, new String[] { "Values along curve", "Distance (\u00b5m)", "[" + varName + "]" });
                plotPane.setPlot2D(plot2D);
                DialogUtils.showComponentCloseDialog(jframe, plotPane, "plot");
            } catch (ImageException | IOException | DataAccessException | MathException e1) {
                e1.printStackTrace();
            }
        }
    });
    GridBagConstraints plotButtonConstraints = new GridBagConstraints();
    plotButtonConstraints.gridx = 0;
    plotButtonConstraints.gridy = 1;
    panel.add(plotButton, plotButtonConstraints);
    jframe.getContentPane().add(panel);
    jframe.setSize(500, 500);
    jframe.addWindowListener(listener);
    jframe.setVisible(true);
    imagePanel.setSourceDataInfo(source);
}
Also used : DisplayAdapterService(cbit.image.DisplayAdapterService) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) ImagePlaneManagerPanel(cbit.image.gui.ImagePlaneManagerPanel) JButton(javax.swing.JButton) VCImage(cbit.image.VCImage) SourceDataInfo(cbit.image.SourceDataInfo) CoordinateIndex(org.vcell.util.CoordinateIndex) JFrame(javax.swing.JFrame) PlotData(cbit.plot.PlotData) DataSymbolMetadataResolver(cbit.vcell.solver.SimulationModelInfo.DataSymbolMetadataResolver) VariableType(cbit.vcell.math.VariableType) VolVariable(cbit.vcell.math.VolVariable) Curve(cbit.vcell.geometry.Curve) VCImageUncompressed(cbit.image.VCImageUncompressed) Range(org.vcell.util.Range) CartesianMesh(cbit.vcell.solvers.CartesianMesh) CurveValueProvider(cbit.vcell.simdata.gui.CurveValueProvider) ActionListener(java.awt.event.ActionListener) Coordinate(org.vcell.util.Coordinate) SpatialSelectionVolume(cbit.vcell.simdata.SpatialSelectionVolume) RegionImage(cbit.vcell.geometry.RegionImage) PlotPane(cbit.plot.gui.PlotPane) Plot2D(cbit.plot.Plot2D) CurveSelectionInfo(cbit.vcell.geometry.CurveSelectionInfo)

Example 12 with CoordinateIndex

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

the class ROIMultiPaintManager method resizeImpl0.

public static void resizeImpl0(ResizeInfo resizeInfo, ImageDataset[] originalData, BufferedImage[] roiComposite) {
    ISize newISize = resizeInfo.getNewSize();
    ISize oldISize = resizeInfo.getOriginalSize();
    if (originalData != null && !originalData[0].getISize().compareEqual(oldISize)) {
        throw new IllegalArgumentException("Original size not match original data");
    }
    if (roiComposite.length != oldISize.getZ() || roiComposite[0].getWidth() != oldISize.getX() || roiComposite[0].getHeight() != oldISize.getY()) {
        throw new IllegalArgumentException("Original size not match roiComposite");
    }
    short[][][] newUnderlayZ = (originalData != null ? new short[originalData.length][newISize.getZ()][newISize.getX() * newISize.getY()] : null);
    ;
    BufferedImage[] newROIZ = new BufferedImage[newISize.getZ()];
    if (resizeInfo.isScaling()) {
        int oldXY = oldISize.getX() * oldISize.getY();
        double oldIncrX = getProperScale(oldISize.getX(), newISize.getX());
        double oldIncrY = getProperScale(oldISize.getY(), newISize.getY());
        double oldIncrZ = getProperScale(oldISize.getZ(), newISize.getZ());
        for (int z = 0; z < newISize.getZ(); z++) {
            int oldIndexZ = (int) (z * oldIncrZ);
            newROIZ[z] = new BufferedImage(newISize.getX(), newISize.getY(), BufferedImage.TYPE_BYTE_INDEXED, getContrastIndexColorModel());
            byte[] newROIZArr = ((DataBufferByte) newROIZ[z].getRaster().getDataBuffer()).getData();
            byte[] oldROIZArr = ((DataBufferByte) roiComposite[oldIndexZ].getData().getDataBuffer()).getData();
            int newXYIndex = 0;
            for (int y = 0; y < newISize.getY(); y++) {
                int oldXYIndex = (((int) (oldIncrY * y)) * oldISize.getX());
                for (int x = 0; x < newISize.getX(); x++) {
                    int oldXIndex = oldXYIndex + (int) (x * oldIncrX);
                    if (originalData != null) {
                        for (int c = 0; c < originalData.length; c++) {
                            short[] oldUnderlayZ = originalData[c].getAllImages()[oldIndexZ].getPixels();
                            // if(true){//smoothing
                            // int cnt = (x>0?1:0)+(x<(newISize.getX()-1)?1:0)+(y>0?1:0)+(y<(newISize.getY()-1)?1:0)+(z>0?1:0)+(x<(newISize.getZ()-1)?1:0);
                            // int zm = (int)((z-1)*oldIncrZ);
                            // int zp = (int)((z+1)*oldIncrZ);
                            // int ym = (((int)(oldIncrY*(y-1)))*oldISize.getX())+(int)(x*oldIncrX);
                            // int yp = (((int)(oldIncrY*(y+1)))*oldISize.getX())+(int)(x*oldIncrX);
                            // int xm = oldXYIndex + (int)((x-1)*oldIncrX);
                            // int xp = oldXYIndex + (int)((x+1)*oldIncrX);
                            // //									System.out.println("cnt="+cnt+" newXYIndex="+newXYIndex+"   base "+x+" "+y+" "+z+"   m "+xm+" "+ym+" "+zm+"   p "+xp+" "+yp+" "+zp);
                            // int sum = oldUnderlayZ[oldXIndex]+
                            // (x>0?oldUnderlayZ[xm]:0)+
                            // (x<(newISize.getX()-1)?oldUnderlayZ[xp]:0)+
                            // (y>0?oldUnderlayZ[ym]:0)+
                            // (y<(newISize.getY()-1)?oldUnderlayZ[yp]:0)+
                            // (z>0?originalData[c].getAllImages()[zm].getPixels()[oldXIndex]:0)+
                            // (z<(newISize.getZ()-1)?originalData[c].getAllImages()[zp].getPixels()[oldXIndex]:0);
                            // newUnderlayZ[c][z][newXYIndex] = (short)((double)sum/(double)(cnt+1));
                            // }else{//nearest neighbor
                            // newUnderlayZ[c][z][newXYIndex] = oldUnderlayZ[oldXIndex];
                            // }
                            newUnderlayZ[c][z][newXYIndex] = oldUnderlayZ[oldXIndex];
                        }
                    }
                    newROIZArr[newXYIndex] = oldROIZArr[oldXIndex];
                    newXYIndex++;
                }
            }
        }
    } else if (resizeInfo.isPadCrop()) {
        CoordinateIndex low = resizeInfo.getLowPadCrop();
        CoordinateIndex high = resizeInfo.getHighPadCrop();
        for (int z = 0; z < newISize.getZ(); z++) {
            newROIZ[z] = new BufferedImage(newISize.getX(), newISize.getY(), BufferedImage.TYPE_BYTE_INDEXED, getContrastIndexColorModel());
            byte[] newROIZArr = ((DataBufferByte) newROIZ[z].getRaster().getDataBuffer()).getData();
            int oldZIndex = z - low.z;
            byte[] oldROIZArr = (oldZIndex < 0 || (z + high.z) >= newISize.getZ() ? null : ((DataBufferByte) roiComposite[oldZIndex].getData().getDataBuffer()).getData());
            if (oldROIZArr == null) {
                continue;
            }
            for (int y = 0; y < newISize.getY(); y++) {
                int oldYIndex = y - low.y;
                if (oldYIndex < 0 || (y + high.y) >= newISize.getY()) {
                    continue;
                }
                int oldXYIndex = (((int) oldYIndex) * oldISize.getX());
                int newXYIndex = y * newISize.getX();
                for (int x = 0; x < newISize.getX(); x++) {
                    int oldXIndex = x - low.x;
                    if (oldXIndex < 0 || (x + high.x) >= newISize.getX()) {
                        continue;
                    }
                    int oldFinalIndex = oldXYIndex + oldXIndex;
                    int newfinalIndex = newXYIndex + x;
                    if (originalData != null) {
                        for (int c = 0; c < originalData.length; c++) {
                            short[] oldUnderlayZ = originalData[c].getAllImages()[(int) oldZIndex].getPixels();
                            newUnderlayZ[c][z][newfinalIndex] = oldUnderlayZ[oldFinalIndex];
                        }
                    }
                    newROIZArr[newfinalIndex] = oldROIZArr[oldFinalIndex];
                // System.out.println(oldXIndex+" "+oldYIndex+" "+oldZIndex+" -- "+x+" "+y+" "+z+" newIndx="+newXYIndex+" oldIndex="+oldFinalIndex);
                }
            }
        }
    } else {
        throw new RuntimeException("Unexpected " + ResizeInfo.class.getName() + " state.");
    }
    resizeInfo.setResizedData(newUnderlayZ, newROIZ);
}
Also used : ISize(org.vcell.util.ISize) DataBufferByte(java.awt.image.DataBufferByte) CoordinateIndex(org.vcell.util.CoordinateIndex) BufferedImage(java.awt.image.BufferedImage) Point(java.awt.Point)

Example 13 with CoordinateIndex

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

the class ROIMultiPaintManager method cropROIData.

private void cropROIData(final Crop3D cropRectangle3D) /*,boolean bThread*/
{
    final AsynchClientTask cropTask = new AsynchClientTask("Cropping...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            ISize origISize = getImageDataSetChannel().getISize();
            CoordinateIndex cropLow = new CoordinateIndex(-cropRectangle3D.low.x, -cropRectangle3D.low.y, -cropRectangle3D.low.z);
            CoordinateIndex cropHigh = new CoordinateIndex(cropRectangle3D.low.x + cropRectangle3D.width - origISize.getX(), cropRectangle3D.low.y + cropRectangle3D.height - origISize.getY(), cropRectangle3D.low.z + cropRectangle3D.depth - origISize.getZ());
            resizeImpl(ResizeInfo.createPadCropResizeInfo(origISize, cropLow, cropHigh), getClientTaskStatusSupport());
            updateAuxiliaryInfo(origISize, getClientTaskStatusSupport());
        }
    };
    final AsynchClientTask updatePanelTask = getUpdateDisplayAfterCropTask();
    final Hashtable<String, Object> taskHash = new Hashtable<String, Object>();
    ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, taskHash, new AsynchClientTask[] { cropTask, updatePanelTask }, false, false, null, true);
// if(bThread){
// ClientTaskDispatcher.dispatch(overlayEditorPanelJAI,taskHash,
// new AsynchClientTask[] {cropTask,updatePanelTask},false,false,null,true);
// }else{
// new Thread(new Runnable() {
// public void run(){
// try{
// cropTask.run(taskHash);
// SwingUtilities.invokeAndWait(new Runnable() {
// public void run() {
// try {
// updatePanelTask.run(taskHash);
// } catch (Exception e) {
// e.printStackTrace();
// throw new RuntimeException(e);
// }
// }
// });
// }catch(Exception e){
// e.printStackTrace();
// DialogUtils.showErrorDialog(overlayEditorPanelJAI, "Crop failed:\n"+e.getMessage()+
// (e.getCause()!= null?"\n"+e.getCause().getMessage():""), e);
// }
// }
// }).run();
// }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) ISize(org.vcell.util.ISize) CoordinateIndex(org.vcell.util.CoordinateIndex)

Example 14 with CoordinateIndex

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

the class ROIMultiPaintManager method findROI.

// -----End UNDO methods-------------------------
private void findROI(final RegionInfo findRegionInfo) {
    if (findRegionInfo == null) {
        return;
    }
    System.out.println("regIndex=" + findRegionInfo.getRegionIndex() + " pixVal=" + findRegionInfo.getPixelValue() + " numPix=" + findRegionInfo.getNumPixels());
    final String COORDINDEX = "COORDINDEX";
    final String START_THREAD = "START_THREAD";
    AsynchClientTask findCoordTask = new AsynchClientTask("Find coordinate...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            hashTable.put(START_THREAD, Thread.currentThread());
            int regionImageSize = regionImage.getNumXY() * regionImage.getNumZ();
            for (int i = 0; i < regionImageSize; i++) {
                if (findRegionInfo.isIndexInRegion(i)) {
                    int z = i / regionImage.getNumXY();
                    int y = (i % regionImage.getNumXY()) / regionImage.getNumX();
                    int x = i % regionImage.getNumX();
                    CoordinateIndex coordinateIndex = new CoordinateIndex(x, y, (B_DISPLAY_ZERO_INDEX_Z ? z : z + 1));
                    hashTable.put(COORDINDEX, coordinateIndex);
                    break;
                }
            }
        }
    };
    AsynchClientTask drawStartTask = new AsynchClientTask("drawStar", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            CoordinateIndex coordinateIndex = (CoordinateIndex) hashTable.get(COORDINDEX);
            if (coordinateIndex == null) {
                throw new Exception("Couldn't find coordinate of first pixel for regionInfo");
            }
            overlayEditorPanelJAI.placeMarkerOverResolved(coordinateIndex, 7);
        }
    };
    AsynchClientTask waitTask = new AsynchClientTask("wait", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            Thread.sleep(1000);
        }
    };
    AsynchClientTask clearStarTask = new AsynchClientTask("drawStar", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            overlayEditorPanelJAI.placeMarkerOverResolved(null, 0);
        }
    };
    ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, new Hashtable<String, Object>(), new AsynchClientTask[] { findCoordTask, drawStartTask, waitTask, clearStarTask });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) CoordinateIndex(org.vcell.util.CoordinateIndex) Point(java.awt.Point) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException)

Example 15 with CoordinateIndex

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

the class MathTestingUtilities method resample3DSpatial.

/**
 * 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[] resample3DSpatial(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);
        // use it to compute a, b, c, d, then e & f	 ** Interpolation in X **
        if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx1) == refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx2) != refMesh.getSubVolumeFromVolumeIndex(i)) {
            volIndx2 = volIndx1;
        } else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx1) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx2) == refMesh.getSubVolumeFromVolumeIndex(i)) {
            volIndx1 = volIndx2;
        } else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx1) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx2) != refMesh.getSubVolumeFromVolumeIndex(i)) {
            throw new RuntimeException("Either subvolume in sourceMesh not equal to refMesh subVol cannot be handled at this time!");
        }
        if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx3) == refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx4) != refMesh.getSubVolumeFromVolumeIndex(i)) {
            volIndx4 = volIndx3;
        } else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx3) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx4) == refMesh.getSubVolumeFromVolumeIndex(i)) {
            volIndx3 = volIndx4;
        } else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx3) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx4) != refMesh.getSubVolumeFromVolumeIndex(i)) {
            throw new RuntimeException("Either subvolume in sourceMesh not equal to refMesh subVol cannot be handled at this time!");
        }
        if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx5) == refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx6) != refMesh.getSubVolumeFromVolumeIndex(i)) {
            volIndx6 = volIndx5;
        } else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx5) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx6) == refMesh.getSubVolumeFromVolumeIndex(i)) {
            volIndx5 = volIndx6;
        } else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx5) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx6) != refMesh.getSubVolumeFromVolumeIndex(i)) {
            throw new RuntimeException("Either subvolume in sourceMesh not equal to refMesh subVol cannot be handled at this time!");
        }
        if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx7) == refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx8) != refMesh.getSubVolumeFromVolumeIndex(i)) {
            volIndx8 = volIndx7;
        } else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx7) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx8) == refMesh.getSubVolumeFromVolumeIndex(i)) {
            volIndx7 = volIndx8;
        } else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx7) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx8) != refMesh.getSubVolumeFromVolumeIndex(i)) {
            throw new RuntimeException("Either subvolume in sourceMesh not equal to refMesh subVol cannot be handled at this time!");
        }
        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