Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
common.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2010, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Id: common.h 4426 2012-02-13 06:14:56Z rusu $
35  *
36  */
37 #ifndef PCL_PCL_VISUALIZER_COMMON_H_
38 #define PCL_PCL_VISUALIZER_COMMON_H_
39 #include <vtkCommand.h>
40 #include <vtkTextActor.h>
41 
42 #include <pcl/pcl_macros.h>
43 #include <Eigen/Dense>
44 
45 namespace pcl
46 {
47  namespace visualization
48  {
56  PCL_EXPORTS void
57  getRandomColors (double &r, double &g, double &b, double min = 0.2, double max = 2.8);
58 
60  {
68  };
69 
71  {
75  };
76 
78 
80  {
81  public:
82  // focal point or lookAt
83  double focal[3];
84 
85  // position of the camera
86  double pos[3];
87 
88  // up vector of the camera
89  double view[3];
90 
91  // clipping planes clip[0] is near clipping plane or also the image plane, and clip [1] is the far clipping plane
92  double clip[2];
93 
94  // field of view angle in y direction (radians)
95  double fovy;
96 
97  // the following variables are the actual position and size of the window on the screen
98  // and NOT the viewport! except for the size, which is the same
99  // the viewport is assumed to be centered and same size as the window.
100  double window_size[2];
101  double window_pos[2];
102 
106  void
107  computeViewMatrix (Eigen::Matrix4d& view_mat) const;
108 
112  void
113  computeProjectionMatrix (Eigen::Matrix4d& proj) const;
114 
122  template<typename PointT> void
123  cvtWindowCoordinates (const PointT& pt, Eigen::Vector4d& window_cord);
124 
135  template<typename PointT> void
136  cvtWindowCoordinates (const PointT& pt, Eigen::Vector4d& window_cord, const Eigen::Matrix4d& composite_mat);
137  };
138 
140  class PCL_EXPORTS FPSCallback : public vtkCommand
141  {
142  public:
143  static FPSCallback *New () { return new FPSCallback;}
144  inline void setTextActor (vtkTextActor *txt) { this->actor_ = txt; }
145  virtual void Execute (vtkObject *, unsigned long, void*);
146  protected:
147  vtkTextActor *actor_;
148  };
149  }
150 }
151 
152 #endif