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

Resets the BoxAccumulator instance to contain just input.

final @NonNull BoxAccumulator

Reset this object to have no bounds.

@NonNull String

Extension functions

final @NonNull BoxAccumulator
AndroidGraphicsConverter.add(
    @NonNull BoxAccumulator receiver,
    @NonNull RectF rect
)

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

Public constructors

BoxAccumulator

Added in 1.0.0-alpha05
public BoxAccumulator()

Constructs an empty BoxAccumulator

BoxAccumulator

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

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

Public methods

add

Added in 1.0.0-alpha05
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 the modified instance to allow chaining function calls.

Returns
@NonNull BoxAccumulator

this

add

Added in 1.0.0-alpha05
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 the modified instance to allow chaining function calls.

Returns
@NonNull BoxAccumulator

this

add

Added in 1.0.0-alpha05
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 the modified instance to allow chaining function calls.

Returns
@NonNull BoxAccumulator

this

add

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

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

Returns the modified instance to allow chaining function calls.

Returns
@NonNull BoxAccumulator

this

add

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

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

Returns the modified instance to allow chaining function calls.

Returns
@NonNull BoxAccumulator

this

add

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

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

Returns the modified instance to allow chaining function calls.

Returns
@NonNull BoxAccumulator

this

add

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

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

Returns the modified instance to allow chaining function calls.

Returns
@NonNull BoxAccumulator

this

equals

public boolean equals(Object other)

getBox

Added in 1.0.0-alpha05
public final Box getBox()

The currently accumulated bounding box, which may be empty

hashCode

public int hashCode()

isAlmostEqual

Added in 1.0.0-alpha05
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-alpha05
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-alpha05
public final @NonNull BoxAccumulator populateFrom(Box input)

Resets the BoxAccumulator instance to contain just input. If input is null, the instance will be reset to empty.

Returns the modified instance to allow chaining function calls.

A BoxAccumulator can be efficiently set to the same values as another BoxAccumulator with populateFrom(other.box).

Returns
@NonNull BoxAccumulator

this

reset

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

Reset this object to have no bounds.

Returns the modified instance to allow chaining function calls.

Returns
@NonNull BoxAccumulator

this

toString

public @NonNull String toString()

Extension functions

AndroidGraphicsConverter.add

public final @NonNull BoxAccumulator AndroidGraphicsConverter.add(
    @NonNull BoxAccumulator receiver,
    @NonNull RectF rect
)

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

This is functionally equivalent to, but more efficient than: add(ImmutableBox.from(rect))

Returns
@NonNull BoxAccumulator

this