Class PlanarImgRangeCopier<T>

  • Type Parameters:
    T - a primitive array type, e.g., byte[].
    All Implemented Interfaces:
    RangeCopier<T>

    class PlanarImgRangeCopier<T>
    extends java.lang.Object
    implements RangeCopier<T>
    Does the actual copying work from a PlanarImg into a primitive array.
    • Field Detail

      • n

        private final int n
      • srcDims

        private final int[] srcDims
      • findRanges

        private final Ranges findRanges
      • memCopy

        private final MemCopy<T> memCopy
      • oob

        private final T oob
      • rangesPerDimension

        private final java.util.List<Ranges.Range>[] rangesPerDimension
      • dsteps

        private final int[] dsteps
      • doffsets

        private final int[] doffsets
      • cdims

        private final int[] cdims
      • csteps

        private final int[] csteps
      • lengths

        private final int[] lengths
    • Method Detail

      • newInstance

        public PlanarImgRangeCopier<T> newInstance()
        Description copied from interface: RangeCopier
        Return a new independent instance of this RangeCopier. This is used for multi-threading. The new instance works on the same source image, but has independent internal state.
        Specified by:
        newInstance in interface RangeCopier<T>
        Returns:
        new independent instance of this RangeCopier
      • copy

        public void copy​(long[] srcPos,
                         T dest,
                         int[] size)
        Copy the block starting at srcPos with the given size into the (appropriately sized) dest array.

        This finds the src range lists for all dimensions and then calls copy(Object, int) to iterate all range combinations.

        Specified by:
        copy in interface RangeCopier<T>
        Parameters:
        srcPos - min coordinates of block to copy from src Img.
        dest - destination array. Type is byte[], float[], etc, corresponding to the src Img's native type.
        size - dimensions of block to copy from src Img.
      • copy

        private void copy​(T dest,
                          int d)
        Iterate the rangesPerDimension list for the given dimension d and recursively call itself for iterating dimension d-1.
        Parameters:
        dest - destination array. Type is byte[], float[], etc, corresponding to the src Img's native type.
        d - current dimension. This method calls itself recursively with d-1 until d==0 is reached.
      • setupDestSize

        private void setupDestSize​(int[] size)
      • updateRange

        private void updateRange​(int d)
      • copyRanges

        private void copyRanges​(T dest)
        Once we get here, setupDestSize(int[]) and updateRange(int) for all dimensions have been called, so the dsteps, doffsets, cdims, and lengths fields have been appropriately set up for the current Range combination. Also cellAccess is positioned on the corresponding cell.
      • copyRangesRecursively

        private void copyRangesRecursively​(T src,
                                           int srcPos,
                                           T dest,
                                           int destPos,
                                           int d)
      • fillRanges

        void fillRanges​(T dest,
                        int dConst)
        Once we get here, setupDestSize(int[]) and updateRange(int) for all dimensions have been called, so the dsteps, doffsets, cdims, and lengths fields have been appropriately set up for the current Range combination. Also cellAccess is positioned on the corresponding cell.
      • fillRangesRecursively

        private void fillRangesRecursively​(T dest,
                                           int destPos,
                                           int d,
                                           int dConst)