Skip to content

Commit

Permalink
Replace PrimitiveBlockUtils.getType(ra) with ra.getType()
Browse files Browse the repository at this point in the history
  • Loading branch information
tpietzsch committed May 7, 2024
1 parent e6d58f2 commit 0b8282d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
13 changes: 0 additions & 13 deletions src/main/java/net/imglib2/blocks/PrimitiveBlocksUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@

import java.util.Arrays;
import java.util.function.Supplier;
import net.imglib2.Interval;
import net.imglib2.Point;
import net.imglib2.RandomAccessible;
import net.imglib2.img.array.ArrayImg;
import net.imglib2.img.array.ArrayImgFactory;
import net.imglib2.img.basictypeaccess.array.ArrayDataAccess;
import net.imglib2.transform.integer.MixedTransform;
import net.imglib2.type.NativeType;
import net.imglib2.type.Type;
import net.imglib2.util.CloseableThreadLocal;

class PrimitiveBlocksUtils
Expand Down Expand Up @@ -86,15 +82,6 @@ static < T extends NativeType< T > > Object extractOobValue( final T type, final
return null;
}

// TODO replace with ra.getType() when that is available in imglib2 core
static < T extends Type< T > > T getType( RandomAccessible< T > ra )
{
final Point p = new Point( ra.numDimensions() );
if ( ra instanceof Interval )
( ( Interval ) ra ).min( p );
return ra.getAt( p ).createVariable();
}

/**
* Computes the inverse of (@code transform}. The {@code MixedTransform
* transform} is a pure axis permutation followed by inversion of some axes,
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/net/imglib2/blocks/ViewAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@
import net.imglib2.transform.integer.MixedTransform;
import net.imglib2.type.NativeType;
import net.imglib2.type.Type;
import net.imglib2.util.Cast;
import net.imglib2.util.Intervals;
import net.imglib2.view.ExtendedRandomAccessibleInterval;
import net.imglib2.view.IntervalView;
import net.imglib2.view.MixedTransformView;

import static net.imglib2.blocks.PrimitiveBlocksUtils.getType;

class ViewAnalyzer
{
/**
Expand Down Expand Up @@ -90,7 +89,7 @@ private ViewAnalyzer( final RandomAccessible< ? > ra )
*/
private < T extends Type< T > > boolean checkViewTypeSupported()
{
final T type = getType( ( RandomAccessible< T > ) ra );
final T type = Cast.unchecked( ra.getType() );
if ( type instanceof NativeType
&& ( ( NativeType ) type ).getEntitiesPerPixel().getRatio() == 1 )
{
Expand Down Expand Up @@ -589,16 +588,16 @@ private boolean splitTransform()

private < T extends NativeType< T >, R extends NativeType< R > > ViewProperties< T, R > getViewProperties()
{
final T viewType = getType( ( RandomAccessible< T > ) ra );
final NativeImg< R, ? > root = ( NativeImg< R, ? > ) nodes.get( nodes.size() - 1 ).view();
final T viewType = Cast.unchecked( ra.getType() );
final NativeImg< R, ? > root = Cast.unchecked( nodes.get( nodes.size() - 1 ).view() );
final R rootType = root.createLinkedType();
return new ViewProperties<>( viewType, root, rootType, oobExtension, transform, permuteInvertTransform, converterSupplier );
}

private < T extends NativeType< T > > FallbackProperties< T > getFallbackProperties()
{
final RandomAccessible< T > view = ( RandomAccessible< T > ) ra;
return new FallbackProperties<>( getType( view ), view );
final RandomAccessible< T > view = Cast.unchecked( ra );
return new FallbackProperties<>( view.getType(), view );
}

public static < T extends NativeType< T >, R extends NativeType< R > > ViewPropertiesOrError< T, R > getViewProperties( RandomAccessible< T > view )
Expand Down

0 comments on commit 0b8282d

Please sign in to comment.