DGtal 1.4.0
Loading...
Searching...
No Matches
testDigitalMetricAdapter.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/volumes/distance/CDigitalMetricSpace.h"
#include "DGtal/geometry/volumes/distance/DigitalMetricAdapter.h"
Include dependency graph for testDigitalMetricAdapter.cpp:

Go to the source code of this file.

Functions

bool testConcepts ()
 
bool testVal ()
 
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
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2014/07/02

Functions for testing class DigitalMetricAdapter.

This file is part of the DGtal library.

Definition in file testDigitalMetricAdapter.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 93 of file testDigitalMetricAdapter.cpp.

94{
95 trace.beginBlock ( "Testing class DigitalMetricAdapter" );
96 trace.info() << "Args:";
97 for ( int i = 0; i < argc; ++i )
98 trace.info() << " " << argv[ i ];
99 trace.info() << endl;
100
101 bool res = testConcepts() && testVal(); // && ... other tests
102 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
103 trace.endBlock();
104 return res ? 0 : 1;
105}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition Common.h:153
bool testConcepts()

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

◆ testConcepts()

bool testConcepts ( )

Example of a test. To be completed.

Definition at line 49 of file testDigitalMetricAdapter.cpp.

50{
51 unsigned int nbok = 0;
52 unsigned int nb = 0;
53
54 typedef Z2i::L2Metric L2;
55 L2 l2;
56 typedef DigitalMetricAdapter<L2> Adapted;
57
58 Adapted adapted(l2);
59
60 BOOST_CONCEPT_ASSERT(( concepts::CDigitalMetricSpace<Adapted> ));
61
62 return nbok == nb;
63}
Aim: simple adapter class which adapts any models of concepts::CMetricSpace to a model of concepts::C...
Aim: implements separable l_p metrics with exact predicates.
Aim: defines the concept of digital metric spaces.

Referenced by main().

◆ testVal()

bool testVal ( )

Example of a test. To be completed.

Definition at line 67 of file testDigitalMetricAdapter.cpp.

68{
69 unsigned int nbok = 0;
70 unsigned int nb = 0;
71
72 typedef Z2i::L2Metric L2;
73 L2 l2;
74 typedef DigitalMetricAdapter<L2> Adapted;
75 Adapted adapted(l2);
76
77 BOOST_CONCEPT_ASSERT(( concepts::CDigitalMetricSpace<Adapted> ));
78
79 L2::Point a(0,0), b(5,2);
80
81 Adapted::Value d = adapted(a,b);
82 trace.info() << "distance= "<< l2(a,b)<< " and adapted= "<< d << std::endl;
83 nbok += (d == 6) ? 1 : 0;
84 nb++;
85 trace.info() << "(" << nbok << "/" << nb << ") "
86 << std::endl;
87 return nbok == nb;
88}

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

Referenced by main().