Example #1
0
 def crop(self, rect: Rectangle):
     '''
     The function "crop" return list containing graph if all nodes of graph located in given rectangle and an empty list otherwise
     :param rect: Rectangle class object
     :return: list containing GraphNodes class object or empty list
     '''
     is_all_nodes_inside = all(rect.contains_point_location(node.location) for node in self._nodes.values())
     return [self] if is_all_nodes_inside else []
Example #2
0
 def crop(self, rect: Rectangle):
     for i, keypoint in enumerate(self.points):
         if not rect.contains_point_location(keypoint.location):
             # Keypoints is complex object and all nodes are important. Crop element - crop all
             return []
     return [deepcopy(self)]
Example #3
0
 def crop(self, rect: Rectangle):
     is_all_nodes_inside = all(
         rect.contains_point_location(node.location)
         for node in self._nodes.values())
     return [self] if is_all_nodes_inside else []