camera.h
Go to the documentation of this file.
00001 #ifndef PCL_OUTOFCORE_CAMERA_H_
00002 #define PCL_OUTOFCORE_CAMERA_H_
00003 
00004 // C++
00005 #include <iostream>
00006 #include <string>
00007 
00008 // PCL
00009 #include <pcl/outofcore/visualization/object.h>
00010 #include <pcl/common/eigen.h>
00011 
00012 // VTK
00013 #include <vtkActor.h>
00014 #include <vtkCamera.h>
00015 #include <vtkCameraActor.h>
00016 #include <vtkPolyData.h>
00017 #include <vtkSmartPointer.h>
00018 
00019 class Camera : public Object
00020 {
00021 public:
00022 
00023   // Operators
00024   // -----------------------------------------------------------------------------
00025   Camera (std::string name);
00026   Camera (std::string name, vtkSmartPointer<vtkCamera> camera);
00027 
00028 private:
00029 //  friend std::ostream & operator<<(std::ostream &os, const Camera& camera);
00030 
00031 public:
00032 
00033   // Accessors
00034   // -----------------------------------------------------------------------------
00035   inline vtkSmartPointer<vtkCamera>
00036   getCamera () const
00037   {
00038     return camera_;
00039   }
00040 
00041   inline vtkSmartPointer<vtkCameraActor>
00042   getCameraActor () const
00043   {
00044     return camera_actor_;
00045   }
00046 
00047   inline vtkSmartPointer<vtkActor>
00048   getHullActor () const
00049   {
00050     return hull_actor_;
00051   }
00052 
00053   inline bool
00054   getDisplay () const
00055   {
00056     return display_;
00057   }
00058 
00059   void
00060   setDisplay (bool display)
00061   {
00062     this->display_ = display;
00063   }
00064 
00065   void
00066   getFrustum (double frustum[])
00067   {
00068     for (int i = 0; i < 24; i++)
00069       frustum[i] = frustum_[i];
00070   }
00071 
00072   void
00073   setProjectionMatrix (const Eigen::Matrix4d &projection_matrix)
00074   {
00075     projection_matrix_ = projection_matrix;
00076   }
00077 
00078   Eigen::Matrix4d
00079   getProjectionMatrix ()
00080   {
00081     return projection_matrix_;
00082   }
00083 
00084   void
00085   setModelViewMatrix (const Eigen::Matrix4d &model_view_matrix)
00086   {
00087     model_view_matrix_ = model_view_matrix;
00088   }
00089 
00090   Eigen::Matrix4d
00091   getModelViewMatrix ()
00092   {
00093     return model_view_matrix_;
00094   }
00095 
00096   Eigen::Matrix4d
00097   getViewProjectionMatrix ()
00098   {
00099     return Eigen::Matrix4d (projection_matrix_ * model_view_matrix_);
00100   }
00101 
00102   Eigen::Vector3d
00103   getPosition ()
00104   {
00105     //Compute eye or position from model view matrix
00106     Eigen::Matrix4d inverse_model_view_matrix = model_view_matrix_.inverse ();
00107     Eigen::Vector3d position;
00108     for (int i = 0; i < 3; i++)
00109     {
00110       position (i) = inverse_model_view_matrix (i, 3);
00111     }
00112 
00113     return position;
00114   }
00115 
00116   inline void
00117   setClippingRange (float near_value = 0.0001f, float far_value = 100000.f)
00118   {
00119     camera_->SetClippingRange (near_value, far_value);
00120   }
00121 
00122   virtual void
00123   render (vtkRenderer* renderer);
00124 
00125   // Methods
00126   // -----------------------------------------------------------------------------
00127   //void computeFrustum(double aspect);
00128   void
00129   computeFrustum ();
00130   //computeFrustum(double aspect);
00131   void
00132   printFrustum ();
00133 
00134 private:
00135 
00136   // Members
00137   // -----------------------------------------------------------------------------
00138   vtkSmartPointer<vtkCamera> camera_;
00139   vtkSmartPointer<vtkCameraActor> camera_actor_;
00140   vtkSmartPointer<vtkActor> hull_actor_;
00141 
00142   bool display_;
00143 
00144   double frustum_[24];
00145   Eigen::Matrix4d projection_matrix_;
00146   Eigen::Matrix4d model_view_matrix_;
00147 
00148   double prevUp_[3];
00149   double prevFocal_[3];
00150   double prevPos_[3];
00151 };
00152 
00153 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:22:36