Package net.imglib2.kdtree
Class KDTreePositions
- java.lang.Object
-
- net.imglib2.kdtree.KDTreePositions
-
- Direct Known Subclasses:
KDTreePositions.Flat,KDTreePositions.Nested
public abstract class KDTreePositions extends java.lang.ObjectStores the positions of the nodes in a KDTree and provides access to them.Currently, there are two implementations:
KDTreePositions.Nestedstores the positions as adouble[][]wherepositions[d][i]is dimensiondof thei-th point. This allows for a total of2^31-8nodes but doesn't keep the positions contiguous in memory.KDTreePositions.Flatstores the positions as adouble[]wherepositions[d + i*n]is dimensiondof thei-th point, withnthe number of dimensions. This means that the positions are contiguous in memory but the number of nodes is limited to(2^31-8)/n.
asNestedArray()returns positions in nesteddouble[][](which is created if class isKDTreePositions.Flat).asFlatArray()returns flatdouble[]if class isKDTreePositions.Flat, otherwisenull.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classKDTreePositions.Flatprivate static classKDTreePositions.Nestedstatic classKDTreePositions.PositionsLayoutWithNESTEDlayout, positions are stored as a nesteddouble[][]array wherepositions[d][i]is dimensiondof thei-th point.
-
Field Summary
Fields Modifier and Type Field Description private RealIntervalboundingBox(package private) intnumDimensions(package private) intnumPoints
-
Constructor Summary
Constructors Constructor Description KDTreePositions(int numDimensions, int numPoints)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract double[]asFlatArray()Get positions of points in the tree as a flatdouble[]array wherepositions[d + i*n]is dimensiondof thei-th point.abstract double[][]asNestedArray()Get positions of points in the tree as a nesteddouble[][]array wherepositions[d][i]is dimensiondof thei-th point.(package private) abstract RealIntervalcreateBoundingBox()static KDTreePositionscreateFlat(double[] positions, int numDimensions)CreateKDTreePositionswith FLATlayout().static KDTreePositionscreateNested(double[][] positions)CreateKDTreePositionswith NESTEDlayout().abstract doubleget(int i, int d)Get the coordinates of the nodeiin dimensiond.abstract KDTreePositions.PositionsLayoutlayout()Get the internal layout of positions.intnumDimensions()intnumPoints()
-
-
-
Field Detail
-
numDimensions
final int numDimensions
-
numPoints
final int numPoints
-
boundingBox
private volatile RealInterval boundingBox
-
-
Method Detail
-
get
public abstract double get(int i, int d)Get the coordinates of the nodeiin dimensiond.- Returns:
- the coordinate
-
asFlatArray
public abstract double[] asFlatArray()
Get positions of points in the tree as a flatdouble[]array wherepositions[d + i*n]is dimensiondof thei-th point.For serialisation and usage by the tree.
Internal storage may be a
NESTEDdouble[][]array. In this case,flatPositions()returnsnull.
-
asNestedArray
public abstract double[][] asNestedArray()
Get positions of points in the tree as a nesteddouble[][]array wherepositions[d][i]is dimensiondof thei-th point.For serialisation and usage by the tree.
Internal storage may be flattened into single
double[]array. In this case, the nesteddouble[][]array is created here.
-
createBoundingBox
abstract RealInterval createBoundingBox()
-
layout
public abstract KDTreePositions.PositionsLayout layout()
Get the internal layout of positions.Positions are stored in either
FLATorNESTEDlayout. WithNESTEDlayout, positions are stored as a nesteddouble[][]array wherepositions[d][i]is dimensiondof thei-th point. WithFLATlayout, positions are stored as a flatdouble[]array, wherepositions[d + i*n]is dimensiondof thei-th point, withnthe number of dimensions.
-
numDimensions
public int numDimensions()
- Returns:
- dimensionality of points in the tree
-
numPoints
public int numPoints()
- Returns:
- number of points in the tree
-
createNested
public static KDTreePositions createNested(double[][] positions)
CreateKDTreePositionswith NESTEDlayout().
-
createFlat
public static KDTreePositions createFlat(double[] positions, int numDimensions)
CreateKDTreePositionswith FLATlayout().
-
-