Try HDFView to see if you can see your 3D data page by page.

The class ncsa.hdf.view.DefaultTableView.java use very similar code to
yours to show 3D data page by page. I copied the part of the code below.

=====
   private void gotoPage(long idx)
   {
       if (dataset.getRank() < 3) {
           return;
       }

       if (isValueChanged) {
           updateValueInFile();
       }

       long[] start = dataset.getStartDims();
       int[] selectedIndex = dataset.getSelectedIndex();
       long[] dims = dataset.getDims();

       if ((idx <0) || (idx >= dims[selectedIndex[2]])) {
           toolkit.beep();
           JOptionPane.showMessageDialog(this,
"Frame number must be between 0 and "+(dims[selectedIndex[2]]-1),
               getTitle(),
               JOptionPane.ERROR_MESSAGE);
           return;
       }

       start[selectedIndex[2]] = idx;
       curFrame = idx;
       dataset.clearData();

       setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

       try {
           dataValue = dataset.getData();
           if (dataset instanceof ScalarDS)
           {
               ((ScalarDS)dataset).convertFromUnsignedC();
               dataValue = dataset.getData();
           }
       }
       catch (Exception ex)
       {
           setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
           dataValue = null;
JOptionPane.showMessageDialog(this, ex, getTitle(), JOptionPane.ERROR_MESSAGE);
           return;
       }

       setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
frameField.setText(String.valueOf(curFrame));
       updateUI();
   }
======

Shane, Hugh A. wrote:
I tried this and get the same results. Any other ideas?

-----Original Message-----
From: [email protected] [mailto:hdf-forum-
[email protected]] On Behalf Of Peter Cao
Sent: Friday, December 04, 2009 3:16 PM
To: [email protected]
Subject: Re: [Hdf-forum] Java HDF : unable to select frame in 3D array


Try this.

public int[] getFrame(Dataset dataset, int frameNum) {

        dataset.init();

        // Select the desired frame

        long[] startDims = dataset.getStartDims();

        int[] idx = getSelectedIndex(); // idx[0]=hight, idx[1]=width,
        idx[2]=depth


        // if you want to look through the first dimension, uncomment out the 
follwing line
        //idx[0]=1; idx[1]=2; idx[2] = 0


        startDims[idx[2]] = frameNum;

        // Grab the frame data

        int[] rawdata = (*int*[])dataset.getData();

        return rawdata;

}




Shane, Hugh A. wrote:
An HDF newbie here...

I'm attempting to use the HDF Object Package 1.6.0_12 to read a
previously created HDF5 formatted file that contains, among other
things, a Dataset containing a 3-dimensional array of integers, row x
column x frame. I want to operate on the data one frame at a time but
am unable to select the frame that I want. The Dataset object seems to
always default to frame 0 and won't budge from there. In the code
fragment below, the returned frame is the same regardless of the value
of frameNum. What am I doing wrong?

public int[] getFrame(Dataset dataset, int frameNum) {

        dataset.init();

        // Select the desired frame

        long[] startDims = dataset.getStartDims();

        startDims[0] = frameNum;

        // Grab the frame data

        int[] rawdata = (*int*[])dataset.getData();

        return rawdata;

}

----------------------------------------------------------------------
--
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org


_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to