def overlaps_with(self, other): """ Returns True if the given |other| piece overlaps with this piece, False otherwise. """ assert isinstance(other, Circuit_Piece), 'other must be a Circuit_Piece' return rects_overlap(self.bbox(), other.bbox())
def crossed_by(self, wire): """ Returns True if the given |wire| crosses this piece, False otherwise. """ assert isinstance(wire, Wire), 'wire must be a Wire' r_min, c_min, r_max, c_max = self.bbox() wire_r_min = min(wire.r_1, wire.r_2) wire_r_max = max(wire.r_1, wire.r_2) wire_c_min = min(wire.c_1, wire.c_2) wire_c_max = max(wire.c_1, wire.c_2) return rects_overlap(self.bbox(), (wire_r_min, wire_c_min, wire_r_max, wire_c_max))