parameters: (list_of_shapes, tolerance = 0.0)
return_statement: return ShapeMerge.mergeShapes(keepers)
docstring: connect(list_of_shapes, tolerance = 0.0): connects solids (walled objects), shells and
      wires by throwing off small parts that result when splitting them at intersections.
  
      Compounds in list_of_shapes are automatically exploded, so self-intersecting compounds
      are valid for connect.
docstring_summary: connect(list_of_shapes, tolerance = 0.0): connects solids (walled objects), shells and
      wires by throwing off small parts that result when splitting them at intersections.
docstring_tokens: connect ( list_of_shapes tolerance = 0 . 0 ) : connects solids ( walled objects ) shells and wires by throwing off small parts that result when splitting them at intersections .
function: def connect(list_of_shapes, tolerance = 0.0):
      """connect(list_of_shapes, tolerance = 0.0): connects solids (walled objects), shells and
      wires by throwing off small parts that result when splitting them at intersections.
  
      Compounds in list_of_shapes are automatically exploded, so self-intersecting compounds
      are valid for connect."""
  
      # explode all compounds before GFA.
      new_list_of_shapes = []
      for sh in list_of_shapes:
          new_list_of_shapes.extend( compoundLeaves(sh) )
      list_of_shapes = new_list_of_shapes
  
      #test if shapes are compatible for connecting
      dim = ShapeMerge.dimensionOfShapes(list_of_shapes)
      if dim == 0:
          raise TypeError("Cannot connect vertices!")
  
      if len(list_of_shapes) < 2:
          return Part.makeCompound(list_of_shapes)
  
      if not generalFuseIsAvailable(): #fallback to legacy
          result = list_of_shapes[0]
          for i in range(1, len(list_of_shapes)):
              result = connect_legacy(result, list_of_shapes[i], tolerance)
          return result
  
      pieces, map = list_of_shapes[0].generalFuse(list_of_shapes[1:], tolerance)
      ao = GeneralFuseResult(list_of_shapes, (pieces, map))
      ao.splitAggregates()
      #print len(ao.pieces)," pieces total"
  
      keepers = []
      all_danglers = [] # debug
  
      #add all biggest dangling pieces
      for src in ao.source_shapes:
          danglers = [piece for piece in ao.piecesFromSource(src) if len(ao.sourcesOfPiece(piece)) == 1]
          all_danglers.extend(danglers)
          largest = shapeOfMaxSize(danglers)
          if largest is not None:
              keepers.append(largest)
  
      touch_test_list = Part.Compound(keepers)
      #add all intersection pieces that touch danglers, triple intersection pieces that touch duals, and so on
      for ii in range(2, ao.largestOverlapCount()+1):
          list_ii_pieces = [piece for piece in ao.pieces if len(ao.sourcesOfPiece(piece)) == ii]
          keepers_2_add = []
          for piece in list_ii_pieces:
              if ShapeMerge.isConnected(piece, touch_test_list):
                  keepers_2_add.append(piece)
          if len(keepers_2_add) == 0:
              break
          keepers.extend(keepers_2_add)
          touch_test_list = Part.Compound(keepers_2_add)
  
  
      #merge, and we are done!
      #print len(keepers)," pieces to keep"
      return ShapeMerge.mergeShapes(keepers)
function_tokens: def connect ( list_of_shapes , tolerance = 0.0 ) : # explode all compounds before GFA. new_list_of_shapes = [ ] for sh in list_of_shapes : new_list_of_shapes . extend ( compoundLeaves ( sh ) ) list_of_shapes = new_list_of_shapes #test if shapes are compatible for connecting dim = ShapeMerge . dimensionOfShapes ( list_of_shapes ) if dim == 0 : raise TypeError ( "Cannot connect vertices!" ) if len ( list_of_shapes ) < 2 : return Part . makeCompound ( list_of_shapes ) if not generalFuseIsAvailable ( ) : #fallback to legacy result = list_of_shapes [ 0 ] for i in range ( 1 , len ( list_of_shapes ) ) : result = connect_legacy ( result , list_of_shapes [ i ] , tolerance ) return result pieces , map = list_of_shapes [ 0 ] . generalFuse ( list_of_shapes [ 1 : ] , tolerance ) ao = GeneralFuseResult ( list_of_shapes , ( pieces , map ) ) ao . splitAggregates ( ) #print len(ao.pieces)," pieces total" keepers = [ ] all_danglers = [ ] # debug #add all biggest dangling pieces for src in ao . source_shapes : danglers = [ piece for piece in ao . piecesFromSource ( src ) if len ( ao . sourcesOfPiece ( piece ) ) == 1 ] all_danglers . extend ( danglers ) largest = shapeOfMaxSize ( danglers ) if largest is not None : keepers . append ( largest ) touch_test_list = Part . Compound ( keepers ) #add all intersection pieces that touch danglers, triple intersection pieces that touch duals, and so on for ii in range ( 2 , ao . largestOverlapCount ( ) + 1 ) : list_ii_pieces = [ piece for piece in ao . pieces if len ( ao . sourcesOfPiece ( piece ) ) == ii ] keepers_2_add = [ ] for piece in list_ii_pieces : if ShapeMerge . isConnected ( piece , touch_test_list ) : keepers_2_add . append ( piece ) if len ( keepers_2_add ) == 0 : break keepers . extend ( keepers_2_add ) touch_test_list = Part . Compound ( keepers_2_add ) #merge, and we are done! #print len(keepers)," pieces to keep" return ShapeMerge . mergeShapes ( keepers )