parameters: (shape, offset)
return_statement: return offsetWires
docstring: Return a list of wires obtained from offsetting wires from the shape.
  
      Return a list of wires obtained from offsetting the wires
      from the given shape by the given offset, and intersection if needed.
docstring_summary: Return a list of wires obtained from offsetting wires from the shape.
docstring_tokens: Return a list of wires obtained from offsetting wires from the shape .
function: def pocket2d(shape, offset):
      """Return a list of wires obtained from offsetting wires from the shape.
  
      Return a list of wires obtained from offsetting the wires
      from the given shape by the given offset, and intersection if needed.
      """
      # find the outer wire
      length = 0
      outerWire = None
      innerWires = []
      for w in shape.Wires:
          if w.BoundBox.DiagonalLength > length:
              outerWire = w
              length = w.BoundBox.DiagonalLength
  
      if not outerWire:
          return []
  
      for w in shape.Wires:
          if w.hashCode() != outerWire.hashCode():
              innerWires.append(w)
  
      o = outerWire.makeOffset(-offset)
  
      if not o.Wires:
          return []
  
      offsetWires = o.Wires
      # print("base offset wires:", offsetWires)
      if not innerWires:
          return offsetWires
  
      for innerWire in innerWires:
          i = innerWire.makeOffset(offset)
          if len(innerWire.Edges) == 1:
              e = innerWire.Edges[0]
              if isinstance(e.Curve, Part.Circle):
                  e = Part.makeCircle(e.Curve.Radius + offset,
                                      e.Curve.Center,
                                      e.Curve.Axis)
                  i = Part.Wire(e)
          if i.Wires:
              # print("offsetting island ", innerWire, " : ", i.Wires)
              for w in i.Wires:
                  added = False
                  # print("checking wire ",w)
                  k = list(range(len(offsetWires)))
                  for j in k:
                      # print("checking against existing wire ", j)
                      ow = offsetWires[j]
                      if ow:
                          if wiresIntersect(w, ow):
                              # print("intersect")
                              f1 = Part.Face(ow)
                              f2 = Part.Face(w)
                              f3 = f1.cut(f2)
                              # print("made new wires: ", f3.Wires)
                              offsetWires[j] = f3.Wires[0]
                              if len(f3.Wires) > 1:
                                  # print("adding more")
                                  offsetWires.extend(f3.Wires[1:])
                              added = True
                          else:
                              a = w.BoundBox
                              b = ow.BoundBox
                              if ((a.XMin <= b.XMin)
                                      and (a.YMin <= b.YMin)
                                      and (a.ZMin <= b.ZMin)
                                      and (a.XMax >= b.XMax)
                                      and (a.YMax >= b.YMax)
                                      and (a.ZMax >= b.ZMax)):
                                  # print("this wire is bigger than "
                                  #       "the outer wire")
                                  offsetWires[j] = None
                                  added = True
                              # else:
                              #   print("doesn't intersect")
                  if not added:
                      # print("doesn't intersect with any other")
                      offsetWires.append(w)
      offsetWires = [o for o in offsetWires if o is not None]
  
      return offsetWires
function_tokens: def pocket2d ( shape , offset ) : # find the outer wire length = 0 outerWire = None innerWires = [ ] for w in shape . Wires : if w . BoundBox . DiagonalLength > length : outerWire = w length = w . BoundBox . DiagonalLength if not outerWire : return [ ] for w in shape . Wires : if w . hashCode ( ) != outerWire . hashCode ( ) : innerWires . append ( w ) o = outerWire . makeOffset ( - offset ) if not o . Wires : return [ ] offsetWires = o . Wires # print("base offset wires:", offsetWires) if not innerWires : return offsetWires for innerWire in innerWires : i = innerWire . makeOffset ( offset ) if len ( innerWire . Edges ) == 1 : e = innerWire . Edges [ 0 ] if isinstance ( e . Curve , Part . Circle ) : e = Part . makeCircle ( e . Curve . Radius + offset , e . Curve . Center , e . Curve . Axis ) i = Part . Wire ( e ) if i . Wires : # print("offsetting island ", innerWire, " : ", i.Wires) for w in i . Wires : added = False # print("checking wire ",w) k = list ( range ( len ( offsetWires ) ) ) for j in k : # print("checking against existing wire ", j) ow = offsetWires [ j ] if ow : if wiresIntersect ( w , ow ) : # print("intersect") f1 = Part . Face ( ow ) f2 = Part . Face ( w ) f3 = f1 . cut ( f2 ) # print("made new wires: ", f3.Wires) offsetWires [ j ] = f3 . Wires [ 0 ] if len ( f3 . Wires ) > 1 : # print("adding more") offsetWires . extend ( f3 . Wires [ 1 : ] ) added = True else : a = w . BoundBox b = ow . BoundBox if ( ( a . XMin <= b . XMin ) and ( a . YMin <= b . YMin ) and ( a . ZMin <= b . ZMin ) and ( a . XMax >= b . XMax ) and ( a . YMax >= b . YMax ) and ( a . ZMax >= b . ZMax ) ) : # print("this wire is bigger than " #       "the outer wire") offsetWires [ j ] = None added = True # else: #   print("doesn't intersect") if not added : # print("doesn't intersect with any other") offsetWires . append ( w ) offsetWires = [ o for o in offsetWires if o is not None ] return offsetWires