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 "panodata/Panorama.h"
00027 
00028 #include "MeshRemapper.h"
00029 
00030 class MeshRemapper;
00031 class VisualizationState;
00032 
00037 class MeshManager
00038 {
00039 public:
00040     MeshManager(HuginBase::Panorama *pano, VisualizationState *visualization_state);
00041     virtual ~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);
00059     bool GetLayoutMode() const;
00060     void SetLayoutScale(double scale);
00061 
00064     class MeshInfo
00065     {
00066     public:
00075         MeshInfo(HuginBase::Panorama * m_pano, HuginBase::SrcPanoImage * image,
00076                  VisualizationState * visualization_state, bool layout_mode_on);
00080         MeshInfo(const MeshInfo & source);
00081         virtual ~MeshInfo();
00083         void CallList() const;
00085         void Update();
00086         unsigned int display_list_number;
00087         void SetScaleFactor(double scale);
00088         void SetSrcImage(HuginBase::SrcPanoImage * image) {this->image = *image;}
00089 
00093         class Coord3D
00094         {
00095             public:
00096                 Coord3D() {}
00097                 explicit Coord3D(hugin_utils::FDiff2D & coord) {x = coord.x; y = coord.y; z = 0;}
00098                 double x,y,z;
00099         };
00100 
00104         class MeshCoords3D {
00105         public:
00106             MeshCoords3D() {}
00107             explicit MeshCoords3D(const MeshRemapper::Coords & coords);
00108             double tex_coords[2][2][2];
00109             double vertex_coords[2][2][3];
00110         };
00111 
00112         
00113     protected:
00114 
00115         virtual void BeforeCompile() {}
00116         virtual void Transform() {}
00117         virtual void AfterCompile() {}
00118     
00119         HuginBase::SrcPanoImage image;
00120         HuginBase::Panorama *m_pano;
00121         double scale_factor;
00122         VisualizationState *m_visualization_state;
00124         MeshRemapper * remap;
00126         void CompileList();
00127         bool layout_mode_on;
00128     };
00129 
00134     class PreviewMeshInfo : public MeshInfo
00135     {
00136     public:
00137         PreviewMeshInfo(HuginBase::Panorama * m_pano, HuginBase::SrcPanoImage * image,
00138                  VisualizationState * visualization_state, bool layout_mode_on) : MeshInfo(m_pano, image, visualization_state, layout_mode_on) {
00139             Update();
00140         }
00141         PreviewMeshInfo(const PreviewMeshInfo & source) : MeshInfo((MeshInfo)source) {
00142             Update();
00143         }
00144 
00145         static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState * state) {return MeshCoords3D(coords);}
00146         static Coord3D GetCoord3D(hugin_utils::FDiff2D & coord, VisualizationState * state) {return Coord3D(coord);}
00147 
00148     };
00149 
00154     class PanosphereOverviewMeshInfo : public MeshInfo
00155     {
00156     public:
00157         PanosphereOverviewMeshInfo(HuginBase::Panorama * m_pano, HuginBase::SrcPanoImage * image,
00158                  VisualizationState * visualization_state, bool layout_mode_on)
00159             : MeshInfo(m_pano, image, visualization_state, layout_mode_on) {
00160                 scale_factor *= scale_diff;
00161                 Update();
00162             }
00163 
00164         PanosphereOverviewMeshInfo(const PanosphereOverviewMeshInfo & source)
00165             : MeshInfo((MeshInfo) source) {
00166                 Update();
00167             }
00168 
00172         static void Convert(double &x, double &y, double &z, double th, double ph, double r);
00173 
00174         static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState * state);
00175         static Coord3D GetCoord3D(hugin_utils::FDiff2D &coord, VisualizationState * state);
00176 
00178         static const double scale_diff;
00179 
00180     protected:
00181 
00182         void BeforeCompile();
00183         void Transform();
00184         void AfterCompile();
00185 
00186         double yaw,pitch;
00187 
00188     };
00189 
00193     class PlaneOverviewMeshInfo : public MeshInfo
00194     {
00195     public:
00196         PlaneOverviewMeshInfo(HuginBase::Panorama * m_pano, HuginBase::SrcPanoImage * image,
00197                  VisualizationState * visualization_state, bool layout_mode_on)
00198             : MeshInfo(m_pano, image, visualization_state, layout_mode_on) {
00199                 Update();
00200             }
00201 
00202         PlaneOverviewMeshInfo(const PlaneOverviewMeshInfo & source)
00203             : MeshInfo((MeshInfo) source) {
00204                 Update();
00205             }
00206 
00207         const static double scale;
00208         static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState * state);
00209         static Coord3D GetCoord3D(hugin_utils::FDiff2D &coord, VisualizationState * state);
00210 
00211     };
00212     
00213     virtual MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords) = 0;
00214     virtual MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &) = 0;
00215     
00216 
00217     virtual MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on) = 0;
00218 
00219 protected:
00220 
00221 
00222     HuginBase::Panorama  * m_pano;
00223     VisualizationState * visualization_state;
00224 
00225     
00226     std::vector<MeshInfo*> meshes;
00227     bool layout_mode_on;
00228 };
00229 
00230 
00231 class PanosphereOverviewMeshManager : public MeshManager
00232 {
00233 public:
00234     PanosphereOverviewMeshManager(HuginBase::Panorama *pano, VisualizationState *visualization_state) : MeshManager(pano, visualization_state) {}
00235     MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords) {return MeshManager::PanosphereOverviewMeshInfo::GetMeshCoords3D(coords, visualization_state);}
00236     MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &coord) {return MeshManager::PanosphereOverviewMeshInfo::GetCoord3D(coord,visualization_state);}
00237 
00238     MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on);
00239 };
00240 
00241 class PlaneOverviewMeshManager : public MeshManager
00242 {
00243 public:
00244     PlaneOverviewMeshManager(HuginBase::Panorama *pano, VisualizationState *visualization_state) : MeshManager(pano, visualization_state) {}
00245     MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords) {return MeshManager::PlaneOverviewMeshInfo::GetMeshCoords3D(coords, visualization_state);}
00246     MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &coord) {return MeshManager::PlaneOverviewMeshInfo::GetCoord3D(coord,visualization_state);}
00247 
00248     MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on);
00249 
00250 };
00251 
00252 class PreviewMeshManager : public MeshManager
00253 {
00254 public:
00255     PreviewMeshManager(HuginBase::Panorama *pano, VisualizationState *visualization_state) : MeshManager(pano, visualization_state) {}
00256     MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords) {return MeshManager::PreviewMeshInfo::GetMeshCoords3D(coords, visualization_state);}
00257     MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &coord) {return MeshManager::PreviewMeshInfo::GetCoord3D(coord,visualization_state);}
00258 
00259     MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on);
00260 
00261 };
00262 
00263 
00264 #endif
00265 

Generated on 10 Dec 2016 for Hugintrunk by  doxygen 1.4.7