DGtal  1.1.0
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 
72 
73 protected:
75 
76 public:
81 
86 
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 
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)
DGtal::Board3DTo2D::camera_upVector
double camera_upVector[3]
camera up-vector
Definition: Board3DTo2D.h:265
DGtal::Board3DTo2D::isValid
bool isValid() const
DGtal::Board3DTo2D::ZNear
double ZNear
znear distance
Definition: Board3DTo2D.h:267
DGtal::Board3DTo2D::TransposeMt
static void TransposeMt(double tmat[16], double mat[16])
DGtal::concepts::CSpace
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:106
DGtal::Display3D
Aim: This semi abstract class defines the stream mechanism to display 3d primitive (like BallVector,...
Definition: Display3D.h:93
DGtal::Board3DTo2D::~Board3DTo2D
~Board3DTo2D()
Definition: Board3DTo2D.h:98
DGtal::Board3DTo2D::Board3DTo2D
Board3DTo2D(KSpace KSEmb)
Definition: Board3DTo2D.h:91
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:80
DGtal::Board3DTo2D::camera_position
double camera_position[3]
camera position
Definition: Board3DTo2D.h:263
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::Board3DTo2D::setCameraDirection
void setCameraDirection(double x, double y, double z)
Definition: Board3DTo2D.h:124
DGtal::Board3DTo2D::CairoEPS
@ CairoEPS
Definition: Board3DTo2D.h:80
DGtal::Board3DTo2D::camera_direction
double camera_direction[3]
camera direction
Definition: Board3DTo2D.h:264
DGtal::Board3DTo2D::project
void project(double x3d, double y3d, double z3d, double &x2d, double &y2d)
DGtal::Board3DTo2D::operator<<
Board3DTo2D & operator<<(const TDrawableWithDisplay3D &object)
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::SpaceND
Definition: SpaceND.h:96
DGtal::Board3DTo2D::operator<<
Board3DTo2D & operator<<(const DGtal::Color &aColor)
DGtal::Board3DTo2D::Viewport
int Viewport[4]
2D viewport
Definition: Board3DTo2D.h:260
DGtal::Board3DTo2D
Class for PDF, PNG, PS, EPS, SVG export drawings with Cairo with 3D->2D projection.
Definition: Board3DTo2D.h:69
DGtal::Board3DTo2D::CairoPNG
@ CairoPNG
Definition: Board3DTo2D.h:80
DGtal::Board3DTo2D::setCameraUpVector
void setCameraUpVector(double x, double y, double z)
Definition: Board3DTo2D.h:133
DGtal::Board3DTo2D< S, KS >::CairoType
CairoType
Definition: Board3DTo2D.h:80
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::Board3DTo2D::init
virtual void init()
DGtal::Board3DTo2D::ZFar
double ZFar
zfar distance
Definition: Board3DTo2D.h:268
DGtal::Board3DTo2D::setCameraPosition
void setCameraPosition(double x, double y, double z)
Definition: Board3DTo2D.h:115
DGtal::Board3DTo2D::setNearFar
void setNearFar(double _near, double _far)
Definition: Board3DTo2D.h:141
DGtal::Board3DTo2D::CairoSVG
@ CairoSVG
Definition: Board3DTo2D.h:80
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::Board3DTo2D::CairoPDF
@ CairoPDF
Definition: Board3DTo2D.h:80
DGtal::Board3DTo2D::precompute_projection_matrix
void precompute_projection_matrix()
DGtal::Board3DTo2D::className
std::string className() const
Definition: Board3DTo2D.h:104
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::Board3DTo2D::myDefaultColor
DGtal::Color myDefaultColor
default color
Definition: Board3DTo2D.h:167
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:394