DGtal  1.4.beta
viewer3D-4bis-illustrationMode.cpp
1 
37 #include <iostream>
38 
39 #include "DGtal/base/Common.h"
40 #include "DGtal/helpers/StdDefs.h"
41 #include "DGtal/shapes/Shapes.h"
42 #include "DGtal/io/viewers/Viewer3D.h"
44 #include "DGtal/io/DrawWithDisplay3DModifier.h"
47 
48 using namespace std;
49 using namespace DGtal;
50 using namespace Z3i;
51 
52 
54 // Standard services - public :
55 
56 int main( int argc, char** argv )
57 {
58 
59  QApplication application(argc,argv);
60 
61  KSpace K;
62  Point plow(0,0,0);
63  Point pup(1,1,0);
64  Domain domain( plow, pup );
65  K.init( plow, pup, true );
66 
68  MyViewer viewer(K);
69  viewer.show();
70 
71  viewer << SetMode3D( domain.className(), "Paving" );
72  viewer << domain;
73 
74  // drawing cells of dimension 3
75 
76  SCell v2 = K.sSpel( Point( 1, 0, 0 ), KSpace::POS ); // +v
77  SCell v3 = K.sSpel( Point( 0, 1, 0 ), KSpace::POS ); // +v
78  SCell v4 = K.sSpel( Point( 1, 1, 0 ), KSpace::NEG ); // +v
80  SCell v = K.sSpel( Point( 0, 0, 0 ), KSpace::POS ); // +v
81  viewer << SetMode3D( v.className(), "Illustration" );
83 
84  viewer << v << v2 << v3;
85 
86 
87  // Surfel of Voxel (0,0)
89  SCell sx = K.sIncident( v, 0, true ); // surfel further along x
90  DGtal::TransformedPrism tsx (sx, v);
92 
93  SCell sy = K.sIncident( v, 1, true ); // surfel further along y
94  SCell sz = K.sIncident( v, 2, true ); // surfel further along z
95  SCell sxn = K.sIncident( v, 0, false ); // surfel further along x
96  SCell syn = K.sIncident( v, 1, false ); // surfel further along y
97  SCell szn = K.sIncident( v, 2, false ); // surfel further along z
98 
99  // Resizing and shifting the surfel towords its associated voxel (v).
100 
101  DGtal::TransformedPrism tsy (sy, v);
102  DGtal::TransformedPrism tsz (sz, v);
103  DGtal::TransformedPrism tsxn (sxn, v);
104  DGtal::TransformedPrism tsyn (syn, v);
105  DGtal::TransformedPrism tszn (szn, v);
106 
107  viewer << tsx << tsy << tsz << tsxn << tsyn << tszn;
108 
109 
110  // Surfel of Voxel (1,0)
111  SCell sx2 = K.sIncident( v2, 0, true ); // surfel further along x
112  SCell sy2 = K.sIncident( v2, 1, true ); // surfel further along y
113  SCell sz2 = K.sIncident( v2, 2, true ); // surfel further along z
114  SCell sxn2 = K.sIncident( v2, 0, false ); // surfel further along x
115  SCell syn2 = K.sIncident( v2, 1, false ); // surfel further along y
116  SCell szn2 = K.sIncident( v2, 2, false ); // surfel further along z
117 
118  // Resizing and shifting the surfel towords its associated voxel (v2).
119  DGtal::TransformedPrism tsx2 (sx2, v2);
120  DGtal::TransformedPrism tsy2 (sy2, v2);
121  DGtal::TransformedPrism tsz2 (sz2, v2);
122  DGtal::TransformedPrism tsxn2 (sxn2, v2);
123  DGtal::TransformedPrism tsyn2 (syn2, v2);
124  DGtal::TransformedPrism tszn2 (szn2, v2);
125 
126  viewer << tsx2 << tsy2 << tsz2 << tsxn2 << tsyn2 << tszn2;
127 
128 
129  // Surfel of Voxel (0,1)
130  SCell sx3 = K.sIncident( v3, 0, true ); // surfel further along x
131  SCell sy3 = K.sIncident( v3, 1, true ); // surfel further along y
132  SCell sz3 = K.sIncident( v3, 2, true ); // surfel further along z
133  SCell sxn3 = K.sIncident( v3, 0, false ); // surfel further along x
134  SCell syn3 = K.sIncident( v3, 1, false ); // surfel further along y
135  SCell szn3 = K.sIncident( v3, 2, false ); // surfel further along z
136 
137  // Shifting the surfel to its associated voxel (v3).
138  DGtal::TransformedPrism tsx3 (sx3, v3);
139  DGtal::TransformedPrism tsy3 (sy3, v3);
140  DGtal::TransformedPrism tsz3 (sz3, v3);
141  DGtal::TransformedPrism tsxn3 (sxn3, v3);
142  DGtal::TransformedPrism tsyn3 (syn3, v3);
143  DGtal::TransformedPrism tszn3 (szn3, v3);
144 
145 
146  viewer << tsx3 << tsy3 << tsz3 << tsxn3 << tsyn3 << tszn3;
147  viewer << MyViewer::updateDisplay;
148 
149  return application.exec();
150 }
151 // //
std::string className() const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
SCell sSpel(Point p, Sign sign=POS) const
From the digital coordinates of a point in Zn, builds the corresponding spel (cell of maximal dimensi...
SCell sIncident(const SCell &c, Dimension k, bool up) const
Return the forward or backward signed cell incident to [c] along axis [k], depending on [up].
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....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
class to modify the position and scale to construct better illustration mode.
int main(int argc, char **argv)
MyPointD Point
Definition: testClone2.cpp:383
KSpace K
Domain domain