Code

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