def addShapeAsHole(self, name='undefined'):
     """Adds a hole in the shape of the current shape with the current position"""
     newhole = Polygon(self.getShapeOriented())
     if self.convex_hull:
         newhole = newhole.convex_hull
     newhole.shape_nfps = defaultdict()
     newhole.name = name
     newhole.position = self.position
     newhole.angle = self.angle
     newhole.origin = affinity.rotate(Point(-self.circle_center[0], -self.circle_center[1]), self.angle, origin=(0,0))
     newhole.origin = affinity.translate(newhole.origin, self.position[0], self.position[1])
     self.hole_shapes.append(newhole)
 def addHole(self, shape):
     """Adds a hole. Expecting a list of points ((x, y), ...)
         If the new hole intersects any existing one, it merges with it"""
     new_hole = orient(Polygon(shape))
     if not new_hole.is_valid: return False # TODO: Error code
     new_hole.shape_nfps = defaultdict() # clear cached NFPS
     holes_to_remove = []
     for hole in self.holes:
         if new_hole.intersects(hole) and not new_hole.touches(hole):
             try:
                 new_hole = Polygon(new_hole.union(hole).exterior.coords) # throw out interior
                 new_hole.shape_nfps = defaultdict() # clear cached NFPS
             except:
                 print("error in adding hole")
             holes_to_remove.append(hole)
     for hole in holes_to_remove:
         try:
             self.hole_holes.remove(hole)
         except:
             self.hole_shapes.remove(hole)
     self.hole_holes.append(new_hole)