BoxAccumulator


public final class BoxAccumulator


A helper class for accumulating the minimum bounding boxes of zero or more geometry objects. In colloquial terms, this can be used to find the smallest Box that contains a set of objects.

Summary

Public constructors

Constructs an empty BoxAccumulator

Constructs a BoxAccumulator, populating the to accumulated bounding box from box.

Public methods

final @NonNull BoxAccumulator
add(Box box)

Expands the accumulated bounding box (if necessary) such that it also contains box.

final @NonNull BoxAccumulator

Expands the accumulated bounding box (if necessary) such that it also contains mesh.

final @NonNull BoxAccumulator

Expands the accumulated bounding box (if necessary) such that it also contains other.

final @NonNull BoxAccumulator
add(@NonNull Parallelogram parallelogram)

Expands the accumulated bounding box (if necessary) such that it also contains parallelogram.

final @NonNull BoxAccumulator
add(@NonNull Vec point)

Expands the accumulated bounding box (if necessary) such that it also contains point.

final @NonNull BoxAccumulator
add(@NonNull Segment segment)

Expands the accumulated bounding box (if necessary) such that it also contains segment.

final @NonNull BoxAccumulator
add(@NonNull Triangle triangle)

Expands the accumulated bounding box (if necessary) such that it also contains triangle.

boolean
equals(Object other)
final Box

The currently accumulated bounding box, which may be empty

int
final boolean
isAlmostEqual(
    @NonNull BoxAccumulator other,
    @FloatRange(from = 0.0) float tolerance
)

Compares this BoxAccumulator with other, and returns true if either: Both this and other are empty Neither this and other are empty, and their boxes are almost equal per Box.isAlmostEqual

final boolean

Returns true if this BoxAccumulator is not empty; this is equivalent to checking if the box property is null.

final @NonNull BoxAccumulator

Populates this BoxAccumulator with the same values contained in input.

final @NonNull BoxAccumulator

Reset this object to have no bounds.

@NonNull String

Public constructors

BoxAccumulator

Added in 1.0.0-alpha01
public BoxAccumulator()

Constructs an empty BoxAccumulator

BoxAccumulator

Added in 1.0.0-alpha01
public BoxAccumulator(@NonNull Box box)

Constructs a BoxAccumulator, populating the to accumulated bounding box from box.

Public methods

add

Added in 1.0.0-alpha01
public final @NonNull BoxAccumulator add(Box box)

Expands the accumulated bounding box (if necessary) such that it also contains box. If box is null, this is a no-op.

Returns
@NonNull BoxAccumulator

this

add

Added in 1.0.0-alpha01
public final @NonNull BoxAccumulator add(@NonNull PartitionedMesh mesh)

Expands the accumulated bounding box (if necessary) such that it also contains mesh. If mesh is empty, this is a no-op.

Returns
@NonNull BoxAccumulator

this

add

Added in 1.0.0-alpha01
public final @NonNull BoxAccumulator add(BoxAccumulator other)

Expands the accumulated bounding box (if necessary) such that it also contains other. If other is null, this is a no-op.

Returns
@NonNull BoxAccumulator

this

add

Added in 1.0.0-alpha01
public final @NonNull BoxAccumulator add(@NonNull Parallelogram parallelogram)

Expands the accumulated bounding box (if necessary) such that it also contains parallelogram.

Returns
@NonNull BoxAccumulator

this

add

Added in 1.0.0-alpha01
public final @NonNull BoxAccumulator add(@NonNull Vec point)

Expands the accumulated bounding box (if necessary) such that it also contains point.

Returns
@NonNull BoxAccumulator

this

add

Added in 1.0.0-alpha01
public final @NonNull BoxAccumulator add(@NonNull Segment segment)

Expands the accumulated bounding box (if necessary) such that it also contains segment.

Returns
@NonNull BoxAccumulator

this

add

Added in 1.0.0-alpha01
public final @NonNull BoxAccumulator add(@NonNull Triangle triangle)

Expands the accumulated bounding box (if necessary) such that it also contains triangle.

Returns
@NonNull BoxAccumulator

this

equals

public boolean equals(Object other)

getBox

Added in 1.0.0-alpha01
public final Box getBox()

The currently accumulated bounding box, which may be empty

hashCode

public int hashCode()

isAlmostEqual

Added in 1.0.0-alpha01
public final boolean isAlmostEqual(
    @NonNull BoxAccumulator other,
    @FloatRange(from = 0.0) float tolerance
)

Compares this BoxAccumulator with other, and returns true if either: Both this and other are empty Neither this and other are empty, and their boxes are almost equal per Box.isAlmostEqual

isEmpty

Added in 1.0.0-alpha01
public final boolean isEmpty()

Returns true if this BoxAccumulator is not empty; this is equivalent to checking if the box property is null.

Note that a zero-area Box is not considered empty, as a Box contains its boundary; so isEmpty will return false even if you have added only a single point to the BoxAccumulator.

populateFrom

Added in 1.0.0-alpha01
public final @NonNull BoxAccumulator populateFrom(@NonNull BoxAccumulator input)

Populates this BoxAccumulator with the same values contained in input.

reset

Added in 1.0.0-alpha01
public final @NonNull BoxAccumulator reset()

Reset this object to have no bounds. Returns the same instance to chain function calls.

toString

public @NonNull String toString()