DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Board3DTo2D.h
1 
17 #pragma once
18 
31 #if defined(Board3DTo2D_RECURSES)
32 #error Recursive header files inclusion detected in Board3DTo2D.h
33 #else // defined(Board3DTo2D_RECURSES)
34 
35 #define Board3DTo2D_RECURSES
36 
37 #if !defined Board3DTo2D_h
38 
39 #define Board3DTo2D_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <vector>
45 #include <algorithm>
46 #include <map>
47 
48 #include "DGtal/base/Common.h"
49 #include "DGtal/base/CountedPtr.h"
50 #include "DGtal/io/Display3D.h"
51 #include "DGtal/io/DrawWithDisplay3DModifier.h"
52 #include "DGtal/io/Color.h"
53 
55 
56 namespace DGtal
57 {
58 
59 
61  // class Board3DTo2D
66  class Board3DTo2D : public Display3D
67  {
68  public:
73 
77  Board3DTo2D();
78 
79 
81 
82 
86  std::string className() const
87  {
88  return "Board3DTo2D";
89  }
90 
97  void setCameraPosition(double x, double y, double z)
98  { camera_position[0] = x; camera_position[1] = y; camera_position[2] = z; }
99 
106  void setCameraDirection(double x, double y, double z)
107  { camera_direction[0] = x; camera_direction[1] = y; camera_direction[2] = z; }
108 
115  void setCameraUpVector(double x, double y, double z)
116  { camera_upVector[0] = x; camera_upVector[1] = y; camera_upVector[2] = z; }
117 
123  void setNearFar(double _near, double _far) { ZNear = _near; ZFar = _far; }
124 
132  void saveCairo(const char *filename, CairoType type, int bWidth, int bHeight);
133 
138  //typedef std::map< std::string, std::string > ModeMapping;
139 
140  // /**
141  // * The associated map type for storing the default styles of
142  // * digital objects.
143  // */
144  // typedef std::map< std::string,CountedPtr<DrawableWithDisplay3D> > StyleMapping;
145 
147 
148 
149 
150 
157  Board3DTo2D & operator<<(const DGtal::Color & aColor);
158 
159 
160 
169  template <typename TDrawableWithDisplay3D>
170  Board3DTo2D & operator<<( const TDrawableWithDisplay3D & object );
171 
172  public:
173 
178  void selfDisplay ( std::ostream & out ) const;
179 
184  bool isValid() const;
185 
186  public:
187 
188 
189  // ------------------------- Private Datas --------------------------------
190  private:
191 
192 
193 
198 
207  void project(double x3d, double y3d, double z3d, double &x2d, double &y2d);
208 
209  int Viewport[4];
210  double matrix[16];
211 
212  double camera_position[3];
213  double camera_direction[3];
214  double camera_upVector[3];
215 
216  double ZNear;
217  double ZFar;
218 
219  protected :
223  virtual void init();
224 
225  private:
226 
227  }; // end of class Board3DTo2D
228 
229 
230 
231 
232 
239  std::ostream&
240  operator<< ( std::ostream & out, const Board3DTo2D & object );
241 
242 } // namespace DGtal
243 
244 
246 // Includes inline functions.
247 #include "DGtal/io/boards/Board3DTo2D.ih"
248 
249 
250 // //
252 
253 #endif // !defined Board3DTo2D_h
254 
255 #undef Board3DTo2D_RECURSES
256 #endif // else defined(Board3DTo2D_RECURSES)