DGtal  0.9.3
Functions
testDisplayKSCell.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/io/viewers/Viewer3D.h"
Include dependency graph for testDisplayKSCell.cpp:

Go to the source code of this file.

Functions

bool testViewer3D ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2011/05/30

Functions for testing class DisplayKSCell.

This file is part of the DGtal library.

Definition in file testDisplayKSCell.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 77 of file testDisplayKSCell.cpp.

References DGtal::Trace::beginBlock(), domain(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::KhalimskySpaceND< dim, TInteger >::sCell(), DGtal::Viewer3D< Space, KSpace >::show(), DGtal::trace, and DGtal::KhalimskySpaceND< dim, TInteger >::uCell().

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 }
void beginBlock(const std::string &keyword="")
const Domain domain(Point(1, 2), Point(6, 5))
Trace trace
Definition: Common.h:137
double endBlock()
std::ostream & emphase()
bool init(const Point &lower, const Point &upper, bool isClosed)
Cell uCell(const PreCell &c) const
MyPointD Point
Definition: testClone2.cpp:383
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

◆ testViewer3D()

bool testViewer3D ( )

Example of a test. To be completed.

Definition at line 59 of file testDisplayKSCell.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

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 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
std::ostream & info()