use of uk.ac.mrc.hgu.Wlz.WlzObject in project bioformats by openmicroscopy.
the class WlzServiceImpl method openRead.
/*
* Helper methods.
*/
private void openRead(String file) throws FormatException, IOException {
state = WLZ_SERVICE_READ;
try {
wlzFP = new WlzFileInputStream(file);
wlzObj = WlzObject.WlzReadObj(wlzFP);
bBox = WlzObject.WlzBoundingBox3I(wlzObj);
objType = WlzObject.WlzGetObjectType(wlzObj);
if (objType == WlzObjectType.WLZ_3D_DOMAINOBJ) {
voxSz = WlzObject.WlzGetVoxelSize(wlzObj);
} else {
voxSz = new WlzDVertex3(1.0, 1.0, 1.0);
}
} catch (WlzException e) {
throw new IOException("Failed to read Woolz object (" + e + ")", e);
}
try {
if (objType == WlzObjectType.WLZ_COMPOUND_ARR_1 || objType == WlzObjectType.WLZ_COMPOUND_ARR_2) {
int count = objType == WlzObjectType.WLZ_COMPOUND_ARR_1 ? 1 : 2;
WlzObject[][] dest = new WlzObject[1][count];
WlzObject.WlzExplode(new int[] { count }, dest, wlzObj);
wlzObj = dest[0][0];
bBox = WlzObject.WlzBoundingBox3I(wlzObj);
objType = WlzObject.WlzGetObjectType(wlzObj);
if (objType == WlzObjectType.WLZ_3D_DOMAINOBJ) {
voxSz = WlzObject.WlzGetVoxelSize(wlzObj);
}
}
if (WlzObject.WlzObjectValuesIsNull(wlzObj) != 0) {
/* Here we use WLZ_GREY_ERROR to indicate that the object has no
* values not an error. */
objGType = WlzGreyType.WLZ_GREY_ERROR;
} else {
// throw an exception here instead of segfaulting during readBytes*
if (WlzObject.WlzGetObjectValuesType(wlzObj) > WlzObjectType.WLZ_GREY_TAB_TILED) {
throw new FormatException("Value table data not supported");
}
objGType = WlzObject.WlzGreyTypeFromObj(wlzObj);
}
} catch (WlzException e) {
throw new FormatException("Unable to determine Woolz object value type (" + e + ")", e);
}
switch(objGType) {
case WlzGreyType.WLZ_GREY_UBYTE:
break;
case WlzGreyType.WLZ_GREY_SHORT:
break;
case WlzGreyType.WLZ_GREY_INT:
break;
case WlzGreyType.WLZ_GREY_FLOAT:
break;
case WlzGreyType.WLZ_GREY_DOUBLE:
break;
case WlzGreyType.WLZ_GREY_RGBA:
break;
case WlzGreyType.WLZ_GREY_ERROR:
break;
default:
throw new FormatException("Inappropriate Woolz object value type (type = " + objGType + ")");
}
}
Aggregations