Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GLProjectionParametersInterface.hh
1 #ifndef __GLPROJECTIONPARAMETERSINTERFACE_hh__
2 #define __GLPROJECTIONPARAMETERSINTERFACE_hh__
3 
4 // includes
5 #include <bias_config.h>
6 
7 #ifndef BIAS_HAVE_OPENGL
8 # error You need BIAS with USE_OpenGL Please recompile BIAS.
9 #endif // BUILD_GLviewer
10 
11 #include <Base/Geometry/HomgPoint3D.hh>
12 #include <Base/Geometry/HomgPoint2D.hh>
13 #include <Base/Geometry/Quaternion.hh>
14 #include <Geometry/RMatrix.hh>
15 #include <Geometry/ProjectionParametersBase.hh>
16 
17 #include <OpenGLFramework/Base/glfRenderTarget.hh>
18 #include <OpenGLFramework/Base/glfFramebufferObject.hh>
19 #include <GLviewer/Scenes/SceneBGImage.hh>
20 #include <GLviewer/OutputAttachments/GLProjectionOutputAttachment.hh>
21 
22 /** Read as frequency/granularity BASIC/MEDIUM/HIGH granularity or frequency */
23 #define GLP_ACTIVITY_BASIC 1
24 #define GLP_ACTIVITY_MEDIUM 2
25 #define GLP_ACTIVITY_HIGH 4
26 #define GLP_ACTIVITY_FULL 7
27 #define GLP_STATE_BASIC 8
28 #define GLP_STATE_MEDIUM 16
29 #define GLP_STATE_HIGH 32
30 #define GLP_STATE_FULL 63
31 #define GLP_PROJECTION 1<<17
32 #define GLP_VIEWPORT 1<<18
33 
34 namespace BIAS {
35 
36  /** @class GLProjectionParametersInterface
37  @brief Abstract interface class to handle changes in rendering
38  parameters by controllers and in rendering contextes
39  @ingroup g_glviewer
40  @author ischiller 04/2009 */
41  class BIASGLviewer_EXPORT GLProjectionParametersInterface {
42  public:
43 
44  typedef enum {
45  /** Do not do anything! Do not render either! */
46  Deny=0,
47  /** rescale internal projection parameters preserving aspect ratio and
48  scale by integer values only. This can lead to two black borders:
49  right and bottom */
51  /** Render part of the image or the whole image, does not change
52  projection parameters.
53  drawingUpperLeft_ are the projection image coordinates which will
54  appear in the rendered image in the upper left corner. */
56  /** Calculate new simple perspective camera parameters keeping the
57  current field of view in "y direction". */
60  /** rescale internal projection parameters preeerving aspectration but
61  use non-integer values.
62  This should result in only one black border.*/
63  AutoRescaleSimple
64  } ViewingReshapeBehaviour;
65 
66  //Needed for clean destruction of children
68 
70  GetMyselfAsProjectionParametersBase() const =0;
71 
72  virtual void SetDebugLevel(const long int lv)=0;
73  virtual void AddDebugLevel(const long int lv)=0;
74 
75  virtual int SetExtrinsics(const BIAS::HomgPoint3D& C,
76  const BIAS::Quaternion<double>& Q)=0;
77  virtual int SetExtrinsics(const BIAS::Vector3<double>& C,
78  const BIAS::Quaternion<double>& Q)=0;
79 
80  virtual int SetExtrinsics(const BIAS::HomgPoint3D& C,
81  const BIAS::RMatrix& R)=0;
82  virtual int SetExtrinsics(const BIAS::Vector3<double>& C,
83  const BIAS::RMatrix& R)=0;
84 
85  virtual int SetExtrinsics(const BIAS::Vector3< double >& C,
86  const BIAS::Vector3< double >& scenePoint,
87  const BIAS::Vector3< double >& up)=0;
88 
89  //Getter
90  virtual int GetExtrinsics(BIAS::Vector3<double>& C,
91  BIAS::Vector3<double>& up)const =0;
92  virtual int GetExtrinsics(BIAS::Vector3<double>& C,
93  BIAS::RMatrix & R)const =0;
94 
95 
96  virtual BIAS::HomgPoint3D UnProject(const unsigned int x,
97  const unsigned int y) = 0;
98  virtual BIAS::HomgPoint3D UnProject(BIAS::HomgPoint2D& point2D,
99  double depth) = 0;
100  virtual BIAS::HomgPoint2D Project(BIAS::HomgPoint3D &point) = 0;
101 
102  virtual bool PoseValid() = 0;
103 
104  /** Takes x, y as window coordinates, checks whether the coordinates
105  lie in the rendered image (in the viewrange of projection). If so
106  \returns the coordinates relative to the upper left image corner of the
107  used viewport and true. else coordintes are unchanged and return value
108  is false. */
109  virtual bool GetViewportCoordinates(int& x, int& y)=0;
110 
111  /** Setting the near and far z-Clipping planes. * @{ */
112  virtual void SetZClippingPlanes (float n, float f)=0;
113  virtual void SetNearClippingPlane(float n)=0;
114  virtual void SetFarClippingPlane (float f)=0;
115  virtual float GetNearClippingPlane() const =0;
116  virtual float GetFarClippingPlane () const =0;
117  /** @} */
118 
119 #ifdef BIAS_HAVE_XML2
120  virtual int XMLRead (const std::string& Filename)=0;
121  virtual int XMLWrite(const std::string& Filename) const =0;
122  virtual int Load (const std::string& filename)=0;
123  virtual int Save (const std::string& filename) const =0;
124 #endif
125  virtual void SetRenderTarget(BIAS::glfRenderTarget* RT)=0;
126  virtual BIAS::glfRenderTarget* GetRenderTarget()=0;
127 
128  virtual void SetClearColor(const BIAS::Vector4<float>& cc)=0;
129  virtual void SetClearDepth(const float d)=0;
130 
131  virtual BIAS::Vector4<float> GetClearColor()=0;
132  virtual float GetClearDepth()=0;
133 
134 
135  virtual void SwitchToOffscreenRendering(bool offscreen = true)=0;
136  virtual void AppendOutputAttachment(int val, std::vector<int> args
137  = std::vector<int>())=0;
138  virtual BIAS::GLProjectionOutputAttachment *GetAttachmentByType(int type)=0;
139  virtual void SetAutoReshapeBehaviour(ViewingReshapeBehaviour newBehaviour)=0;
140 
141  //obtain rendered images and parts of it
142  virtual double GetDepth(const unsigned int x, const unsigned int y) = 0;
143  virtual double GetDepth(const BIAS::HomgPoint2D& p) =0;
144 
145  virtual int GetDepthMap(BIAS::Image<float>& depthMap,
146  const float invalid=0.0)=0;
147  virtual void TranslateZToDepth(BIAS::Image<float>& ztodepth,
148  const float invalid = 0.0,
149  const bool flip = true) const = 0;
150  virtual void TranslateDepthToZ(BIAS::Image<float>& depthtoz,
151  const float invalid = 0.0,
152  const bool flip = true) const = 0;
153  virtual void TranslateZToMetricZ(BIAS::Image<float>& depthMap,
154  const float invalid = 0.0,
155  const bool flip = true) const = 0;
156  virtual int GetZBuffer(BIAS::Image<float>& zBuffer)=0;
157  virtual int GetMetricZMap(BIAS::Image<float>& metricZMap,
158  const float invalid = 0.0) =0;
159  virtual void GetImage(BIAS::Image<unsigned char>& image)=0;
160  virtual void GetGreyImage(BIAS::Image<unsigned char>& image)=0;
161 
162  //Draw function
163  virtual int Draw(std::vector<BIAS::SceneBase *>& scenes,
164  BIAS::SceneBGImage* backgroundImageScene = NULL,
165  BIAS::glfFramebufferObject* theTarget = NULL)=0;
166  protected:
168 
169  private:
170 
171  }; // class GLProjectionParametersInterface
172 
173 } // namespace
174 
175 #endif //__GLPROJECTIONPARAMETERSINTERFACE_hh__
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
Scene that renders a background image behind all other scenes.
Definition: SceneBGImage.hh:42
rescale internal projection parameters preserving aspect ratio and scale by integer values only...
3D rotation matrix
Definition: RMatrix.hh:49
Abstract interface class to handle changes in rendering parameters by controllers and in rendering co...
Render part of the image or the whole image, does not change projection parameters.
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Definition: HomgPoint3D.hh:61
Calculate new simple perspective camera parameters keeping the current field of view in &quot;y direction&quot;...
Class for extra rendering pass in GLProjection (for now only used in glutGLviewer) ...
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
Interface for render targets.