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<bogie_objects.size(); ++i)
- bogie_objects[i] = get_object(vt.get_bogies()[i].object);
+ const vector<VehicleType::Axle> &axles = vt.get_axles();
+ for(vector<VehicleType::Axle>::const_iterator i=axles.begin(); i!=axles.end(); ++i)
+ axle_objects[0].push_back(get_object(i->object));
+
+ const vector<VehicleType::Bogie> &bogies = vt.get_bogies();
+ for(vector<VehicleType::Bogie>::const_iterator i=bogies.begin(); i!=bogies.end(); ++i)
+ {
+ bogie_objects.push_back(get_object(i->object));
+ axle_objects.push_back(vector<GL::Object *>());
+ for(vector<VehicleType::Axle>::const_iterator j=i->axles.begin(); j!=i->axles.end(); ++j)
+ axle_objects.back().push_back(get_object(j->object));
+ }
}
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
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)