| 14307 | |
| 14308 | |
| 14309 | class Quad: |
| 14310 | |
| 14311 | def __abs__(self): |
| 14312 | if self.is_empty: |
| 14313 | return 0.0 |
| 14314 | return abs(self.ul - self.ur) * abs(self.ul - self.ll) |
| 14315 | |
| 14316 | def __add__(self, q): |
| 14317 | if hasattr(q, "__float__"): |
| 14318 | return Quad(self.ul + q, self.ur + q, self.ll + q, self.lr + q) |
| 14319 | if len(q) != 4: |
| 14320 | raise ValueError("Quad: bad seq len") |
| 14321 | return Quad(self.ul + q[0], self.ur + q[1], self.ll + q[2], self.lr + q[3]) |
| 14322 | |
| 14323 | def __bool__(self): |
| 14324 | return not self.is_empty |
| 14325 | |
| 14326 | def __contains__(self, x): |
| 14327 | try: |
| 14328 | l = x.__len__() |
| 14329 | except Exception: |
| 14330 | if g_exceptions_verbose > 1: exception_info() |
| 14331 | return False |
| 14332 | if l == 2: |
| 14333 | return util_point_in_quad(x, self) |
| 14334 | if l != 4: |
| 14335 | return False |
| 14336 | if CheckRect(x): |
| 14337 | if Rect(x).is_empty: |
| 14338 | return True |
| 14339 | return util_point_in_quad(x[:2], self) and util_point_in_quad(x[2:], self) |
| 14340 | if CheckQuad(x): |
| 14341 | for i in range(4): |
| 14342 | if not util_point_in_quad(x[i], self): |
| 14343 | return False |
| 14344 | return True |
| 14345 | return False |
| 14346 | |
| 14347 | def __eq__(self, quad): |
| 14348 | if not hasattr(quad, "__len__"): |
| 14349 | return False |
| 14350 | return len(quad) == 4 and ( |
| 14351 | self.ul == quad[0] and |
| 14352 | self.ur == quad[1] and |
| 14353 | self.ll == quad[2] and |
| 14354 | self.lr == quad[3] |
| 14355 | ) |
| 14356 | |
| 14357 | def __getitem__(self, i): |
| 14358 | return (self.ul, self.ur, self.ll, self.lr)[i] |
| 14359 | |
| 14360 | def __hash__(self): |
| 14361 | return hash(tuple(self)) |
| 14362 | |
| 14363 | def __init__(self, *args, ul=None, ur=None, ll=None, lr=None): |
| 14364 | ''' |
| 14365 | Quad() - all zero points |
| 14366 | Quad(ul, ur, ll, lr) |
no outgoing calls
no test coverage detected
searching dependent graphs…