Class KDTreePositions
java.lang.Object
net.imglib2.kdtree.KDTreePositions
- Direct Known Subclasses:
KDTreePositions.Flat, KDTreePositions.Nested
Stores 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 nested double[][]
(which is created if class is KDTreePositions.Flat). asFlatArray()
returns flat double[] if class is KDTreePositions.Flat, otherwise null.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classstatic enumWithNESTEDlayout, positions are stored as a nesteddouble[][]array wherepositions[d][i]is dimensiondof thei-th point. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate RealInterval(package private) final int(package private) final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract double[]Get positions of points in the tree as a flatdouble[]array wherepositions[d + i*n]is dimensiondof thei-th point.abstract double[][]Get positions of points in the tree as a nesteddouble[][]array wherepositions[d][i]is dimensiondof thei-th point.(package private) abstract RealIntervalstatic 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.intint
-
Field Details
-
numDimensions
final int numDimensions -
numPoints
final int numPoints -
boundingBox
-
-
Constructor Details
-
KDTreePositions
KDTreePositions(int numDimensions, int numPoints)
-
-
Method Details
-
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
-
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
CreateKDTreePositionswith NESTEDlayout(). -
createFlat
CreateKDTreePositionswith FLATlayout().
-