Previous: Compound paths, Up: GEOMLIB



5.8 Special curve types

The following classes are used in Kernel to allow a similar access to special graphical objects like points and decorators as well as to other curves. These types redefine necessary virtual functions of item class to support their Bézier expansion. Because of the specific GEOMLIB structure, all geometrical functions such as bounding boxes computing or arc lengths are automatically supported. A short implementation can can be found in geomlib/special.h and geomlib/special.c.

5.8.1 Point item

     struct geom_point_item {
       struct geom_item item; /* ancestor instance structure */
       struct geom_point point; /* a point in plane */
     };

The previous simple type offers the interface to single points in plane. Most of geometrical functions could be improved by a specialized implementation working without Bézier expansion.

5.8.2 Callback-expansion item

     struct geom_callback_item {
       struct geom_item item; /* ancestor instance structure */
       int (*func)(struct geom_callback_item *, struct geom_fpath *);
           /* expansion callback */
     };

An instance of the callback_item class can express any continuous curve, that can be expanded to a sequence of rational Bézier curves. When Bézier expansion is required, callback given by func pointer is executed. This routine should append the sequence of rational Bézier curves to the end of fpath (the path is in the first phase as described in Class fpath). If the computation raises an error, callback may return a negative error code which is propagated to all geometrical functions results. After a change to the curve is applied, user should invalidate possibly stored expansion by geom_item_after_change. The TIME parametrization of callback-expansion items equals BTIME (parametrization of the expansion).