]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/trackpart.h
e0f3144e3d348f582137079b338390c44f7e09ef
[r2c2.git] / source / libr2c2 / trackpart.h
1 #ifndef LIBR2C2_TRACKPART_H_
2 #define LIBR2C2_TRACKPART_H_
3
4 #include <msp/datafile/objectloader.h>
5 #include "geometry.h"
6
7 namespace R2C2 {
8
9 class TrackPart
10 {
11 public:
12         class Loader: public Msp::DataFile::ObjectLoader<TrackPart>
13         {
14         public:
15                 Loader(TrackPart &);
16         private:
17                 virtual void finish();
18                 void start(float, float, float);
19         };
20
21 private:
22         Vector pos;
23         Angle dir;
24         float length;
25         float radius;
26         unsigned path;
27         bool dead_end;
28         TrackPart *links[2];
29         Shape *shape;
30
31 public:
32         TrackPart();
33         ~TrackPart();
34
35         float get_length() const;
36         bool is_curved() const { return radius; }
37         OrientedPoint get_point(float) const;
38         OrientedPoint get_nearest_point(const Vector &) const;
39         unsigned get_path() const { return path; }
40         bool is_dead_end() const { return dead_end; }
41         void check_link(TrackPart &);
42         TrackPart *get_link(unsigned) const;
43         void create_shape();
44         const Shape &get_shape() const { return *shape; }
45 };
46
47 } // namespace R2C2
48
49 #endif