Package net.imglib2.view
Class TransformBuilder<T>
- java.lang.Object
-
- net.imglib2.view.TransformBuilder<T>
-
- Direct Known Subclasses:
IterableTransformBuilder
public class TransformBuilder<T> extends java.lang.ObjectThe "brain" of the Views framework. Simplifies View cascades to provide the most efficient accessor for a specified Interval.
-
-
Field Summary
Fields Modifier and Type Field Description protected BoundingBoxboundingBoxInterval transformed to the currently visited view.protected RandomAccessible<T>sourceProvides the untransformed random access.protected java.util.LinkedList<Transform>transformsList of transforms that have to be applied when wrapping thesourceRandomAccess to obtain a RandomAccess in the target coordinate system.
-
Constructor Summary
Constructors Modifier Constructor Description protectedTransformBuilder(Interval interval, RandomAccessible<T> randomAccessible)Create a new TransformBuilder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RandomAccessible<T>build()Create a sequence of wrapped RandomAccessibles from thetransformslist.static <S> RandomAccessible<S>getEfficientRandomAccessible(Interval interval, RandomAccessible<S> randomAccessible)Get a RandomAccessible which provides RandomAccess to the specifiedintervalofrandomAccessible.static booleanisComponentMapping(Mixed t)static booleanisIdentity(Mixed t)static booleanisSlicing(Mixed t)static booleanisTranslation(Mixed t)protected voidprependTransform(Transform t)Prepend a transform to thetransformslist.protected voidsimplifyTransforms()Simplify thetransformslist.protected voidvisit(RandomAccessible<T> randomAccessible)Visit a RandomAccessible (while traversing the view hierarchy).protected voidvisitExtended(ExtendedRandomAccessibleInterval<T,?> randomAccessible)Visit a ExtendedRandomAccessibleInterval (while traversing the view hierarchy).protected voidvisitTransformed(TransformedRandomAccessible<T> randomAccessible)Visit a TransformedRandomAccessible (while traversing the view hierarchy).protected RandomAccessible<T>wrapGenericTransform(RandomAccessible<T> s, Transform t)protected RandomAccessible<T>wrapMixedTransform(RandomAccessible<T> s, MixedTransform t)protected RandomAccessible<T>wrapSlicingTransform(RandomAccessible<T> s, SlicingTransform t)protected RandomAccessible<T>wrapTranslationTransform(RandomAccessible<T> s, TranslationTransform t)
-
-
-
Field Detail
-
source
protected RandomAccessible<T> source
Provides the untransformed random access.
-
boundingBox
protected BoundingBox boundingBox
Interval transformed to the currently visited view. null means that the interval is infinite.
-
-
Constructor Detail
-
TransformBuilder
protected TransformBuilder(Interval interval, RandomAccessible<T> randomAccessible)
Create a new TransformBuilder. Starting fromrandomAccessible, go down the view hierarchy to the RandomAccessible that will provide the source RandomAccess into the specifiedinterval. While traversing the view hierarchy transforms are collected into thetransformslist. These transforms have to be applied when wrapping the source RandomAccess to obtain a RandomAccess in the coordinate system ofrandomAccessible.- Parameters:
interval- The interval in which access is needed. This is converted to a bounding box which is propagated through the transforms down the view hierarchy.randomAccessible-
-
-
Method Detail
-
getEfficientRandomAccessible
public static <S> RandomAccessible<S> getEfficientRandomAccessible(Interval interval, RandomAccessible<S> randomAccessible)
Get a RandomAccessible which provides RandomAccess to the specifiedintervalofrandomAccessible.Create a new TransformBuilder that traverses the view hierarchy starting from
randomAccessible.build()an efficient RandomAccessible by joining and simplifying the collected transformations.- Parameters:
interval- The interval in which access is needed.randomAccessible-
-
prependTransform
protected void prependTransform(Transform t)
Prepend a transform to thetransformslist. Also apply the transform toboundingBox, which will be used to specify the interval for the RandomAccess on the final source (at the end of the view chain). This is called while traversing the view hierarchy.- Parameters:
t- the transform to add.
-
visit
protected void visit(RandomAccessible<T> randomAccessible)
Visit a RandomAccessible (while traversing the view hierarchy). TherandomAccessibleis handled byvisitTransformed(TransformedRandomAccessible)orvisitExtended(ExtendedRandomAccessibleInterval)when it has the appropriate type. Otherwise, the traversal stops andrandomAccessibleis set as thesource.- Parameters:
randomAccessible-
-
visitTransformed
protected void visitTransformed(TransformedRandomAccessible<T> randomAccessible)
Visit a TransformedRandomAccessible (while traversing the view hierarchy). Append the view's transform to the list andvisit(RandomAccessible)the view's source.- Parameters:
randomAccessible-
-
visitExtended
protected void visitExtended(ExtendedRandomAccessibleInterval<T,?> randomAccessible)
Visit a ExtendedRandomAccessibleInterval (while traversing the view hierarchy). If the no out-of-bounds extension is needed for the current bounding box,visit(RandomAccessible)the view's source. Otherwise, the traversal stops andrandomAccessibleis set as thesource.- Parameters:
randomAccessible-
-
isIdentity
public static boolean isIdentity(Mixed t)
-
isTranslation
public static boolean isTranslation(Mixed t)
-
isComponentMapping
public static boolean isComponentMapping(Mixed t)
-
isSlicing
public static boolean isSlicing(Mixed t)
-
simplifyTransforms
protected void simplifyTransforms()
Simplify thetransformslist. First, concatenate neighboring transforms if possible. Then, for everyMixedtransform:- remove it if it is the identity transforms.
- replace it by a
TranslationTransformif it is a pure translation. - replace it by a
SlicingTransformif it is a pure slicing.
-
build
protected RandomAccessible<T> build()
Create a sequence of wrapped RandomAccessibles from thetransformslist.- Returns:
- RandomAccessible on the interval specified in the constructor.
-
wrapGenericTransform
protected RandomAccessible<T> wrapGenericTransform(RandomAccessible<T> s, Transform t)
-
wrapMixedTransform
protected RandomAccessible<T> wrapMixedTransform(RandomAccessible<T> s, MixedTransform t)
-
wrapTranslationTransform
protected RandomAccessible<T> wrapTranslationTransform(RandomAccessible<T> s, TranslationTransform t)
-
wrapSlicingTransform
protected RandomAccessible<T> wrapSlicingTransform(RandomAccessible<T> s, SlicingTransform t)
-
-