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