]> git.tdb.fi Git - r2c2.git/blob - source/3d/catalogue.cpp
Split mesh generation from Track3D to TrackType3D
[r2c2.git] / source / 3d / catalogue.cpp
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #include "catalogue.h"
9 #include "tracktype.h"
10
11 using namespace std;
12 using namespace Msp;
13
14 namespace Marklin {
15
16 Catalogue3D::Catalogue3D(const Catalogue &c):
17         catalogue(c)
18 {
19         const map<unsigned, TrackType *> &trks = catalogue.get_tracks();
20         for(map<unsigned, TrackType *>::const_iterator i=trks.begin(); i!=trks.end(); ++i)
21                 tracks[i->second] = new TrackType3D(*this, *i->second);
22 }
23
24 const TrackType3D &Catalogue3D::get_track(const TrackType &tt) const
25 {
26         map<const TrackType *, TrackType3D *>::const_iterator i = tracks.find(&tt);
27         if(i==tracks.end())
28                 throw KeyError("Unknown track type");
29
30         return *i->second;
31 }
32
33 } // namespace Marklin