T
- the type of elements stored in the structure, each of which must map to a ObjectMask
.public class IntersectingObjects<T> extends Object
It can store elements of any type, so long each element maps deterministically to an ObjectMask
.
Internally, a r-tree data structure is used of object-masks (indexed via a derived bounding-box) for efficient queries. However, search methods check not only bounding-box overlap, but also that objects have at least one overlapping voxel.
All objects that are passed to the constructor are initially included. An existing object may be removed, but no additional object may be added.
Note that when an object is removed, it remains in the objects
associated with the
r-tree, but is removed from the index.
for a related structure operating only on bounding-boxes
Constructor and Description |
---|
IntersectingObjects(Collection<T> elements,
java.util.function.Function<T,ObjectMask> extractObject)
Creates an r-tree for particular objects, as extracted from elements.
|
Modifier and Type | Method and Description |
---|---|
GraphWithoutPayload<T> |
asGraph()
Constructs a graph where each vertex is an element and an edge exists between any elements
that intersect.
|
Set<T> |
contains(Point3i point)
All elements that contain a particular point.
|
static IntersectingObjects<ObjectMask> |
create(ObjectCollection objects)
Creates from an
ObjectCollection . |
Set<T> |
intersectsWith(BoundingBox box)
All elements that intersect with a particular bounding box.
|
Set<T> |
intersectsWith(ObjectMask object)
All elements that intersect with a particular object.
|
java.util.stream.Stream<T> |
intersectsWithStream(ObjectMask object)
|
void |
remove(T element)
Removes an object-mask, so that it is no longer considered in queries.
|
int |
size()
Number of items in the r-tree.
|
Set<Set<T>> |
spatiallySeparate()
Splits the collection of objects into spatially separate clusters.
|
public IntersectingObjects(Collection<T> elements, java.util.function.Function<T,ObjectMask> extractObject)
elements
- the elements, each corresponding to a unique object.extractObject
- a function that extracts a unique ObjectMask
from an element.public static IntersectingObjects<ObjectMask> create(ObjectCollection objects)
ObjectCollection
.objects
- the objects whose intersection will be checked.IntersectingObjects
for objects
.public Set<T> contains(Point3i point)
Note that the point must exist as an on pixel on the actual ObjectMask
, not
just within the bounding box of the object.
point
- the particular point that must exist in all objects that are searched for.point
, being empty if no
objects do.public Set<T> intersectsWith(ObjectMask object)
object
- the object with which objects should intersectobjectToIntersectWith
, being empty if no objects intersect.public java.util.stream.Stream<T> intersectsWithStream(ObjectMask object)
object
- the object with which objects should intersectobjectToIntersectWith
, being
empty if no objects intersect.public Set<T> intersectsWith(BoundingBox box)
box
- the bounding-box with which objects should intersect.box
, being empty if no
objects intersect.public void remove(T element)
Note the associated ObjectCollection
remains unchanged.
If no entry can be found matching exactly the object, no change happens. No error is reported.
If multiple entries exist that match exactly the object,then all entries are removed.
element
- the element to removepublic Set<Set<T>> spatiallySeparate()
Any objects whose bounding-boxes intersect belong to the same cluster, but otherwise not.
This is similar to a simplified DB Scan algorithm.
public GraphWithoutPayload<T> asGraph()
public int size()
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.