DGtal  0.9.3
dgtalBoard3DTo2D-KSCell.cpp
1 
37 //#include <iostream>
39 #include "DGtal/io/boards/Board3DTo2D.h"
40 #include "DGtal/base/Common.h"
41 #include "DGtal/helpers/StdDefs.h"
42 #include "DGtal/shapes/Shapes.h"
44 
45 using namespace std;
46 using namespace DGtal;
47 using namespace Z3i;
48 
50 // Standard services - public :
51 
52 int main()
53 {
54 
55 
56  KSpace K;
57  Point plow(0,0,0);
58  Point pup(3,3,2);
59  Domain domain( plow, pup );
60  K.init( plow, pup, true );
61 
62  Board3DTo2D<> board(K);
63 
64  board << SetMode3D( domain.className(), "Paving" );
65  board << domain;
66 
67  // Drawing cell of dimension 3
68  Cell voxelA = K.uCell(Point(1,1,1));
69  SCell voxelB = K.sCell(Point(1,1,3));
70  board << voxelB << voxelA;
71 
72  // drawing cells of dimension 2
73  SCell surfelA = K.sCell( Point( 2, 1, 3 ) );
74  SCell surfelB = K.sCell( Point( 1, 0, 1 ), false );
75  Cell surfelC = K.uCell( Point( 1, 2, 1 ) );
76  SCell surfelD = K.sCell( Point( 1, 1, 0 ) );
77  Cell surfelE = K.uCell( Point( 1, 1, 2 ) );
78  board << surfelA << surfelB << surfelC << surfelD << surfelE;
79 
80  Cell linelA = K.uCell(Point(2,1 ,2));
81  SCell linelB = K.sCell(Point(2,2 ,1));
82  SCell linelC = K.sCell(Point(1,2 ,2), false);
83  board << linelA << linelB << linelC;
84 
85  Cell center = K.uCell(Point(5,5,5));
86 
87  // Testing display of oriented surfels:
88  SCell ssurfelXZ = K.sCell( Point( 5, 6, 5 ), false );
89  SCell ssurfelXY = K.sCell( Point( 5, 5, 6 ), false );
90  SCell ssurfelZY = K.sCell( Point( 6, 5, 5 ), false );
91  board << center;
92 
93  SCell ssurfelXZo = K.sCell( Point( 5, 4, 5 ), false );
94  SCell ssurfelXYo = K.sCell( Point( 5, 5, 4 ), false );
95  SCell ssurfelZYo = K.sCell( Point( 4, 5, 5 ), false );
96 
97  board << ssurfelXZ << ssurfelXY << ssurfelZY;
98  board << ssurfelXZo << ssurfelXYo << ssurfelZYo;
99 
100  // Testing display oriented pointels
101 
102  Cell pointelA = K.uCell(Point(2, 2, 2));
103  SCell pointelB = K.sCell(Point(4, 4, 4), true);
104  SCell pointelC = K.sCell(Point(6, 4, 4), false);
105  SCell linelAC = K.sCell(Point(5, 4, 4), false);
106  board << pointelA << pointelB << pointelC << linelAC;
107 
108  /*board << CameraPosition(2.69044, 1.73705, -1.89961)
109  << CameraDirection(-0.515153, -0.212857, 0.830247)
110  << CameraUpVector(0.48806, -0.869135, 0.0800053);*/
111 
112  board << CameraPosition(3.49239, 3.04746, -1.40276)
113  << CameraDirection(-0.605129, -0.454197, 0.653853)
114  << CameraUpVector(0.516135, -0.84913, -0.112173);
115 
116  //board << SetMode3D(board.className(), "WireFrameMode");
117  board.saveCairo("dgtalBoard3DTo2D-KSCell.png", Board3DTo2D<Space, KSpace>::CairoPNG, 600, 400);
118 
119 }
120 // //
CameraUpVector class to set camera up-vector.
const Domain domain(Point(1, 2), Point(6, 5))
Class for PDF, PNG, PS, EPS, SVG export drawings with Cairo with 3D->2D projection.
Definition: Common.h:145
KhalimskySpaceND< 2, Integer > KSpace
Definition: StdDefs.h:77
CameraDirection class to set camera direction.
STL namespace.
CameraPosition class to set camera position.
int main(int argc, char **argv)
std::string className() const
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
KSpace K
KSpace::Cell Cell
Modifier class in a Display3D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithDisplay3D.