def intersects_with_segment(box: Box, segment: Segment, context: Context) -> bool: """ Checks if the box intersects the segment. """ segment_box = context.segment_box(segment) return (intersects_with( segment_box, box) and (is_subset_of(segment_box, box) or any( context.segments_relation(edge, segment) is not Relation.DISJOINT for edge in to_edges(box, context))))
def coupled_with_segment(box: Box, segment: Segment, context: Context) -> bool: """ Checks if the box intersects the segment at more than one point. """ segment_box = context.segment_box(segment) return (coupled_with(segment_box, box) and (is_subset_of(segment_box, box) or any( context.segments_relation(edge, segment) not in (Relation.TOUCH, Relation.DISJOINT) for edge in to_edges(box, context))))
def relate_segment(multiregion: Multiregion, segment: Segment, context: Context) -> Relation: return _relate_multisegment(multiregion, context.multisegment_cls([segment]), context.segment_box(segment), context)