dap4/d4core/src/main/java/dap4/core/util/DapUtil.java
static public List<Slice>
    indexToSlices(Index indices)
            throws DapException
    {
        // short circuit the scalar case
        if(indices.getRank() == 0)
            return Slice.SCALARSLICES;
        // offset = d3*(d2*(d1*(x1))+x2)+x3
        List<Slice> slices = new ArrayList<>(indices.rank);
        for(int i = 0; i < indices.rank; i++) {
            long isize = indices.indices[i];
            slices.add(new Slice(isize, isize + 1, 1, indices.dimsizes[i]));
        }
        return slices;
    }
static public List<Slice>
    indexToSlices(Index indices)
            throws DapException
    {
        // short circuit the scalar case
        if(indices.getRank() == 0)
            return Slice.SCALARSLICES;
        // offset = d3*(d2*(d1*(x1))+x2)+x3
        List<Slice> slices = new ArrayList<>(indices.rank);
        for(int i = 0; i < indices.rank; i++) {
            long isize = indices.indices[i];
            slices.add(new Slice(isize, isize + 1, 1, indices.dimsizes[i]));
        }
        return slices;
    }
static public List < Slice > indexToSlices ( Index indices ) throws DapException { // short circuit the scalar case if ( indices . getRank ( ) == 0 ) return Slice . SCALARSLICES ; // offset = d3*(d2*(d1*(x1))+x2)+x3 List < Slice > slices = new ArrayList <> ( indices . rank ) ; for ( int i = 0 ; i < indices . rank ; i ++ ) { long isize = indices . indices [ i ] ; slices . add ( new Slice ( isize , isize + 1 , 1 , indices . dimsizes [ i ] ) ) ; } return slices ; }
Given an offset (single index) and a set of dimensions
compute the set of dimension indices that correspond
to the offset.
Given an offset ( single index ) and a set of dimensions compute the set of dimension indices that correspond to the offset .