MaterialNode.py 763 B

123456789101112131415161718192021
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import Optional
  4. from .ContainerNode import ContainerNode
  5. #
  6. # A MaterialNode is a node in the material lookup tree/map/table. It contains 2 (extra) fields:
  7. # - material_map: a one-to-one map of "material_root_id" to material_node.
  8. # - children_map: the key-value map for child nodes of this node. This is used in a lookup tree.
  9. #
  10. #
  11. class MaterialNode(ContainerNode):
  12. __slots__ = ("material_map", "children_map")
  13. def __init__(self, metadata: Optional[dict] = None):
  14. super().__init__(metadata = metadata)
  15. self.material_map = {} # material_root_id -> material_node
  16. self.children_map = {} # mapping for the child nodes