DGtal  0.9.2
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/Color.h"
52 
53 #include "DGtal/kernel/CSpace.h"
54 
55 
57 
58 namespace DGtal
59 {
60 
62 // class Board3DTo2D
67 template < typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
68 class Board3DTo2D : public Display3D<Space, KSpace>
69 {
70 
71  BOOST_CONCEPT_ASSERT((concepts::CSpace<Space>));
72 
73 protected:
74  using Display3D<Space, KSpace>::myQuadsMap;
75 
76 public:
81 
85  Board3DTo2D();
86 
91  Board3DTo2D( KSpace KSEmb )
92  : Display3D<Space,KSpace>( KSEmb )
93  {
94  init();
95  }
96 
97 
99 
100 
104  std::string className() const
105  {
106  return "Board3DTo2D";
107  }
108 
115  void setCameraPosition(double x, double y, double z)
116  { camera_position[0] = x; camera_position[1] = y; camera_position[2] = z; }
117 
124  void setCameraDirection(double x, double y, double z)
125  { camera_direction[0] = x; camera_direction[1] = y; camera_direction[2] = z; }
126 
133  void setCameraUpVector(double x, double y, double z)
134  { camera_upVector[0] = x; camera_upVector[1] = y; camera_upVector[2] = z; }
135 
141  void setNearFar(double _near, double _far) { ZNear = _near; ZFar = _far; }
142 
150  void saveCairo(const char *filename, CairoType type, int bWidth, int bHeight);
151 
152 
153 
158  //typedef std::map< std::string, std::string > ModeMapping;
159 
160  // /**
161  // * The associated map type for storing the default styles of
162  // * digital objects.
163  // */
164  // typedef std::map< std::string,CountedPtr<DrawableWithDisplay3D> > StyleMapping;
165 
166 
168 
169 
176  Board3DTo2D & operator<<(const DGtal::Color & aColor);
177 
178 
187  template <typename TDrawableWithDisplay3D>
188  Board3DTo2D & operator<<( const TDrawableWithDisplay3D & object );
189 
194  void selfDisplay ( std::ostream & out ) const;
195 
200  bool isValid() const;
201 
202 
203  // ------------------------- Private Datas --------------------------------
204 private:
205 
211  static
212  void TransposeMt(double tmat[16], double mat[16]);
213 
220  static
221  void MulMt(double v[4], double mat[16], double b[4]);
222 
236  static
237  void LookAtMt(double mat[16],
238  double eyex, double eyey, double eyez,
239  double dirx, double diry, double dirz,
240  double upx, double upy, double upz);
241 
242 
247 
256  void project(double x3d, double y3d, double z3d, double &x2d, double &y2d);
257 
258 
259 
260  int Viewport[4];
261  double matrix[16];
262 
263  double camera_position[3];
264  double camera_direction[3];
265  double camera_upVector[3];
266 
267  double ZNear;
268  double ZFar;
269 
270 protected :
274  virtual void init();
275 
276 private:
277 
278 }; // end of class Board3DTo2D
279 
280 
281 template < typename Space, typename KSpace>
288 std::ostream&
289 operator<< ( std::ostream & out, const Board3DTo2D<Space,KSpace> & object );
290 
291 } // namespace DGtal
292 
293 
295 // Includes inline functions.
296 #include "DGtal/io/boards/Board3DTo2D.ih"
297 
298 // //
300 
301 #endif // !defined Board3DTo2D_h
302 
303 #undef Board3DTo2D_RECURSES
304 #endif // else defined(Board3DTo2D_RECURSES)
double camera_direction[3]
camera direction
Definition: Board3DTo2D.h:264
void precompute_projection_matrix()
static void MulMt(double v[4], double mat[16], double b[4])
Class for PDF, PNG, PS, EPS, SVG export drawings with Cairo with 3D->2D projection.
Definition: Common.h:138
Aim: SpaceND is a utility class that defines the fundamental structure of a Digital Space in ND...
Definition: SpaceND.h:95
void saveCairo(const char *filename, CairoType type, int bWidth, int bHeight)
double camera_upVector[3]
camera up-vector
Definition: Board3DTo2D.h:265
int Viewport[4]
2D viewport
Definition: Board3DTo2D.h:260
BOOST_CONCEPT_ASSERT((concepts::CSpace< Space >))
static void LookAtMt(double mat[16], double eyex, double eyey, double eyez, double dirx, double diry, double dirz, double upx, double upy, double upz)
double ZFar
zfar distance
Definition: Board3DTo2D.h:268
Board3DTo2D & operator<<(const DGtal::Color &aColor)
double ZNear
znear distance
Definition: Board3DTo2D.h:267
void selfDisplay(std::ostream &out) const
void project(double x3d, double y3d, double z3d, double &x2d, double &y2d)
void setCameraPosition(double x, double y, double z)
Definition: Board3DTo2D.h:115
void setNearFar(double _near, double _far)
Definition: Board3DTo2D.h:141
void setCameraUpVector(double x, double y, double z)
Definition: Board3DTo2D.h:133
DGtal is the top-level namespace which contains all DGtal functions and types.
bool isValid() const
virtual void init()
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
std::string className() const
Definition: Board3DTo2D.h:104
DGtal::Color myDefaultColor
default color
Definition: Board3DTo2D.h:167
double camera_position[3]
camera position
Definition: Board3DTo2D.h:263
void setCameraDirection(double x, double y, double z)
Definition: Board3DTo2D.h:124
Aim: This semi abstract class defines the stream mechanism to display 3d primitive (like BallVector...
Definition: Common.h:134
static void TransposeMt(double tmat[16], double mat[16])
Board3DTo2D(KSpace KSEmb)
Definition: Board3DTo2D.h:91