]> git.tdb.fi Git - r2c2.git/blob - source/3d/catalogue.h
Convert Catalogue to a Collection
[r2c2.git] / source / 3d / catalogue.h
1 #ifndef R2C2_3D_CATALOGUE_H_
2 #define R2C2_3D_CATALOGUE_H_
3
4 #include <msp/datafile/collection.h>
5 #include <msp/datafile/directorysource.h>
6 #include <msp/gl/mesh.h>
7 #include <msp/gl/resources.h>
8 #include "libr2c2/catalogue.h"
9 #include "typemap.h"
10
11 namespace R2C2 {
12
13 class ObjectType3D;
14
15 class Catalogue3D: public Msp::GL::Resources
16 {
17 private:
18         typedef std::map<const ObjectType *, ObjectType3D *> ObjectMap;
19         typedef std::map<const TrackAppearance *, Msp::GL::Mesh *> EndpointMap;
20
21         Catalogue &catalogue;
22         Msp::DataFile::DirectorySource src;
23         ObjectMap objects;
24         EndpointMap endpoint_meshes;
25
26 public:
27         Catalogue3D(Catalogue &);
28         ~Catalogue3D();
29
30         const Catalogue &get_catalogue() const { return catalogue; }
31
32         const ObjectType3D &get_3d(const ObjectType &);
33         const ObjectType3D &get_3d(const ObjectType &) const;
34
35         template<typename T>
36         const typename TypeMap3D<T>::Type3D &get_3d(const T &ot) const
37         { return dynamic_cast<const typename TypeMap3D<T>::Type3D &>(get_3d(static_cast<const ObjectType &>(ot))); }
38
39         template<typename T>
40         const typename TypeMap3D<T>::Type3D &get_3d(const T &ot)
41         { return dynamic_cast<const typename TypeMap3D<T>::Type3D &>(get_3d(static_cast<const ObjectType &>(ot))); }
42
43 private:
44         void build_endpoint_mesh(const TrackAppearance &);
45 public:
46         const Msp::GL::Mesh &get_endpoint_mesh(const TrackAppearance &);
47         const Msp::GL::Mesh &get_endpoint_mesh(const TrackAppearance &) const;
48 };
49
50 }
51
52 #endif