DGtal 1.3.0
Loading...
Searching...
No Matches
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"

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 142 of file testDigitalShapesDecorator.cpp.

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

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

◆ testDigitalShapesDecorator()

bool testDigitalShapesDecorator ( )

Example of a test. To be completed.

Definition at line 55 of file testDigitalShapesDecorator.cpp.

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

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

Referenced by main().