X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftracktype.h;h=c1963c42d8444a0628219c4eadda4c1507ad6171;hb=508ee4bfcc0f8fb1373fb7af251c59c873ef896f;hp=1b1c78ce998de86b736d252774643bce2346bfba;hpb=64340dad429ba4040538fc06b6882aabdb489925;p=r2c2.git diff --git a/source/libr2c2/tracktype.h b/source/libr2c2/tracktype.h index 1b1c78c..c1963c4 100644 --- a/source/libr2c2/tracktype.h +++ b/source/libr2c2/tracktype.h @@ -2,41 +2,51 @@ #define LIBR2C2_TRACKTYPE_H_ #include -#include "articlenumber.h" #include "geometry.h" +#include "objecttype.h" #include "trackpart.h" namespace R2C2 { -class TrackType +class TrackAppearance; + +class TrackType: public ObjectType { public: struct Endpoint { Vector pos; - float dir; // Direction outwards from the endpoint + Angle dir; // Direction outwards from the endpoint unsigned paths; - Endpoint(float, float, float, unsigned); + Endpoint(float, float, const Angle &, unsigned); + + bool has_path(unsigned p) const { return paths&(1< + class Loader: public Msp::DataFile::DerivedObjectLoader { + public: + typedef Msp::DataFile::Collection Collection; + private: + Collection &coll; bool state_bits_set; public: - Loader(TrackType &); + Loader(TrackType &, Collection &); + + virtual Collection &get_collection() const { return coll; } private: virtual void finish(); + void appearance(const std::string &); void part(); - void position(float, float, float); void state_bits(unsigned); }; private: - ArticleNumber art_nr; - std::string description; + const TrackAppearance *appearance; std::vector parts; std::vector endpoints; unsigned state_bits; @@ -44,14 +54,15 @@ private: std::string object; public: - TrackType(const ArticleNumber &); + TrackType(); - const ArticleNumber &get_article_number() const { return art_nr; } - const std::string &get_description() const { return description; } + const TrackAppearance &get_appearance() const; + float get_gauge() const; float get_total_length() const; float get_path_length(int) const; unsigned get_paths() const; unsigned get_n_paths() const; + unsigned coerce_path(unsigned, unsigned) const; unsigned get_state_bits() const { return state_bits; } bool is_turnout() const; bool is_dead_end() const; @@ -60,8 +71,8 @@ public: const std::vector &get_parts() const { return parts; } const std::vector &get_endpoints() const { return endpoints; } const Endpoint &get_endpoint(unsigned) const; - TrackPoint get_point(unsigned, unsigned, float) const; - bool collide_ray(const Vector &, const Vector &, float) const; + OrientedPoint get_point(unsigned, unsigned, float) const; + OrientedPoint get_nearest_point(const Vector &) const; private: void collect_endpoints();