Class PredicateImplementation<T>
- Type Parameters:
T
- buffer-type
- All Implemented Interfaces:
VoxelsPredicate
VoxelsPredicate
for a particular Voxels
.- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionPredicateImplementation
(Voxels<T> voxels, Predicate<T> predicate) Creates a newPredicateImplementation
instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Does at least one value satisfy the predicate - across all voxels?int
count()
Counts the number of values satisfying the predicate - across all voxels.int
countForObject
(ObjectMask object) Counts the number of values satisfying the predicate - but restricted to voxels corresponding to on in an object-mask.deriveObject
(BoundingBox box) Creates anObjectMask
for all the voxels inside the bounding-box satisfying the predicate.Creates anObjectMask
for all the voxels satisfying the predicate, minimally fitting the bounding-box to the on voxels only.boolean
higherCountExistsThan
(int threshold) Whether the count is greater than a particular threshold.boolean
lowerCountExistsThan
(int threshold) Whether the count is less than a particular threshold.
-
Constructor Details
-
PredicateImplementation
Creates a newPredicateImplementation
instance.- Parameters:
voxels
- The voxels on which the predicate is based.predicate
- Checks if the current value of a buffer matches a predicate
-
-
Method Details
-
anyExists
public boolean anyExists()Description copied from interface:VoxelsPredicate
Does at least one value satisfy the predicate - across all voxels?The computational cost of the operation is
O(n)
in the number of voxels in the worst-case. Typically, it exits earlier.- Specified by:
anyExists
in interfaceVoxelsPredicate
- Returns:
- true iff at least one value exists.
-
count
public int count()Description copied from interface:VoxelsPredicate
Counts the number of values satisfying the predicate - across all voxels.The computational cost of the operation is
O(n)
in the number of voxels.- Specified by:
count
in interfaceVoxelsPredicate
- Returns:
- the total count.
-
countForObject
Description copied from interface:VoxelsPredicate
Counts the number of values satisfying the predicate - but restricted to voxels corresponding to on in an object-mask.The computational cost of the operation is
O(n)
in the number of voxels.- Specified by:
countForObject
in interfaceVoxelsPredicate
- Parameters:
object
- the object-mask.- Returns:
- the total count according to the above constraint.
-
higherCountExistsThan
public boolean higherCountExistsThan(int threshold) Description copied from interface:VoxelsPredicate
Whether the count is greater than a particular threshold.The computational cost of the operation is
O(n)
in the number of voxels in the worst-case. Typically, it exits earlier.- Specified by:
higherCountExistsThan
in interfaceVoxelsPredicate
- Parameters:
threshold
- the threshold.- Returns:
- true as soon as more voxels are counted than the threshold, false if it never occurs.
-
lowerCountExistsThan
public boolean lowerCountExistsThan(int threshold) Description copied from interface:VoxelsPredicate
Whether the count is less than a particular threshold.The computational cost of the operation is
O(n)
in the number of voxels in the worst-case. Typically, it exits earlier.- Specified by:
lowerCountExistsThan
in interfaceVoxelsPredicate
- Parameters:
threshold
- the threshold.- Returns:
- false as soon as as many voxels as threshold, true if it never occurs.
-
deriveObject
Description copied from interface:VoxelsPredicate
Creates anObjectMask
for all the voxels inside the bounding-box satisfying the predicate.Any voxels satisfying the predicate are set to on.
All other voxels are set to off.
Unlike
VoxelsPredicate.deriveObjectTight()
, this operates only within a certain bounding-box, and always uses an identical bounding-box for the createdObjectMask
asbox
.The computational cost of the operation is
O(n)
in the number of voxels inbox
only.- Specified by:
deriveObject
in interfaceVoxelsPredicate
- Parameters:
box
- bounding-box.- Returns:
- an object-mask referring to the bounding-box, with the same corner-position and size
as
box
.
-
deriveObjectTight
Description copied from interface:VoxelsPredicate
Creates anObjectMask
for all the voxels satisfying the predicate, minimally fitting the bounding-box to the on voxels only.Any voxels satisfying the predicate are set to on.
All other voxels are set to off.
Unlike
VoxelsPredicate.deriveObject(BoundingBox)
, this operates all the voxels, and will typically use a much smaller bounding-box (fewer voxels) to describe the on voxels.The computational cost of the operation is
O(n)
in the number of voxels inbox
only.- Specified by:
deriveObjectTight
in interfaceVoxelsPredicate
- Returns:
- an object-mask indicating all voxels that match the predicate, and with as minimal a
bounding-box as possible to contain these. If no voxels match, then
Optional.empty()
.
-