DGtal  0.9.3
Functions
testEuclideanShapesDecorator.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/EuclideanShapesDecorator.h"
#include "DGtal/shapes/implicit/ImplicitBall.h"
Include dependency graph for testEuclideanShapesDecorator.cpp:

Go to the source code of this file.

Functions

bool testEuclideanShapesDecorator ()
 
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 EuclideanShapesDecorator.

This file is part of the DGtal library.

Definition in file testEuclideanShapesDecorator.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 120 of file testEuclideanShapesDecorator.cpp.

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

121 {
122  trace.beginBlock ( "Testing class EuclideanShapesDecorator" );
123  trace.info() << "Args:";
124  for ( int i = 0; i < argc; ++i )
125  trace.info() << " " << argv[ i ];
126  trace.info() << std::endl;
127 
128  bool res = testEuclideanShapesDecorator(); // && ... other tests
129  trace.emphase() << ( res ? "Passed." : "Error." ) << std::endl;
130  trace.endBlock();
131  return res ? 0 : 1;
132 }
void beginBlock(const std::string &keyword="")
bool testEuclideanShapesDecorator()
Trace trace
Definition: Common.h:137
double endBlock()
std::ostream & emphase()
std::ostream & info()

◆ testEuclideanShapesDecorator()

bool testEuclideanShapesDecorator ( )

Definition at line 50 of file testEuclideanShapesDecorator.cpp.

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

Referenced by main().

51 {
52  unsigned int nbok = 0;
53  unsigned int nb = 0;
54 
55  trace.beginBlock ( "Testing Unary operation on euclidean shapes ..." );
56 
57  typedef ImplicitBall< Z2i::Space > ShapeA;
58  typedef ShapeA::RealPoint RealPoint;
59 
60  ShapeA shapeA(Z2i::RealPoint( -2.501, 0.0 ), 2.5013);
61  ShapeA shapeB(Z2i::RealPoint( 2, 0.0 ), 2.5013);
62  ShapeA shapeC(Z2i::RealPoint( 0.0, 0.0 ), 2.5);
63 
65  CSG s_union ( shapeA );
66  s_union.plus( shapeB );
67 
68  CSG s_intersec ( shapeA );
69  s_intersec.plus( shapeB );
70  s_intersec.intersection( shapeC );
71 
72  CSG s_minus ( shapeA );
73  s_minus.minus( shapeC );
74 
75 
76  nbok += (( s_union.orientation( RealPoint( -5.1, 0.0 )) == INSIDE )
77  || ( s_union.orientation( RealPoint( -5.1, 0.0 )) == ON ))? 0 : 1;
78  nbok += (( s_union.orientation( RealPoint( 0.0, 0.0 )) == INSIDE )
79  || ( s_union.orientation( RealPoint( 0.0, 0.0 )) == ON ))? 1 : 0;
80  nbok += (( s_union.orientation( RealPoint( 4.6, 0.0 )) == INSIDE )
81  || ( s_union.orientation( RealPoint( 4.6, 0.0 )) == ON ))? 0 : 1;
82  nbok += (( s_union.orientation( RealPoint( 4.5, 0.0 )) == INSIDE )
83  || ( s_union.orientation( RealPoint( 4.5, 0.0 )) == ON ))? 1 : 0;
84  nbok += (( s_union.orientation( RealPoint( -5.0, 0.0 )) == INSIDE )
85  || ( s_union.orientation( RealPoint( -5.0, 0.0 )) == ON ))? 1 : 0;
86 
87 
88  nbok += (( s_intersec.orientation( RealPoint( -2.6, 0.0 )) == INSIDE )
89  || ( s_intersec.orientation( RealPoint( -2.6, 0.0 )) == ON ))? 0 : 1;
90  nbok += (( s_intersec.orientation( RealPoint( 2.5, 0.0 )) == INSIDE )
91  || ( s_intersec.orientation( RealPoint( 2.5, 0.0 )) == ON ))? 1 : 0;
92  nbok += (( s_intersec.orientation( RealPoint( 2.6, 0.0 )) == INSIDE )
93  || ( s_intersec.orientation( RealPoint( 2.6, 0.0 )) == ON ))? 0 : 1;
94  nbok += (( s_intersec.orientation( RealPoint( 0.0, 2.5 )) == INSIDE )
95  || ( s_intersec.orientation( RealPoint( 0.0, 2.5 )) == ON ))? 0 : 1;
96 
97 
98  nbok += (( s_minus.orientation( RealPoint( -5.0, 0.0 )) == INSIDE )
99  || ( s_minus.orientation( RealPoint( -5.0, 0.0 )) == ON ))? 1 : 0;
100  nbok += (( s_minus.orientation( RealPoint( -1.0, 0.0 )) == INSIDE )
101  || ( s_minus.orientation( RealPoint( -1.0, 0.0 )) == ON ))? 0 : 1;
102  nbok += (( s_minus.orientation( RealPoint( 0.0, 2.0 )) == INSIDE )
103  || ( s_minus.orientation( RealPoint( 0.0, 2.0 )) == ON ))? 0 : 1;
104  nbok += (( s_minus.orientation( RealPoint( -2.6, 0.0 )) == INSIDE )
105  || ( s_minus.orientation( RealPoint( -2.6, 0.0 )) == ON ))? 1 : 0;
106 
107 
108  nb = 13;
109 
110 
111  trace.info() << "(" << nbok << "/" << nb << ") "
112  << "true == true" << std::endl;
113  trace.endBlock();
114  return nbok == nb;
115 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
Aim: Constructive Solid Geometry (CSG) between models of CEuclideanBoundedShape and CEuclideanOriente...
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD...
Definition: ImplicitBall.h:64
std::ostream & info()
Space::RealPoint RealPoint
Definition: StdDefs.h:97