parameters: (self, tree)
docstring: Args:
              tree: dictionary describing the csg tree
docstring_summary: Args:
              tree: dictionary describing the csg tree
docstring_tokens: Args : tree : dictionary describing the csg tree
function: def __init__(self, tree):
          """
          Args:
              tree: dictionary describing the csg tree
  
          """
  
          if isinstance(tree, CSGTree):
              self.tree = tree.tree
          elif "mesh" in tree:
              # leaf case
              mesh = tree["mesh"]
              self.tree = PyMesh.CSGTree.create_leaf("igl",
                      mesh.vertices, mesh.faces)
          elif "union" in tree:
              num_operands = len(tree["union"])
              if num_operands == 1:
                  self.tree = CSGTree(tree["union"][0]).tree
              elif num_operands == 2:
                  children = [ CSGTree(subtree) for subtree in tree["union"] ]
                  self.tree = PyMesh.CSGTree.create("igl")
                  self.tree.set_operand_1(children[0].tree)
                  self.tree.set_operand_2(children[1].tree)
                  self.tree.compute_union()
              elif num_operands > 2:
                  mid = num_operands // 2
                  child1 = CSGTree({"union": tree["union"][:mid]})
                  child2 = CSGTree({"union": tree["union"][mid:]})
                  self.tree = PyMesh.CSGTree.create("igl")
                  self.tree.set_operand_1(child1.tree)
                  self.tree.set_operand_2(child2.tree)
                  self.tree.compute_union()
              else:
                  raise RuntimeError("No operand provided for union operation")
          elif "intersection" in tree:
              num_operands = len(tree["intersection"])
              if num_operands == 1:
                  self.tree = CSGTree(tree["intersection"][0]).tree
              elif num_operands == 2:
                  children = [ CSGTree(subtree) for subtree in tree["intersection"] ]
                  self.tree = PyMesh.CSGTree.create("igl")
                  self.tree.set_operand_1(children[0].tree)
                  self.tree.set_operand_2(children[1].tree)
                  self.tree.compute_intersection()
              elif num_operands > 2:
                  mid = num_operands // 2
                  child1 = CSGTree({"intersection": tree["intersection"][:mid]})
                  child2 = CSGTree({"intersection": tree["intersection"][mid:]})
                  self.tree = PyMesh.CSGTree.create("igl")
                  self.tree.set_operand_1(child1.tree)
                  self.tree.set_operand_2(child2.tree)
                  self.tree.compute_intersection()
              else:
                  raise RuntimeError("No operand provided for intersection operation")
          elif "difference" in tree:
              children = [ CSGTree(subtree) for subtree in tree["difference"] ]
              assert(len(children) == 2)
              self.tree = PyMesh.CSGTree.create("igl")
              self.tree.set_operand_1(children[0].tree)
              self.tree.set_operand_2(children[1].tree)
              self.tree.compute_difference()
          elif "symmetric_difference" in tree:
              children = [ CSGTree(subtree) for subtree in
                      tree["symmetric_difference"] ]
              assert(len(children) == 2)
              self.tree = PyMesh.CSGTree.create("igl")
              self.tree.set_operand_1(children[0].tree)
              self.tree.set_operand_2(children[1].tree)
              self.tree.compute_symmetric_difference()
          else:
              raise NotImplementedError(
                      "Unsupported boolean operation or incorrect csg tree")
function_tokens: def __init__ ( self , tree ) : if isinstance ( tree , CSGTree ) : self . tree = tree . tree elif "mesh" in tree : # leaf case mesh = tree [ "mesh" ] self . tree = PyMesh . CSGTree . create_leaf ( "igl" , mesh . vertices , mesh . faces ) elif "union" in tree : num_operands = len ( tree [ "union" ] ) if num_operands == 1 : self . tree = CSGTree ( tree [ "union" ] [ 0 ] ) . tree elif num_operands == 2 : children = [ CSGTree ( subtree ) for subtree in tree [ "union" ] ] self . tree = PyMesh . CSGTree . create ( "igl" ) self . tree . set_operand_1 ( children [ 0 ] . tree ) self . tree . set_operand_2 ( children [ 1 ] . tree ) self . tree . compute_union ( ) elif num_operands > 2 : mid = num_operands // 2 child1 = CSGTree ( { "union" : tree [ "union" ] [ : mid ] } ) child2 = CSGTree ( { "union" : tree [ "union" ] [ mid : ] } ) self . tree = PyMesh . CSGTree . create ( "igl" ) self . tree . set_operand_1 ( child1 . tree ) self . tree . set_operand_2 ( child2 . tree ) self . tree . compute_union ( ) else : raise RuntimeError ( "No operand provided for union operation" ) elif "intersection" in tree : num_operands = len ( tree [ "intersection" ] ) if num_operands == 1 : self . tree = CSGTree ( tree [ "intersection" ] [ 0 ] ) . tree elif num_operands == 2 : children = [ CSGTree ( subtree ) for subtree in tree [ "intersection" ] ] self . tree = PyMesh . CSGTree . create ( "igl" ) self . tree . set_operand_1 ( children [ 0 ] . tree ) self . tree . set_operand_2 ( children [ 1 ] . tree ) self . tree . compute_intersection ( ) elif num_operands > 2 : mid = num_operands // 2 child1 = CSGTree ( { "intersection" : tree [ "intersection" ] [ : mid ] } ) child2 = CSGTree ( { "intersection" : tree [ "intersection" ] [ mid : ] } ) self . tree = PyMesh . CSGTree . create ( "igl" ) self . tree . set_operand_1 ( child1 . tree ) self . tree . set_operand_2 ( child2 . tree ) self . tree . compute_intersection ( ) else : raise RuntimeError ( "No operand provided for intersection operation" ) elif "difference" in tree : children = [ CSGTree ( subtree ) for subtree in tree [ "difference" ] ] assert ( len ( children ) == 2 ) self . tree = PyMesh . CSGTree . create ( "igl" ) self . tree . set_operand_1 ( children [ 0 ] . tree ) self . tree . set_operand_2 ( children [ 1 ] . tree ) self . tree . compute_difference ( ) elif "symmetric_difference" in tree : children = [ CSGTree ( subtree ) for subtree in tree [ "symmetric_difference" ] ] assert ( len ( children ) == 2 ) self . tree = PyMesh . CSGTree . create ( "igl" ) self . tree . set_operand_1 ( children [ 0 ] . tree ) self . tree . set_operand_2 ( children [ 1 ] . tree ) self . tree . compute_symmetric_difference ( ) else : raise NotImplementedError ( "Unsupported boolean operation or incorrect csg tree" )