DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ctopo-1-3d.cpp
1 
30 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include <QtGui/qapplication.h>
35 #include "DGtal/io/viewers/Viewer3D.h"
36 #include "DGtal/io/DrawWithDisplay3DModifier.h"
37 
39 
40 using namespace std;
41 using namespace DGtal;
42 using namespace DGtal::Z3i;
43 
45 
46 int main( int argc, char** argv )
47 {
48  // for 3D display with Viewer3D
49  QApplication application(argc,argv);
50 
51  KSpace K;
52  Point plow(0,0,0);
53  Point pup(3,3,2);
54  Domain domain( plow, pup );
55  K.init( plow, pup, true );
56 
57  Viewer3D viewer;
58  viewer.show();
59  viewer << SetMode3D( domain.className(), "Paving" );
60 
61  Cell ptlow = K.uPointel( plow ); // pointel (0*2,0*2, 0*2)
62  Cell ptup1 = K.uPointel( pup ); // pointel (3*2,3*2, 2*2)
63  Cell ptup2 = K.uTranslation( ptup1, Point::diagonal() ); // pointel (4*2, 4*2, 3*2)
64 
65  viewer << ptlow << ptup1 << ptup2;
66 
67  // drawing cells of dimension 0
68  Cell p1= K.uCell(Point(0,0,2)); // pointel (0*2,0*2,2*2)
69  Cell p2= K.uCell(Point(0,2,2)); // ...
70  Cell p3= K.uCell(Point(2,2,2));
71  Cell p4= K.uCell(Point(2,0,2));
72  Cell p5= K.uCell(Point(0,0,4));
73  Cell p6= K.uCell(Point(0,2,4));
74  Cell p7= K.uCell(Point(2,2,4));
75  Cell p8= K.uCell(Point(2,0,4));
76  viewer << p1 << p2 << p3 << p4 << p5 << p6 << p7 << p8;
77 
78  // drawing Cells of dimension 1
79  Cell linel0 = K.uCell( Point( 1, 0, 2 ) ); // linel (2*1+1, 0, 2*2)
80  Cell linel1 = K.uCell( Point( 1, 2, 2 ) ); // ...
81  Cell linel2 = K.uCell( Point( 0, 1, 2 ) );
82  Cell linel3 = K.uCell( Point( 2, 1, 2 ) );
83 
84  Cell linel4 = K.uCell( Point( 1, 0, 4 ) );
85  Cell linel5 = K.uCell( Point( 1, 2, 4 ) );
86  Cell linel6 = K.uCell( Point( 0, 1, 4 ) );
87  Cell linel7 = K.uCell( Point( 2, 1, 4 ) );
88 
89  Cell linel8 = K.uCell( Point( 0, 0, 3 ) );
90  Cell linel9 = K.uCell( Point( 0, 2, 3 ) );
91  Cell linel10 = K.uCell( Point( 2, 0, 3 ) );
92  Cell linel11 = K.uCell( Point( 2, 2, 3 ) );
93 
94 
95  Cell linel12 = K.uCell( Point( 3, 2, 2 ) );
96 
97  viewer << linel0<< linel1<< linel2 << linel3 ;
98  viewer << linel4<< linel5<< linel6 << linel7 ;
99  viewer << linel8<< linel9<< linel10 << linel11 << linel12;
100 
101  // drawing cells of dimension 2
102 
103  Cell surfelA = K.uCell( Point( 2, 1, 3 ) ); // surfel (2*2,2*1+1,2*3+1)
104  Cell surfelB = K.uCell( Point( 1, 0, 1 ) ); // surfel (2*1,2*0,2*1+1)
105  Cell surfelC = K.uCell( Point( 2, 1, 1 ) ); // surfel (2*2,2*1+1,2*1+1)
106  viewer << surfelA << surfelB << surfelC;
107 
108  // drawing cells of dimension 3
109  Cell vox1 = K.uCell( Point( 3, 3, 3 ) ); // voxel (2*3+1,2*3+1,2*3+1)
110  Cell vox2 = K.uCell( Point( 1, 1, 3 ) ); // voxel (2*1+1,2*1+1,2*3+1)
111  viewer << vox1 << vox2;
112 
113  viewer<< Viewer3D::updateDisplay;
114  return application.exec();
115 
116 }