DGtal  0.9.2
ctopo-1s-3d.cpp
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/io/viewers/Viewer3D.h"
35 
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 
57  MyViewer viewer(K);
58  viewer.show();
59  //viewer << SetMode3D( domain.className(), "Paving" );
60 
61  SCell ptlow = K.sPointel( plow ); // pointel (0*2,0*2, 0*2)
62  SCell ptup1 = K.sPointel( pup ); // pointel (3*2,3*2, 2*2)
63  SCell ptup2 = K.sTranslation( ptup1, Point::diagonal() ); // pointel (4*2, 4*2, 3*2)
64 
65  viewer << ptlow << ptup1 << ptup2;
66 
67  // drawing cells of dimension 0
68  SCell p1= K.sCell(Point(0,0,2),false); // pointel (0*2,0*2,2*2)
69  SCell p2= K.sCell(Point(0,2,2)); // ...
70  SCell p3= K.sCell(Point(2,2,2),false);
71  SCell p4= K.sCell(Point(2,0,2));
72  SCell p5= K.sCell(Point(0,0,4),false);
73  SCell p6= K.sCell(Point(0,2,4));
74  SCell p7= K.sCell(Point(2,2,4), false);
75  SCell p8= K.sCell(Point(2,0,4));
76  viewer << p1 << p2 << p3 << p4 << p5 << p6 << p7 << p8;
77 
78  // drawing Cells of dimension 1
79  SCell linel0 = K.sCell( Point( 1, 0, 2 ) ); // linel (2*1+1, 0, 2*2)
80  SCell linel1 = K.sCell( Point( 1, 2, 2 ) ); // ...
81  SCell linel2 = K.sCell( Point( 0, 1, 2 ) );
82  SCell linel3 = K.sCell( Point( 2, 1, 2 ) );
83 
84  SCell linel4 = K.sCell( Point( 1, 0, 4 ) );
85  SCell linel5 = K.sCell( Point( 1, 2, 4 ) );
86  SCell linel6 = K.sCell( Point( 0, 1, 4 ) );
87  SCell linel7 = K.sCell( Point( 2, 1, 4 ) );
88 
89  SCell linel8 = K.sCell( Point( 0, 0, 3 ) );
90  SCell linel9 = K.sCell( Point( 0, 2, 3 ) );
91  SCell linel10 = K.sCell( Point( 2, 0, 3 ) );
92  SCell linel11 = K.sCell( Point( 2, 2, 3 ) );
93 
94 
95  SCell linel12 = K.sCell( 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  SCell surfelA = K.sCell( Point( 2, 1, 3 ) ); // surfel (2*2,2*1+1,2*3+1)
104  SCell surfelB = K.sCell( Point( 1, 0, 1 ) ); // surfel (2*1,2*0,2*1+1)
105  SCell surfelC = K.sCell( Point( 2, 1, 1 ),false ); // surfel (2*2,2*1+1,2*1+1)
106  viewer << surfelA << surfelB << surfelC;
107 
108  // drawing cells of dimension 3
109  SCell vox1 = K.sCell( Point( 3, 3, 3 ) ); // voxel (2*3+1,2*3+1,2*3+1)
110  SCell vox2 = K.sCell( Point( 1, 1, 3 ) ,false ); // voxel (2*1+1,2*1+1,2*3+1)
111  viewer << vox1 << vox2;
112 
113 
114  viewer << CameraPosition(-2.9, 2.96, 2.64)
115  << CameraDirection(0.6, -0.43, 0.65)
116  << CameraUpVector(0.32, 0.900, 0.29);
117 
118  viewer<< MyViewer::updateDisplay;
119  return application.exec();
120 
121  return 0;
122 }
CameraUpVector class to set camera up-vector.
SCell sPointel(Point p, Sign sign=POS) const
Z3i this namespace gathers the standard of types for 3D imagery.
SCell sCell(const SPreCell &c) const
CameraDirection class to set camera direction.
STL namespace.
bool init(const Point &lower, const Point &upper, bool isClosed)
CameraPosition class to set camera position.
DGtal is the top-level namespace which contains all DGtal functions and types.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value...
SCell sTranslation(const SCell &p, const Vector &vec) const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...