00001 #ifndef _VRR_GEOMLIB_TYPES_H_ 00002 #define _VRR_GEOMLIB_TYPES_H_ 00003 00013 #include "geomlib/base.h" 00014 00015 00016 /*------------------------------------------------------------------------* 00017 * * 00018 * BASIC DEFINITIONS * 00019 * * 00020 *------------------------------------------------------------------------*/ 00021 00022 00024 struct geom_point { 00025 real x; 00026 real y; 00027 }; 00028 00029 00031 struct geom_point_w { 00032 real x; 00033 real y; 00034 real w; 00035 }; 00036 00037 00039 struct geom_vector { 00040 real dx; 00041 real dy; 00042 }; 00043 00044 00046 struct geom_rectangle { 00047 struct geom_point ll; 00048 struct geom_point ur; 00049 }; 00050 00051 00052 /*------------------------------------------------------------------------* 00053 * * 00054 * AFFINE TRANSFORMATIONS * 00055 * * 00056 *------------------------------------------------------------------------*/ 00057 00058 00060 struct geom_transform { 00061 uns flags; 00062 real coef[2][3]; 00063 }; 00064 00065 00067 struct geom_transform2 { 00068 struct geom_transform primary; 00069 struct geom_transform inverted; 00070 }; 00071 00072 00073 /*------------------------------------------------------------------------* 00074 * * 00075 * ITEMS AND GROUPS * 00076 * * 00077 *------------------------------------------------------------------------*/ 00078 00079 00081 // FIXME: rewrite to balanced tree 00082 struct geom_item { 00083 struct geom_o o; 00084 ccnode node; 00085 struct geom_group *owner; 00086 }; 00087 00088 00090 struct geom_group { 00091 struct geom_item item; 00092 cclist list; 00093 }; 00094 00095 00096 /*------------------------------------------------------------------------* 00097 * * 00098 * CURVE TYPES * 00099 * * 00100 *------------------------------------------------------------------------*/ 00101 00102 00104 struct geom_curve { 00105 struct geom_item item; 00106 }; 00107 00108 00110 struct geom_segment { 00111 struct geom_curve curve; 00112 struct geom_point a; 00113 struct geom_point b; 00114 }; 00115 00116 00118 struct geom_bezier { 00119 struct geom_curve curve; 00120 struct geom_point_w pt[4]; 00121 struct geom_rectangle bbox; 00122 real alength; 00123 }; 00124 00125 00138 struct geom_parabolic_arc { 00139 struct geom_curve curve; 00140 struct geom_point center; 00141 real rotation; 00142 real distance; 00143 real start; 00144 real end; 00145 }; 00146 00147 00159 struct geom_arc { 00160 struct geom_curve curve; 00161 struct geom_point center; 00162 real radius; 00163 real start; 00164 real end; 00165 }; 00166 00167 00181 struct geom_elliptic_arc { 00182 struct geom_curve curve; 00183 struct geom_point center; 00184 real rotation; 00185 real a_radius; 00186 real b_radius; 00187 real start; 00188 real dif; 00189 }; 00190 00191 00206 struct geom_hyperbolic_arc { 00207 struct geom_curve curve; 00208 struct geom_point center; 00209 real rotation; 00210 real major; 00211 real minor; 00212 real start; 00213 real end; 00214 }; 00215 00216 00218 struct geom_nurbs { 00219 struct geom_curve curve; 00220 u8 degree; 00221 cclist knots; 00222 }; 00223 00224 struct geom_nurbs_knot { 00225 ccnode node; 00226 real time; 00227 struct geom_point_w point; 00228 }; 00229 00230 00231 /*------------------------------------------------------------------------* 00232 * * 00233 * CONTINOUS GROUP OF CURVES - PATH * 00234 * * 00235 *------------------------------------------------------------------------*/ 00236 00237 00238 struct geom_path { 00239 struct geom_group group; 00240 real alength; 00241 }; 00242 00243 /* Path with fast greedy curve allocator. */ 00244 struct geom_fpath { 00245 struct geom_path path; 00246 struct geom_fpath_block *block_last; 00247 byte *block_ptr; 00248 uns block_free; 00249 uns total_size; 00250 }; 00251 00252 struct geom_fpath_block { 00253 struct geom_fpath_block *prev; 00254 byte start; 00255 }; 00256 00257 00258 /*------------------------------------------------------------------------* 00259 * * 00260 * SPECIAL ITEMS * 00261 * * 00262 *------------------------------------------------------------------------*/ 00263 00264 struct geom_point_item { 00265 struct geom_item item; 00266 struct geom_point point; 00267 }; 00268 00269 struct geom_callback_item { 00270 struct geom_item item; 00271 int (*func)(struct geom_callback_item *, struct geom_fpath *); 00272 }; 00273 typedef int (geom_callback_item_func)(struct geom_callback_item *, struct geom_fpath *); 00274 00275 00276 /*------------------------------------------------------------------------* 00277 * * 00278 * PATHSET * 00279 * * 00280 *------------------------------------------------------------------------*/ 00281 00282 struct geom_pathset { 00283 struct geom_group group; 00284 }; 00285 00286 00287 00288 00290 struct geom_bezier_subdiv { 00291 uns count; 00292 uns size; 00293 struct geom_bezier_subdiv_item *items; 00294 }; 00295 00297 struct geom_bezier_subdiv_item { 00298 double left; 00299 double right; 00300 struct geom_bezier bezier; 00301 }; 00302 00303 00304 #define GEOM_INTERSECTION_POINT 0x00000001 00305 #define GEOM_INTERSECTION_TIME1 0x00000002 00306 #define GEOM_INTERSECTION_TIME2 0x00000004 00307 #define GEOM_INTERSECTION_ALL (GEOM_INTERSECTION_POINT | GEOM_INTERSECTION_TIME1 | GEOM_INTERSECTION_TIME2) 00308 00309 struct geom_intersection { 00310 struct geom_point point; 00311 real time1; 00312 real time2; 00313 }; 00314 00315 #define GEOM_NEAREST_POINT 0x00000001 00316 #define GEOM_NEAREST_TIME 0x00000002 00317 #define GEOM_NEAREST_DIST 0x00000004 00318 #define GEOM_NEAREST_ALL (GEOM_NEAREST_POINT | GEOM_NEAREST_TIME | GEOM_NEAREST_DIST) 00319 00320 struct geom_nearest { 00321 struct geom_point point; 00322 real time; 00323 real dist; 00324 }; 00325 00326 #define GEOM_CURVE_POINT_POINT 0x00000001 00327 #define GEOM_CURVE_POINT_TIME 0x00000002 00328 #define GEOM_CURVE_POINT_ALL (GEOM_CURVE_POINT_POINT | GEOM_CURVE_POINT_TIME) 00329 00330 struct geom_curve_point { 00331 struct geom_point point; 00332 real time; 00333 }; 00334 00335 00336 /*------------------------------------------------------------------------* 00337 * * 00338 * RTREE DEFINITIONS * 00339 * * 00340 *------------------------------------------------------------------------*/ 00341 00342 /* 00343 Limitations: 00344 2 <= GEOM_RTREE_MIN <= (GEOM_RTREE_MAX + 1) / 2 00345 0 <= GEOM_RTREE_REINSERT <= GEOM_RTREE_MAX - GEOM_RTREE_MIN + 1 00346 */ 00347 #define GEOM_RTREE_MIN 3 00349 #define GEOM_RTREE_MAX 5 00350 #define GEOM_RTREE_REINSERT 3 00353 struct geom_rtree { 00354 struct geom_rtree_node *root; 00355 clist lquery; 00356 }; 00357 00359 struct geom_rtree_obj { 00360 struct geom_rectangle bbox; 00361 struct geom_rtree_node *parent; 00362 }; 00363 00365 struct geom_rtree_node { 00366 struct geom_rectangle bbox; 00367 byte count; 00368 byte height; 00369 struct geom_rtree_node *parent; 00370 struct geom_rtree_node *child[GEOM_RTREE_MAX + 1]; 00371 }; 00372 00374 struct geom_rtree_query { 00375 struct geom_rtree *rtree; 00376 struct geom_rectangle box; 00377 cnode nquery; 00378 void *call_show; 00379 void *call_hide; 00380 void *call_update; 00381 }; 00382 00384 typedef void geom_rtree_query_callback(struct geom_rtree_query *query, struct geom_rtree_obj *obj, uns flags); 00385 00386 00387 /*------------------------------------------------------------------------* 00388 * * 00389 * CURVES APPROXIMATION * 00390 * * 00391 *------------------------------------------------------------------------*/ 00392 00394 struct geom_approx_item { 00395 uns type; 00396 double left; 00397 double right; 00398 union { 00399 /* substructure for any of GEOM_APPROX_BEZIER types */ 00400 struct { 00401 struct geom_bezier bezier; 00402 } bezier; 00403 00404 /* substructure for GEOM_APPROX_POINT type */ 00405 struct { 00406 struct geom_point point; 00407 } point; 00408 00409 /* substructure for GEOM_APPROX_ARC type */ 00410 struct { 00411 struct geom_point center; 00412 double radius; 00413 double angle_start; 00414 double angle_end; 00415 } arc; 00416 00417 /* substructure for GEOM_APPROX_ELLIPTIC_ARC type */ 00418 struct { 00419 struct geom_point center; 00420 double a_radius; 00421 double b_radius; 00422 double angle_start; 00423 double angle_end; 00424 double rotation; 00425 } el_arc; 00426 } data; 00427 }; 00428 00430 struct geom_approx { 00431 uns size; 00432 uns count; 00433 double right; 00434 struct geom_approx_item *items; 00435 }; 00436 00437 00438 /*------------------------------------------------------------------------* 00439 * * 00440 * MATRIX DEFINITION * 00441 * * 00442 *------------------------------------------------------------------------*/ 00443 00445 struct geom_matrix { 00446 uns m; 00447 uns n; 00448 uns w; 00449 double *data; 00450 }; 00451 00452 00453 /*------------------------------------------------------------------------* 00454 * * 00455 * CONIC SECTIONS * 00456 * * 00457 *------------------------------------------------------------------------*/ 00458 00460 enum geom_conic_type { 00461 GEOM_CONIC_PARABOLIC_ARC, 00462 GEOM_CONIC_ARC, 00463 GEOM_CONIC_ELLIPTIC_ARC, 00464 GEOM_CONIC_HYPERBOLIC_ARC 00465 }; 00466 00467 00469 struct geom_conic { 00470 enum geom_conic_type type; 00471 union { 00472 struct geom_parabolic_arc parabolic_arc; 00473 struct geom_arc arc; 00474 struct geom_elliptic_arc elliptic_arc; 00475 struct geom_hyperbolic_arc hyperbolic_arc; 00476 } data; 00477 }; 00478 00479 00480 #endif /* _VRR_GEOM_TYPES_H_ */ 00481
1.3.5