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 TrackAppearance;
14 class TrackType: public ObjectType
20 Angle dir; // Direction outwards from the endpoint
23 Endpoint(float, float, const Angle &, unsigned);
25 bool has_path(unsigned p) const { return paths&(1<<p); }
26 bool has_common_paths(const Endpoint &e) const { return paths&e.paths; }
29 class Loader: public Msp::DataFile::DerivedObjectLoader<TrackType, ObjectType::Loader>
37 virtual void finish();
39 void position(float, float, float);
40 void state_bits(unsigned);
44 const TrackAppearance &appearance;
45 std::vector<TrackPart> parts;
46 std::vector<Endpoint> endpoints;
48 unsigned autofit_preference;
52 TrackType(const ArticleNumber &, const TrackAppearance &);
54 const TrackAppearance &get_appearance() const { return appearance; }
55 float get_total_length() const;
56 float get_path_length(int) const;
57 unsigned get_paths() const;
58 unsigned get_n_paths() const;
59 unsigned coerce_path(unsigned, unsigned) const;
60 unsigned get_state_bits() const { return state_bits; }
61 bool is_turnout() const;
62 bool is_dead_end() const;
63 unsigned get_autofit_preference() const { return autofit_preference; }
64 const std::string &get_object() const { return object; }
65 const std::vector<TrackPart> &get_parts() const { return parts; }
66 const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
67 const Endpoint &get_endpoint(unsigned) const;
68 OrientedPoint get_point(unsigned, unsigned, float) const;
69 OrientedPoint get_nearest_point(const Vector &) const;
72 void collect_endpoints();