DGtal 1.3.0
Loading...
Searching...
No Matches
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
43using namespace std;
44using namespace DGtal;
45
47// Functions for testing class DGtalBIGINTEGER.
49
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;
73
74 return nbok == nb;
75}
76
77
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;
94
95 DGtal::BigInteger a, b, c;
96
97 a = 1234;
98 b = "-5678";
99 Point p(a,b);
100
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
134int 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// //
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
std::string className() const
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:154
mpz_class BigInteger
Multi-precision integer with GMP implementation.
Definition: BasicTypes.h:79
STL namespace.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
int main()
Definition: testBits.cpp:56
MyPointD Point
Definition: testClone2.cpp:383
FreemanChain< int > Contour
bool testDGtalBIGINTEGER()
bool testBIGINTEGERSpace()
Domain domain
HyperRectDomain< Space > Domain