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

android

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

android

Public functions

BoxAccumulator
add(box: Box?)

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

android
BoxAccumulator

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

android
BoxAccumulator

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

android
BoxAccumulator
add(parallelogram: Parallelogram)

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

android
BoxAccumulator
add(point: Vec)

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

android
BoxAccumulator
add(segment: Segment)

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

android
BoxAccumulator
add(triangle: Triangle)

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

android
open operator Boolean
equals(other: Any?)
android
open Int
android
Boolean
isAlmostEqual(
    other: BoxAccumulator,
    tolerance: @FloatRange(from = 0.0) Float
)

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

android
Boolean

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

android
BoxAccumulator
populateFrom(input: Box?)

Resets the BoxAccumulator instance to contain just input.

android
BoxAccumulator

Reset this object to have no bounds.

android
open String
android

Public properties

Box?

The currently accumulated bounding box, which may be empty

android

Extension functions

BoxAccumulator

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

android
BoxAccumulator

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

android
BoxAccumulator

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

android

Public constructors

BoxAccumulator

BoxAccumulator()

Constructs an empty BoxAccumulator

BoxAccumulator

BoxAccumulator(box: Box)

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

Public functions

add

fun add(box: Box?): BoxAccumulator

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
BoxAccumulator

this

add

fun add(mesh: PartitionedMesh): BoxAccumulator

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
BoxAccumulator

this

add

fun add(other: BoxAccumulator?): BoxAccumulator

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
BoxAccumulator

this

add

fun add(parallelogram: Parallelogram): BoxAccumulator

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

Returns the modified instance to allow chaining function calls.

Returns
BoxAccumulator

this

add

fun add(point: Vec): BoxAccumulator

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

Returns the modified instance to allow chaining function calls.

Returns
BoxAccumulator

this

add

fun add(segment: Segment): BoxAccumulator

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

Returns the modified instance to allow chaining function calls.

Returns
BoxAccumulator

this

add

fun add(triangle: Triangle): BoxAccumulator

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

Returns the modified instance to allow chaining function calls.

Returns
BoxAccumulator

this

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

isAlmostEqual

fun isAlmostEqual(
    other: BoxAccumulator,
    tolerance: @FloatRange(from = 0.0) Float
): Boolean

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

fun isEmpty(): Boolean

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

fun populateFrom(input: Box?): BoxAccumulator

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
BoxAccumulator

this

reset

fun reset(): BoxAccumulator

Reset this object to have no bounds.

Returns the modified instance to allow chaining function calls.

Returns
BoxAccumulator

this

toString

open fun toString(): String

Public properties

box

val boxBox?

The currently accumulated bounding box, which may be empty

Extension functions

add

fun BoxAccumulator.add(rect: RectF): BoxAccumulator

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
BoxAccumulator

this

fun BoxAccumulator.add(rect: MutableRect): BoxAccumulator

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

Returns the modified instance to allow chaining calls.

Returns
BoxAccumulator

this

fun BoxAccumulator.add(rect: Rect): BoxAccumulator

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

Returns the modified instance to allow chaining calls.

Returns
BoxAccumulator

this