]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/vehicle.h
Split vehicle placement code to a separate class
[r2c2.git] / source / libr2c2 / vehicle.h
index 1e9454fa5afb0fd2607099a72cbfc5c1e06de205..b1e9163f1019336045ed142c5c5ff91c01510a57 100644 (file)
@@ -4,6 +4,7 @@
 #include "geometry.h"
 #include "object.h"
 #include "trackoffsetiter.h"
+#include "vehicleplacement.h"
 #include "vehicletype.h"
 
 namespace R2C2 {
@@ -62,7 +63,7 @@ private:
        Train *train;
        Vehicle *next;
        Vehicle *prev;
-       TrackOffsetIter track;
+       VehiclePlacement placement;
        std::vector<Axle> axles;
        std::vector<Axle *> fixed_axles;
        std::vector<Bogie> bogies;
@@ -90,32 +91,26 @@ public:
        virtual void set_position(const Vector &) { }
        virtual void set_rotation(const Angle &) { }
        virtual void set_tilt(const Angle &) { }
-       void place(const TrackIter &, float, PlaceMode = CENTER);
+       void place(const TrackOffsetIter &, VehiclePlacement::Anchor = VehiclePlacement::CENTER);
        void unplace();
        void advance(float);
-       const TrackOffsetIter &get_track_iter() const { return track; }
-       Track *get_track() const { return track.track(); }
-       unsigned get_entry() const { return track.entry(); }
-       float get_offset() const { return track.offset(); }
+       const VehiclePlacement &get_placement() const { return placement; }
+       bool is_placed() const { return placement.is_placed(); }
        const Axle &get_axle(unsigned) const;
        const Axle &get_fixed_axle(unsigned) const;
        const Bogie &get_bogie(unsigned) const;
        const Axle &get_bogie_axle(unsigned, unsigned) const;
        const Rod &get_rod(unsigned) const;
 private:
-       void update_position();
+       void update_position(int);
        void update_position_from(const Vehicle &);
        void propagate_position();
        void propagate_forward();
        void propagate_backward();
-       void check_sensor(float, unsigned &);
+       void check_sensor(const TrackOffsetIter &, unsigned &, bool);
        void turn_axles(float);
        void update_rods();
 
-       void adjust_for_distance(TrackOffsetIter &, TrackOffsetIter &, float, float = 0.5) const;
-       OrientedPoint get_point(const Vector &, const Vector &, float = 0.5) const;
-       OrientedPoint get_point(const TrackOffsetIter &, float, float = 0.5) const;
-
 public:
        virtual unsigned get_n_link_slots() const;
        virtual Vehicle *get_link(unsigned) const;