DGtal  1.0.0
ctopo-1-3d.cpp
Go to the documentation of this file.
1 
55 #include <iostream>
57 #include "DGtal/base/Common.h"
58 #include "DGtal/helpers/StdDefs.h"
59 
60 #include "DGtal/io/DrawWithDisplay3DModifier.h"
61 #include "DGtal/io/viewers/Viewer3D.h"
62 
64 
65 using namespace std;
66 using namespace DGtal;
67 using namespace DGtal::Z3i;
68 
70 
71 int main( int argc, char** argv )
72 {
73  // for 3D display with Viewer3D
74  QApplication application(argc,argv);
75 
76  KSpace K;
77  Point plow(0,0,0);
78  Point pup(3,3,2);
79  Domain domain( plow, pup );
80  K.init( plow, pup, true );
81  //
83  MyViewer viewer(K);
84  viewer.show();
85  viewer << SetMode3D( domain.className(), "Paving" );
86 
87  Cell ptlow = K.uPointel( plow ); // pointel (0*2,0*2, 0*2)
88  Cell ptup1 = K.uPointel( pup ); // pointel (3*2,3*2, 2*2)
89  Cell ptup2 = K.uTranslation( ptup1, Point::diagonal() ); // pointel (4*2, 4*2, 3*2)
90 
91  viewer << ptlow << ptup1 << ptup2;
92 
93  // drawing cells of dimension 0
94  Cell p1= K.uCell(Point(0,0,2)); // pointel (0*2,0*2,2*2)
95  Cell p2= K.uCell(Point(0,2,2)); // ...
96  Cell p3= K.uCell(Point(2,2,2));
97  Cell p4= K.uCell(Point(2,0,2));
98  Cell p5= K.uCell(Point(0,0,4));
99  Cell p6= K.uCell(Point(0,2,4));
100  Cell p7= K.uCell(Point(2,2,4));
101  Cell p8= K.uCell(Point(2,0,4));
102  viewer << p1 << p2 << p3 << p4 << p5 << p6 << p7 << p8;
103 
104  // drawing Cells of dimension 1
105  Cell linel0 = K.uCell( Point( 1, 0, 2 ) ); // linel (2*1+1, 0, 2*2)
106  Cell linel1 = K.uCell( Point( 1, 2, 2 ) ); // ...
107  Cell linel2 = K.uCell( Point( 0, 1, 2 ) );
108  Cell linel3 = K.uCell( Point( 2, 1, 2 ) );
109 
110  Cell linel4 = K.uCell( Point( 1, 0, 4 ) );
111  Cell linel5 = K.uCell( Point( 1, 2, 4 ) );
112  Cell linel6 = K.uCell( Point( 0, 1, 4 ) );
113  Cell linel7 = K.uCell( Point( 2, 1, 4 ) );
114 
115  Cell linel8 = K.uCell( Point( 0, 0, 3 ) );
116  Cell linel9 = K.uCell( Point( 0, 2, 3 ) );
117  Cell linel10 = K.uCell( Point( 2, 0, 3 ) );
118  Cell linel11 = K.uCell( Point( 2, 2, 3 ) );
119 
120 
121  Cell linel12 = K.uCell( Point( 3, 2, 2 ) );
122 
123  viewer << linel0<< linel1<< linel2 << linel3 ;
124  viewer << linel4<< linel5<< linel6 << linel7 ;
125  viewer << linel8<< linel9<< linel10 << linel11 << linel12;
126 
127  // drawing cells of dimension 2
128 
129  Cell surfelA = K.uCell( Point( 2, 1, 3 ) ); // surfel (2*2,2*1+1,2*3+1)
130  Cell surfelB = K.uCell( Point( 1, 0, 1 ) ); // surfel (2*1,2*0,2*1+1)
131  Cell surfelC = K.uCell( Point( 2, 1, 1 ) ); // surfel (2*2,2*1+1,2*1+1)
132  viewer << surfelA << surfelB << surfelC;
133 
134  // drawing cells of dimension 3
135  Cell vox1 = K.uCell( Point( 3, 3, 3 ) ); // voxel (2*3+1,2*3+1,2*3+1)
136  Cell vox2 = K.uCell( Point( 1, 1, 3 ) ); // voxel (2*1+1,2*1+1,2*3+1)
137  viewer << vox1 << vox2;
138 
139  viewer<< MyViewer::updateDisplay;
140  return application.exec();
141 
142 }
Cell uPointel(Point p) const
From the digital coordinates of a point in Zn, builds the corresponding pointel (cell of dimension 0)...
Z3i this namespace gathers the standard of types for 3D imagery.
Domain domain
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Cell uCell(const PreCell &c) const
From an unsigned cell, returns an unsigned cell lying into this Khalismky space.
std::string className() const
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
KSpace K
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Cell uTranslation(const Cell &p, const Vector &vec) const
Add the vector [vec] to [p].
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
int main(int argc, char **argv)
Definition: ctopo-1-3d.cpp:71
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....