File size: 1,222 Bytes
d4b77ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
cdef extern from "region.h":
    ctypedef enum region_type "RegionType":
        EMTPY 
        SPECIAL
        RECTANGEL
        POLYGON
        MASK

    ctypedef struct region_bounds:
        float top
        float bottom
        float left
        float right

    ctypedef struct region_rectangle:
        float x
        float y
        float width
        float height

    # ctypedef struct region_mask:
    #     int x
    #     int y
    #     int width
    #     int height
    #     char *data
    
    ctypedef struct region_polygon:
        int count
        float *x
        float *y

    ctypedef union region_container_data:
        region_rectangle rectangle
        region_polygon polygon
        # region_mask mask
        int special

    ctypedef struct region_container:
        region_type type
        region_container_data data

    # ctypedef struct region_overlap:
    #     float overlap
    #     float only1
    #     float only2

    # region_overlap region_compute_overlap(const region_container* ra, const region_container* rb, region_bounds bounds)

    float compute_polygon_overlap(const region_polygon* p1, const region_polygon* p2, float *only1, float *only2, region_bounds bounds)