1 /* 2 Copyright (C) 2017-2021, Dirk Krause 3 SPDX-License-Identifier: BSD-3-Clause 4 */ 5 6 /* 7 WARNING: This file was generated by the dkct program (see 8 http://dktools.sourceforge.net/ for details). 9 Changes you make here will be lost if dkct is run again! 10 You should modify the original source and run dkct on it. 11 Original source: dk4bb.ctr 12 */ 13 14 #ifndef DK4BB_H_INCLUDED 15 /** Avoid multiple inclusions. */ 16 #define DK4BB_H_INCLUDED 1 17 18 19 /** @file dk4bb.h Bounding box for drawing operations. 20 */ 21 22 #ifndef DK4CONF_H_INCLUDED 23 #if DK4_BUILDING_DKTOOLS4 24 #include "dk4conf.h" 25 #else 26 #include <dktools-4/dk4conf.h> 27 #endif 28 #endif 29 30 #ifndef DK4TYPES_H_INCLUDED 31 #if DK4_BUILDING_DKTOOLS4 32 #include <libdk4base/dk4types.h> 33 #else 34 #include <dktools-4/dk4types.h> 35 #endif 36 #endif 37 38 39 40 /** Bounding box. 41 */ 42 typedef struct { 43 double xmin; /**< Minimum x value. */ 44 double xmax; /**< Maximum x value. */ 45 double ymin; /**< Minimum y value. */ 46 double ymax; /**< Maximum y value. */ 47 unsigned char fl; /**< Flags: Have x (bit 0), have y (bit 1). */ 48 } dk4_bb_t; 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 55 /** Initialize bounding box. 56 @param bbptr Bounding box to initialize. 57 */ 58 59 void 60 dk4bb_init( 61 dk4_bb_t *bbptr 62 ); 63 64 65 /** Add x coordinate to bounding box. 66 @param bbptr Bounding box to modify. 67 @param x Coordinate value to add. 68 */ 69 70 void 71 dk4bb_add_x( 72 dk4_bb_t *bbptr, 73 double x 74 ); 75 76 77 /** Add y coordinate to bounding box. 78 @param bbptr Bounding box to modify. 79 @param y Coordinate value to add. 80 */ 81 82 void 83 dk4bb_add_y( 84 dk4_bb_t *bbptr, 85 double y 86 ); 87 88 89 /** Add point to bounding box. 90 @param bbptr Bounding box to modify. 91 @param x X coordinate of point. 92 @param y Y coordinate of point. 93 */ 94 95 void 96 dk4bb_add_point( 97 dk4_bb_t *bbptr, 98 double x, 99 double y 100 ); 101 102 103 /** Add Bezier spline segment to bounding box. 104 @param bbptr Bounding box to modify. 105 @param x0 Start point, x coordinate. 106 @param y0 Start point, y coordinate. 107 @param c0x Control point next to start point, x coordinate. 108 @param c0y Control point next to start point, y coordinate. 109 @param c1x Control point next to end point, x coordinate. 110 @param c1y Control point next to end point, y coordinate. 111 @param x1 End point, x coordinate. 112 @param y1 End point, y coordinate. 113 */ 114 115 void 116 dk4bb_add_bezier( 117 dk4_bb_t *bbptr, 118 double x0, 119 double y0, 120 double c0x, 121 double c0y, 122 double c1x, 123 double c1y, 124 double x1, 125 double y1 126 ); 127 128 129 /** Add bounding box for a rotated ellipse. 130 @param bbptr Bounding box to modify. 131 @param xc Center point x coordinate. 132 @param yc Center point y coordinate. 133 @param rx X radius. 134 @param ry Y radius. 135 @param rot Rotation counterclockwise in radians. 136 */ 137 138 void 139 dk4bb_add_rotated_ellipse( 140 dk4_bb_t *bbptr, 141 double xc, 142 double yc, 143 double rx, 144 double ry, 145 double rot 146 ); 147 148 149 /** Add one bounding box to another one. 150 @param pdest Destination bounding box. 151 @param psrc Source bounding box. 152 */ 153 154 void 155 dk4bb_add_bb( 156 dk4_bb_t *pdest, 157 dk4_bb_t const *psrc 158 ); 159 160 161 /** Check whether an x value is saved in the bounding box. 162 @param bbptr Bounding box to query. 163 @return 1 if x value available, 0 otherwise. 164 */ 165 166 int 167 dk4bb_have_x( 168 const dk4_bb_t *bbptr 169 ); 170 171 172 /** Check whether an y value is saved in the bounding box. 173 @param bbptr Bounding box to query. 174 @return 1 if y value available, 0 otherwise. 175 */ 176 177 int 178 dk4bb_have_y( 179 const dk4_bb_t *bbptr 180 ); 181 182 183 /** Retrieve minimum x value. 184 @param bbptr Bounding box to query. 185 @return Minimum x value saved in the bounding box. 186 */ 187 188 double 189 dk4bb_get_xmin( 190 const dk4_bb_t *bbptr 191 ); 192 193 194 /** Retrieve maximum x value. 195 @param bbptr Bounding box to query. 196 @return Maximum x value saved in the bounding box. 197 */ 198 199 double 200 dk4bb_get_xmax( 201 const dk4_bb_t *bbptr 202 ); 203 204 205 /** Retrieve minimum y value. 206 @param bbptr Bounding box to query. 207 @return Minimum y value saved in the bounding box. 208 */ 209 210 double 211 dk4bb_get_ymin( 212 const dk4_bb_t *bbptr 213 ); 214 215 216 /** Retrieve maximum y value. 217 @param bbptr Bounding box to query. 218 @return Maximum y value saved in the bounding box. 219 */ 220 221 double 222 dk4bb_get_ymax( 223 const dk4_bb_t *bbptr 224 ); 225 226 227 /** Check whether an outer box contains an inner box candidate. 228 Both boxes must have both x and y information. 229 @param pouter Outer box. 230 @param pinner Inner box candidate. 231 @param aborder Flag: Allow overlapping borders. 232 @return 1 if pouter contains pinner, 0 otherwise. 233 */ 234 235 int 236 dk4bb_contains_bb( 237 const dk4_bb_t *pouter, 238 const dk4_bb_t *pinner, 239 int aborder 240 ); 241 242 243 #ifdef __cplusplus 244 } 245 #endif 246 247 /* vim: set ai sw=4 ts=4 : */ 248 249 250 #endif 251