Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeshManager.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
23 #ifndef _MESHMANAGER_H
24 #define _MESHMANAGER_H
25 
26 #include "panodata/Panorama.h"
27 
28 #include "MeshRemapper.h"
29 
30 class MeshRemapper;
31 class VisualizationState;
32 
38 {
39 public:
41  virtual ~MeshManager();
42 
43  void CheckUpdate();
44 
46  void CleanMeshes();
47  void RenderMesh(unsigned int image_number) const;
48  unsigned int GetDisplayList(unsigned int image_number) const;
49 
57  void SetLayoutMode(bool state);
59  bool GetLayoutMode() const;
60  void SetLayoutScale(double scale);
61 
64  class MeshInfo
65  {
66  public:
76  VisualizationState * visualization_state, bool layout_mode_on);
80  MeshInfo(const MeshInfo & source);
81  virtual ~MeshInfo();
83  void CallList() const;
85  void Update();
86  unsigned int display_list_number;
87  void SetScaleFactor(double scale);
88  void SetSrcImage(HuginBase::SrcPanoImage * image) {this->image = *image;}
89 
93  class Coord3D
94  {
95  public:
96  Coord3D() {}
97  explicit Coord3D(hugin_utils::FDiff2D & coord) {x = coord.x; y = coord.y; z = 0;}
98  double x,y,z;
99  };
100 
104  class MeshCoords3D {
105  public:
107  explicit MeshCoords3D(const MeshRemapper::Coords & coords);
108  double tex_coords[2][2][2];
109  double vertex_coords[2][2][3];
110  };
111 
112 
113  protected:
114 
115  virtual void BeforeCompile() {}
116  virtual void Transform() {}
117  virtual void AfterCompile() {}
118 
121  double scale_factor;
126  void CompileList();
128  };
129 
134  class PreviewMeshInfo : public MeshInfo
135  {
136  public:
138  VisualizationState * visualization_state, bool layout_mode_on) : MeshInfo(m_pano, image, visualization_state, layout_mode_on) {
139  Update();
140  }
141  PreviewMeshInfo(const PreviewMeshInfo & source) : MeshInfo((MeshInfo)source) {
142  Update();
143  }
144 
146  static Coord3D GetCoord3D(hugin_utils::FDiff2D & coord, VisualizationState * state) {return Coord3D(coord);}
147 
148  };
149 
155  {
156  public:
158  VisualizationState * visualization_state, bool layout_mode_on)
159  : MeshInfo(m_pano, image, visualization_state, layout_mode_on) {
161  Update();
162  }
163 
165  : MeshInfo((MeshInfo) source) {
166  Update();
167  }
168 
172  static void Convert(double &x, double &y, double &z, double th, double ph, double r);
173 
174  static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState * state);
175  static Coord3D GetCoord3D(hugin_utils::FDiff2D &coord, VisualizationState * state);
176 
178  static const double scale_diff;
179 
180  protected:
181 
182  void BeforeCompile();
183  void Transform();
184  void AfterCompile();
185 
186  double yaw,pitch;
187 
188  };
189 
194  {
195  public:
197  VisualizationState * visualization_state, bool layout_mode_on)
198  : MeshInfo(m_pano, image, visualization_state, layout_mode_on) {
199  Update();
200  }
201 
203  : MeshInfo((MeshInfo) source) {
204  Update();
205  }
206 
207  const static double scale;
210 
211  };
212 
215 
216 
218 
219 protected:
220 
221 
224 
225 
226  std::vector<MeshInfo*> meshes;
228 };
229 
230 
232 {
233 public:
237 
239 };
240 
242 {
243 public:
247 
249 
250 };
251 
253 {
254 public:
258 
260 
261 };
262 
263 
264 #endif
265 
a subclass for the panosphere it converts coordinates obtained from an equirectangular projection to ...
Definition: MeshManager.h:154
PlaneOverviewMeshInfo(const PlaneOverviewMeshInfo &source)
Definition: MeshManager.h:202
An abstract base class for objects that calculate an approximate remap specified by quadrilatrials...
Definition: MeshRemapper.h:43
MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords)
Definition: MeshManager.h:256
PanosphereOverviewMeshInfo(HuginBase::Panorama *m_pano, HuginBase::SrcPanoImage *image, VisualizationState *visualization_state, bool layout_mode_on)
Definition: MeshManager.h:157
MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords)
Definition: MeshManager.h:245
MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on)
MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &coord)
Definition: MeshManager.h:236
void CompileList()
Use the remapper to create the display list.
MeshInfo(HuginBase::Panorama *m_pano, HuginBase::SrcPanoImage *image, VisualizationState *visualization_state, bool layout_mode_on)
Constructor: Creates the mesh for a given image of a panorama.
subclass for the plane overview mode.
Definition: MeshManager.h:193
PlaneOverviewMeshManager(HuginBase::Panorama *pano, VisualizationState *visualization_state)
Definition: MeshManager.h:244
A class for exchanging pointers to coordinates.
Definition: MeshRemapper.h:60
PreviewMeshManager(HuginBase::Panorama *pano, VisualizationState *visualization_state)
Definition: MeshManager.h:255
void SetSrcImage(HuginBase::SrcPanoImage *image)
Definition: MeshManager.h:88
void SetLayoutScale(double scale)
PreviewMeshInfo(const PreviewMeshInfo &source)
Definition: MeshManager.h:141
MeshRemapper * remap
The ramapper we should use.
Definition: MeshManager.h:124
static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState *state)
PlaneOverviewMeshInfo(HuginBase::Panorama *m_pano, HuginBase::SrcPanoImage *image, VisualizationState *visualization_state, bool layout_mode_on)
Definition: MeshManager.h:196
bool GetLayoutMode() const
return if layout mode is active
MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &coord)
Definition: MeshManager.h:246
virtual void AfterCompile()
Definition: MeshManager.h:117
unsigned int display_list_number
Definition: MeshManager.h:86
virtual ~MeshManager()
Definition: MeshManager.cpp:63
HuginBase::SrcPanoImage image
Definition: MeshManager.h:119
Model for a panorama.
Definition: Panorama.h:152
bool layout_mode_on
Definition: MeshManager.h:227
MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on)
HuginBase::Panorama * m_pano
Definition: MeshManager.h:120
HuginBase::Panorama * m_pano
Definition: MeshManager.h:222
std::vector< MeshInfo * > meshes
Definition: MeshManager.h:226
void Update()
Recreate the mesh when the image or panorama it represents changes.
virtual void Transform()
Definition: MeshManager.h:116
static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState *state)
Definition: MeshManager.h:145
static void Convert(double &x, double &y, double &z, double th, double ph, double r)
convert from spherical to cartesian coordinates
void CleanMeshes()
Remove meshes for images that have been deleted.
virtual MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &)=0
MeshInfo::Coord3D GetCoord3D(hugin_utils::FDiff2D &coord)
Definition: MeshManager.h:257
MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords)
Definition: MeshManager.h:235
PanosphereOverviewMeshManager(HuginBase::Panorama *pano, VisualizationState *visualization_state)
Definition: MeshManager.h:234
VisualizationState * visualization_state
Definition: MeshManager.h:223
VisualizationState * m_visualization_state
Definition: MeshManager.h:122
A MeshManager handles the graphics system representation of a remapping, by creating OpenGL display l...
Definition: MeshManager.h:37
Handles the remapper and a display list for a specific image.
Definition: MeshManager.h:64
virtual MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on)=0
MeshInfo * ObtainMeshInfo(HuginBase::SrcPanoImage *, bool layout_mode_on)
static Coord3D GetCoord3D(hugin_utils::FDiff2D &coord, VisualizationState *state)
Definition: MeshManager.h:146
static const double scale_diff
scale factor to be used for the layout mode TODO: test this for more scenarios
Definition: MeshManager.h:178
static MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords, VisualizationState *state)
void RenderMesh(unsigned int image_number) const
Definition: MeshManager.cpp:99
a class to keep data of a single rectangle with texture coordinates
Definition: MeshManager.h:104
PanosphereOverviewMeshInfo(const PanosphereOverviewMeshInfo &source)
Definition: MeshManager.h:164
void SetLayoutMode(bool state)
Turn layout mode on or off.
void SetScaleFactor(double scale)
virtual MeshInfo::MeshCoords3D GetMeshCoords3D(MeshRemapper::Coords &coords)=0
virtual void BeforeCompile()
Definition: MeshManager.h:115
subclass of MeshInfo for the preview It actually does nothing in addition to the base class ...
Definition: MeshManager.h:134
Coord3D(hugin_utils::FDiff2D &coord)
Definition: MeshManager.h:97
All variables of a source image.
Definition: SrcPanoImage.h:194
static Coord3D GetCoord3D(hugin_utils::FDiff2D &coord, VisualizationState *state)
void CallList() const
Draw the mesh.
PreviewMeshInfo(HuginBase::Panorama *m_pano, HuginBase::SrcPanoImage *image, VisualizationState *visualization_state, bool layout_mode_on)
Definition: MeshManager.h:137
static Coord3D GetCoord3D(hugin_utils::FDiff2D &coord, VisualizationState *state)
a class to handle a 3D point
Definition: MeshManager.h:93
MeshManager(HuginBase::Panorama *pano, VisualizationState *visualization_state)
Definition: MeshManager.cpp:56
unsigned int GetDisplayList(unsigned int image_number) const
void CheckUpdate()
Definition: MeshManager.cpp:71