Class IntersectingObjects<T>
- Type Parameters:
T
- the type of elements stored in the structure, each of which must map to aObjectMask
.
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.
- Author:
- Owen Feehan
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIntersectingObjects
(Collection<T> elements, Function<T, ObjectMask> extractObject) Creates an r-tree for particular objects, as extracted from elements. -
Method Summary
Modifier and TypeMethodDescriptionasGraph()
Constructs a graph where each vertex is an element and an edge exists between any elements that intersect.All elements that contain a particular point.static IntersectingObjects
<ObjectMask> create
(ObjectCollection objects) Creates from anObjectCollection
.intersectsWith
(ObjectMask object) All elements that intersect with a particular object.All elements that intersect with a particular bounding box.intersectsWithStream
(ObjectMask object) void
Removes an object-mask, so that it is no longer considered in queries.int
size()
Number of items in the r-tree.Splits the collection of objects into spatially separate clusters.
-
Constructor Details
-
IntersectingObjects
Creates an r-tree for particular objects, as extracted from elements.- Parameters:
elements
- the elements, each corresponding to a unique object.extractObject
- a function that extracts a uniqueObjectMask
from an element.
-
-
Method Details
-
create
Creates from anObjectCollection
.- Parameters:
objects
- the objects whose intersection will be checked.- Returns:
- a newly created
IntersectingObjects
forobjects
.
-
contains
All elements that contain a particular point.Note that the point must exist as an on pixel on the actual
ObjectMask
, not just within the bounding box of the object.- Parameters:
point
- the particular point that must exist in all objects that are searched for.- Returns:
- a newly created set of all elements that contain
point
, being empty if no objects do.
-
intersectsWith
All elements that intersect with a particular object.- Parameters:
object
- the object with which objects should intersect- Returns:
- a newly created set of all elements that intersect with
objectToIntersectWith
, being empty if no objects intersect.
-
intersectsWithStream
- Parameters:
object
- the object with which objects should intersect- Returns:
- a stream of all objects that intersect with
objectToIntersectWith
, being empty if no objects intersect.
-
intersectsWith
All elements that intersect with a particular bounding box.- Parameters:
box
- the bounding-box with which objects should intersect.- Returns:
- a newly created set of all objects that intersect with
box
, being empty if no objects intersect.
-
remove
Removes an object-mask, so that it is no longer considered in queries.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.
- Parameters:
element
- the element to remove
-
spatiallySeparate
Splits the collection of objects into spatially separate clusters.Any objects whose bounding-boxes intersect belong to the same cluster, but otherwise not.
This is similar to a simplified DB Scan algorithm.
- Returns:
- a list of object-collections, each object-collection is guaranteed to be spatially separate from the others.
-
asGraph
Constructs a graph where each vertex is an element and an edge exists between any elements that intersect.- Returns:
- a newly created graph, reusing the existing elements as vertices.
-
size
public int size()Number of items in the r-tree.- Returns:
- the number of items
-