DGtal  0.9.2
dgtalBoard3D-2-ks.cpp
1 
29 #include <iostream>
30 #include "DGtal/io/boards/Board3D.h"
31 #include "DGtal/base/Common.h"
32 #include "DGtal/helpers/StdDefs.h"
33 #include "DGtal/shapes/Shapes.h"
34 #include "DGtal/io/DrawWithDisplay3DModifier.h"
35 
36 using namespace std;
37 using namespace DGtal;
38 using namespace Z3i;
39 
40 
41 // Standard services - public :
42 
43 int main( )
44 {
45 
46  KSpace K;
47  Point plow(0,0,0);
48  Point pup(1,1,0);
49  Domain domain( plow, pup );
50  K.init( plow, pup, true );
51 
52  Board3D<Space, KSpace> board(K);
53 
54  // drawing cells of dimension 3
55 
56  SCell v2 = K.sSpel( Point( 1, 0, 0 ), KSpace::POS ); // +v
57  SCell v3 = K.sSpel( Point( 0, 1, 0 ), KSpace::POS ); // +v
58  SCell v4 = K.sSpel( Point( 1, 1, 0 ), KSpace::NEG ); // +v
60  SCell v = K.sSpel( Point( 0, 0, 0 ), KSpace::POS ); // +v
61  board << SetMode3D( v.className(), "Illustration" );
63 
64  board << v << v2 << v3;
65  board.saveOBJ("board3D-2-ks.obj");
66 
67  Board3D<Space, KSpace> board2(K);
68 
69  // Surfel of Voxel (0,0)
71  SCell sx = K.sIncident( v, 0, true ); // surfel further along x
72  DGtal::TransformedPrism tsx (sx, v);
74 
75  SCell sy = K.sIncident( v, 1, true ); // surfel further along y
76  SCell sz = K.sIncident( v, 2, true ); // surfel further along z
77  SCell sxn = K.sIncident( v, 0, false ); // surfel further along x
78  SCell syn = K.sIncident( v, 1, false ); // surfel further along y
79  SCell szn = K.sIncident( v, 2, false ); // surfel further along z
80 
81  // Resizing and shifting the surfel towords its associated voxel (v).
82 
83  DGtal::TransformedPrism tsy (sy, v);
84  DGtal::TransformedPrism tsz (sz, v);
85  DGtal::TransformedPrism tsxn (sxn, v);
86  DGtal::TransformedPrism tsyn (syn, v);
87  DGtal::TransformedPrism tszn (szn, v);
88 
89  board2 << tsx << tsy << tsz << tsxn << tsyn << tszn;
90 
91 
92  // Surfel of Voxel (1,0)
93  SCell sx2 = K.sIncident( v2, 0, true ); // surfel further along x
94  SCell sy2 = K.sIncident( v2, 1, true ); // surfel further along y
95  SCell sz2 = K.sIncident( v2, 2, true ); // surfel further along z
96  SCell sxn2 = K.sIncident( v2, 0, false ); // surfel further along x
97  SCell syn2 = K.sIncident( v2, 1, false ); // surfel further along y
98  SCell szn2 = K.sIncident( v2, 2, false ); // surfel further along z
99 
100  // Resizing and shifting the surfel towords its associated voxel (v2).
101  DGtal::TransformedPrism tsx2 (sx2, v2);
102  DGtal::TransformedPrism tsy2 (sy2, v2);
103  DGtal::TransformedPrism tsz2 (sz2, v2);
104  DGtal::TransformedPrism tsxn2 (sxn2, v2);
105  DGtal::TransformedPrism tsyn2 (syn2, v2);
106  DGtal::TransformedPrism tszn2 (szn2, v2);
107 
108  board2 << tsx2 << tsy2 << tsz2 << tsxn2 << tsyn2 << tszn2;
109 
110 
111  // Surfel of Voxel (0,1)
112  SCell sx3 = K.sIncident( v3, 0, true ); // surfel further along x
113  SCell sy3 = K.sIncident( v3, 1, true ); // surfel further along y
114  SCell sz3 = K.sIncident( v3, 2, true ); // surfel further along z
115  SCell sxn3 = K.sIncident( v3, 0, false ); // surfel further along x
116  SCell syn3 = K.sIncident( v3, 1, false ); // surfel further along y
117  SCell szn3 = K.sIncident( v3, 2, false ); // surfel further along z
118 
119  // Shifting the surfel to its associated voxel (v3).
120  DGtal::TransformedPrism tsx3 (sx3, v3);
121  DGtal::TransformedPrism tsy3 (sy3, v3);
122  DGtal::TransformedPrism tsz3 (sz3, v3);
123  DGtal::TransformedPrism tsxn3 (sxn3, v3);
124  DGtal::TransformedPrism tsyn3 (syn3, v3);
125  DGtal::TransformedPrism tszn3 (szn3, v3);
126 
127 
128  board2 << tsx3 << tsy3 << tsz3 << tsxn3 << tsyn3 << tszn3;
129 
130  std::cout << "save obj" << std::endl;
131  board2.saveOBJ("board3D-2bis-ks.obj");
132 
133 
134 }
KhalimskySpaceND< 2, Integer > KSpace
Definition: StdDefs.h:77
STL namespace.
The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling ...
Definition: Board3D.h:81
DGtal is the top-level namespace which contains all DGtal functions and types.
class to modify the position and scale to construct better illustration mode.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithDisplay3D.