1 #ifndef LIBR2C2_TRACKTYPE_H_
2 #define LIBR2C2_TRACKTYPE_H_
4 #include <msp/datafile/objectloader.h>
5 #include "articlenumber.h"
7 #include "objecttype.h"
12 class TrackType: public ObjectType
18 Angle dir; // Direction outwards from the endpoint
21 Endpoint(float, float, const Angle &, unsigned);
23 bool has_path(unsigned p) const { return paths&(1<<p); }
24 bool has_common_paths(const Endpoint &e) const { return paths&e.paths; }
27 class Loader: public Msp::DataFile::DerivedObjectLoader<TrackType, ObjectType::Loader>
35 virtual void finish();
37 void position(float, float, float);
38 void state_bits(unsigned);
42 std::vector<TrackPart> parts;
43 std::vector<Endpoint> endpoints;
45 unsigned autofit_preference;
49 TrackType(const ArticleNumber &);
51 float get_total_length() const;
52 float get_path_length(int) const;
53 unsigned get_paths() const;
54 unsigned get_n_paths() const;
55 unsigned get_state_bits() const { return state_bits; }
56 bool is_turnout() const;
57 bool is_dead_end() const;
58 unsigned get_autofit_preference() const { return autofit_preference; }
59 const std::string &get_object() const { return object; }
60 const std::vector<TrackPart> &get_parts() const { return parts; }
61 const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
62 const Endpoint &get_endpoint(unsigned) const;
63 OrientedPoint get_point(unsigned, unsigned, float) const;
64 OrientedPoint get_nearest_point(const Vector &) const;
67 void collect_endpoints();