File size: 3,410 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */
#ifndef _REGION_H_
#define _REGION_H_
#ifdef TRAX_STATIC_DEFINE
# define __TRAX_EXPORT
#else
# ifndef __TRAX_EXPORT
# if defined(_MSC_VER)
# ifdef trax_EXPORTS
/* We are building this library */
# define __TRAX_EXPORT __declspec(dllexport)
# else
/* We are using this library */
# define __TRAX_EXPORT __declspec(dllimport)
# endif
# elif defined(__GNUC__)
# ifdef trax_EXPORTS
/* We are building this library */
# define __TRAX_EXPORT __attribute__((visibility("default")))
# else
/* We are using this library */
# define __TRAX_EXPORT __attribute__((visibility("default")))
# endif
# endif
# endif
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#define TRAX_DEFAULT_CODE 0
#define REGION_LEGACY_RASTERIZATION 1
#ifdef __cplusplus
extern "C" {
#endif
typedef enum region_type {EMPTY, SPECIAL, RECTANGLE, POLYGON, MASK} region_type;
typedef struct region_bounds {
float top;
float bottom;
float left;
float right;
} region_bounds;
typedef struct region_polygon {
int count;
float* x;
float* y;
} region_polygon;
typedef struct region_mask {
int x;
int y;
int width;
int height;
char* data;
} region_mask;
typedef struct region_rectangle {
float x;
float y;
float width;
float height;
} region_rectangle;
typedef struct region_container {
enum region_type type;
union {
region_rectangle rectangle;
region_polygon polygon;
region_mask mask;
int special;
} data;
} region_container;
typedef struct region_overlap {
float overlap;
float only1;
float only2;
} region_overlap;
extern const region_bounds region_no_bounds;
__TRAX_EXPORT int region_set_flags(int mask);
__TRAX_EXPORT int region_clear_flags(int mask);
__TRAX_EXPORT region_overlap region_compute_overlap(const region_container* ra, const region_container* rb, region_bounds bounds);
__TRAX_EXPORT float compute_polygon_overlap(const region_polygon* p1, const region_polygon* p2, float *only1, float *only2, region_bounds bounds);
__TRAX_EXPORT region_bounds region_create_bounds(float left, float top, float right, float bottom);
__TRAX_EXPORT region_bounds region_compute_bounds(const region_container* region);
__TRAX_EXPORT int region_parse(const char* buffer, region_container** region);
__TRAX_EXPORT char* region_string(region_container* region);
__TRAX_EXPORT void region_print(FILE* out, region_container* region);
__TRAX_EXPORT region_container* region_convert(const region_container* region, region_type type);
__TRAX_EXPORT void region_release(region_container** region);
__TRAX_EXPORT region_container* region_create_special(int code);
__TRAX_EXPORT region_container* region_create_rectangle(float x, float y, float width, float height);
__TRAX_EXPORT region_container* region_create_polygon(int count);
__TRAX_EXPORT int region_contains_point(region_container* r, float x, float y);
__TRAX_EXPORT void region_get_mask(region_container* r, char* mask, int width, int height);
__TRAX_EXPORT void region_get_mask_offset(region_container* r, char* mask, int x, int y, int width, int height);
#ifdef __cplusplus
}
#endif
#endif
|