DGtal  1.3.beta
Board3DTo2D.h
1 
17 #pragma once
18 
30 #if !defined(WITH_CAIRO)
31 #error "Board3DTo2D requires Cairo (WITH_CAIRO option when building DGtal)"
32 #endif
33 
34 #if defined(Board3DTo2D_RECURSES)
35 #error Recursive header files inclusion detected in Board3DTo2D.h
36 #else // defined(Board3DTo2D_RECURSES)
37 
38 #define Board3DTo2D_RECURSES
39 
40 #if !defined Board3DTo2D_h
41 
42 #define Board3DTo2D_h
43 
45 // Inclusions
46 #include <iostream>
47 #include <vector>
48 #include <algorithm>
49 #include <map>
50 
51 #include "DGtal/base/Common.h"
52 #include "DGtal/base/CountedPtr.h"
53 #include "DGtal/io/Display3D.h"
54 #include "DGtal/io/Color.h"
55 
56 #include "DGtal/kernel/CSpace.h"
57 
59 
60 namespace DGtal
61 {
62 
64 // class Board3DTo2D
69 template < typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
70 class Board3DTo2D : public Display3D<Space, KSpace>
71 {
72 
73  BOOST_CONCEPT_ASSERT((concepts::CSpace<Space>));
74 
75 protected:
77 
78 public:
83 
87  Board3DTo2D();
88 
94  : Display3D<Space,KSpace>( KSEmb )
95  {
96  init();
97  }
98 
99 
101 
102 
106  std::string className() const
107  {
108  return "Board3DTo2D";
109  }
110 
117  void setCameraPosition(double x, double y, double z)
118  { camera_position[0] = x; camera_position[1] = y; camera_position[2] = z; }
119 
126  void setCameraDirection(double x, double y, double z)
127  { camera_direction[0] = x; camera_direction[1] = y; camera_direction[2] = z; }
128 
135  void setCameraUpVector(double x, double y, double z)
136  { camera_upVector[0] = x; camera_upVector[1] = y; camera_upVector[2] = z; }
137 
143  void setNearFar(double _near, double _far) { ZNear = _near; ZFar = _far; }
144 
152  void saveCairo(const char *filename, CairoType type, int bWidth, int bHeight);
153 
154 
155 
160  //typedef std::map< std::string, std::string > ModeMapping;
161 
162  // /**
163  // * The associated map type for storing the default styles of
164  // * digital objects.
165  // */
166  // typedef std::map< std::string,CountedPtr<DrawableWithDisplay3D> > StyleMapping;
167 
168 
170 
171 
178  Board3DTo2D & operator<<(const DGtal::Color & aColor);
179 
180 
189  template <typename TDrawableWithDisplay3D>
190  Board3DTo2D & operator<<( const TDrawableWithDisplay3D & object );
191 
196  void selfDisplay ( std::ostream & out ) const;
197 
202  bool isValid() const;
203 
204 
205  // ------------------------- Private Datas --------------------------------
206 private:
207 
213  static
214  void TransposeMt(double tmat[16], double mat[16]);
215 
222  static
223  void MulMt(double v[4], double mat[16], double b[4]);
224 
238  static
239  void LookAtMt(double mat[16],
240  double eyex, double eyey, double eyez,
241  double dirx, double diry, double dirz,
242  double upx, double upy, double upz);
243 
244 
249 
258  void project(double x3d, double y3d, double z3d, double &x2d, double &y2d);
259 
260 
261 
262  int Viewport[4];
263  double matrix[16];
264 
265  double camera_position[3];
266  double camera_direction[3];
267  double camera_upVector[3];
268 
269  double ZNear;
270  double ZFar;
271 
272 protected :
276  virtual void init();
277 
278 private:
279 
280 }; // end of class Board3DTo2D
281 
282 
283 template < typename Space, typename KSpace>
290 std::ostream&
291 operator<< ( std::ostream & out, const Board3DTo2D<Space,KSpace> & object );
292 
293 } // namespace DGtal
294 
295 
297 // Includes inline functions.
298 #include "DGtal/io/boards/Board3DTo2D.ih"
299 
300 // //
302 
303 #endif // !defined Board3DTo2D_h
304 
305 #undef Board3DTo2D_RECURSES
306 #endif // else defined(Board3DTo2D_RECURSES)
DGtal::Board3DTo2D::camera_upVector
double camera_upVector[3]
camera up-vector
Definition: Board3DTo2D.h:267
DGtal::Board3DTo2D::isValid
bool isValid() const
DGtal::Board3DTo2D::ZNear
double ZNear
znear distance
Definition: Board3DTo2D.h:269
DGtal::Board3DTo2D::TransposeMt
static void TransposeMt(double tmat[16], double mat[16])
DGtal::Display3D
Aim: This semi abstract class defines the stream mechanism to display 3d primitive (like BallVector,...
Definition: Common.h:158
DGtal::Board3DTo2D::~Board3DTo2D
~Board3DTo2D()
Definition: Board3DTo2D.h:100
DGtal::Board3DTo2D::Board3DTo2D
Board3DTo2D(KSpace KSEmb)
Definition: Board3DTo2D.h:93
DGtal::Board3DTo2D::LookAtMt
static void LookAtMt(double mat[16], double eyex, double eyey, double eyez, double dirx, double diry, double dirz, double upx, double upy, double upz)
DGtal::Board3DTo2D::CairoPS
@ CairoPS
Definition: Board3DTo2D.h:82
DGtal::Board3DTo2D::camera_position
double camera_position[3]
camera position
Definition: Board3DTo2D.h:265
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
DGtal::Board3DTo2D::setCameraDirection
void setCameraDirection(double x, double y, double z)
Definition: Board3DTo2D.h:126
DGtal::Board3DTo2D::CairoEPS
@ CairoEPS
Definition: Board3DTo2D.h:82
DGtal::Board3DTo2D::camera_direction
double camera_direction[3]
camera direction
Definition: Board3DTo2D.h:266
DGtal::Board3DTo2D::project
void project(double x3d, double y3d, double z3d, double &x2d, double &y2d)
DGtal::Board3DTo2D::Board3DTo2D
Board3DTo2D()
DGtal::Board3DTo2D::MulMt
static void MulMt(double v[4], double mat[16], double b[4])
DGtal::Board3DTo2D::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::SpaceND
Definition: SpaceND.h:95
DGtal::Board3DTo2D::operator<<
Board3DTo2D & operator<<(const DGtal::Color &aColor)
DGtal::Board3DTo2D::Viewport
int Viewport[4]
2D viewport
Definition: Board3DTo2D.h:262
DGtal::Board3DTo2D
Class for PDF, PNG, PS, EPS, SVG export drawings with Cairo with 3D->2D projection.
Definition: Common.h:162
DGtal::Board3DTo2D::CairoPNG
@ CairoPNG
Definition: Board3DTo2D.h:82
DGtal::Board3DTo2D::setCameraUpVector
void setCameraUpVector(double x, double y, double z)
Definition: Board3DTo2D.h:135
DGtal::Board3DTo2D< S, KS >::CairoType
CairoType
Definition: Board3DTo2D.h:82
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::Board3DTo2D::init
virtual void init()
DGtal::Board3DTo2D::ZFar
double ZFar
zfar distance
Definition: Board3DTo2D.h:270
DGtal::Board3DTo2D::setCameraPosition
void setCameraPosition(double x, double y, double z)
Definition: Board3DTo2D.h:117
DGtal::Board3DTo2D::setNearFar
void setNearFar(double _near, double _far)
Definition: Board3DTo2D.h:143
DGtal::Board3DTo2D::CairoSVG
@ CairoSVG
Definition: Board3DTo2D.h:82
DGtal::Board3DTo2D::CairoPDF
@ CairoPDF
Definition: Board3DTo2D.h:82
DGtal::Board3DTo2D::precompute_projection_matrix
void precompute_projection_matrix()
DGtal::Board3DTo2D::className
std::string className() const
Definition: Board3DTo2D.h:106
DGtal::Board3DTo2D::saveCairo
void saveCairo(const char *filename, CairoType type, int bWidth, int bHeight)
DGtal::Board3DTo2D::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CSpace< Space >))
DGtal::Display3D::myQuadsMap
QuadsMap myQuadsMap
Definition: Display3D.h:845
DGtal::Board3DTo2D::myDefaultColor
DGtal::Color myDefaultColor
default color
Definition: Board3DTo2D.h:169
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64