X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftracktype.h;h=9d167d18c7c91822ebd25b1dd047fc8a6233309e;hb=2875ea548e0567ad2ce1b8f9bda58e6452813204;hp=9c4865f1ff3f655bd8578a98ae200ab46bc866d4;hpb=c5f5ec54e81a6a85f911fa1075a0939a7352fbfd;p=r2c2.git diff --git a/source/libr2c2/tracktype.h b/source/libr2c2/tracktype.h index 9c4865f..9d167d1 100644 --- a/source/libr2c2/tracktype.h +++ b/source/libr2c2/tracktype.h @@ -1,33 +1,32 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #ifndef LIBR2C2_TRACKTYPE_H_ #define LIBR2C2_TRACKTYPE_H_ -#include +#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 { - Point pos; - float dir; // Direction outwards from the endpoint + Vector pos; + 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 { private: bool state_bits_set; @@ -42,8 +41,7 @@ public: }; private: - ArticleNumber art_nr; - std::string description; + const TrackAppearance &appearance; std::vector parts; std::vector endpoints; unsigned state_bits; @@ -51,14 +49,15 @@ private: std::string object; public: - TrackType(const ArticleNumber &); + TrackType(const ArticleNumber &, const TrackAppearance &); - const ArticleNumber &get_article_number() const { return art_nr; } - const std::string &get_description() const { return description; } + const TrackAppearance &get_appearance() const { return appearance; } + 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; @@ -67,7 +66,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; + OrientedPoint get_point(unsigned, unsigned, float) const; + OrientedPoint get_nearest_point(const Vector &) const; private: void collect_endpoints();