Contructive Solid Geometry Tree. Perhaps the best way of describing supported operations is using context free grammar: * ``mesh`` operation: This operation is always a leaf node of the tree. >>> tree = pymesh.CSGTree({"mesh": mesh}) * ``union`` operation: >>> t
| 3 | from .meshio import form_mesh |
| 4 | |
| 5 | class CSGTree: |
| 6 | """ Contructive Solid Geometry Tree. |
| 7 | |
| 8 | Perhaps the best way of describing supported operations is using context |
| 9 | free grammar: |
| 10 | |
| 11 | * ``mesh`` operation: This operation is always a leaf node of the tree. |
| 12 | |
| 13 | >>> tree = pymesh.CSGTree({"mesh": mesh}) |
| 14 | |
| 15 | * ``union`` operation: |
| 16 | |
| 17 | >>> tree = pymesh.CSGTree({"union": |
| 18 | ... [TREE_1, TREE_2, ..., TREE_N] |
| 19 | ... }) |
| 20 | |
| 21 | * ``intersection`` operations: |
| 22 | |
| 23 | >>> tree = pymesh.CSGTree({"intersection": |
| 24 | ... [TREE_1, TREE_2, ..., TREE_N] |
| 25 | ... }) |
| 26 | |
| 27 | * ``difference`` operations: |
| 28 | |
| 29 | >>> tree = pymesh.CSGTree({"difference": |
| 30 | ... [TREE_1, TREE_2] |
| 31 | ... }) |
| 32 | |
| 33 | * ``symmetric_difference`` operations: |
| 34 | |
| 35 | >>> tree = pymesh.CSGTree({"symmetric_difference": |
| 36 | ... [TREE_1, TREE_2] |
| 37 | ... }) |
| 38 | |
| 39 | Where ``TREE_X`` could be any of the nodes defined above. |
| 40 | |
| 41 | A tree can be build up incrementally: |
| 42 | |
| 43 | >>> left_tree = pymesh.CSGTree({"mesh": mesh_1}) |
| 44 | >>> right_tree = pymesh.CSGTree({"mesh": mesh_2}) |
| 45 | >>> tree = pymesh.CSGTree({"union": [left_tree, right_tree]}) |
| 46 | >>> mesh = tree.mesh |
| 47 | |
| 48 | Or constructed from a dict: |
| 49 | |
| 50 | >>> tree = pymesh.CSGTree({"union": |
| 51 | ... [{"mesh": mesh_1}, {"mesh": mesh_2}] |
| 52 | ... }) |
| 53 | >>> mesh = tree.mesh |
| 54 | """ |
| 55 | def __init__(self, tree): |
| 56 | """ |
| 57 | Args: |
| 58 | tree: dictionary describing the csg tree |
| 59 | |
| 60 | """ |
| 61 | |
| 62 | if isinstance(tree, CSGTree): |
no outgoing calls