Package sc.fiji.snt.util
Class BoundingBox
java.lang.Object
sc.fiji.snt.util.BoundingBox
- All Implemented Interfaces:
Cloneable
A BoundingBox contains information (including spatial calibration) of a
tracing canvas bounding box, i.e., the minimum bounding cuboid containing all
nodes (
SNTPoints) of a reconstructed structure.- Author:
- Tiago Ferreira
-
Field Summary
FieldsModifier and TypeFieldDescriptionUsed to store information about this bounding box.protected PointInImageThe bounding box origin (SE, lower corner)protected PointInImageThe origin opposite (NW, upper corner)protected StringdoubleThe 'voxel width' of the bounding boxdoubleThe 'voxel height' of the bounding boxdoubleThe 'voxel depth' of the bounding box -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an 'empty' BoundingBox using default values, with the box origin defined as a point withDouble.NaNcoordinates andDouble.NaNdimensionsBoundingBox(Collection<? extends SNTPoint> points) Computes a bounding box from a point cloud. -
Method Summary
Modifier and TypeMethodDescriptionvoidComputes the bounding box of the specified point cloud and appends it to this bounding box, resizing it as needed.clone()Creates a copy of this BoundingBox.voidcombine(BoundingBox other) Combines this bounding box with another one.voidComputes a new positioning so that this box encloses the specified point cloud.booleancontains(BoundingBox boundingBox) Checks whether the specified BoundingBox is enclosed by this one .booleanbooleancontains2D(SNTPoint point) doubledepth()booleanij.measure.CalibrationCreates a Calibration object using information from this BoundingBoxdoubleGets the box diagonaldouble[]Gets this BoundingBox dimensions in real world units.double[]getDimensions(boolean scaled) Gets this BoundingBox dimensions.getUnit()Gets the length unit of voxel spacingbooleaninthashCode()doubleheight()voidinferSpacing(Collection<SWCPoint> points) Infers the voxel spacing of this box from the inter-node distances of a Collection ofSWCPoints.intersection(BoundingBox other) Retrieves the intersection cuboid between this bounding with another bounding box.booleanisScaled()Checks whether this BoundingBox is spatially calibrated, i.e., if voxel spacing has been specifiedorigin()Retrieves the origin of this box.Retrieves the origin opposite of this box.protected voidreset()static StringsanitizedUnit(String unit) scale(double[] scale) voidsetDimensions(long uncalibratedWidth, long uncalibratedHeight, long uncalibratedDepth) Sets the dimensions of this bounding box using uncalibrated (pixel) lengths.voidsetOrigin(PointInImage origin) Sets the origin for this box, i.e., its (xMin, yMin, zMin) vertex.voidsetOriginOpposite(PointInImage originOpposite) Sets the origin opposite for this box, i.e., its (xMax, yMax, zMax) vertex.voidsetSpacing(double xSpacing, double ySpacing, double zSpacing, String spacingUnit) Sets the voxel spacing.voidSets the default length unit for voxel spacing (typically um, for SWC reconstructions)shift(double[] offset) org.jzy3d.maths.BoundingBox3dtoString()Retrieves the origin of this box in unscaled ("pixel" units)Retrieves the origin opposite of this box in unscaled ("pixel" units)doublewidth()
-
Field Details
-
xSpacing
public double xSpacingThe 'voxel width' of the bounding box -
ySpacing
public double ySpacingThe 'voxel height' of the bounding box -
zSpacing
public double zSpacingThe 'voxel depth' of the bounding box -
info
Used to store information about this bounding box. Default is null -
spacingUnit
-
origin
The bounding box origin (SE, lower corner) -
originOpposite
The origin opposite (NW, upper corner)
-
-
Constructor Details
-
BoundingBox
public BoundingBox()Constructs an 'empty' BoundingBox using default values, with the box origin defined as a point withDouble.NaNcoordinates andDouble.NaNdimensions -
BoundingBox
Computes a bounding box from a point cloud.- Parameters:
points- the point cloud
-
-
Method Details
-
reset
protected void reset() -
setSpacing
Sets the voxel spacing.- Parameters:
xSpacing- the 'voxel width' of the bounding boxySpacing- the 'voxel height' of the bounding boxzSpacing- the 'voxel depth' of the bounding boxspacingUnit- the length unit
-
compute
Computes a new positioning so that this box encloses the specified point cloud.- Parameters:
iterator- the iterator of the points Collection
-
append
Computes the bounding box of the specified point cloud and appends it to this bounding box, resizing it as needed.- Parameters:
iterator- the iterator of the points Collection
-
getCentroid
-
inferSpacing
Infers the voxel spacing of this box from the inter-node distances of a Collection ofSWCPoints.- Parameters:
points- the point collection
-
isScaled
public boolean isScaled()Checks whether this BoundingBox is spatially calibrated, i.e., if voxel spacing has been specified- Returns:
- true, if voxel spacing has been specified
-
setUnit
Sets the default length unit for voxel spacing (typically um, for SWC reconstructions)- Parameters:
unit- the new unit
-
sanitizedUnit
-
getUnit
Gets the length unit of voxel spacing- Returns:
- the unit
-
getCalibration
public ij.measure.Calibration getCalibration()Creates a Calibration object using information from this BoundingBox- Returns:
- the Calibration object
-
getDimensions
public double[] getDimensions()Gets this BoundingBox dimensions in real world units.- Returns:
- the BoundingBox dimensions {width, height, depth}.
-
getDimensions
public double[] getDimensions(boolean scaled) Gets this BoundingBox dimensions.- Parameters:
scaled- If true, dimensions are retrieved in real world units, otherwise in ("pixel") units- Returns:
- the BoundingBox dimensions {width, height, depth}.
-
getDiagonal
public double getDiagonal()Gets the box diagonal- Returns:
- the diagonal of BoundingBox
-
contains
Checks whether the specified BoundingBox is enclosed by this one .- Parameters:
boundingBox- the bounding box to be tested- Returns:
- true, if successful
-
contains2D
-
contains
-
combine
Combines this bounding box with another one. It is assumed both boxes share the same voxel spacing/Calibration.- Parameters:
other- the bounding box to be combined.
-
intersection
Retrieves the intersection cuboid between this bounding with another bounding box. It is assumed both boxes share the same voxel spacing/Calibration.- Parameters:
other- the second bounding box.- Returns:
- The intersection cuboid.
-
origin
Retrieves the origin of this box.- Returns:
- the origin
-
originOpposite
Retrieves the origin opposite of this box.- Returns:
- the origin
-
unscaledOrigin
Retrieves the origin of this box in unscaled ("pixel" units)- Returns:
- the unscaled origin
-
unscaledOriginOpposite
Retrieves the origin opposite of this box in unscaled ("pixel" units)- Returns:
- the unscaled origin opposite
-
width
public double width() -
height
public double height() -
depth
public double depth() -
setDimensions
public void setDimensions(long uncalibratedWidth, long uncalibratedHeight, long uncalibratedDepth) throws IllegalArgumentException Sets the dimensions of this bounding box using uncalibrated (pixel) lengths.- Parameters:
uncalibratedWidth- the uncalibrated widthuncalibratedHeight- the uncalibrated heightuncalibratedDepth- the uncalibrated depth- Throws:
IllegalArgumentException- If origin has not been set orcompute(Iterator)has not been called
-
setOrigin
Sets the origin for this box, i.e., its (xMin, yMin, zMin) vertex.- Parameters:
origin- the new origin
-
setOriginOpposite
Sets the origin opposite for this box, i.e., its (xMax, yMax, zMax) vertex.- Parameters:
originOpposite- the new origin opposite.
-
hasDimensions
public boolean hasDimensions() -
toBoundingBox3d
public org.jzy3d.maths.BoundingBox3d toBoundingBox3d() -
scale
-
shift
-
hashCode
public int hashCode() -
equals
-
clone
Creates a copy of this BoundingBox. -
toString
-