Code

first set of updates to headers for clean gcc 4.3 builds
[inkscape.git] / src / libnr / n-art-bpath.h
1 #ifndef SEEN_LIBNR_N_ART_BPATH_H
2 #define SEEN_LIBNR_N_ART_BPATH_H
4 /** \file
5  * NArtBpath: old-style path segment.
6  */
8 #include <stdlib.h>
10 #include "libnr/nr-point.h"
11 #include "libnr/nr-path-code.h"
13 /**
14  * Old-style path segment.
15  *
16  * Arrays of paths segment start with a MOVETO or MOVETO_OPEN segment
17  * where the former indicates the beginning of a closed subpath.
18  * \see subpath_from_bpath()
19  */
20 class NArtBpath {
21 public:
22     NRPathcode code; ///< Type of segment
23     double x1, y1;   ///< Position of control point in case of NR_CURVETO
24     double x2, y2;   ///< Position of control point in case of NR_CURVETO
25     double x3, y3;   ///< Position of next point
27     /// Convert i-th position data pair to Point object
28     /// \pre 1 <= i <= 3
29     NR::Point c(unsigned const i) const {
30         switch (i) {
31             case 1: return NR::Point(x1, y1);
32             case 2: return NR::Point(x2, y2);
33             case 3: return NR::Point(x3, y3);
34             default: abort();
35         }
36     }
38     /// Set i-th position data pair from Point
39     /// \pre 1 <= i <= 3
40     void setC(unsigned const i, NR::Point const &p) {
41         using NR::X; using NR::Y;
42         switch (i) {
43             case 1: x1 = p[X]; y1 = p[Y]; break;
44             case 2: x2 = p[X]; y2 = p[Y]; break;
45             case 3: x3 = p[X]; y3 = p[Y]; break;
46             default: abort();
47         }
48     }
49 };
52 #endif /* !SEEN_LIBNR_N_ART_BPATH_H */
54 /*
55   Local Variables:
56   mode:c++
57   c-file-style:"stroustrup"
58   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
59   indent-tabs-mode:nil
60   fill-column:99
61   End:
62 */
63 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :