Code

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