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)

Holds objects assoiated 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)

add an object associated with a primitive

display(scene)
get(space)

get the objects associated with the given primitive

keysfor(space)

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

points

vec3

segments

(vec3,vec3)

triangles

(vec3,vec3,vec3)

update(other)

add the elements from an other PositionMap or from an iteravble

meshcellsize(mesh)

returns a good cell size to index primitives of a mesh with a PositionMap

See implementation.

class PointSet(cellsize, iterable=None, manage=None)

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 retreive 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)
__getitem__(pt)
__sub__(iterable)
add(pt)

add a point

difference_update(iterable)

remove the points from an iteravble

discard(pt)

remove the point at given location if any

keyfor(pt)

hash key for a point

remove(pt)

remove a point

update(iterable)

add the points from an iterable