DGtal  0.9.3
testDisplayKSCell.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
34 
35 using namespace std;
36 using namespace DGtal;
37 
38 
39 
41 #include <iostream>
42 #include "DGtal/base/Common.h"
43 #include "DGtal/helpers/StdDefs.h"
44 #include "DGtal/shapes/Shapes.h"
45 #include "DGtal/io/viewers/Viewer3D.h"
47 
48 using namespace std;
49 using namespace DGtal;
50 using namespace Z3i;
51 
53 // Functions for testing Display of display of KS space Cell.
55 
60 {
61  unsigned int nbok = 0;
62  unsigned int nb = 0;
63 
64  trace.beginBlock ( "Testing block ..." );
65  nbok += true ? 1 : 0;
66  nb++;
67  trace.info() << "(" << nbok << "/" << nb << ") "
68  << "true == true" << std::endl;
69  trace.endBlock();
70 
71  return nbok == nb;
72 }
73 
75 // Standard services - public :
76 
77 int main( int argc, char** argv )
78 {
79 
80  QApplication application(argc,argv);
81 
82 
83  KSpace K;
84  Point plow(0,0,0);
85  Point pup(3,3,2);
86  Domain domain( plow, pup );
87  K.init( plow, pup, true );
88 
89  Viewer3D<Space, KSpace> viewer(K);
90  viewer.show();
91  trace.beginBlock ( "Testing display KSCell in Viewer 3D" );
92  //viewer << SetMode3D( domain.className(), "Paving" );
93  // if the domain is visible can't see the cubes inside
94  // viewer << domain;
95 
96 
97  // Drawing cell of dimension 3
98  Cell voxelA = K.uCell(Point(1, 1, 1));
99  SCell voxelB = K.sCell(Point(1, 1, 3));
100  viewer << voxelB<< voxelA;//
101 
102  // drawing cells of dimension 2
103  SCell surfelA = K.sCell( Point( 2, 1, 3 ) );
104  SCell surfelB = K.sCell( Point( 1, 0, 1 ), false );
105  Cell surfelC = K.uCell( Point( 1, 2, 1 ) );
106  SCell surfelD = K.sCell( Point( 1, 1, 0 ) );
107  Cell surfelE = K.uCell( Point( 1, 1, 2 ) );
108  viewer << surfelA << surfelB << surfelC << surfelD << surfelE;
109 
110  Cell linelA = K.uCell(Point(2, 1 ,2));
111  SCell linelB = K.sCell(Point(2, 2 ,1));
112  SCell linelC = K.sCell(Point(1, 2 ,2), false);
113  viewer << linelA << linelB << linelC;
114 
115 
116  Cell center = K.uCell(Point(5,5,5));
117 // Testing display of oriented surfels:
118  SCell ssurfelXZ = K.sCell( Point( 5, 6, 5 ), false );
119  SCell ssurfelXY = K.sCell( Point( 5, 5, 6 ), false );
120  SCell ssurfelZY = K.sCell( Point( 6, 5, 5 ), false );
121  viewer<< center;
122 
123  SCell ssurfelXZo = K.sCell( Point( 5, 4, 5 ), false );
124  SCell ssurfelXYo = K.sCell( Point( 5, 5, 4 ), false );
125  SCell ssurfelZYo = K.sCell( Point( 4, 5, 5 ), false );
126 
127  viewer << ssurfelXZ << ssurfelXY << ssurfelZY;
128  viewer << ssurfelXZo << ssurfelXYo << ssurfelZYo;
129 
130  // Testing display oriented pointels
131  Cell pointelA = K.uCell(Point(2, 2, 2));
132  SCell pointelB = K.sCell(Point(4, 4, 4), true);
133  SCell pointelC = K.sCell(Point(6, 4, 4), false);
134  SCell linelAC = K.sCell(Point(5, 4, 4), false);
135  viewer << pointelA << pointelB << pointelC << linelAC;
136 
137  viewer << Viewer3D<>::updateDisplay;
138 
139  bool res = application.exec();
140  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
141  trace.endBlock();
142  return res ? 0 : 1;
143 }
144 // //
void beginBlock(const std::string &keyword="")
const Domain domain(Point(1, 2), Point(6, 5))
Trace trace
Definition: Common.h:137
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
STL namespace.
double endBlock()
bool testViewer3D()
int main(int argc, char **argv)
std::ostream & emphase()
bool init(const Point &lower, const Point &upper, bool isClosed)
Cell uCell(const PreCell &c) const
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value...
KSpace K
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...
SCell sCell(const SPreCell &c) const