MeshManager.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00023 #ifndef _MESHMANAGER_H
00024 #define _MESHMANAGER_H
00025 
00026 #include "PT/Panorama.h"
00027 
00028 #include "MeshRemapper.h"
00029 
00030 class MeshRemapper;
00031 class VisualizationState;
00032 
00037 class MeshManager
00038 {
00039 public:
00040     MeshManager(PT::Panorama *pano, VisualizationState *visualization_state);
00041     ~MeshManager();
00042 
00043     void CheckUpdate();
00044     
00046     void CleanMeshes();
00047     void RenderMesh(unsigned int image_number) const;
00048     unsigned int GetDisplayList(unsigned int image_number) const;
00049     
00057     void SetLayoutMode(bool state);
00058     void SetLayoutScale(double scale);
00059 
00062     class MeshInfo
00063     {
00064     public:
00073         MeshInfo(PT::Panorama * m_pano, HuginBase::SrcPanoImage * image,
00074                  VisualizationState * visualization_state, bool layout_mode_on);
00078         MeshInfo(const MeshInfo & source);
00079         ~MeshInfo();
00081         void CallList() const;
00083         void Update();
00084         unsigned int display_list_number;
00085         void SetScaleFactor(double scale);
00086         void SetSrcImage(HuginBase::SrcPanoImage * image) {this->image = *image;}
00087 
00091         class Coord3D
00092         {
00093             public:
00094                 Coord3D() {}
00095                 Coord3D(hugin_utils::FDiff2D & coord) {x = coord.x; y = coord.y; z = 0;}
00096                 double x,y,z;
00097         };
00098 
00102         class MeshCoords3D {
00103         public:
00104             MeshCoords3D() {}
00105             MeshCoords3D(const MeshRemapper::Coords & coords);
00106             double tex_coords[2][2][2];
00107             double vertex_coords[2][2][3];
00108         };
00109 
00110         
00111     protected:
00112 
00113         virtual void BeforeCompile() {}
00114         virtual void Transform() {}
00115         virtual void AfterCompile() {}
00116     
00117         HuginBase::SrcPanoImage image;
00118         PT::Panorama *m_pano;
00119         double scale_factor;
00120         VisualizationState *m_visualization_state;
00122         MeshRemapper * remap;
00124         void CompileList();
00125         bool layout_mode_on;
00126     };
00127 
00132     class PreviewMeshInfo : public MeshInfo
00133     {
00134     public:
00135         PreviewMeshInfo(PT::Panorama * m_pano, HuginBase::SrcPanoImage * image,
00136                  VisualizationState * visualization_state, bool layout_mode_on) : MeshInfo(m_pano, image, visualization_state, layout_mode_on) {
00137             Update();
00138         }
00139         PreviewMeshInfo(const PreviewMeshInfo & source) : MeshInfo((MeshInfo)source) {
00140             Update();
00141         }
00142 
00143         static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState * state) {return MeshCoords3D(coords);}
00144         static Coord3D GetCoord3D(hugin_utils::FDiff2D & coord, VisualizationState * state) {return Coord3D(coord);}
00145 
00146     };
00147 
00152     class PanosphereOverviewMeshInfo : public MeshInfo
00153     {
00154     public:
00155         PanosphereOverviewMeshInfo(PT::Panorama * m_pano, HuginBase::SrcPanoImage * image,
00156                  VisualizationState * visualization_state, bool layout_mode_on)
00157             : MeshInfo(m_pano, image, visualization_state, layout_mode_on) {
00158                 scale_factor *= scale_diff;
00159                 Update();
00160             }
00161 
00162         PanosphereOverviewMeshInfo(const PanosphereOverviewMeshInfo & source)
00163             : MeshInfo((MeshInfo) source) {
00164                 Update();
00165             }
00166 
00170         static void Convert(double &x, double &y, double &z, double th, double ph, double r);
00171 
00172         static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState * state);
00173         static Coord3D GetCoord3D(hugin_utils::FDiff2D &coord, VisualizationState * state);
00174 
00176         static const double scale_diff;
00177 
00178     protected:
00179 
00180         void BeforeCompile();
00181         void Transform();
00182         void AfterCompile();
00183 
00184         double yaw,pitch;
00185 
00186     };
00187 
00191     class PlaneOverviewMeshInfo : public MeshInfo
00192     {
00193     public:
00194         PlaneOverviewMeshInfo(PT::Panorama * m_pano, HuginBase::SrcPanoImage * image,
00195                  VisualizationState * visualization_state, bool layout_mode_on)
00196             : MeshInfo(m_pano, image, visualization_state, layout_mode_on) {
00197                 Update();
00198             }
00199 
00200         PlaneOverviewMeshInfo(const PlaneOverviewMeshInfo & source)
00201             : MeshInfo((MeshInfo) source) {
00202                 Update();
00203             }
00204 
00205         const static double scale;
00206         static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState * state);
00207         static Coord3D GetCoord3D(hugin_utils::FDiff2D &coord, VisualizationState * state);
00208 
00209     };
00210     
00211     virtual MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords) = 0;
00212     virtual MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &) = 0;
00213     
00214 
00215     virtual MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on) = 0;
00216 
00217 protected:
00218 
00219 
00220     PT::Panorama  * m_pano;
00221     VisualizationState * visualization_state;
00222 
00223     
00224     std::vector<MeshInfo*> meshes;
00225     bool layout_mode_on;
00226 };
00227 
00228 
00229 class PanosphereOverviewMeshManager : public MeshManager
00230 {
00231 public:
00232     PanosphereOverviewMeshManager(PT::Panorama *pano, VisualizationState *visualization_state) : MeshManager(pano, visualization_state) {}
00233     MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords) {return MeshManager::PanosphereOverviewMeshInfo::GetMeshCoords3D(coords, visualization_state);}
00234     MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &coord) {return MeshManager::PanosphereOverviewMeshInfo::GetCoord3D(coord,visualization_state);}
00235 
00236     MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on);
00237 };
00238 
00239 class PlaneOverviewMeshManager : public MeshManager
00240 {
00241 public:
00242     PlaneOverviewMeshManager(PT::Panorama *pano, VisualizationState *visualization_state) : MeshManager(pano, visualization_state) {}
00243     MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords) {return MeshManager::PlaneOverviewMeshInfo::GetMeshCoords3D(coords, visualization_state);}
00244     MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &coord) {return MeshManager::PlaneOverviewMeshInfo::GetCoord3D(coord,visualization_state);}
00245 
00246     MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on);
00247 
00248 };
00249 
00250 class PreviewMeshManager : public MeshManager
00251 {
00252 public:
00253     PreviewMeshManager(PT::Panorama *pano, VisualizationState *visualization_state) : MeshManager(pano, visualization_state) {}
00254     MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords) {return MeshManager::PreviewMeshInfo::GetMeshCoords3D(coords, visualization_state);}
00255     MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &coord) {return MeshManager::PreviewMeshInfo::GetCoord3D(coord,visualization_state);}
00256 
00257     MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on);
00258 
00259 };
00260 
00261 
00262 #endif
00263 

Generated on 26 Oct 2014 for Hugintrunk by  doxygen 1.4.7