DGtal  0.9.2
viewer3D-4bis-illustrationMode.cpp
1 
30 #include <iostream>
32 
33 #include "DGtal/base/Common.h"
34 #include "DGtal/helpers/StdDefs.h"
35 #include "DGtal/shapes/Shapes.h"
36 #include "DGtal/io/viewers/Viewer3D.h"
38 #include "DGtal/io/DrawWithDisplay3DModifier.h"
41 
42 using namespace std;
43 using namespace DGtal;
44 using namespace Z3i;
45 
46 
48 // Standard services - public :
49 
50 int main( int argc, char** argv )
51 {
52 
53  QApplication application(argc,argv);
54 
55  KSpace K;
56  Point plow(0,0,0);
57  Point pup(1,1,0);
58  Domain domain( plow, pup );
59  K.init( plow, pup, true );
60 
62  MyViewer viewer(K);
63  viewer.show();
64 
65  viewer << SetMode3D( domain.className(), "Paving" );
66  viewer << domain;
67 
68  // drawing cells of dimension 3
69 
70  SCell v2 = K.sSpel( Point( 1, 0, 0 ), KSpace::POS ); // +v
71  SCell v3 = K.sSpel( Point( 0, 1, 0 ), KSpace::POS ); // +v
72  SCell v4 = K.sSpel( Point( 1, 1, 0 ), KSpace::NEG ); // +v
74  SCell v = K.sSpel( Point( 0, 0, 0 ), KSpace::POS ); // +v
75  viewer << SetMode3D( v.className(), "Illustration" );
77 
78  viewer << v << v2 << v3;
79 
80 
81  // Surfel of Voxel (0,0)
83  SCell sx = K.sIncident( v, 0, true ); // surfel further along x
84  DGtal::TransformedPrism tsx (sx, v);
86 
87  SCell sy = K.sIncident( v, 1, true ); // surfel further along y
88  SCell sz = K.sIncident( v, 2, true ); // surfel further along z
89  SCell sxn = K.sIncident( v, 0, false ); // surfel further along x
90  SCell syn = K.sIncident( v, 1, false ); // surfel further along y
91  SCell szn = K.sIncident( v, 2, false ); // surfel further along z
92 
93  // Resizing and shifting the surfel towords its associated voxel (v).
94 
95  DGtal::TransformedPrism tsy (sy, v);
96  DGtal::TransformedPrism tsz (sz, v);
97  DGtal::TransformedPrism tsxn (sxn, v);
98  DGtal::TransformedPrism tsyn (syn, v);
99  DGtal::TransformedPrism tszn (szn, v);
100 
101  viewer << tsx << tsy << tsz << tsxn << tsyn << tszn;
102 
103 
104  // Surfel of Voxel (1,0)
105  SCell sx2 = K.sIncident( v2, 0, true ); // surfel further along x
106  SCell sy2 = K.sIncident( v2, 1, true ); // surfel further along y
107  SCell sz2 = K.sIncident( v2, 2, true ); // surfel further along z
108  SCell sxn2 = K.sIncident( v2, 0, false ); // surfel further along x
109  SCell syn2 = K.sIncident( v2, 1, false ); // surfel further along y
110  SCell szn2 = K.sIncident( v2, 2, false ); // surfel further along z
111 
112  // Resizing and shifting the surfel towords its associated voxel (v2).
113  DGtal::TransformedPrism tsx2 (sx2, v2);
114  DGtal::TransformedPrism tsy2 (sy2, v2);
115  DGtal::TransformedPrism tsz2 (sz2, v2);
116  DGtal::TransformedPrism tsxn2 (sxn2, v2);
117  DGtal::TransformedPrism tsyn2 (syn2, v2);
118  DGtal::TransformedPrism tszn2 (szn2, v2);
119 
120  viewer << tsx2 << tsy2 << tsz2 << tsxn2 << tsyn2 << tszn2;
121 
122 
123  // Surfel of Voxel (0,1)
124  SCell sx3 = K.sIncident( v3, 0, true ); // surfel further along x
125  SCell sy3 = K.sIncident( v3, 1, true ); // surfel further along y
126  SCell sz3 = K.sIncident( v3, 2, true ); // surfel further along z
127  SCell sxn3 = K.sIncident( v3, 0, false ); // surfel further along x
128  SCell syn3 = K.sIncident( v3, 1, false ); // surfel further along y
129  SCell szn3 = K.sIncident( v3, 2, false ); // surfel further along z
130 
131  // Shifting the surfel to its associated voxel (v3).
132  DGtal::TransformedPrism tsx3 (sx3, v3);
133  DGtal::TransformedPrism tsy3 (sy3, v3);
134  DGtal::TransformedPrism tsz3 (sz3, v3);
135  DGtal::TransformedPrism tsxn3 (sxn3, v3);
136  DGtal::TransformedPrism tsyn3 (syn3, v3);
137  DGtal::TransformedPrism tszn3 (szn3, v3);
138 
139 
140  viewer << tsx3 << tsy3 << tsz3 << tsxn3 << tsyn3 << tszn3;
141  viewer << MyViewer::updateDisplay;
142 
143  return application.exec();
144 }
145 // //
KhalimskySpaceND< 2, Integer > KSpace
Definition: StdDefs.h:77
STL namespace.
std::string className() const
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.