X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Fvehicletype.cpp;h=be6b985be828df81ed6bdf8a1288af638686dc81;hb=9abaa89f495307c7e90cbef51ae0fedbaff001db;hp=91c123866de22888bd67e8ed725bc92e6b080741;hpb=7ff28ec88dedc3a2327feb4a507ae622cb953113;p=r2c2.git diff --git a/source/3d/vehicletype.cpp b/source/3d/vehicletype.cpp index 91c1238..be6b985 100644 --- a/source/3d/vehicletype.cpp +++ b/source/3d/vehicletype.cpp @@ -17,12 +17,22 @@ namespace Marklin { VehicleType3D::VehicleType3D(Catalogue3D &, const VehicleType &vt): body_object(0), - bogie_objects(vt.get_bogies().size()) + axle_objects(1) { body_object = get_object(vt.get_object()); - for(unsigned i=0; i &axles = vt.get_axles(); + for(vector::const_iterator i=axles.begin(); i!=axles.end(); ++i) + axle_objects[0].push_back(get_object(i->object)); + + const vector &bogies = vt.get_bogies(); + for(vector::const_iterator i=bogies.begin(); i!=bogies.end(); ++i) + { + bogie_objects.push_back(get_object(i->object)); + axle_objects.push_back(vector()); + for(vector::const_iterator j=i->axles.begin(); j!=i->axles.end(); ++j) + axle_objects.back().push_back(get_object(j->object)); + } } VehicleType3D::~VehicleType3D() @@ -31,9 +41,11 @@ VehicleType3D::~VehicleType3D() delete i->second; } -const GL::Object *VehicleType3D::get_axle_object(unsigned) const +const GL::Object *VehicleType3D::get_axle_object(unsigned i) const { - return 0; + if(i>=axle_objects[0].size()) + throw InvalidParameterValue("Axle index out of range"); + return axle_objects[0][i]; } const GL::Object *VehicleType3D::get_bogie_object(unsigned i) const @@ -43,9 +55,13 @@ const GL::Object *VehicleType3D::get_bogie_object(unsigned i) const return bogie_objects[i]; } -const GL::Object *VehicleType3D::get_bogie_axle_object(unsigned, unsigned) const +const GL::Object *VehicleType3D::get_bogie_axle_object(unsigned i, unsigned j) const { - return 0; + if(i>=bogie_objects.size()) + throw InvalidParameterValue("Bogie index out of range"); + if(j>=axle_objects[i+1].size()) + throw InvalidParameterValue("Axle index out of range"); + return axle_objects[i+1][j]; } GL::Object *VehicleType3D::get_object(const string &name)