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
add(space, obj)[source]

Add an object associated with a primitive

display(scene)[source]
get(space)[source]

Get the objects associated with the given primitive

keysfor(space)[source]

Rasterize the primitive, yielding the successive position keys currently allowed primitives are

points:vec3
segments:(vec3,vec3)
triangles:(vec3,vec3,vec3)
update(other)[source]

Add the elements from an other PositionMap or from an iterable

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 same

Methods 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
__add__(iterable)[source]
__getitem__(pt)[source]
__sub__(iterable)[source]
add(pt)[source]

Add a point

difference_update(iterable)[source]

Remove the points from an iterable

discard(pt)[source]

Remove the point at given location if any

keyfor(pt)[source]

Hash key for a point

remove(pt)[source]

Remove a point

update(iterable)[source]

Add the points from an iterable