DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ctopo-1s-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"
38 
39 using namespace std;
40 using namespace DGtal;
41 using namespace DGtal::Z3i;
42 
44 
45 int main( int argc, char** argv )
46 {
47  // for 3D display with Viewer3D
48  QApplication application(argc,argv);
49 
50  KSpace K;
51  Point plow(0,0,0);
52  Point pup(3,3,2);
53  Domain domain( plow, pup );
54  K.init( plow, pup, true );
55 
56  Viewer3D viewer;
57  viewer.show();
58  viewer << SetMode3D( domain.className(), "Paving" );
59 
60  SCell ptlow = K.sPointel( plow ); // pointel (0*2,0*2, 0*2)
61  SCell ptup1 = K.sPointel( pup ); // pointel (3*2,3*2, 2*2)
62  SCell ptup2 = K.sTranslation( ptup1, Point::diagonal() ); // pointel (4*2, 4*2, 3*2)
63 
64  viewer << ptlow << ptup1 << ptup2;
65 
66  // drawing cells of dimension 0
67  SCell p1= K.sCell(Point(0,0,2),false); // pointel (0*2,0*2,2*2)
68  SCell p2= K.sCell(Point(0,2,2)); // ...
69  SCell p3= K.sCell(Point(2,2,2),false);
70  SCell p4= K.sCell(Point(2,0,2));
71  SCell p5= K.sCell(Point(0,0,4),false);
72  SCell p6= K.sCell(Point(0,2,4));
73  SCell p7= K.sCell(Point(2,2,4), false);
74  SCell p8= K.sCell(Point(2,0,4));
75  viewer << p1 << p2 << p3 << p4 << p5 << p6 << p7 << p8;
76 
77  // drawing Cells of dimension 1
78  SCell linel0 = K.sCell( Point( 1, 0, 2 ) ); // linel (2*1+1, 0, 2*2)
79  SCell linel1 = K.sCell( Point( 1, 2, 2 ) ); // ...
80  SCell linel2 = K.sCell( Point( 0, 1, 2 ) );
81  SCell linel3 = K.sCell( Point( 2, 1, 2 ) );
82 
83  SCell linel4 = K.sCell( Point( 1, 0, 4 ) );
84  SCell linel5 = K.sCell( Point( 1, 2, 4 ) );
85  SCell linel6 = K.sCell( Point( 0, 1, 4 ) );
86  SCell linel7 = K.sCell( Point( 2, 1, 4 ) );
87 
88  SCell linel8 = K.sCell( Point( 0, 0, 3 ) );
89  SCell linel9 = K.sCell( Point( 0, 2, 3 ) );
90  SCell linel10 = K.sCell( Point( 2, 0, 3 ) );
91  SCell linel11 = K.sCell( Point( 2, 2, 3 ) );
92 
93 
94  SCell linel12 = K.sCell( Point( 3, 2, 2 ) );
95 
96  viewer << linel0<< linel1<< linel2 << linel3 ;
97  viewer << linel4<< linel5<< linel6 << linel7 ;
98  viewer << linel8<< linel9<< linel10 << linel11 << linel12;
99 
100  // drawing cells of dimension 2
101 
102  SCell surfelA = K.sCell( Point( 2, 1, 3 ) ); // surfel (2*2,2*1+1,2*3+1)
103  SCell surfelB = K.sCell( Point( 1, 0, 1 ) ); // surfel (2*1,2*0,2*1+1)
104  SCell surfelC = K.sCell( Point( 2, 1, 1 ),false ); // surfel (2*2,2*1+1,2*1+1)
105  viewer << surfelA << surfelB << surfelC;
106 
107  // drawing cells of dimension 3
108  SCell vox1 = K.sCell( Point( 3, 3, 3 ) ); // voxel (2*3+1,2*3+1,2*3+1)
109  SCell vox2 = K.sCell( Point( 1, 1, 3 ) ,false ); // voxel (2*1+1,2*1+1,2*3+1)
110  viewer << vox1 << vox2;
111 
112  viewer << CameraPosition(-2.9, 2.96, 2.64)
113  << CameraDirection(0.6, -0.43, 0.65)
114  << CameraUpVector(0.32, 0.900, 0.29);
115  viewer<< Viewer3D::updateDisplay;
116  return application.exec();
117 
118  return 0;
119 }