DGtal  0.9.3
Functions
testDigitalShapesDecorator.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/shapes/DigitalShapesDecorator.h"
#include "DGtal/shapes/parametric/Ball2D.h"
Include dependency graph for testDigitalShapesDecorator.cpp:

Go to the source code of this file.

Functions

bool testDigitalShapesDecorator ()
 
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
Jérémy Levallois (jerem.nosp@m.y.le.nosp@m.vallo.nosp@m.is@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), INSA-Lyon, France LAboratoire de MAthématiques - LAMA (CNRS, UMR 5127), Université de Savoie, France
Date
2012/12/07

Functions for testing class DigitalShapesDecorator.

This file is part of the DGtal library.

Definition in file testDigitalShapesDecorator.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 141 of file testDigitalShapesDecorator.cpp.

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

142 {
143  trace.beginBlock ( "Testing class DigitalShapesDecorator" );
144  trace.info() << "Args:";
145  for ( int i = 0; i < argc; ++i )
146  trace.info() << " " << argv[ i ];
147  trace.info() << std::endl;
148 
149  bool res = testDigitalShapesDecorator(); // && ... other tests
150  trace.emphase() << ( res ? "Passed." : "Error." ) << std::endl;
151  trace.endBlock();
152  return res ? 0 : 1;
153 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
bool testDigitalShapesDecorator()
double endBlock()
std::ostream & emphase()
std::ostream & info()

◆ testDigitalShapesDecorator()

bool testDigitalShapesDecorator ( )

Example of a test. To be completed.

Definition at line 55 of file testDigitalShapesDecorator.cpp.

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

Referenced by main().

56 {
57  unsigned int nbok = 0;
58  unsigned int nb = 0;
59 
60  trace.beginBlock ( "Testing Unary operation on digital shapes ..." );
61 
62  typedef Ball2D< Z2i::Space > ShapeA;
63  typedef GaussDigitizer< Z2i::Space, ShapeA > MyGaussDigitizerA;
64 
65  typedef ShapeA::Point Point;
66 
67  double h = 0.5;
68 
69  ShapeA shapeA(-2.501, 0.0, 2.5013);
70  ShapeA shapeB(2, 0.0, 2.5013);
71  ShapeA shapeC(0.0, 0.0, 2.5);
72 
73  MyGaussDigitizerA digShapeA;
74  digShapeA.attach( shapeA );
75  digShapeA.init( shapeA.getLowerBound(), shapeA.getUpperBound(), h );
76 
77  MyGaussDigitizerA digShapeB;
78  digShapeB.attach( shapeB );
79  digShapeB.init( shapeB.getLowerBound(), shapeB.getUpperBound(), h );
80 
81  MyGaussDigitizerA digShapeC;
82  digShapeC.attach( shapeC );
83  digShapeC.init( shapeC.getLowerBound(), shapeC.getUpperBound(), h );
84 
85 
87  CSG s_union ( digShapeA );
88  s_union.plus( digShapeB );
89 
90  CSG s_intersec ( digShapeA );
91  s_intersec.plus( digShapeB );
92  s_intersec.intersection( digShapeC );
93 
94  CSG s_minus ( digShapeA );
95  s_minus.minus( digShapeC );
96 
97 
98  nbok += (( s_union.orientation( Point( -12, 0 )) == INSIDE )
99  || ( s_union.orientation( Point( -12, 0 )) == ON ))? 0 : 1;
100  nbok += (( s_union.orientation( Point( 0, 0 )) == INSIDE )
101  || ( s_union.orientation( Point( 0, 0 )) == ON ))? 1 : 0;
102  nbok += (( s_union.orientation( Point( 10, 0 )) == INSIDE )
103  || ( s_union.orientation( Point( 10, 0 )) == ON ))? 0 : 1;
104  nbok += (( s_union.orientation( Point( 9, 0 )) == INSIDE )
105  || ( s_union.orientation( Point( 9, 0 )) == ON ))? 1 : 0;
106  nbok += (( s_union.orientation( Point( -10, 0 )) == INSIDE )
107  || ( s_union.orientation( Point( -10, 0 )) == ON ))? 1 : 0;
108 
109 
110  nbok += (( s_intersec.orientation( Point( -6, 0 )) == INSIDE )
111  || ( s_intersec.orientation( Point( -6, 0 )) == ON ))? 0 : 1;
112  nbok += (( s_intersec.orientation( Point( 4, 0 )) == INSIDE )
113  || ( s_intersec.orientation( Point( 4, 0 )) == ON ))? 1 : 0;
114  nbok += (( s_intersec.orientation( Point( 6, 0 )) == INSIDE )
115  || ( s_intersec.orientation( Point( 6, 0 )) == ON ))? 0 : 1;
116  nbok += (( s_intersec.orientation( Point( 0, 5 )) == INSIDE )
117  || ( s_intersec.orientation( Point( 0, 5 )) == ON ))? 0 : 1;
118 
119 
120  nbok += (( s_minus.orientation( Point( -9, 0 )) == INSIDE )
121  || ( s_minus.orientation( Point( -9, 0 )) == ON ))? 1 : 0;
122  nbok += (( s_minus.orientation( Point( -2, 0 )) == INSIDE )
123  || ( s_minus.orientation( Point( -2, 0 )) == ON ))? 0 : 1;
124  nbok += (( s_minus.orientation( Point( 0, 2 )) == INSIDE )
125  || ( s_minus.orientation( Point( 0, 2 )) == ON ))? 0 : 1;
126  nbok += (( s_minus.orientation( Point( -8, 0 )) == INSIDE )
127  || ( s_minus.orientation( Point( -8, 0 )) == ON ))? 1 : 0;
128 
129  nb = 13;
130 
131 
132  trace.info() << "(" << nbok << "/" << nb << ") "
133  << "true == true" << std::endl;
134  trace.endBlock();
135  return nbok == nb;
136 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
Aim: Model of the concept StarShaped represents any circle in the plane.
Definition: Ball2D.h:60
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: Constructive Solid Geometry (CSG) between models of CDigitalBoundedShape and CDigitalOrientedSha...
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()