hashing - Fast access to space associated data
This modules provide tools for accessing data using its space location (not for final user).
The complexity and therefore the cost of those operations are most of the time close to the hashmap complexity O(1). It means data is found in time independently of the actual size of the mesh or whatever storage it is.
-
class
PositionMap
(cellsize, iterable=None)[source] Holds objects associated with their location. Every object can be bound to multiple locations, and each location can hold multiple objects.
cellsize
defines the box size for location hashing (the smaller it is, the bigger the memory footprint will be for non-point primitives)- Attributes defined here:
cellsize: the boxing parameter (DON’T CHANGE IT IF NON-EMPTY) dict: the hashmap from box to objects lists
-
__contains__
(space)[source] check if any stored object is potentially intersecting the given primitive
-
add
(space, obj)[source] add an object associated with a primitive check
keysfor
for a description of allowed primitives
-
get
(space)[source] get the objects potentially intersecting the given primitive check
keysfor
for a description of allowed primitives
-
meshcellsize
(mesh)[source] Returns a good cell size to index primitives of a mesh with a PositionMap
See implementation.
-
class
PointSet
(cellsize, iterable=None, manage=None)[source] Holds a list of points and hash them. The points are holds using indices, that allows to get the point buffer at any time, or to retrieve only a point index.
cellsize
defines the box size in which two points are considered to be the sameMethods are inspired from the builtin type set
- Attributes defined here:
points: the point buffer (READ-ONLY PURPOSE) cellsize: the boxing parameter (DON’T CHANGE IT IF NON-EMPTY). mendatory and is the distance at which you want to distinguish points dict: the hashmap from box to point indices - Build parameters:
iterable: use it to build the set by inserting elements manage: pass a list for inplace use it, only indexing will be built
-
__iadd__
(iterable) add points from an iterable
-
__isub__
(iterable) Remove the points from an iterable
-
add
(pt) int [source] add a point to the set if no equivalent point is at this position return the index of the created point or the pre-existing point at this position.
-
keyfor
(pt)[source] hash key for a point. points with the same key will be considered equivalent and merged in the set