Skip to content
Snippets Groups Projects
Commit 6df5af0e authored by Frantz Pili's avatar Frantz Pili
Browse files

Branch for grouped images loading

parent 79c40295
Branches
Tags
No related merge requests found
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
package fr.soleil.cdma.box.data; package fr.soleil.cdma.box.data;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import org.cdma.dictionary.LogicalGroup; import org.cdma.dictionary.LogicalGroup;
import org.cdma.interfaces.IKey; import org.cdma.interfaces.IKey;
...@@ -67,6 +68,19 @@ public class ImageStack extends ReferencedData { ...@@ -67,6 +68,19 @@ public class ImageStack extends ReferencedData {
return image; return image;
} }
public List<FlatData> getImageWithMultiPositions(int numberOfImages, int... position) {
List<FlatData> images = null;
ICDMAReader cdmaReader = getReader();
if ((cdmaReader != null) && (bufferSize != null) && (position != null)) {
if (position.length != bufferSize.length) {
position = Arrays.copyOf(position, bufferSize.length);
}
images = cdmaReader.readCDMFlatComplexArrayWithMultiPositions(parentGroup, dataItemKey, numberOfImages,
position, imageShape, ctxDataItem, true);
}
return images;
}
public Object getCompleteStack() { public Object getCompleteStack() {
Object result = null; Object result = null;
ICDMAReader cdmaReader = getReader(); ICDMAReader cdmaReader = getReader();
......
...@@ -10,6 +10,7 @@ package fr.soleil.cdma.box.data.scan; ...@@ -10,6 +10,7 @@ package fr.soleil.cdma.box.data.scan;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import fr.soleil.cdma.box.data.FlatData; import fr.soleil.cdma.box.data.FlatData;
...@@ -373,6 +374,20 @@ public class ScanData { ...@@ -373,6 +374,20 @@ public class ScanData {
return result; return result;
} }
/**
* Returns the image at a particular coordinate
*
* @param index The coordinate
* @return A {@link FlatData} {@link SoftIndexedData}. <code>null</code> if no such image.
*/
public List<FlatData> getImageWithMultiPositions(int numberOfImages, int[] firstPosition) {
List<FlatData> result = null;
if (images != null) {
result = images.getImageWithMultiPositions(numberOfImages, firstPosition);
}
return result;
}
public void setImages(ImageStack images) { public void setImages(ImageStack images) {
this.images = images; this.images = images;
} }
......
...@@ -1140,6 +1140,131 @@ public abstract class AbstractCDMAReader implements ICDMAReader { ...@@ -1140,6 +1140,131 @@ public abstract class AbstractCDMAReader implements ICDMAReader {
return result; return result;
} }
@Override
public List<FlatData> readCDMFlatComplexArrayWithMultiPositions(LogicalGroup parent, IKey key, int numberOfImages,
int[] origin, int[] resultShape, ContextDataItem ctxDataItem, boolean lockAccess) {
List<FlatData> result = null;
if (lockAccess) {
synchronized (AccessController.ACCESS_LOCK) {
beforeDataTreatment();
result = readCDMFlatComplexArrayNoLockWithMultiPositions(parent, key, numberOfImages, origin,
resultShape, ctxDataItem);
afterDataTreatment();
}
} else {
result = readCDMFlatComplexArrayNoLockWithMultiPositions(parent, key, numberOfImages, origin, resultShape,
ctxDataItem);
}
return result;
}
protected List<FlatData> readCDMFlatComplexArrayNoLockWithMultiPositions(LogicalGroup parent, IKey key,
int numberOfImages, int[] origin, int[] resultShape, ContextDataItem ctxDataItem) {
StringBuffer str = new StringBuffer();
for (int i = 0; i < origin.length; i++) {
str.append(" position [ " + i + " ] = " + origin[i]);
}
System.out.println("READ CDMA() START... numberOfImages : " + numberOfImages + " avec les Positions : "
+ str.toString());
long startMethode = System.currentTimeMillis();
List<FlatData> result = null;
if ((parent != null) && (key != null)) {
try {
IDataItem item = readCDMADataItemWithCtx(parent, key, ctxDataItem);
if (item != null) {
IArray array;
if ((origin != null) && (resultShape != null)) {
int[] tempShape = resultShape;
if (resultShape.length < origin.length) {
tempShape = new int[origin.length];
int maxIndex = origin.length - resultShape.length;
for (int i = 0; i < maxIndex; i++) {
tempShape[i] = 1;
}
System.arraycopy(resultShape, 0, tempShape, maxIndex, resultShape.length);
}
if (tempShape.length > 2) {
tempShape[tempShape.length - 3] = numberOfImages;
}
System.out.println("GETDATA START...");
long startData = System.currentTimeMillis();
array = item.getData(origin, tempShape);
long endData = System.currentTimeMillis();
System.out.println("GETDATA END... : " + (endData - startData));
} else {
array = item.getData();
}
if (array != null) {
result = new ArrayList<FlatData>();
System.out.println("extractArrayValue() START...");
long startextractData = System.currentTimeMillis();
Object value = extractArrayValue(item, array, true);
for (int i = 0; i < numberOfImages; i++) {
result.add(new FlatData(resultShape, null));
}
long endextractData = System.currentTimeMillis();
System.out.println("extractArrayValue() END... : " + (endextractData - startextractData));
// TODO reactivate
// if ((resultShape != null) && (resultShape.length > 1)) {
// int length = resultShape[resultShape.length - 2] * resultShape[resultShape.length - 1];
// if (length > 0) {
// int fullLength = Array.getLength(value);
// int count = fullLength / length;
// Class<?> dataType = ArrayUtils.recoverDataType(value);
// for (int i = 0; i < count; i++) {
// Object tmp = Array.newInstance(dataType, length);
// System.arraycopy(value, i * length, tmp, 0, length);
// result.add(new FlatData(resultShape, tmp));
// }
// } else {
// result.add(new FlatData(resultShape, value));
// }
// } else {
// result.add(new FlatData(resultShape, value));
// }
// XXX not that useful
// ISliceIterator iterator = array.getSliceIterator(2);
// while (iterator.hasNext()) {
// IArray imageArray = iterator.getArrayNext();
//
//// System.out.println("EXTRACT START...");
//// long startExtract = System.currentTimeMillis();
//
// Object value = extractArrayValue(item, imageArray, true);
//
//// long endExtract = System.currentTimeMillis();
//// System.out.println("EXTRACT END... : " + (endExtract - startExtract));
//
// result.add(new FlatData(resultShape, value));
// }
}
}
} catch (Exception e) {
result = null;
loggingTool.getLogger().log(Level.SEVERE, "Could not read array", e);
}
}
long endMethode = System.currentTimeMillis();
System.out.println("READ CDMA() END... : " + (endMethode - startMethode));
return result;
}
@Override @Override
public FlatData readCDMFlatComplexArray(LogicalGroup parent, IKey key, int[] origin, int[] resultShape, public FlatData readCDMFlatComplexArray(LogicalGroup parent, IKey key, int[] origin, int[] resultShape,
boolean lockAccess) { boolean lockAccess) {
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
******************************************************************************/ ******************************************************************************/
package fr.soleil.cdma.box.reader; package fr.soleil.cdma.box.reader;
import java.util.List;
import org.cdma.dictionary.LogicalGroup; import org.cdma.dictionary.LogicalGroup;
import org.cdma.interfaces.IDataItem; import org.cdma.interfaces.IDataItem;
import org.cdma.interfaces.IDataset; import org.cdma.interfaces.IDataset;
...@@ -152,6 +154,9 @@ public interface ICDMAReader extends ICancelable { ...@@ -152,6 +154,9 @@ public interface ICDMAReader extends ICancelable {
public FlatData readCDMFlatComplexArrayWithCtx(LogicalGroup parent, IKey key, int[] origin, int[] shape, public FlatData readCDMFlatComplexArrayWithCtx(LogicalGroup parent, IKey key, int[] origin, int[] shape,
ContextDataItem ctxDataItem, boolean lockAccess); ContextDataItem ctxDataItem, boolean lockAccess);
public List<FlatData> readCDMFlatComplexArrayWithMultiPositions(LogicalGroup parent, IKey key, int numberOfImages,
int[] origin, int[] resultShape, ContextDataItem ctxDataItem, boolean lockAccess);
/** /**
* Recovers an {@link IDataItem}, reads its array, and returns it as a {@link FlatData} * Recovers an {@link IDataItem}, reads its array, and returns it as a {@link FlatData}
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment