DGtal  1.5.beta
DGtal::Board3DTo2D< Space, KSpace > Class Template Reference

Class for PDF, PNG, PS, EPS, SVG export drawings with Cairo with 3D->2D projection. More...

#include <DGtal/io/boards/Board3DTo2D.h>

Inheritance diagram for DGtal::Board3DTo2D< Space, KSpace >:
[legend]

Public Types

enum  CairoType {
  CairoPDF , CairoPNG , CairoPS , CairoEPS ,
  CairoSVG
}
 
- Public Types inherited from DGtal::Display3D< Z3i::Space, Z3i::KSpace >
enum  StreamKey
 
typedef Display3D< Z3i::Space, Z3i::KSpaceSelf
 
typedef Space::RealPoint RealPoint
 RealPoint type. More...
 
typedef Space::RealVector RealVector
 RealVector type. More...
 
typedef CanonicEmbedder< Z3i::SpaceEmbedder
 
typedef CanonicCellEmbedder< Z3i::KSpaceCellEmbedder
 
typedef CanonicSCellEmbedder< Z3i::KSpaceSCellEmbedder
 
typedef int(* SelectCallbackFct) (void *viewer, DGtal::int32_t name, void *data)
 Select callback function type. More...
 
typedef std::map< DGtal::int32_t, std::vector< QuadD3D > > QuadsMap
 The type that maps identifier name -> vector of QuadD3D. More...
 
typedef std::map< DGtal::int32_t, std::vector< CubeD3D > > CubesMap
 The type that maps identifier name -> vector of CubeD3D. More...
 
typedef std::map< std::string, std::string > ModeMapping
 
typedef std::map< std::string, CountedPtr< DrawableWithDisplay3D > > StyleMapping
 

Public Member Functions

 Board3DTo2D ()
 
 Board3DTo2D (KSpace KSEmb)
 
 ~Board3DTo2D ()
 
std::string className () const
 
void setCameraPosition (double x, double y, double z)
 
void setCameraDirection (double x, double y, double z)
 
void setCameraUpVector (double x, double y, double z)
 
void setNearFar (double _near, double _far)
 
void saveCairo (const char *filename, CairoType type, int bWidth, int bHeight)
 
Board3DTo2Doperator<< (const DGtal::Color &aColor)
 
template<typename TDrawableWithDisplay3D >
Board3DTo2Doperator<< (const TDrawableWithDisplay3D &object)
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
- Public Member Functions inherited from DGtal::Display3D< Z3i::Space, Z3i::KSpace >
 BOOST_CONCEPT_ASSERT ((concepts::CSpace< Z3i::Space >))
 
virtual ~Display3D ()
 
 Display3D (const Z3i::KSpace &KSEmb)
 
 Display3D ()
 
 Display3D (const Display3D &)=delete
 Copy constructor. Deleted. More...
 
 Display3D (Display3D &&)=delete
 Move constructor. Deleted. More...
 
Display3Doperator= (const Display3D &)=delete
 Assignment operator. Deleted. More...
 
Display3Doperator= (Display3D &&)=delete
 Move operator. Deleted. More...
 
const Embedderembedder () const
 
const CellEmbeddercellEmbedder () const
 
const SCellEmbeddersCellEmbedder () const
 
const Z3i::KSpacespace () const
 
virtual void setFillColor (DGtal::Color aColor)
 
virtual void setFillTransparency (unsigned char alpha)
 
virtual void setLineColor (DGtal::Color aColor)
 
virtual DGtal::Color getFillColor ()
 
virtual DGtal::Color getLineColor ()
 
virtual void setKSpace (const Z3i::KSpace &aKSpace)
 
void setName3d (DGtal::int32_t name=-1)
 
DGtal::int32_t name3d () const
 
void setSelectCallback3D (SelectCallbackFct fct, void *data, DGtal::int32_t min_name, DGtal::int32_t max_name)
 
SelectCallbackFct getSelectCallback3D (DGtal::int32_t aName, void *&data) const
 
void addClippingPlane (double a, double b, double c, double d, bool drawPlane)
 
std::string getMode (const std::string &objectName) const
 
void createNewLineList (std::string s="")
 
void createNewBallList (std::string s="")
 
DGtal::int32_t createNewCubeList ()
 
bool deleteCubeList (const DGtal::int32_t name)
 
DGtal::int32_t createNewQuadList ()
 
bool deleteQuadList (const DGtal::int32_t name)
 
void createNewTriangleList (std::string s="")
 
void createNewPolygonList (std::string s="")
 
void addQuad (const RealPoint &p1, const RealPoint &p2, const RealPoint &p3, const RealPoint &p4)
 
void addQuadWithNormal (const RealPoint &p1, const RealPoint &p2, const RealPoint &p3, const RealPoint &p4, const RealPoint &n, const bool enableReorientation, const bool enableDoubleFace=false)
 
void addQuadFromSurfelCenter (const RealPoint &baseQuadCenter, bool xSurfel, bool ySurfel, bool zSurfel)
 
void addQuadFromSurfelCenterWithNormal (const RealPoint &baseQuadCenter, bool xSurfel, bool ySurfel, bool zSurfel, const RealVector &aNormal, const bool enableReorientation, const bool sign, const bool enableDoubleFace=false)
 
void addTriangle (const RealPoint &p1, const RealPoint &p2, const RealPoint &p3)
 
void addPolygon (const std::vector< RealPoint > &vertices)
 
void addLine (const RealPoint &p1, const RealPoint &p2, const double width=0.03)
 
void addCube (const RealPoint &center, double width=1.0)
 
void addBall (const RealPoint &center, const double radius=0.5, const unsigned int resolution=30)
 
void addPrism (const RealPoint &baseQuadCenter, bool xSurfel, bool ySurfel, bool zSurfel, double sizeShiftFactor, double sizeFactor=1.0, bool isSigned=false, bool aSign=true)
 
void addBasicSurfel (const RealPoint &baseQuadCenter, bool xSurfel, bool ySurfel, bool zSurfel)
 
void addCone (const RealPoint &p1, const RealPoint &p2, double width=0.08)
 
void addCylinder (const RealPoint &p1, const RealPoint &p2, const double width=0.02)
 
void updateBoundingBox (const RealPoint &point)
 
void exportToMesh (Mesh< RealPoint > &aMesh) const
 
Display3Doperator<< (const TDrawableWithDisplay3D &object)
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
void clear ()
 
RealPoint embed (const typename Space::Point &dp) const
 
RealPoint embedKS (const typename KSpace::SCell &cell) const
 
RealPoint embedKS (const DGtal::TransformedPrism &aTrans) const
 
RealPoint embedK (const typename KSpace::Cell &cell) const
 

Data Fields

DGtal::Color myDefaultColor
 default color More...
 
- Data Fields inherited from DGtal::Display3D< Z3i::Space, Z3i::KSpace >
ModeMapping myModes
 
StyleMapping myStyles
 
bool myBoundingPtEmptyTag
 True if the bounding box is empty (no objects added) More...
 
double myBoundingPtUp [3]
 upper point of the bounding box More...
 
double myBoundingPtLow [3]
 lower point of the bouding box More...
 

Protected Member Functions

virtual void init ()
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CSpace< Space >))
 
void precompute_projection_matrix ()
 
void project (double x3d, double y3d, double z3d, double &x2d, double &y2d)
 

Static Private Member Functions

static void TransposeMt (double tmat[16], double mat[16])
 
static void MulMt (double v[4], double mat[16], double b[4])
 
static void LookAtMt (double mat[16], double eyex, double eyey, double eyez, double dirx, double diry, double dirz, double upx, double upy, double upz)
 

Private Attributes

int Viewport [4]
 2D viewport More...
 
double matrix [16]
 projection matrix More...
 
double camera_position [3]
 camera position More...
 
double camera_direction [3]
 camera direction More...
 
double camera_upVector [3]
 camera up-vector More...
 
double ZNear
 znear distance More...
 
double ZFar
 zfar distance More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from DGtal::Display3D< Z3i::Space, Z3i::KSpace >
static void cross (double dst[3], double srcA[3], double srcB[3])
 
static void normalize (double vec[3])
 
- Protected Attributes inherited from DGtal::Display3D< Z3i::Space, Z3i::KSpace >
Z3i::KSpace myKSpace
 The Khalimsky space. More...
 
EmbeddermyEmbedder
 an embeder from a dgtal space point to a real space point More...
 
CellEmbeddermyCellEmbedder
 an embeder from a unsigned khalimsky space point to a real space point More...
 
SCellEmbeddermySCellEmbedder
 an embeder from a signed khalimsky space point to a real space point More...
 
DGtal::Color myCurrentFillColor
 
DGtal::Color myCurrentLineColor
 
double myCurrentfShiftVisuPrisms
 
std::vector< std::vector< LineD3D > > myLineSetList
 
std::vector< std::vector< BallD3D > > myBallSetList
 
std::vector< ClippingPlaneD3D > myClippingPlaneList
 
std::vector< QuadD3D > myPrismList
 
QuadsMap myQuadsMap
 
std::vector< std::vector< TriangleD3D > > myTriangleSetList
 Represents all the triangles drawn in the Display3D. More...
 
std::vector< std::vector< PolygonD3D > > myPolygonSetList
 Represents all the polygon drawn in the Display3D. More...
 
CubesMap myCubesMap
 
std::vector< std::string > myCubeSetNameList
 
std::vector< std::string > myLineSetNameList
 
std::vector< std::string > myBallSetNameList
 
std::vector< std::string > myClippingPlaneNameList
 
std::vector< std::string > myPrismNameList
 
std::vector< std::string > myQuadSetNameList
 
std::vector< std::string > myTriangleSetNameList
 
std::vector< std::string > myPolygonSetNameList
 
DGtal::int32_t myName3d
 
std::set< SelectCallbackFctStore > mySelectCallBackFcts
 
bool myBoundingPtChangedTag
 

Detailed Description

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
class DGtal::Board3DTo2D< Space, KSpace >

Class for PDF, PNG, PS, EPS, SVG export drawings with Cairo with 3D->2D projection.

Description of class 'Board3DTo2D'

Definition at line 70 of file Board3DTo2D.h.

Member Enumeration Documentation

◆ CairoType

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
enum DGtal::Board3DTo2D::CairoType

Cairo type for save files.

Enumerator
CairoPDF 
CairoPNG 
CairoPS 
CairoEPS 
CairoSVG 

Definition at line 82 of file Board3DTo2D.h.

Constructor & Destructor Documentation

◆ Board3DTo2D() [1/2]

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
DGtal::Board3DTo2D< Space, KSpace >::Board3DTo2D ( )

Constructor.

◆ Board3DTo2D() [2/2]

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
DGtal::Board3DTo2D< Space, KSpace >::Board3DTo2D ( KSpace  KSEmb)
inline

Constructor with a khalimsky space

Parameters
KSEmbthe Khalimsky space

Definition at line 93 of file Board3DTo2D.h.

94  : Display3D<Space,KSpace>( KSEmb )
95  {
96  init();
97  }
virtual void init()

References DGtal::Board3DTo2D< Space, KSpace >::init().

◆ ~Board3DTo2D()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
DGtal::Board3DTo2D< Space, KSpace >::~Board3DTo2D ( )
inline

Definition at line 100 of file Board3DTo2D.h.

100 {}

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
DGtal::Board3DTo2D< Space, KSpace >::BOOST_CONCEPT_ASSERT ( (concepts::CSpace< Space >)  )
private

◆ className()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
std::string DGtal::Board3DTo2D< Space, KSpace >::className ( ) const
inline
Returns
the style name used for drawing this object.

Definition at line 106 of file Board3DTo2D.h.

107  {
108  return "Board3DTo2D";
109  }

◆ init()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
virtual void DGtal::Board3DTo2D< Space, KSpace >::init ( )
protectedvirtual

init function (should be in Constructor).

Referenced by DGtal::Board3DTo2D< Space, KSpace >::Board3DTo2D().

◆ isValid()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
bool DGtal::Board3DTo2D< Space, KSpace >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ LookAtMt()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
static void DGtal::Board3DTo2D< Space, KSpace >::LookAtMt ( double  mat[16],
double  eyex,
double  eyey,
double  eyez,
double  dirx,
double  diry,
double  dirz,
double  upx,
double  upy,
double  upz 
)
staticprivate

Compute 4x4 LookAt matrix.

Parameters
matdestination matrix.
eyexx position of eye.
eyeyy position of eye.
eyezz position of eye.
dirxx direction of eye.
diryy direction of eye.
dirzz director of eye.
upxx coordinate of up-vector.
upyy coordinate of up-vector.
upzz coordinate of up-vector.

◆ MulMt()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
static void DGtal::Board3DTo2D< Space, KSpace >::MulMt ( double  v[4],
double  mat[16],
double  b[4] 
)
staticprivate

Multiply a 3d vector by a 4x4 matrix.

Parameters
vdestination vector.
matsource matrix.
bsource vector.

◆ operator<<() [1/2]

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
Board3DTo2D& DGtal::Board3DTo2D< Space, KSpace >::operator<< ( const DGtal::Color aColor)

Set the default color for future drawing.

Parameters
aColora DGtal::Color (allow to set a trasnparency value).

◆ operator<<() [2/2]

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
template<typename TDrawableWithDisplay3D >
Board3DTo2D& DGtal::Board3DTo2D< Space, KSpace >::operator<< ( const TDrawableWithDisplay3D &  object)

Draws the drawable [object] in this board. It should satisfy the concept CDrawableWithDisplay3D, which requires for instance a method setStyle( Board3DTo2D & ).

Parameters
objectany drawable object.
Returns
a reference on 'this'.

◆ precompute_projection_matrix()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3DTo2D< Space, KSpace >::precompute_projection_matrix ( )
private

Precompute 4x4 projection matrix for 3D->2D projection.

◆ project()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3DTo2D< Space, KSpace >::project ( double  x3d,
double  y3d,
double  z3d,
double &  x2d,
double &  y2d 
)
private

Project a 3d point (3D->2D).

Parameters
x3dx position of the 3d point.
y3dy position of the 3d point.
z3dz position of the 3d point.
x2dx destination projection position of the 2d point.
y2dy destination projection position of the 2d point.

◆ saveCairo()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3DTo2D< Space, KSpace >::saveCairo ( const char *  filename,
CairoType  type,
int  bWidth,
int  bHeight 
)

Save a Cairo image.

Parameters
filenamefilename of the image to save.
typetype of the image to save (CairoPDF, CairoPNG, CairoPS, CairoEPS, CairoSVG).
bWidthwidth of the image to save.
bHeightheight of the image to save.

Referenced by main().

◆ selfDisplay()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3DTo2D< Space, KSpace >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ setCameraDirection()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3DTo2D< Space, KSpace >::setCameraDirection ( double  x,
double  y,
double  z 
)
inline

Set camera direction.

Parameters
xx direction.
yy direction.
zz direction.

Definition at line 126 of file Board3DTo2D.h.

127  { camera_direction[0] = x; camera_direction[1] = y; camera_direction[2] = z; }
double camera_direction[3]
camera direction
Definition: Board3DTo2D.h:266

References DGtal::Board3DTo2D< Space, KSpace >::camera_direction.

◆ setCameraPosition()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3DTo2D< Space, KSpace >::setCameraPosition ( double  x,
double  y,
double  z 
)
inline

Set camera position.

Parameters
xx position.
yy position.
zz position.

Definition at line 117 of file Board3DTo2D.h.

118  { camera_position[0] = x; camera_position[1] = y; camera_position[2] = z; }
double camera_position[3]
camera position
Definition: Board3DTo2D.h:265

References DGtal::Board3DTo2D< Space, KSpace >::camera_position.

◆ setCameraUpVector()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3DTo2D< Space, KSpace >::setCameraUpVector ( double  x,
double  y,
double  z 
)
inline

Set camera up-vector.

Parameters
xx coordinate of up-vector.
yy coordinate of up-vector.
zz coordinate of up-vector.

Definition at line 135 of file Board3DTo2D.h.

136  { camera_upVector[0] = x; camera_upVector[1] = y; camera_upVector[2] = z; }
double camera_upVector[3]
camera up-vector
Definition: Board3DTo2D.h:267

References DGtal::Board3DTo2D< Space, KSpace >::camera_upVector.

◆ setNearFar()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
void DGtal::Board3DTo2D< Space, KSpace >::setNearFar ( double  _near,
double  _far 
)
inline

Set near and far distance, too near or too far end up not visible.

Parameters
_nearnear distance.
_farfar distance.

Definition at line 143 of file Board3DTo2D.h.

143 { ZNear = _near; ZFar = _far; }
double ZNear
znear distance
Definition: Board3DTo2D.h:269
double ZFar
zfar distance
Definition: Board3DTo2D.h:270

References DGtal::Board3DTo2D< Space, KSpace >::ZFar, and DGtal::Board3DTo2D< Space, KSpace >::ZNear.

◆ TransposeMt()

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
static void DGtal::Board3DTo2D< Space, KSpace >::TransposeMt ( double  tmat[16],
double  mat[16] 
)
staticprivate

Transpose a 4x4 matrix.

Parameters
tmatdestination matrix.
matsource matrix.

Field Documentation

◆ camera_direction

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
double DGtal::Board3DTo2D< Space, KSpace >::camera_direction[3]
private

camera direction

Definition at line 266 of file Board3DTo2D.h.

Referenced by DGtal::Board3DTo2D< Space, KSpace >::setCameraDirection().

◆ camera_position

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
double DGtal::Board3DTo2D< Space, KSpace >::camera_position[3]
private

camera position

Definition at line 265 of file Board3DTo2D.h.

Referenced by DGtal::Board3DTo2D< Space, KSpace >::setCameraPosition().

◆ camera_upVector

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
double DGtal::Board3DTo2D< Space, KSpace >::camera_upVector[3]
private

camera up-vector

Definition at line 267 of file Board3DTo2D.h.

Referenced by DGtal::Board3DTo2D< Space, KSpace >::setCameraUpVector().

◆ matrix

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
double DGtal::Board3DTo2D< Space, KSpace >::matrix[16]
private

projection matrix

Definition at line 263 of file Board3DTo2D.h.

◆ myDefaultColor

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
DGtal::Color DGtal::Board3DTo2D< Space, KSpace >::myDefaultColor

default color

The associated map type for storing possible modes used for displaying for digital objects.

Definition at line 169 of file Board3DTo2D.h.

◆ Viewport

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
int DGtal::Board3DTo2D< Space, KSpace >::Viewport[4]
private

2D viewport

Definition at line 262 of file Board3DTo2D.h.

◆ ZFar

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
double DGtal::Board3DTo2D< Space, KSpace >::ZFar
private

zfar distance

Definition at line 270 of file Board3DTo2D.h.

Referenced by DGtal::Board3DTo2D< Space, KSpace >::setNearFar().

◆ ZNear

template<typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
double DGtal::Board3DTo2D< Space, KSpace >::ZNear
private

znear distance

Definition at line 269 of file Board3DTo2D.h.

Referenced by DGtal::Board3DTo2D< Space, KSpace >::setNearFar().


The documentation for this class was generated from the following files: