Beispiel #1
0
 def clear_extra_entry_points(self, new_entry_point):
     most_recent_farthest_ep_index = -1
     for i, ep_i in enumerate(self.entry_points):
         for j, ep_j in enumerate(self.entry_points[i + 1:]):
             if PointUtil.get_distance_from_point(
                     ep_i, ep_j,
                     self.point_util) > self.max_valid_distance():
                 most_recent_farthest_ep_index = i
     if most_recent_farthest_ep_index != -1:
         self.entry_points = self.entry_points[
             most_recent_farthest_ep_index:]
         return True
     return False
Beispiel #2
0
    def find_diameter(entry_points, geometry_solver=None):
        point_util = None
        if geometry_solver:
            point_util = geometry_solver.point_util
        if len(entry_points) < 2:
            corner_old, corner_new = entry_points[0], entry_points[0]
            diameter = 0
            return diameter, (corner_old, corner_new)

        diameter = 0
        corner_old, corner_new = None, None
        for possible_corners in combinations(entry_points, 2):
            tmp_diameter = PointUtil.get_distance_from_point(
                possible_corners[0], possible_corners[1], point_util)
            if tmp_diameter >= diameter:
                diameter, corner_old, corner_new = tmp_diameter, possible_corners[
                    0], possible_corners[1]

        if corner_old is not None:
            return diameter, (corner_old, corner_new)
        return diameter, None