DGtal
0.6.devel
Main Page
Related Pages
Modules
Namespaces
Data Structures
Examples
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
src
DGtal
geometry
curves
FP.h
1
17
#pragma once
18
31
#if defined(FP_RECURSES)
32
#error Recursive header files inclusion detected in FP.h
33
#else // defined(FP_RECURSES)
34
35
#define FP_RECURSES
36
37
#if !defined FP_h
38
39
#define FP_h
40
42
// Inclusions
43
#include <iostream>
44
#include <list>
45
#include "DGtal/kernel/CInteger.h"
46
#include "DGtal/kernel/PointVector.h"
47
#include "DGtal/geometry/curves/ArithmeticalDSS.h"
48
#include "DGtal/base/Circulator.h"
49
#include "DGtal/base/Exceptions.h"
50
#include "DGtal/base/Common.h"
51
#include "DGtal/io/Color.h"
53
54
namespace
DGtal
55
{
56
58
71
template
<
typename
ArithmeticalDSS>
72
class
Adapter
73
{
74
protected
:
78
ArithmeticalDSS
*
myDSS
;
79
public
:
83
virtual
typename
ArithmeticalDSS::Point
firstLeaningPoint
()
const
= 0;
87
virtual
typename
ArithmeticalDSS::Point
lastLeaningPoint
()
const
= 0;
88
};
89
105
template
<
typename
ArithmeticalDSS>
106
class
Adapter4ConvexPart
:
public
Adapter
<ArithmeticalDSS>
107
{
108
public
:
113
Adapter4ConvexPart
(
ArithmeticalDSS
& aDSS)
114
{
115
this->
myDSS
= &aDSS;
116
}
120
typename
ArithmeticalDSS::Point
firstLeaningPoint
()
const
121
{
122
return
this->
myDSS
->
getUf
();
123
}
127
typename
ArithmeticalDSS::Point
lastLeaningPoint
()
const
128
{
129
return
this->
myDSS
->
getUl
();
130
}
131
};
132
148
template
<
typename
ArithmeticalDSS>
149
class
Adapter4ConcavePart
:
public
Adapter
<ArithmeticalDSS>
150
{
151
public
:
156
Adapter4ConcavePart
(
ArithmeticalDSS
& aDSS)
157
{
158
this->
myDSS
= &aDSS;
159
}
163
typename
ArithmeticalDSS::Point
firstLeaningPoint
()
const
164
{
165
return
this->
myDSS
->
getLf
();
166
}
170
typename
ArithmeticalDSS::Point
lastLeaningPoint
()
const
171
{
172
return
this->
myDSS
->
getLl
();
173
}
174
};
176
177
179
// template class FP
221
template
<
typename
TIterator,
typename
TInteger,
int
connectivity>
222
class
FP
223
{
224
225
// ----------------------- Types ------------------------------
226
public
:
227
228
229
BOOST_CONCEPT_ASSERT
((
CInteger<TInteger>
) );
230
231
typedef
DGtal::PointVector<2,TInteger>
Point
;
232
typedef
DGtal::PointVector<2,TInteger>
Vector
;
233
234
typedef
DGtal::PointVector<2, double>
RealPoint
;
235
typedef
DGtal::PointVector<2, double>
RealVector
;
236
237
typedef
DGtal::ArithmeticalDSS<TIterator,TInteger,connectivity>
DSSComputer
;
238
typedef
DGtal::ArithmeticalDSS<DGtal::Circulator<TIterator>
,TInteger,connectivity>
DSSComputerInLoop
;
239
240
typedef
std::list<Point>
Polygon
;
241
242
243
244
// ----------------------- Standard services ------------------------------
245
public
:
246
252
FP
(
const
TIterator& itb,
const
TIterator& ite)
throw
(
InputException
) ;
253
261
FP
(
const
TIterator& itb,
const
TIterator& ite,
const
bool
& isClosed)
throw
(
InputException
) ;
262
266
~FP
();
267
268
// ----------------------- Interface --------------------------------------
269
public
:
270
274
const
Polygon
&
polygon
()
const
275
{
276
return
myPolygon
;
277
};
278
282
bool
flagIsClosed
()
const
283
{
284
return
myFlagIsClosed
;
285
};
286
287
292
bool
isValid
()
const
;
293
297
typename
Polygon::size_type
size
()
const
;
298
299
304
template
<
typename
OutputIterator>
305
OutputIterator
copyFP
(OutputIterator result)
const
;
306
311
template
<
typename
OutputIterator>
312
OutputIterator
copyMLP
(OutputIterator result)
const
;
313
314
315
// ------------------------- Protected Datas ------------------------------
316
private
:
317
318
// ------------------------- Private Datas --------------------------------
319
private
:
320
321
/*
322
* list where each vertex of the FP is stored
323
*/
324
Polygon
myPolygon
;
325
326
/*
327
* bool equal to 'true' if the list has to be consider as circular
328
* 'false' otherwise
329
*/
330
bool
myFlagIsClosed
;
331
332
// ------------------------- Hidden services ------------------------------
333
protected
:
334
335
336
337
private
:
338
347
template
<
typename
DSS,
typename
Adapter>
348
bool
initConvexityConcavity
( DSS &aDSS,
349
Adapter
* &anAdapter,
350
const
typename
DSS::ConstIterator& i );
351
360
template
<
typename
DSS,
typename
Adapter>
361
void
mainAlgorithm
( DSS ¤tDSS,
Adapter
* adapter,
362
bool
isConvex,
363
typename
DSS::ConstIterator i,
364
const
typename
DSS::ConstIterator& end )
throw
(
InputException
) ;
365
366
375
RealPoint
getRealPoint
(
const
Point
& a,
const
Point
& b,
const
Point
& c)
const
;
376
384
bool
quadrant
(
const
Vector
& v,
const
int
& q)
const
;
385
391
FP
(
const
FP
& other );
392
399
FP
&
operator=
(
const
FP
& other );
400
401
// ------------------------- Display ------------------------------------
402
public
:
403
404
/*
405
* Writes/Displays the object on an output stream.
406
* @param out the output stream where the object is written.
407
*/
408
void
selfDisplay
( std::ostream & out )
const
;
409
410
411
// --------------- CDrawableWithBoard2D realization --------------------
412
public
:
413
419
//DrawableWithBoard2D* defaultStyle( std::string mode = "" ) const;
420
424
std::string
className
()
const
;
425
426
};
// end of class FP
427
428
435
template
<
typename
TIterator,
typename
TInteger,
int
connectivity>
436
std::ostream&
437
operator<< ( std::ostream & out, const FP<TIterator,TInteger,connectivity> & object );
438
439
}
// namespace DGtal
440
441
443
// Includes inline functions.
444
#include "DGtal/geometry/curves/FP.ih"
445
446
// //
448
449
#endif // !defined FP_h
450
451
#undef FP_RECURSES
452
#endif // else defined(FP_RECURSES)
Generated on Wed Dec 19 2012 19:10:24 for DGtal by
1.8.1.1