Search in sources :

Example 1 with WlzFileInputStream

use of uk.ac.mrc.hgu.Wlz.WlzFileInputStream 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 + ")");
    }
}
Also used : WlzException(uk.ac.mrc.hgu.Wlz.WlzException) WlzFileInputStream(uk.ac.mrc.hgu.Wlz.WlzFileInputStream) WlzObject(uk.ac.mrc.hgu.Wlz.WlzObject) IOException(java.io.IOException) FormatException(loci.formats.FormatException) WlzDVertex3(uk.ac.mrc.hgu.Wlz.WlzDVertex3)

Aggregations

IOException (java.io.IOException)1 FormatException (loci.formats.FormatException)1 WlzDVertex3 (uk.ac.mrc.hgu.Wlz.WlzDVertex3)1 WlzException (uk.ac.mrc.hgu.Wlz.WlzException)1 WlzFileInputStream (uk.ac.mrc.hgu.Wlz.WlzFileInputStream)1 WlzObject (uk.ac.mrc.hgu.Wlz.WlzObject)1