35 #include "DGtal/base/Common.h"
38 #include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
39 #include "DGtal/geometry/curves/StabbingCircleComputer.h"
40 #include "DGtal/geometry/curves/estimation/SegmentComputerEstimators.h"
42 #include "DGtal/io/boards/Board2D.h"
45 #include "ConfigTest.h"
50 using namespace DGtal;
62 template<
typename DSSComputer>
63 bool testTangentFromDSS(
69 trace.
info() <<
"feeding segment computer " << endl;
77 trace.
info() <<
"building and using the functor " << endl;
78 const double epsilon = 0.00001;
86 double q1 = f.eval(itb);
87 double q2 = std::atan2((
double)dss.a(),(
double)dss.b());
88 trace.
info() <<
"Tangent orientation : " << q1 <<
" == " << q2 << endl;
89 nbok += (std::abs(q1 - q2) < epsilon)?1:0;
91 trace.
info() <<
"(" << nbok <<
"/" << nb <<
")" << std::endl;
98 Quantity q1 = f.eval(itb);
99 Quantity q2 = Quantity(dss.b(), dss.a());
100 trace.
info() <<
"Tangent vector : " << q1 <<
" == " << q2 << endl;
101 nbok += (q1 == q2)?1:0;
103 trace.
info() <<
"(" << nbok <<
"/" << nb <<
")" << std::endl;
110 Quantity q1 = f.eval(itb);
111 double n = std::sqrt( (
double)dss.a()*dss.a() + (
double)dss.b()*dss.b() );
112 Quantity q2 = Quantity((
double)dss.b()/n, (
double)dss.a()/n);
113 trace.
info() <<
"Normalized tangent vector : " << q1 <<
" == " << q2 << endl;
114 nbok += ((std::abs(q1[0] - q2[0]) < epsilon)&&(std::abs(q1[1] - q2[1]) < epsilon))?1:0;
116 trace.
info() <<
"(" << nbok <<
"/" << nb <<
")" << std::endl;
126 template<
typename DCAComputer>
133 trace.
info() <<
"feeding segment computer " << endl;
141 trace.
info() <<
"building and using the functor " << endl;
142 const double epsilon = 0.00001;
149 f.
init(1.0, itb, ite);
151 double q1 = f.eval(itb);
152 f.init(0.1, itb, ite);
153 double q2 = f.eval(itb);
154 trace.
info() <<
"Curvature (h=1): " << q1 << std::endl;
155 trace.
info() <<
"Curvature (h=0.1): " << q2 << std::endl;
156 nbok += ((q1 >= 0)&&(q1 < 1)&&(q2 >= 0)&&(q2 < 10)
157 &&(std::abs(q2-(10*q1)) < epsilon))?1:0;
159 trace.
info() <<
"(" << nbok <<
"/" << nb <<
")" << std::endl;
167 Quantity q1 = f.eval( it );
168 trace.
info() <<
"Tangent: " << q1 <<
" == [PointVector] {1, 0} " << std::endl;
169 nbok += (std::abs(q1[0]-1.0) < epsilon)
170 && (std::abs(q1[1]) < epsilon) ? 1 : 0;
172 trace.
info() <<
"(" << nbok <<
"/" << nb <<
")" << std::endl;
179 f.init(1.0, itb, ite);
181 Quantity q1 = f.eval( it );
182 trace.
info() <<
"Position (h=1): " << q1.first <<
" (<=0), " << q1.second <<
" (>0) " << std::endl;
183 f.init(0.1, itb, ite);
185 Quantity q2 = f.eval( it );
186 trace.
info() <<
"Position (h=0.1): " << q2.first <<
" (<=0), " << q2.second <<
" (>0) " << std::endl;
187 nbok += ( (q1.first < epsilon)
188 && (q1.second > -epsilon)
189 && (std::abs((q1.second - q1.first) - 1) < epsilon)
190 && (q2.first < epsilon)
191 && (q2.second > -epsilon)
192 && (std::abs((q2.second - q2.first) - 0.1) < epsilon) )? 1 : 0;
194 trace.
info() <<
"(" << nbok <<
"/" << nb <<
")" << std::endl;
204 int main(
int argc,
char** argv )
208 for (
int i = 0; i < argc; ++i )
220 typedef std::vector<Point>
Range;
227 curve4.push_back(
Point(0,0));
228 curve4.push_back(
Point(1,0));
229 curve4.push_back(
Point(1,1));
230 curve4.push_back(
Point(2,1));
231 curve4.push_back(
Point(3,1));
232 curve4.push_back(
Point(3,2));
233 curve4.push_back(
Point(4,2));
234 curve4.push_back(
Point(5,2));
235 curve4.push_back(
Point(6,2));
236 curve4.push_back(
Point(6,3));
237 curve4.push_back(
Point(7,3));
240 curve8.push_back(
Point(0,0));
241 curve8.push_back(
Point(1,1));
242 curve8.push_back(
Point(2,1));
243 curve8.push_back(
Point(3,2));
244 curve8.push_back(
Point(4,2));
245 curve8.push_back(
Point(5,2));
246 curve8.push_back(
Point(6,3));
247 curve8.push_back(
Point(7,3));
248 curve8.push_back(
Point(8,4));
249 curve8.push_back(
Point(9,4));
250 curve8.push_back(
Point(10,5));
253 res = res && testTangentFromDSS<DSS4>(curve4.
begin(), curve4.
end())
254 && testTangentFromDSS<DSS8>(curve8.
begin(), curve8.
end());
258 typedef std::pair<Point,Point> Pair;
259 typedef std::vector<Pair>
Range;
264 curve.push_back(std::make_pair(
Point(0,0),
Point(0,1)));
265 curve.push_back(std::make_pair(
Point(1,0),
Point(1,1)));
267 curve.push_back(std::make_pair(
Point(2,1),
Point(2,2)));
268 curve.push_back(std::make_pair(
Point(3,1),
Point(3,2)));
269 curve.push_back(std::make_pair(
Point(4,1),
Point(4,2)));
271 curve.push_back(std::make_pair(
Point(5,2),
Point(5,3)));
272 curve.push_back(std::make_pair(
Point(6,2),
Point(6,3)));
273 curve.push_back(std::make_pair(
Point(7,2),
Point(7,3)));
274 curve.push_back(std::make_pair(
Point(8,2),
Point(8,3)));
275 curve.push_back(std::make_pair(
Point(9,2),
Point(9,3)));
277 curve.push_back(std::make_pair(
Point(10,1),
Point(10,2)));
278 curve.push_back(std::make_pair(
Point(11,1),
Point(11,2)));
279 curve.push_back(std::make_pair(
Point(12,1),
Point(12,2)));
281 curve.push_back(std::make_pair(
Point(13,0),
Point(13,1)));
282 curve.push_back(std::make_pair(
Point(14,0),
Point(14,1)));
284 res = res && testFromDCA<DCA>(curve.
begin(), curve.
end())
285 && testFromDCA<DCA>(curve.
begin()+2, curve.
begin()+12);
289 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
Aim: On-line recognition of a digital circular arcs (DCA) defined as a sequence of connected grid edg...
void beginBlock(const std::string &keyword="")
void attach(const SegmentComputer &aSC)
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
void attach(const SegmentComputer &aSC)
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
void longestSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &end, IteratorType)
IC getMiddleIterator(const IC &itb, const IC &ite, RandomAccessCategory)
int main(int argc, char **argv)