DGtal
1.5.beta
testDGtalGMP.cpp
Go to the documentation of this file.
1
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "DGtal/io/boards/Board2D.h"
34
#include "DGtal/kernel/SpaceND.h"
35
#include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
36
#include "DGtal/geometry/curves/FreemanChain.h"
37
#include "DGtal/geometry/curves/GreedySegmentation.h"
38
#include "DGtal/kernel/domains/HyperRectDomain.h"
39
#include "DGtal/images/ImageContainerBySTLVector.h"
40
42
43
using namespace
std;
44
using namespace
DGtal
;
45
47
// Functions for testing class DGtalBIGINTEGER.
49
53
bool
testDGtalBIGINTEGER
()
54
{
55
unsigned
int
nbok = 0;
56
unsigned
int
nb = 0;
57
58
trace
.
beginBlock
(
"BIGINTEGER linking test..."
);
59
60
DGtal::BigInteger
a, b, c;
61
62
a = 1234;
63
b =
"-5678"
;
64
c = a+b;
65
trace
.
info
() <<
"sum is "
<< c <<
"\n"
;
66
trace
.
info
() <<
"absolute value is "
<< abs(c) <<
"\n"
;
67
68
nbok += (abs(c)==4444) ? 1 : 0;
69
nb++;
70
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
71
<<
"true == true"
<< std::endl;
72
trace
.
endBlock
();
73
74
return
nbok == nb;
75
}
76
77
82
bool
testBIGINTEGERSpace
()
83
{
84
unsigned
int
nbok = 0;
85
unsigned
int
nb = 0;
86
87
trace
.
beginBlock
(
"BIGINTEGER Space test..."
);
88
89
//This space is weird...
90
typedef
SpaceND<2, DGtal::BigInteger>
Space2;
91
typedef
Space2::Point
Point
;
92
typedef
Space2::Point::Coordinate Coordinate;
93
typedef
HyperRectDomain<Space2>
Domain
;
94
95
DGtal::BigInteger
a, b, c;
96
97
a = 1234;
98
b =
"-5678"
;
99
Point
p(a,b);
100
101
typedef
FreemanChain<Coordinate>
Contour
;
102
103
// Construct the Freeman chain
104
std::stringstream ss(stringstream::in | stringstream::out);
105
ss <<
"31 16 11121212121212212121212212122122222322323233323333333323333323303330330030300000100010010010001000101010101111"
<< endl;
106
Contour
theContour( ss );
107
108
Point
p1( 0, 0 );
109
Point
p2( 31, 31 );
110
111
trace
.
info
() <<
"p2.norm()= "
<< p2.norm()<<endl;
112
113
Domain
domain
( p1, p2 );
114
Board2D
aBoard;
115
aBoard <<
SetMode
(
domain
.
className
(),
"Grid"
)
116
<<
domain
117
<< theContour;
118
119
aBoard.
saveSVG
(
"testgmpcontour.svg"
);
120
121
122
nbok +=
true
? 1 : 0;
123
nb++;
124
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
125
<<
"true == true"
<< std::endl;
126
trace
.
endBlock
();
127
128
return
nbok == nb;
129
}
130
132
// Standard services - public :
133
134
int
main
(
int
argc,
char
** argv )
135
{
136
trace
.
beginBlock
(
"Testing class DGtalBIGINTEGER"
);
137
trace
.
info
() <<
"Args:"
;
138
for
(
int
i = 0; i < argc; ++i )
139
trace
.
info
() <<
" "
<< argv[ i ];
140
trace
.
info
() << endl;
141
142
bool
res =
testDGtalBIGINTEGER
() &&
testBIGINTEGERSpace
();
// && ... other tests
143
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
144
trace
.
endBlock
();
145
return
res ? 0 : 1;
146
}
147
// //
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition:
Board2D.h:71
DGtal::FreemanChain
Definition:
FreemanChain.h:114
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition:
HyperRectDomain.h:100
DGtal::HyperRectDomain::className
std::string className() const
DGtal::SpaceND
Definition:
SpaceND.h:96
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
LibBoard::Board::saveSVG
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition:
Board.cpp:1011
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::trace
Trace trace
Definition:
Common.h:153
DGtal::BigInteger
mpz_class BigInteger
Multi-precision integer with GMP implementation.
Definition:
BasicTypes.h:79
DGtal::SetMode
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition:
Board2D.h:247
Point
MyPointD Point
Definition:
testClone2.cpp:383
Contour
FreemanChain< int > Contour
Definition:
testCombinDSS.cpp:59
testDGtalBIGINTEGER
bool testDGtalBIGINTEGER()
Definition:
testDGtalGMP.cpp:53
main
int main(int argc, char **argv)
Definition:
testDGtalGMP.cpp:134
testBIGINTEGERSpace
bool testBIGINTEGERSpace()
Definition:
testDGtalGMP.cpp:82
domain
Domain domain
Definition:
testProjection.cpp:88
Domain
HyperRectDomain< Space > Domain
Definition:
testSimpleRandomAccessRangeFromPoint.cpp:44
tests
kernel
testDGtalGMP.cpp
Generated on Fri Dec 20 2024 12:44:32 for DGtal by
1.9.1