DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testInHalfPlane.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/PointVector.h"
#include "DGtal/geometry/tools/determinant/Simple2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/AvnaimEtAl2x2DetSignComputer.h"
#include "DGtal/geometry/tools/determinant/COrientationFunctor2.h"
#include "DGtal/geometry/tools/determinant/InHalfPlaneBy2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
#include "DGtal/geometry/tools/determinant/InGeneralizedDiskOfGivenRadius.h"

Go to the source code of this file.

Functions

template<typename OrientationFunctor >
bool testInHalfPlane (OrientationFunctor f)
 
bool testInGeneralizedDiskOfGivenRadius ()
 
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
Tristan Roussillon (trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2013/11/22

Functions for testing models of COrientationFunctor2.

This file is part of the DGtal library.

Definition in file testInHalfPlane.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 269 of file testInHalfPlane.cpp.

270{
271 trace.beginBlock ( "Testing class InHalfPlane" );
272 trace.info() << "Args:";
273 for ( int i = 0; i < argc; ++i )
274 trace.info() << " " << argv[ i ];
275 trace.info() << endl;
276
278
279 bool res = true;
280
283 res = res && testInHalfPlane( Functor1() );
284
286 res = res && testInHalfPlane( Functor2() );
287
289
290 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
291 trace.endBlock();
292 return res ? 0 : 1;
293}
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Aim: Small class useful to compute the determinant of a 2x2 matrix from its four coefficients,...
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:154
MyPointD Point
Definition: testClone2.cpp:383
bool testInGeneralizedDiskOfGivenRadius()
bool testInHalfPlane(OrientationFunctor f)

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

◆ testInGeneralizedDiskOfGivenRadius()

bool testInGeneralizedDiskOfGivenRadius ( )

Example of a test. To be completed.

Definition at line 97 of file testInHalfPlane.cpp.

98{
99 unsigned int nbok = 0;
100 unsigned int nb = 0;
101
105 BOOST_CONCEPT_ASSERT(( concepts::COrientationFunctor2<Functor> ));
106 typedef Functor::Value Value;
107
108 Value res;
109
110 trace.beginBlock ( "Infinite radius..." );
111
112 Functor f_inf; //infinite radius by default
113 trace.info() << f_inf << " " << f_inf.isValid() << endl;
114
115 f_inf.init( Point(0,0), Point(5,2) );
116 res = f_inf( Point(7,3) );
117 trace.info() << res << " > 0 " << std::endl;
118 if ( res > NumberTraits<Value>::ZERO )
119 nbok++;
120 nb++;
121 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
122
123 f_inf.init( Point(0,0), Point(5,2) );
124 res = f_inf( Point(8,3) );
125 trace.info() << res << " < 0 " << std::endl;
126 if ( res < NumberTraits<Value>::ZERO )
127 nbok++;
128 nb++;
129 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
130
131 f_inf.init( Point(0,0), Point(5,2) );
132 res = f_inf( Point(10,4) );
133 trace.info() << res << " == 0 " << std::endl;
134 if ( res == NumberTraits<Value>::ZERO )
135 nbok++;
136 nb++;
137 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
138
139 Functor f_inf2(false); //infinite radius too, but with another orientation
140 trace.info() << f_inf2 << " " << f_inf2.isValid() << endl;
141
142 f_inf2.init( Point(0,0), Point(5,2) );
143 res = f_inf2( Point(7,3) );
144 trace.info() << res << " < 0 " << std::endl;
145 if ( res < NumberTraits<Value>::ZERO )
146 nbok++;
147 nb++;
148 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
149
150 f_inf2.init( Point(0,0), Point(5,2) );
151 res = f_inf2( Point(8,3) );
152 trace.info() << res << " > 0 " << std::endl;
153 if ( res > NumberTraits<Value>::ZERO )
154 nbok++;
155 nb++;
156 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
157
158 f_inf2.init( Point(0,0), Point(5,2) );
159 res = f_inf2( Point(10,4) );
160 trace.info() << res << " == 0 " << std::endl;
161 if ( res == NumberTraits<Value>::ZERO )
162 nbok++;
163 nb++;
164 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
165
166 trace.endBlock();
167
168 trace.beginBlock ( "Finite radius..." );
169
170 Functor f5(true, 25, 1); //radius 5 with positive orientation
171 trace.info() << f5 << " " << f5.isValid() << endl;
172
173 f5.init( Point(5,0), Point(0,5) );
174 res = f5( Point(-4,1) );
175 trace.info() << res << " > 0 " << std::endl;
176 if ( res > NumberTraits<Value>::ZERO )
177 nbok++;
178 nb++;
179 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
180
181 res = f5( Point(-5,1) );
182 trace.info() << res << " < 0 " << std::endl;
183 if ( res < NumberTraits<Value>::ZERO )
184 nbok++;
185 nb++;
186 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
187
188 res = f5( Point(-3,4) );
189 trace.info() << res << " == 0 " << std::endl;
190 if ( res == NumberTraits<Value>::ZERO )
191 nbok++;
192 nb++;
193 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
194
195 res = f5( Point(-1,6) );
196 trace.info() << res << " < 0 " << std::endl;
197 if ( res < NumberTraits<Value>::ZERO )
198 nbok++;
199 nb++;
200 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
201
202 res = f5( Point(-1,7) );
203 trace.info() << res << " < 0 " << std::endl;
204 if ( res < NumberTraits<Value>::ZERO )
205 nbok++;
206 nb++;
207 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
208
209 Functor f52(false, 25, 1); //radius 5 with negative orientation
210 trace.info() << f52 << " " << f52.isValid() << endl;
211
212 f52.init( Point(-5,0), Point(0,5) );
213 res = f52( Point(4,1) );
214 trace.info() << res << " < 0 " << std::endl;
215 if ( res < NumberTraits<Value>::ZERO )
216 nbok++;
217 nb++;
218 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
219
220 res = f52( Point(3,1) );
221 trace.info() << res << " < 0 " << std::endl;
222 if ( res < NumberTraits<Value>::ZERO )
223 nbok++;
224 nb++;
225 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
226
227 res = f52( Point(5,1) );
228 trace.info() << res << " > 0 " << std::endl;
229 if ( res > NumberTraits<Value>::ZERO )
230 nbok++;
231 nb++;
232 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
233
234 res = f52( Point(3,4) );
235 trace.info() << res << " == 0 " << std::endl;
236 if ( res == NumberTraits<Value>::ZERO )
237 nbok++;
238 nb++;
239 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
240
241 res = f52( Point(4,3) );
242 trace.info() << res << " == 0 " << std::endl;
243 if ( res == NumberTraits<Value>::ZERO )
244 nbok++;
245 nb++;
246 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
247
248 res = f52( Point(1,6) );
249 trace.info() << res << " > 0 " << std::endl;
250 if ( res > NumberTraits<Value>::ZERO )
251 nbok++;
252 nb++;
253 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
254
255 res = f52( Point(1,7) );
256 trace.info() << res << " > 0 " << std::endl;
257 if ( res > NumberTraits<Value>::ZERO )
258 nbok++;
259 nb++;
260 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
261
262 trace.endBlock();
263
264
265 return nbok == nb;
266}
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Aim: This class implements an orientation functor that provides a way to determine the position of ...
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:564
Aim: This concept is a refinement of COrientationFunctor, useful for simple algebraic curves that can...
InHalfPlaneBySimple3x3Matrix< Point, double > Functor

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

Referenced by main().

◆ testInHalfPlane()

template<typename OrientationFunctor >
bool testInHalfPlane ( OrientationFunctor  f)

Example of a test. To be completed.

Parameters
fany orientation functor
Template Parameters
OrientationFunctora model of COrientationFunctor2

Definition at line 57 of file testInHalfPlane.cpp.

58{
60
61 unsigned int nbok = 0;
62 unsigned int nb = 0;
63
64 trace.beginBlock ( "Testing block ..." );
65 trace.info() << f << endl;
66
67 typedef typename OrientationFunctor::Value Value;
68 typedef typename OrientationFunctor::Point Point;
69 Point a(0,0);
70 Point b(5,2);
71
72 //first quadrant
73 f.init(a, b);
74 if (f( Point(2,1) ) == NumberTraits<Value>::ONE)
75 nbok++; //a, b, (2,1) are CCW oriented
76 nb++;
77 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
78
79 if (f( Point(3,1) ) == -NumberTraits<Value>::ONE)
80 nbok++; //a, b, (3,1) are CW oriented
81 nb++;
82 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
83
84 if (f( Point(10,4) ) == NumberTraits<Value>::ZERO)
85 nbok++; //a, b, (10,4) belong to the same line
86 nb++;
87 trace.info() << "(" << nbok << "/" << nb << ") " << endl;
88
90
91 return nbok == nb;
92}

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

Referenced by main().