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.
Connectivity¶
edgekey(a, b)
¶
Return a key for a non-directional edge
Source code in madcad/hashing.py
18 19 20 21 | |
facekeyo(a, b, c)
¶
Return a key for an oriented face
Source code in madcad/hashing.py
23 24 25 26 27 | |
arrangeface(f, p)
¶
Return the face indices rotated the way p is the first index, if p is in the face
Source code in madcad/hashing.py
29 30 31 32 33 | |
arrangeedge(e, p)
¶
Return the edge indices rotated the way p is the first index, if p is in the edge
Source code in madcad/hashing.py
35 36 37 38 | |
connpp(ngons)
¶
Point to point connectivity
input is a list of ngons (tuple of 2 to n indices)
Source code in madcad/hashing.py
40 41 42 43 44 45 46 47 48 49 50 51 | |
connef(faces)
¶
Oriented edge to face connectivity
Source code in madcad/hashing.py
53 54 55 56 57 58 59 | |
connpe(edges)
¶
Point to edge connectivity
Source code in madcad/hashing.py
61 62 63 64 65 66 67 | |
connexity(links)
¶
Return the number of links referencing each point as a dictionary {point: num links}
Source code in madcad/hashing.py
70 71 72 73 74 75 76 | |
suites(lines, oriented=True, cut=True, loop=False)
¶
Return a list of the suites that can be formed with lines.
lines is an iterable of edges
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
oriented
|
specifies that (a,b) and (c,b) will not be assembled |
True
|
|
cut
|
cut suites when they are crossing each others |
True
|
Return a list of the sequences that can be formed
Source code in madcad/hashing.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
Specific Hashmaps¶
PositionMap(cellsize, iterable=None)
¶
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
Source code in madcad/hashing.py
140 141 142 143 144 | |
keysfor(space)
¶
Rasterize the primitive, yielding the successive position keys currently allowed primitives are
:points: vec3
:segments: (vec3,vec3)
:triangles: (vec3,vec3,vec3)
Source code in madcad/hashing.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
update(other)
¶
Add the elements from an other PositionMap or from an iterable
Source code in madcad/hashing.py
283 284 285 286 287 288 289 290 291 292 293 294 | |
add(space, obj)
¶
add an object associated with a primitive
check keysfor for a description of allowed primitives
Source code in madcad/hashing.py
296 297 298 299 300 301 302 303 | |
get(space)
¶
get the objects potentially intersecting the given primitive
check keysfor for a description of allowed primitives
Source code in madcad/hashing.py
305 306 307 308 309 310 311 312 | |
display(scene)
¶
Source code in madcad/hashing.py
332 333 334 335 336 337 338 339 | |
__contains__(space)
¶
check if any stored object is potentially intersecting the given primitive
Source code in madcad/hashing.py
314 315 316 | |
meshcellsize(mesh)
¶
Returns a good cell size to index primitives of a mesh with a PositionMap
See implementation.
Source code in madcad/hashing.py
341 342 343 344 345 346 347 348 | |
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 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
Source code in madcad/hashing.py
369 370 371 372 373 374 375 376 377 378 379 | |
__iadd__ = update
class-attribute
instance-attribute
¶
__isub__ = difference_update
class-attribute
instance-attribute
¶
keyfor(pt)
¶
hash key for a point. points with the same key will be considered equivalent and merged in the set
Source code in madcad/hashing.py
381 382 383 384 385 386 | |
update(iterable)
¶
add points from an iterable
Source code in madcad/hashing.py
403 404 405 | |
difference_update(iterable)
¶
Remove the points from an iterable
Source code in madcad/hashing.py
406 407 408 | |
add(pt)
¶
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.
Source code in madcad/hashing.py
410 411 412 413 414 415 416 417 418 419 420 | |
remove(pt)
¶
remove the point at given position point from the set, returning its former index. raise if no point exist at this position
Source code in madcad/hashing.py
421 422 423 424 425 426 427 428 429 430 | |
discard(pt)
¶
remove all points at positions equivalent to the given location (if any)
Source code in madcad/hashing.py
431 432 433 434 435 | |
__getitem__(pt)
¶
return the index of the point at given location in the set
Source code in madcad/hashing.py
442 443 444 445 446 | |
__contains__(pt)
¶
true if there is a point at the given location in the set
Source code in madcad/hashing.py
437 438 439 440 441 | |
__add__(iterable)
¶
Source code in madcad/hashing.py
450 451 452 453 454 | |
__sub__(iterable)
¶
Source code in madcad/hashing.py
455 456 457 458 459 | |
Asso(iter=None)
¶
Bases: object
Associative container. This is a sort dict that stores as many values as we want for each key. The return value for a key is then always an iterable of the associated values, even when the value set to the key is unique and is not an iterator.
Asso(iterable) the iterable must yields (key,value) pairs Asso(keys=[], values=[]) build form existing lists, assuming they are already sorted
Source code in madcad/hashing.py
471 472 473 474 475 476 477 | |
__getitem__(key)
¶
return an iterable of the objects associated to the given key
Source code in madcad/hashing.py
479 480 481 482 483 484 485 486 487 | |
__contains__(key)
¶
return True if key is associated to something
Source code in madcad/hashing.py
578 579 580 | |
add(key, value)
¶
associate a new value to this key
Source code in madcad/hashing.py
489 490 491 492 493 494 495 496 497 | |
remove(key, value)
¶
Source code in madcad/hashing.py
499 500 501 502 503 504 505 506 507 508 509 510 | |
discard(key, value)
¶
remove all (key,value) pair of that table
Source code in madcad/hashing.py
512 513 514 515 516 517 518 519 520 521 522 523 | |
update(other)
¶
append all key,value associations to this Asso
Source code in madcad/hashing.py
525 526 527 528 529 530 | |
__add__(other)
¶
Source code in madcad/hashing.py
532 533 534 535 536 | |
clear()
¶
empty the container
Source code in madcad/hashing.py
549 550 551 | |
items()
¶
iterator of (key, value) pairs
Source code in madcad/hashing.py
553 554 555 556 | |
keys()
¶
iterator of the keys
Source code in madcad/hashing.py
558 559 560 561 | |
values()
¶
iterator of the values
Source code in madcad/hashing.py
563 564 565 | |
connexity(key)
¶
return the number of values associated to the given key
Source code in madcad/hashing.py
567 568 569 570 571 572 573 574 575 | |