DGtal  0.9.2
ctopo-1-3d.cpp
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 
35 #include "DGtal/io/DrawWithDisplay3DModifier.h"
36 #include "DGtal/io/viewers/Viewer3D.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  //
58  MyViewer viewer(K);
59  viewer.show();
60  viewer << SetMode3D( domain.className(), "Paving" );
61 
62  Cell ptlow = K.uPointel( plow ); // pointel (0*2,0*2, 0*2)
63  Cell ptup1 = K.uPointel( pup ); // pointel (3*2,3*2, 2*2)
64  Cell ptup2 = K.uTranslation( ptup1, Point::diagonal() ); // pointel (4*2, 4*2, 3*2)
65 
66  viewer << ptlow << ptup1 << ptup2;
67 
68  // drawing cells of dimension 0
69  Cell p1= K.uCell(Point(0,0,2)); // pointel (0*2,0*2,2*2)
70  Cell p2= K.uCell(Point(0,2,2)); // ...
71  Cell p3= K.uCell(Point(2,2,2));
72  Cell p4= K.uCell(Point(2,0,2));
73  Cell p5= K.uCell(Point(0,0,4));
74  Cell p6= K.uCell(Point(0,2,4));
75  Cell p7= K.uCell(Point(2,2,4));
76  Cell p8= K.uCell(Point(2,0,4));
77  viewer << p1 << p2 << p3 << p4 << p5 << p6 << p7 << p8;
78 
79  // drawing Cells of dimension 1
80  Cell linel0 = K.uCell( Point( 1, 0, 2 ) ); // linel (2*1+1, 0, 2*2)
81  Cell linel1 = K.uCell( Point( 1, 2, 2 ) ); // ...
82  Cell linel2 = K.uCell( Point( 0, 1, 2 ) );
83  Cell linel3 = K.uCell( Point( 2, 1, 2 ) );
84 
85  Cell linel4 = K.uCell( Point( 1, 0, 4 ) );
86  Cell linel5 = K.uCell( Point( 1, 2, 4 ) );
87  Cell linel6 = K.uCell( Point( 0, 1, 4 ) );
88  Cell linel7 = K.uCell( Point( 2, 1, 4 ) );
89 
90  Cell linel8 = K.uCell( Point( 0, 0, 3 ) );
91  Cell linel9 = K.uCell( Point( 0, 2, 3 ) );
92  Cell linel10 = K.uCell( Point( 2, 0, 3 ) );
93  Cell linel11 = K.uCell( Point( 2, 2, 3 ) );
94 
95 
96  Cell linel12 = K.uCell( Point( 3, 2, 2 ) );
97 
98  viewer << linel0<< linel1<< linel2 << linel3 ;
99  viewer << linel4<< linel5<< linel6 << linel7 ;
100  viewer << linel8<< linel9<< linel10 << linel11 << linel12;
101 
102  // drawing cells of dimension 2
103 
104  Cell surfelA = K.uCell( Point( 2, 1, 3 ) ); // surfel (2*2,2*1+1,2*3+1)
105  Cell surfelB = K.uCell( Point( 1, 0, 1 ) ); // surfel (2*1,2*0,2*1+1)
106  Cell surfelC = K.uCell( Point( 2, 1, 1 ) ); // surfel (2*2,2*1+1,2*1+1)
107  viewer << surfelA << surfelB << surfelC;
108 
109  // drawing cells of dimension 3
110  Cell vox1 = K.uCell( Point( 3, 3, 3 ) ); // voxel (2*3+1,2*3+1,2*3+1)
111  Cell vox2 = K.uCell( Point( 1, 1, 3 ) ); // voxel (2*1+1,2*1+1,2*3+1)
112  viewer << vox1 << vox2;
113 
114  viewer<< MyViewer::updateDisplay;
115  return application.exec();
116 
117 }
Z3i this namespace gathers the standard of types for 3D imagery.
STL namespace.
Cell uCell(const PreCell &c) const
Cell uPointel(Point p) const
std::string className() const
bool init(const Point &lower, const Point &upper, bool isClosed)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...
Modifier class in a Display3D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithDisplay3D.
Cell uTranslation(const Cell &p, const Vector &vec) const