DGtal 1.3.0
Loading...
Searching...
No Matches
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)
38#define Board3DTo2D_RECURSES
39
40#if !defined Board3DTo2D_h
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
60namespace DGtal
61{
62
64// class Board3DTo2D
69template < typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
70class Board3DTo2D : public Display3D<Space, KSpace>
71{
72
74
75protected:
77
78public:
83
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
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 --------------------------------
206private:
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];
267 double camera_upVector[3];
268
269 double ZNear;
270 double ZFar;
271
272protected :
276 virtual void init();
277
278private:
279
280}; // end of class Board3DTo2D
281
282
283template < typename Space, typename KSpace>
290std::ostream&
291operator<< ( 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)
Class for PDF, PNG, PS, EPS, SVG export drawings with Cairo with 3D->2D projection.
Definition: Board3DTo2D.h:71
void project(double x3d, double y3d, double z3d, double &x2d, double &y2d)
static void TransposeMt(double tmat[16], double mat[16])
std::string className() const
Definition: Board3DTo2D.h:106
int Viewport[4]
2D viewport
Definition: Board3DTo2D.h:262
double camera_upVector[3]
camera up-vector
Definition: Board3DTo2D.h:267
static void LookAtMt(double mat[16], double eyex, double eyey, double eyez, double dirx, double diry, double dirz, double upx, double upy, double upz)
static void MulMt(double v[4], double mat[16], double b[4])
void setNearFar(double _near, double _far)
Definition: Board3DTo2D.h:143
double ZNear
znear distance
Definition: Board3DTo2D.h:269
double camera_direction[3]
camera direction
Definition: Board3DTo2D.h:266
void setCameraUpVector(double x, double y, double z)
Definition: Board3DTo2D.h:135
virtual void init()
void setCameraDirection(double x, double y, double z)
Definition: Board3DTo2D.h:126
double camera_position[3]
camera position
Definition: Board3DTo2D.h:265
void saveCairo(const char *filename, CairoType type, int bWidth, int bHeight)
double ZFar
zfar distance
Definition: Board3DTo2D.h:270
Board3DTo2D & operator<<(const DGtal::Color &aColor)
bool isValid() const
void precompute_projection_matrix()
DGtal::Color myDefaultColor
default color
Definition: Board3DTo2D.h:169
BOOST_CONCEPT_ASSERT((concepts::CSpace< Space >))
void setCameraPosition(double x, double y, double z)
Definition: Board3DTo2D.h:117
Board3DTo2D & operator<<(const TDrawableWithDisplay3D &object)
void selfDisplay(std::ostream &out) const
Board3DTo2D(KSpace KSEmb)
Definition: Board3DTo2D.h:93
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
Aim: This semi abstract class defines the stream mechanism to display 3d primitive (like BallVector,...
Definition: Display3D.h:93
QuadsMap myQuadsMap
Definition: Display3D.h:845
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:106