@Override public Fraction getEntitiesPerPixel() { return t.getEntitiesPerPixel(); }
@Override public void fwd() { if ( ++index > lastIndex ) { index = 0; ++sliceIndex; type.updateContainer( this ); } type.updateIndex( index ); }
@Override public ImagePlusImg< T, ? > create( final long[] dim, final T type ) { return ( ImagePlusImg< T, ? > ) type.createSuitableNativeImg( this, dim ); }
protected PlanarRandomAccess( final PlanarRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); sliceSteps = randomAccess.sliceSteps; width = randomAccess.width; sliceIndex = randomAccess.sliceIndex; for ( int d = 0; d < n; ++d ) position[ d ] = randomAccess.position[ d ]; type = randomAccess.type.duplicateTypeOnSameNativeImg(); type.updateContainer( this ); type.updateIndex( randomAccess.type.getIndex() ); }
public static < A extends VolatileArrayDataAccess< A > > CreateInvalidVolatileCell< A > get( final CellGrid grid, final Fraction entitiesPerPixel, final PrimitiveType primitiveType, final boolean dirty ) throws IllegalArgumentException { if ( primitiveType == PrimitiveType.UNDEFINED ) throw new IllegalArgumentException( "Cannot instantiate " + CreateInvalidVolatileCell.class.getSimpleName() + " for unrecognized primitive type" ); return new CreateInvalidVolatileCell< A >( grid, entitiesPerPixel, EmptyArrayCreator.get( primitiveType, dirty ) ); } }
protected CellCursor( final CellCursor< T, C > cursor ) { super( cursor.numDimensions() ); this.type = cursor.type.duplicateTypeOnSameNativeImg(); this.cursorOnCells = cursor.cursorOnCells.copyCursor(); isNotLastCell = cursor.isNotLastCell; lastIndexInCell = cursor.lastIndexInCell; index = cursor.index; type.updateContainer( this ); type.updateIndex( index ); }
@Deprecated @Override public CellImg< T, ? > create( final long[] dimensions, final T type ) { cache( type ); @SuppressWarnings( { "unchecked", "rawtypes" } ) final CellImg< T, ? > img = create( dimensions, type, ( NativeTypeFactory ) type.getNativeTypeFactory() ); return img; } }
@Override public void setPosition( final long[] position ) { type.updateIndex( ( int ) position[ 0 ] ); this.position[ 0 ] = ( int ) position[ 0 ]; } }
@Override public Cell< CA > get( final Long key ) throws Exception { final long index = key; final int n = grid.numDimensions(); final long[] cellMin = new long[ n ]; final int[] cellDims = new int[ n ]; final long[] cellMax = new long[ n ]; grid.getCellDimensions( index, cellMin, cellDims ); final long numEntities = entitiesPerPixel.mulCeil( Intervals.numElements( cellDims ) ); final A data = creator.createArray( ( int ) numEntities ); final T t = createType( data ); t.updateIndex( 0 ); for ( int d = 0; d < n; ++d ) cellMax[ d ] = cellMin[ d ] + cellDims[ d ] - 1; for ( final T s : Views.interval( source, cellMin, cellMax ) ) { t.set( s ); t.incIndex(); } return new Cell<>( cellDims, cellMin, rewrap.apply( data ) ); }
protected void copyDataTo( final AbstractCellImg< T, ?, ?, ? > copy ) { final CellCursor< T, C > source = this.cursor(); final CellCursor< T, ? > target = copy.cursor(); while ( source.hasNext() ) target.next().set( source.next() ); } }
/** * {@inheritDoc} */ @Override public final void fwd() { type.incIndex(); }
public NtreeCursor( final NtreeImg< T, ? > img ) { super( img ); this.img = img; this.type = img.createLinkedType(); for ( int d = 0; d < n; d++ ) position[ d ] = 0; position[ 0 ]--; type.updateContainer( this ); }
@Override public T createLinkedType() { try { return linkedType.duplicateTypeOnSameNativeImg(); } catch ( final NullPointerException e ) { return null; } }
public static < A extends ArrayDataAccess< A > > EmptyCellCacheLoader< A > get( final CellGrid grid, final Fraction entitiesPerPixel, final PrimitiveType primitiveType, final Set< AccessFlags > flags ) { final A creator = ArrayDataAccessFactory.get( primitiveType, flags ); return creator == null ? null : new EmptyCellCacheLoader<>( grid, entitiesPerPixel, creator ); } }
protected CellCursor( final CellCursor< T, C > cursor ) { super( cursor.numDimensions() ); this.type = cursor.type.duplicateTypeOnSameNativeImg(); this.cursorOnCells = cursor.cursorOnCells.copyCursor(); isNotLastCell = cursor.isNotLastCell; lastIndexInCell = cursor.lastIndexInCell; index = cursor.index; type.updateContainer( this ); type.updateIndex( index ); }
@Deprecated @Override public ArrayImg< T, ? > create( final long[] dim, final T type ) { cache( type ); @SuppressWarnings( { "unchecked", "rawtypes" } ) final ArrayImg< T, ? > img = create( dim, type, ( NativeTypeFactory ) type.getNativeTypeFactory() ); return img; } }
@Override public void updateIndex( final int i ) { t.updateIndex( i ); }
protected PlanarRandomAccess( final PlanarRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); sliceSteps = randomAccess.sliceSteps; width = randomAccess.width; sliceIndex = randomAccess.sliceIndex; for ( int d = 0; d < n; ++d ) position[ d ] = randomAccess.position[ d ]; type = randomAccess.type.duplicateTypeOnSameNativeImg(); type.updateContainer( this ); type.updateIndex( randomAccess.type.getIndex() ); }
protected void copyDataTo( final AbstractCellImg< T, ?, ?, ? > copy ) { final CellCursor< T, C > source = this.cursor(); final CellCursor< T, ? > target = copy.cursor(); while ( source.hasNext() ) target.next().set( source.next() ); } }