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
topology
KhalimskySpaceND.h
1
17
#pragma once
18
31
#if defined(KhalimskySpaceND_RECURSES)
32
#error Recursive header files inclusion detected in KhalimskySpaceND.h
33
#else // defined(KhalimskySpaceND_RECURSES)
34
35
#define KhalimskySpaceND_RECURSES
36
37
#if !defined KhalimskySpaceND_h
38
39
#define KhalimskySpaceND_h
40
42
// Inclusions
43
#include <iostream>
44
#include <set>
45
#include <map>
46
#include "DGtal/base/Common.h"
47
#include "DGtal/kernel/CInteger.h"
48
#include "DGtal/kernel/CCommutativeRing.h"
49
#include "DGtal/kernel/CSignedInteger.h"
50
#include "DGtal/kernel/PointVector.h"
51
#include "DGtal/kernel/SpaceND.h"
52
//#include "DGtal/io/boards/Board2D.h"
53
54
55
//#include "DGtal/io/Display3D.h"
56
57
#ifdef _MSC_VER
58
#if defined( max )
59
#undef max
60
#define _HAS_MSVC_MAX_ true
61
#endif
62
#if defined( min )
63
#undef min
64
#define _HAS_MSVC_MIN_ true
65
#endif
66
#endif
67
68
70
71
namespace
DGtal
72
{
73
78
template
<
Dimension
dim,
79
typename
TInteger =
DGtal::int32_t
>
80
struct
KhalimskyCell
81
{
82
83
//Integer must be a model of the concept CInteger.
84
BOOST_CONCEPT_ASSERT
((
CInteger<TInteger>
) );
85
//Integer must be signed to characterize a ring.
86
BOOST_CONCEPT_ASSERT
((
CSignedInteger<TInteger>
) );
87
88
public
:
89
typedef
TInteger
Integer
;
90
91
typedef
typename
NumberTraits<Integer>::UnsignedVersion
UnsignedInteger
;
92
typedef
PointVector< dim, Integer >
Point
;
93
94
Point
myCoordinates
;
95
99
KhalimskyCell
();
100
106
KhalimskyCell
(
const
KhalimskyCell
& other );
107
113
KhalimskyCell
(
const
Point
& point );
114
120
KhalimskyCell
&
operator=
(
const
KhalimskyCell
& other );
121
126
bool
operator==
(
const
KhalimskyCell
& other )
const
;
127
132
bool
operator!=
(
const
KhalimskyCell
& other )
const
;
133
138
bool
operator<
(
const
KhalimskyCell
& other )
const
;
139
140
// --------------- CDrawableWithBoard2D realization -------------------
141
public
:
142
147
//DrawableWithBoard2D* defaultStyle( std::string mode = "" ) const;
148
152
std::string
className
()
const
;
153
154
};
155
156
template
<
Dimension
dim,
157
typename
TInteger >
158
std::ostream &
159
operator<<
( std::ostream & out,
160
const
KhalimskyCell< dim, TInteger >
&
object
);
161
166
template
<
Dimension
dim,
167
typename
TInteger =
DGtal::int32_t
>
168
struct
SignedKhalimskyCell
169
{
170
//Integer must be a model of the concept CInteger.
171
BOOST_CONCEPT_ASSERT
((
CInteger<TInteger>
) );
172
//Integer must be signed to characterize a ring.
173
BOOST_CONCEPT_ASSERT
((
CSignedInteger<TInteger>
) );
174
175
public
:
176
typedef
TInteger
Integer
;
177
typedef
typename
NumberTraits<Integer>::UnsignedVersion
UnsignedInteger
;
178
typedef
PointVector< dim, Integer >
Point
;
179
180
Point
myCoordinates
;
181
bool
myPositive
;
182
186
SignedKhalimskyCell
();
187
193
SignedKhalimskyCell
(
const
SignedKhalimskyCell
& other );
194
201
SignedKhalimskyCell
(
const
Point
& point,
bool
positive );
202
208
SignedKhalimskyCell
&
operator=
(
const
SignedKhalimskyCell
& other );
209
214
bool
operator==
(
const
SignedKhalimskyCell
& other )
const
;
215
220
bool
operator!=
(
const
SignedKhalimskyCell
& other )
const
;
221
226
bool
operator<
(
const
SignedKhalimskyCell
& other )
const
;
227
228
// --------------- CDrawableWithBoard2D realization -------------------
229
public
:
230
235
//DrawableWithBoard2D* defaultStyle( std::string mode = "" ) const;
236
240
std::string
className
()
const
;
241
242
};
243
244
template
<
Dimension
dim,
245
typename
TInteger >
246
std::ostream &
247
operator<<
( std::ostream & out,
248
const
SignedKhalimskyCell< dim, TInteger >
&
object
);
249
264
template
<
Dimension
dim,
265
typename
TInteger =
DGtal::int32_t
>
266
class
CellDirectionIterator
267
{
268
public
:
269
typedef
TInteger
Integer
;
270
// Cells
271
typedef
KhalimskyCell< dim, Integer >
Cell
;
272
typedef
SignedKhalimskyCell< dim, Integer >
SCell
;
273
274
public
:
279
CellDirectionIterator
(
Cell
cell,
bool
open =
true
);
280
285
CellDirectionIterator
(
SCell
scell,
bool
open =
true
);
286
290
Dimension
operator*
()
const
;
291
295
CellDirectionIterator
&
operator++
();
296
303
bool
operator!=
(
const
Integer
)
const
;
304
308
bool
end
()
const
;
309
314
bool
operator!=
(
const
CellDirectionIterator
& other )
const
;
315
320
bool
operator==
(
const
CellDirectionIterator
& other )
const
;
321
322
private
:
324
Dimension
myDir
;
326
Cell
myCell
;
329
bool
myOpen
;
330
331
private
:
333
void
find
();
334
};
335
336
338
// template class KhalimskySpaceND
356
template
<
Dimension
dim,
357
typename
TInteger =
DGtal::int32_t
>
358
class
KhalimskySpaceND
359
{
360
//Integer must be signed to characterize a ring.
361
BOOST_CONCEPT_ASSERT
((
CCommutativeRing<TInteger>
) );
362
363
public
:
365
typedef
TInteger
Integer
;
366
368
typedef
typename
NumberTraits<Integer>::UnsignedVersion
Size
;
369
370
// Cells
371
typedef
KhalimskyCell< dim, Integer >
Cell
;
372
typedef
SignedKhalimskyCell< dim, Integer >
SCell
;
373
typedef
SCell
Surfel
;
374
typedef
bool
Sign
;
375
typedef
CellDirectionIterator< dim, Integer >
DirIterator
;
376
377
//Points and Vectors
378
typedef
PointVector< dim, Integer >
Point
;
379
typedef
PointVector< dim, Integer >
Vector
;
380
381
typedef
SpaceND<dim, Integer>
Space
;
382
typedef
KhalimskySpaceND<dim, Integer>
KhalimskySpace
;
383
384
#if defined ( WIN32 )
385
// static constants
386
static
const
Dimension
dimension
= dim;
387
static
const
Dimension
DIM
= dim;
388
static
const
Sign
POS
=
true
;
389
static
const
Sign
NEG
=
false
;
390
#else
391
// static constants
392
static
const
Dimension
dimension
= dim;
393
static
const
Dimension
DIM
;
394
static
const
Sign
POS
;
395
static
const
Sign
NEG
;
396
#endif //WIN32
397
398
template
<
typename
CellType>
399
struct
AnyCellCollection
:
public
std::deque<CellType> {
400
typedef
CellType
Value
;
401
typedef
typename
std::deque<CellType>
Container
;
402
typedef
typename
std::deque<CellType>::iterator
Iterator
;
403
typedef
typename
std::deque<CellType>::const_iterator
ConstIterator
;
404
};
405
406
// Neighborhoods, Incident cells, Faces and Cofaces
407
typedef
AnyCellCollection<Cell>
Cells
;
408
typedef
AnyCellCollection<SCell>
SCells
;
409
410
// Sets, Maps
412
typedef
std::set<Cell>
CellSet
;
414
typedef
std::set<SCell>
SCellSet
;
416
typedef
std::set<SCell>
SurfelSet
;
419
template
<
typename
Value>
struct
CellMap
{
420
typedef
std::map<SCell,Value>
Type
;
421
};
424
template
<
typename
Value>
struct
SCellMap
{
425
typedef
std::map<SCell,Value>
Type
;
426
};
429
template
<
typename
Value>
struct
SurfelMap
{
430
typedef
std::map<SCell,Value>
Type
;
431
};
432
// ----------------------- Standard services ------------------------------
433
public
:
434
438
~KhalimskySpaceND
();
439
443
KhalimskySpaceND
();
444
449
KhalimskySpaceND
(
const
KhalimskySpaceND
& other );
450
456
KhalimskySpaceND
&
operator=
(
const
KhalimskySpaceND
& other );
457
469
bool
init
(
const
Point
& lower,
470
const
Point
& upper,
471
bool
closed );
472
473
// ------------------------- Basic services ------------------------------
474
public
:
475
480
Size
size
(
Dimension
k )
const
;
485
Integer
min
(
Dimension
k )
const
;
490
Integer
max
(
Dimension
k )
const
;
494
const
Point
&
lowerBound
()
const
;
498
const
Point
&
upperBound
()
const
;
502
const
Cell
&
lowerCell
()
const
;
506
const
Cell
&
upperCell
()
const
;
507
511
bool
isSpaceClosed
()
const
;
512
513
// ----------------------- Cell creation services --------------------------
514
public
:
515
523
Cell
uCell
(
const
Point
& kp )
const
;
524
535
Cell
uCell
(
const
Point
& p,
const
Cell
& c )
const
;
536
545
SCell
sCell
(
const
Point
& kp,
Sign
sign =
POS
)
const
;
546
557
SCell
sCell
(
const
Point
& p,
const
SCell
& c )
const
;
558
567
Cell
uSpel
(
const
Point
& p )
const
;
568
578
SCell
sSpel
(
const
Point
& p,
Sign
sign =
POS
)
const
;
579
588
Cell
uPointel
(
const
Point
& p )
const
;
589
599
SCell
sPointel
(
const
Point
& p,
Sign
sign =
POS
)
const
;
600
601
602
// ----------------------- Read accessors to cells ------------------------
603
public
:
609
Integer
uKCoord
(
const
Cell
& c,
Dimension
k )
const
;
610
616
Integer
uCoord
(
const
Cell
& c,
Dimension
k )
const
;
617
622
Point
uKCoords
(
const
Cell
& c )
const
;
623
628
Point
uCoords
(
const
Cell
& c )
const
;
629
635
Integer
sKCoord
(
const
SCell
& c,
Dimension
k )
const
;
636
642
Integer
sCoord
(
const
SCell
& c,
Dimension
k )
const
;
643
648
Point
sKCoords
(
const
SCell
& c )
const
;
649
654
Point
sCoords
(
const
SCell
& c )
const
;
655
660
Sign
sSign
(
const
SCell
& c )
const
;
661
662
// ----------------------- Write accessors to cells ------------------------
663
public
:
664
671
void
uSetKCoord
(
Cell
& c,
Dimension
k,
const
Integer
& i )
const
;
672
679
void
sSetKCoord
(
SCell
& c,
Dimension
k,
const
Integer
& i )
const
;
680
687
void
uSetCoord
(
Cell
& c,
Dimension
k,
Integer
i )
const
;
688
695
void
sSetCoord
(
SCell
& c,
Dimension
k,
Integer
i )
const
;
696
702
void
uSetKCoords
(
Cell
& c,
const
Point
& kp )
const
;
703
709
void
sSetKCoords
(
SCell
& c,
const
Point
& kp )
const
;
710
716
void
uSetCoords
(
Cell
& c,
const
Point
& kp )
const
;
717
723
void
sSetCoords
(
SCell
& c,
const
Point
& kp )
const
;
724
730
void
sSetSign
(
SCell
& c,
Sign
s )
const
;
731
732
// -------------------- Conversion signed/unsigned ------------------------
733
public
:
740
SCell
signs
(
const
Cell
& p,
Sign
s )
const
;
741
747
Cell
unsigns
(
const
SCell
& p )
const
;
748
754
SCell
sOpp
(
const
SCell
& p )
const
;
755
756
// ------------------------- Cell topology services -----------------------
757
public
:
762
Integer
uTopology
(
const
Cell
& p )
const
;
763
768
Integer
sTopology
(
const
SCell
& p )
const
;
769
774
Dimension
uDim
(
const
Cell
& p )
const
;
775
780
Dimension
sDim
(
const
SCell
& p )
const
;
781
786
bool
uIsSurfel
(
const
Cell
& b )
const
;
787
792
bool
sIsSurfel
(
const
SCell
& b )
const
;
793
799
bool
uIsOpen
(
const
Cell
& p,
Dimension
k )
const
;
800
806
bool
sIsOpen
(
const
SCell
& p,
Dimension
k )
const
;
807
808
// -------------------- Iterator services for cells ------------------------
809
public
:
810
831
DirIterator
uDirs
(
const
Cell
& p )
const
;
832
853
DirIterator
sDirs
(
const
SCell
& p )
const
;
854
875
DirIterator
uOrthDirs
(
const
Cell
& p )
const
;
876
897
DirIterator
sOrthDirs
(
const
SCell
& p )
const
;
898
906
Dimension
uOrthDir
(
const
Cell
& s )
const
;
907
915
Dimension
sOrthDir
(
const
SCell
& s )
const
;
916
917
// -------------------- Unsigned cell geometry services --------------------
918
public
:
919
923
Cell
uFirst
(
const
Cell
& p )
const
;
924
928
Cell
uLast
(
const
Cell
& p )
const
;
929
938
Cell
uGetIncr
(
const
Cell
& p,
Dimension
k )
const
;
939
948
bool
uIsMax
(
const
Cell
& p,
Dimension
k )
const
;
949
950
958
bool
uIsInside
(
const
Cell
& p,
Dimension
k )
const
;
959
960
969
Cell
uGetMax
(
const
Cell
& p,
Dimension
k )
const
;
970
979
Cell
uGetDecr
(
const
Cell
& p,
Dimension
k )
const
;
980
989
bool
uIsMin
(
const
Cell
& p,
Dimension
k )
const
;
990
999
Cell
uGetMin
(
const
Cell
& p,
Dimension
k )
const
;
1000
1001
1011
Cell
uGetAdd
(
const
Cell
& p,
Dimension
k,
const
Integer
& x )
const
;
1012
1022
Cell
uGetSub
(
const
Cell
& p,
Dimension
k,
const
Integer
& x )
const
;
1023
1030
Integer
uDistanceToMax
(
const
Cell
& p,
Dimension
k )
const
;
1031
1040
Integer
uDistanceToMin
(
const
Cell
& p,
Dimension
k )
const
;
1041
1049
Cell
uTranslation
(
const
Cell
& p,
const
Vector
& vec )
const
;
1050
1060
Cell
uProjection
(
const
Cell
& p,
const
Cell
& bound,
Dimension
k )
const
;
1061
1071
void
uProject
(
Cell
& p,
const
Cell
& bound,
Dimension
k )
const
;
1072
1094
bool
uNext
(
Cell
& p,
const
Cell
& lower,
const
Cell
& upper )
const
;
1095
1096
// -------------------- Signed cell geometry services --------------------
1097
public
:
1098
1102
SCell
sFirst
(
const
SCell
& p )
const
;
1103
1107
SCell
sLast
(
const
SCell
& p )
const
;
1108
1117
SCell
sGetIncr
(
const
SCell
& p,
Dimension
k )
const
;
1118
1127
bool
sIsMax
(
const
SCell
& p,
Dimension
k )
const
;
1128
1136
bool
sIsInside
(
const
SCell
& p,
Dimension
k )
const
;
1137
1146
SCell
sGetMax
(
const
SCell
& p,
Dimension
k )
const
;
1147
1156
SCell
sGetDecr
(
const
SCell
& p,
Dimension
k )
const
;
1157
1166
bool
sIsMin
(
const
SCell
& p,
Dimension
k )
const
;
1167
1176
SCell
sGetMin
(
const
SCell
& p,
Dimension
k )
const
;
1177
1187
SCell
sGetAdd
(
const
SCell
& p,
Dimension
k,
const
Integer
& x )
const
;
1188
1198
SCell
sGetSub
(
const
SCell
& p,
Dimension
k,
const
Integer
& x )
const
;
1199
1206
Integer
sDistanceToMax
(
const
SCell
& p,
Dimension
k )
const
;
1207
1216
Integer
sDistanceToMin
(
const
SCell
& p,
Dimension
k )
const
;
1217
1225
SCell
sTranslation
(
const
SCell
& p,
const
Vector
& vec )
const
;
1226
1236
SCell
sProjection
(
const
SCell
& p,
const
SCell
& bound,
Dimension
k )
const
;
1237
1247
void
sProject
(
SCell
& p,
const
SCell
& bound,
Dimension
k )
const
;
1248
1270
bool
sNext
(
SCell
& p,
const
SCell
& lower,
const
SCell
& upper )
const
;
1271
1272
// ----------------------- Neighborhood services --------------------------
1273
public
:
1274
1283
Cells
uNeighborhood
(
const
Cell
& cell )
const
;
1284
1293
SCells
sNeighborhood
(
const
SCell
& cell )
const
;
1294
1304
Cells
uProperNeighborhood
(
const
Cell
& cell )
const
;
1305
1315
SCells
sProperNeighborhood
(
const
SCell
& cell )
const
;
1316
1329
Cell
uAdjacent
(
const
Cell
& p,
Dimension
k,
bool
up )
const
;
1342
SCell
sAdjacent
(
const
SCell
& p,
Dimension
k,
bool
up )
const
;
1343
1344
// ----------------------- Incidence services --------------------------
1345
public
:
1346
1363
Cell
uIncident
(
const
Cell
& c,
Dimension
k,
bool
up )
const
;
1364
1384
SCell
sIncident
(
const
SCell
& c,
Dimension
k,
bool
up )
const
;
1385
1390
Cells
uLowerIncident
(
const
Cell
& c )
const
;
1391
1396
Cells
uUpperIncident
(
const
Cell
& c )
const
;
1397
1403
SCells
sLowerIncident
(
const
SCell
& c )
const
;
1404
1410
SCells
sUpperIncident
(
const
SCell
& c )
const
;
1411
1416
Cells
uFaces
(
const
Cell
& c )
const
;
1417
1422
Cells
uCoFaces
(
const
Cell
& c )
const
;
1423
1440
bool
sDirect
(
const
SCell
& p,
Dimension
k )
const
;
1441
1449
SCell
sDirectIncident
(
const
SCell
& p,
Dimension
k )
const
;
1450
1458
SCell
sIndirectIncident
(
const
SCell
& p,
Dimension
k )
const
;
1459
1460
1461
// ----------------------- Interface --------------------------------------
1462
public
:
1463
1468
void
selfDisplay
( std::ostream & out )
const
;
1469
1474
bool
isValid
()
const
;
1475
1476
// ------------------------- Protected Datas ------------------------------
1477
private
:
1478
// ------------------------- Private Datas --------------------------------
1479
private
:
1480
Point
myLower
;
1481
Point
myUpper
;
1482
Cell
myCellLower
;
1483
Cell
myCellUpper
;
1484
bool
myIsClosed
;
1485
// ------------------------- Hidden services ------------------------------
1486
protected
:
1487
1488
1489
private
:
1490
1491
1492
1493
// ------------------------- Internals ------------------------------------
1494
private
:
1495
1496
};
// end of class KhalimskySpaceND
1497
1498
1505
template
<
Dimension
dim,
1506
typename
TInteger >
1507
std::ostream&
1508
operator<<
( std::ostream & out,
1509
const
KhalimskySpaceND<dim, TInteger >
&
object
);
1510
1511
}
// namespace DGtal
1512
1513
1515
// Includes inline functions.
1516
#include "DGtal/topology/KhalimskySpaceND.ih"
1517
1518
// //
1520
1521
#endif // !defined KhalimskySpaceND_h
1522
1523
#undef KhalimskySpaceND_RECURSES
1524
#endif // else defined(KhalimskySpaceND_RECURSES)
Generated on Wed Dec 19 2012 19:10:28 for DGtal by
1.8.1.1