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
48 49 50 51 52 53 54 55 56 57 58 59 | |
connef(faces)
¶
Oriented edge to face connectivity
Source code in madcad/hashing.py
61 62 63 64 65 66 67 | |
connpe(edges)
¶
Point to edge connectivity
Source code in madcad/hashing.py
69 70 71 72 73 74 75 | |
connexity(links)
¶
Return the number of links referencing each point as a dictionary {point: num links}
Source code in madcad/hashing.py
78 79 80 81 82 83 84 | |
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
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 123 124 125 126 127 128 129 130 | |
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
148 149 150 151 152 | |
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
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
update(other)
¶
Add the elements from an other PositionMap or from an iterable
Source code in madcad/hashing.py
291 292 293 294 295 296 297 298 299 300 301 302 | |
add(space, obj)
¶
add an object associated with a primitive
check keysfor for a description of allowed primitives
Source code in madcad/hashing.py
304 305 306 307 308 309 310 311 | |
get(space)
¶
get the objects potentially intersecting the given primitive
check keysfor for a description of allowed primitives
Source code in madcad/hashing.py
313 314 315 316 317 318 319 320 | |
display(scene)
¶
Source code in madcad/hashing.py
340 341 342 343 344 345 346 347 | |
__contains__(space)
¶
check if any stored object is potentially intersecting the given primitive
Source code in madcad/hashing.py
322 323 324 | |
meshcellsize(mesh)
¶
Returns a good cell size to index primitives of a mesh with a PositionMap
See implementation.
Source code in madcad/hashing.py
349 350 351 352 353 354 355 356 | |
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
377 378 379 380 381 382 383 384 385 386 387 | |
__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
389 390 391 392 393 394 | |
update(iterable)
¶
add points from an iterable
Source code in madcad/hashing.py
411 412 413 | |
difference_update(iterable)
¶
Remove the points from an iterable
Source code in madcad/hashing.py
414 415 416 | |
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
418 419 420 421 422 423 424 425 426 427 428 | |
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
429 430 431 432 433 434 435 436 437 438 | |
discard(pt)
¶
remove all points at positions equivalent to the given location (if any)
Source code in madcad/hashing.py
439 440 441 442 443 | |
__getitem__(pt)
¶
return the index of the point at given location in the set
Source code in madcad/hashing.py
450 451 452 453 454 | |
__contains__(pt)
¶
true if there is a point at the given location in the set
Source code in madcad/hashing.py
445 446 447 448 449 | |
__add__(iterable)
¶
Source code in madcad/hashing.py
458 459 460 461 462 | |
__sub__(iterable)
¶
Source code in madcad/hashing.py
463 464 465 466 467 | |
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
479 480 481 482 483 484 485 | |
__getitem__(key)
¶
return an iterable of the objects associated to the given key
Source code in madcad/hashing.py
487 488 489 490 491 492 493 494 495 | |
__contains__(key)
¶
return True if key is associated to something
Source code in madcad/hashing.py
586 587 588 | |
add(key, value)
¶
associate a new value to this key
Source code in madcad/hashing.py
497 498 499 500 501 502 503 504 505 | |
remove(key, value)
¶
Source code in madcad/hashing.py
507 508 509 510 511 512 513 514 515 516 517 518 | |
discard(key, value)
¶
remove all (key,value) pair of that table
Source code in madcad/hashing.py
520 521 522 523 524 525 526 527 528 529 530 531 | |
update(other)
¶
append all key,value associations to this Asso
Source code in madcad/hashing.py
533 534 535 536 537 538 | |
__add__(other)
¶
Source code in madcad/hashing.py
540 541 542 543 544 | |
clear()
¶
empty the container
Source code in madcad/hashing.py
557 558 559 | |
items()
¶
iterator of (key, value) pairs
Source code in madcad/hashing.py
561 562 563 564 | |
keys()
¶
iterator of the keys
Source code in madcad/hashing.py
566 567 568 569 | |
values()
¶
iterator of the values
Source code in madcad/hashing.py
571 572 573 | |
connexity(key)
¶
return the number of values associated to the given key
Source code in madcad/hashing.py
575 576 577 578 579 580 581 582 583 | |