Skip to content
Snippets Groups Projects
Commit c891f3eb authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Generalize BasicLoader::valueAt()

parent ab29d576
No related branches found
No related tags found
No related merge requests found
......@@ -37,18 +37,20 @@ public abstract class BasicLoader {
*/
public abstract int[] loadPlaneData(final int plane) throws IOException;
/**
* Read value from plane at specified offset.
*
* @param plane Zero based plane index.
* @param offset Offset on flattened plane data.
* @return Plane value at the index.
*/
protected int valueAt(final int plane, final int offset) {
new Exception().printStackTrace(System.err);
assert (false) : "Unimplemented overload of BasicLoader::valueAt()";
return Integer.MIN_VALUE;
}
// /**
// * Read value from plane at specified offset.
// *
// * @param plane Zero based plane index.
// * @param offset Offset on flattened plane data.
// * @return Plane value at the index.
// */
// protected int valueAt(final int plane, final int offset) {
// new Exception().printStackTrace(System.err);
// assert (false) : "Unimplemented overload of BasicLoader::valueAt()";
// return Integer.MIN_VALUE;
// }
protected abstract int valueAt(final int plane, final int x, final int y, final int width);
/**
* Wrap column (x) index based on specified wrapping strategy.
......@@ -149,7 +151,9 @@ public abstract class BasicLoader {
break;
srcX = wrapColumnIndex(srcX);
}
rowVectors[vectorIndex][vectorX] = valueAt(plane, Block.index(srcX, row, dims.getY()));
// TODO(Moravec): dims.getY() should probably be dims.getX()! Check this!
rowVectors[vectorIndex][vectorX] = valueAt(plane, srcX, row, dims.getY());
}
++vectorIndex;
}
......@@ -217,7 +221,8 @@ public abstract class BasicLoader {
}
srcX = wrapColumnIndex(srcX);
}
block[Block.index(x, y, blockDim.getX())] = valueAt(planeIndex, Block.index(srcX, srcY, dims.getX()));
block[Block.index(x, y, blockDim.getX())] = valueAt(planeIndex, srcX, srcY, dims.getX());
}
}
}
......@@ -284,7 +289,7 @@ public abstract class BasicLoader {
srcX = wrapColumnIndex(srcX);
}
voxel[Voxel.dataIndex(x, y, z, voxelDim)] = valueAt(srcZ, Block.index(srcX, srcY, dims.getX()));
voxel[Voxel.dataIndex(x, y, z, voxelDim)] = valueAt(srcZ, srcX, srcY, dims.getX());
}
}
}
......
package cz.it4i.qcmp.io.loader;
import cz.it4i.qcmp.data.Block;
import cz.it4i.qcmp.data.Range;
import cz.it4i.qcmp.data.V2i;
import cz.it4i.qcmp.data.V3i;
......@@ -44,9 +45,10 @@ public class FlatBufferLoader extends BasicLoader implements IPlaneLoader {
}
}
@Override
protected int valueAt(final int plane, final int offset) {
return TypeConverter.shortToInt(((short[]) bufferInputData.getPixelBuffer())[(plane * planePixelCount) + offset]);
protected int valueAt(final int plane, final int x, final int y, final int width) {
return TypeConverter.shortToInt(((short[]) bufferInputData.getPixelBuffer())[(plane * planePixelCount) + Block.index(x, y, width)]);
}
@Override
......
package cz.it4i.qcmp.io.loader;
import cz.it4i.qcmp.data.Block;
import cz.it4i.qcmp.data.Range;
import cz.it4i.qcmp.data.V2i;
import cz.it4i.qcmp.data.V3i;
......@@ -36,11 +37,10 @@ public final class ImageJBufferLoader extends BasicLoader implements IPlaneLoade
final short[] srcBuffer = (short[]) bufferInputData.getPixelBuffer(plane);
return TypeConverter.shortArrayToIntArray(srcBuffer);
}
@Override
protected int valueAt(final int plane, final int offset) {
return TypeConverter.shortToInt(((short[]) bufferInputData.getPixelBuffer(plane))[offset]);
protected int valueAt(int plane, int x, int y, int width) {
return TypeConverter.shortToInt(((short[]) bufferInputData.getPixelBuffer(plane))[Block.index(x, y, width)]);
}
@Override
......
......@@ -20,6 +20,13 @@ public final class RawDataLoader extends BasicLoader implements IPlaneLoader {
this.inputDataInfo = inputDataInfo;
}
@Override
protected int valueAt(final int plane, final int x, final int y, final int width) {
new Exception().printStackTrace(System.err);
assert (false) : "RawDataLoader shouldn't use valueAt impl methods!";
return -1;
}
@Override
public int[] loadPlaneData(final int plane) throws IOException {
final byte[] buffer;
......
......@@ -29,6 +29,13 @@ public final class SCIFIOLoader extends BasicLoader implements IPlaneLoader {
this.reader = ScifioWrapper.getReader(this.inputDataInfo.getFilePath());
}
@Override
protected int valueAt(final int plane, final int x, final int y, final int width) {
new Exception().printStackTrace(System.err);
assert (false) : "SCIFIOLoader shouldn't use valueAt impl methods!";
return -1;
}
@Override
public int[] loadPlaneData(final int plane) throws IOException {
final byte[] planeBytes;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment