VR-Forces 4.1.1 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
include
geometry
surface.h
Go to the documentation of this file.
1
/*******************************************************************************
2
** Copyright (c) 2003 MAK Technologies, Inc.
3
** All rights reserved.
4
*******************************************************************************/
5
/*******************************************************************************
6
** $RCSfile: surface.h,v $ $Revision: 1.21 $ $State: Exp $
7
*******************************************************************************/
8
9
#ifndef surface_H_
10
#define surface_H_
11
12
#include <vlutil/vlConfig.h>
13
#include "
geometry/geometryDefines.h
"
14
#include "
geometry/gdbColor.h
"
15
#include <stdio.h>
16
#include <locale>
17
#include <string>
18
#include <vlutil/vlString.h>
19
20
class
DtTerrainDatabase
;
21
class
DtMapSurfaceToRoughness
;
22
23
// enumeration DtSoilType is used to specify the soiltype
24
// associated with a surface
25
typedef
enum
26
{
27
SoftSoil
,
28
Swamp
,
29
Mud
,
30
Forest
,
31
Grass
,
32
CultivatedFields
,
33
Orchards
,
34
Rock
,
35
Boulder
,
36
Sand
,
37
DirtRoad
,
38
GravelRoad
,
39
PavedRoad
,
40
MuddyRoad
,
41
AsphaltOrOtherHardSurface
,
42
USRailRoad
,
43
EuroRailRoad
,
44
Flimsy
,
45
BodyOfWater
,
46
UndefinedSoilType
47
}
DtSoilType
;
48
49
typedef
enum
50
{
51
Ocean
,
52
Lake
,
53
River
,
54
Pond
,
55
Stream
,
56
Brook
,
57
UnspecifiedBodyOfWater
58
}
DtBodyOfWaterType
;
59
60
typedef
enum
61
{
62
CfBuilding
,
63
CfTree
,
64
UnspecifiedCulturalFeature
65
}
DtCulturalFeatureType
;
66
67
// enumeration DtEnvState is used to specify the prevailing
68
// environmental condition over a surface.
69
typedef
enum
70
{
71
Dry
,
72
Wet
,
73
Icy
,
74
Snow
,
75
UnspecifiedEnvState
76
}
DtEnvState
;
77
78
enum
DtRoughnessSoilType
79
{
80
DtPavedRoad
= 0,
81
DtHardPacked
,
82
DtRocks
,
83
DtSand
,
84
DtGravel
,
85
DtShallowWater
,
86
DtMuck
,
87
DtDeepWater
88
};
89
90
// class DtSurface:
91
//
92
// DtSurface has two member variables, a color specification and an
93
// unsigned 32-bit vector that specifies its characteristics - medium
94
// the surface is in, soil type, environmental state, etc.
95
//
96
// The characteristics vector is laid out as follows (Note: we refer to the
97
// most significant bit as bit-0 and the least significant bit as bit-31):
98
//
99
// bit interpretation when the bit is set
100
// --- ----------------------------------
101
//
102
// medium specification. Initially, we only envision Ground and Water Surface
103
// being used.
104
//
105
// bit 0 -- surface is Ground (is equivalent to IsTerrainSkin in
106
// earlier version)
107
// 1 -- surface is above ground
108
// 2 -- surface is under ground
109
// 3 -- top surface of a body of water
110
// 4 -- surface is above water
111
// 5 -- surface is under water
112
// 6,7 -- unused
113
//
114
// environment specification; the default is dry, unless otherwise specified.
115
//
116
// 8 -- surface is dry
117
// 9 -- surface is wet
118
// 10 -- surface is icy
119
// 11 -- surface is (covered with?) snow
120
//
121
// 12-15 -- unspecified
122
//
123
// soiltype specification
124
// when medium is ground
125
// 16 -- improved/unimproved
126
// when medium is WaterSurface
127
// 16 -- deep/shallow
128
// when medium is above ground
129
// 16 -- surface is / is not part of cultural feature
130
// 17-23 -- currently unused
131
//
132
// bits 24-31 are laid out as follows
133
// 0000 0000 -- unspecified soil type
134
// 0000 0001 -- softsoil (ground/unimproved)
135
// 0000 0010 -- swamp (ground/unimproved)
136
// 0000 0011 -- mud (ground/unimproved)
137
// 0000 0100 -- forest (ground/unimproved)
138
// 0000 0101 -- grass (ground)
139
// 0000 0110 -- Cultivated Fields (ground)
140
// 0000 0111 -- Orchards (ground)
141
// 0000 1000 -- Rock (ground/unimproved)
142
// 0000 1001 -- Boulder (ground/unimproved)
143
// 0000 1010 -- Sand (ground/unimproved)
144
// 0000 1011 -- Dirt Road (ground/improved)
145
// 0000 1100 -- Gravel Road (ground/improved)
146
// 0000 1101 -- paved road (ground/improved)
147
// 0000 1110 -- asphalt/other hard surface (ground/improved)
148
// 0000 1111 -- Railroad US (ground/improved)
149
// 0001 0000 -- RailRoad Euro (ground/improved)
150
// 0001 0001 -- flimsy (to map from ctdb soil types)
151
// 0001 0010 -- muddy road (ground/unimproved)
152
//
153
// body of water specification
154
//
155
// bits 24-31 are laid out as follows
156
// 0000 0001 -- ocean (water surface)
157
// 0000 0010 -- lake (water surface)
158
// 0000 0011 -- river (water surface)
159
// 0000 0100 -- pond (water surface)
160
// 0000 0101 -- stream(water surface)
161
// 0000 0110 -- brook (water surface)
162
//
163
// cultural feature specification
164
//
165
// bits 24-31 are laid out as follows
166
// 0000 0001 -- building (above ground)
167
// 0000 0010 -- tree (above ground)
168
169
class
DT_DLL_geometry
DtSurface
170
{
171
public
:
172
173
// enumeration DtMedium is used to specify where a surface
174
// is situated.
175
typedef
enum
176
{
177
Ground
,
178
AboveGround
,
179
UnderGround
,
180
WaterSurface
,
181
AboveWater
,
182
UnderWater
,
183
UnspecifiedMedium
184
} DtMedium;
185
186
typedef
unsigned
int
DtCharacteristics
;
187
188
public
:
189
190
// default constructor
191
DtSurface
();
192
193
// destructor
194
virtual
~
DtSurface
();
195
196
// copy constructor
197
DtSurface
(
const
DtSurface
& orig);
198
199
// assignment operator
200
DtSurface
& operator=(
const
DtSurface
& orig);
201
202
// comparison operators
203
bool
operator==
(
const
DtSurface
& orig)
const
;
204
bool
operator!=
(
const
DtSurface
& orig)
const
;
205
206
// accessor / mutator functions
207
virtual
const
DtColor
& color()
const
;
208
virtual
void
setColor(
const
DtColor
& c);
209
210
// Set/Get the surface characteristics field.
211
virtual
void
setSurfaceCharacteristics(
DtCharacteristics
surfChar);
212
virtual
DtCharacteristics
characteristics()
const
;
213
214
// \return A string that describes the surface characteristic.
215
DtString
surfaceCharacteristicsString()
const
;
216
217
// functions to return medium, environmental
218
// state, soil type, body of water type, and cultural feature type.
219
virtual
DtMedium
whereSurface()
const
;
220
virtual
DtEnvState
envState()
const
;
221
virtual
DtSoilType
soilType()
const
;
222
virtual
DtBodyOfWaterType
bodyOfWaterType()
const
;
223
virtual
DtCulturalFeatureType
culturalFeatureType()
const
;
224
225
// functions to return medium, environmental
226
// state, soil type, body of water type, and
227
// cultural feature type as a string.
228
virtual
DtString
mediumString()
const
;
229
virtual
DtString
envStateString()
const
;
230
virtual
DtString
soilTypeString()
const
;
231
virtual
DtString
bodyOfWaterTypeString()
const
;
232
virtual
DtString
culturalFeatureTypeString()
const
;
233
234
virtual
DtRoughnessSoilType
roughnessSoilType()
const
;
235
virtual
DtString
roughnessSoilTypeString()
const
;
236
237
// Set/Get whether the surface is ground.
238
virtual
void
setIsGround(
bool
onOff);
239
virtual
bool
isGround()
const
;
240
242
243
// Set/Get whether the surface is above ground.
244
virtual
void
setAboveGround(
bool
onOff);
245
virtual
bool
aboveGround()
const
;
246
247
// Set/Get whether the surface is under ground.
248
virtual
void
setUnderGround(
bool
onOff);
249
virtual
bool
underGround()
const
;
250
251
// Set/Get whether the surface is water.
252
virtual
void
setIsWaterSurface(
bool
onOff);
253
virtual
bool
isWaterSurface()
const
;
254
255
// Set/Get whether the surface is above water.
256
virtual
void
setAboveWater(
bool
onOff);
257
virtual
bool
aboveWater()
const
;
258
259
// Set/Get whether the surface is under water.
260
virtual
void
setUnderWater(
bool
onOff);
261
virtual
bool
underWater()
const
;
262
264
265
// Set/Get whether the surface is dry.
266
virtual
void
setIsDry(
bool
onOff);
267
virtual
bool
isDry()
const
;
268
269
// Set/Get whether the surface is wet.
270
virtual
void
setIsWet(
bool
onOff);
271
virtual
bool
isWet()
const
;
272
273
// Set/Get whether the surface is icy.
274
virtual
void
setIsIcy(
bool
onOff);
275
virtual
bool
isIcy()
const
;
276
277
// Set/Get whether the surface is covered by snow.
278
virtual
void
setIsCoveredBySnow(
bool
onOff);
279
virtual
bool
isCoveredBySnow()
const
;
280
281
282
// Set/Get whether the surface is improved.
283
// The medium is required to be Ground.
284
virtual
void
setIsImproved(
bool
onOff);
285
virtual
bool
isImproved()
const
;
286
virtual
bool
isUnimproved()
const
;
287
288
// Set/Get whether the surface is a body of water
289
// and is deep.
290
virtual
void
setIsDeep(
bool
onOff);
291
virtual
bool
isDeep()
const
;
292
virtual
bool
isShallow()
const
;
293
294
// Set/Get whether the surface is a part of a cultural
295
// feature. The medium is required to be AboveGround.
296
virtual
void
setIsCulturalFeature(
bool
onOff);
297
virtual
bool
isCulturalFeature()
const
;
298
299
// Accessor/Mutator functions for soil type
300
301
// Set/Get whether the surface is soft soil.
302
virtual
void
setIsSoftSoil(
bool
onOff);
303
virtual
bool
isSoftSoil()
const
;
304
305
// Set/Get whether the surface is swamp.
306
virtual
void
setIsSwamp(
bool
onOff);
307
virtual
bool
isSwamp()
const
;
308
309
// Set/Get whether the surface is mud.
310
virtual
void
setIsMud(
bool
onOff);
311
virtual
bool
isMud()
const
;
312
313
// Set/Get whether the surface is forest.
314
virtual
void
setIsForest(
bool
onOff);
315
virtual
bool
isForest()
const
;
316
317
// Set/Get whether the surface is grass.
318
virtual
void
setIsGrass(
bool
onOff);
319
virtual
bool
isGrass()
const
;
320
321
// Set/Get whether the surface is grass.
322
virtual
void
setIsCultivatedField(
bool
onOff);
323
virtual
bool
isCultivatedField()
const
;
324
325
// Set/Get whether the surface is grass.
326
virtual
void
setIsOrchard(
bool
onOff);
327
virtual
bool
isOrchard()
const
;
328
329
// Set/Get whether the surface is rock.
330
virtual
void
setIsRock(
bool
onOff);
331
virtual
bool
isRock()
const
;
332
333
// Set/Get whether the surface is boulder.
334
virtual
void
setIsBoulder(
bool
onOff);
335
virtual
bool
isBoulder()
const
;
336
337
// Set/Get whether the surface is sand.
338
virtual
void
setIsSand(
bool
onOff);
339
virtual
bool
isSand()
const
;
340
341
// Set/Get whether the surface is dirt road.
342
virtual
void
setIsDirtRoad(
bool
onOff);
343
virtual
bool
isDirtRoad()
const
;
344
345
// Set/Get whether the surface is gravel road.
346
virtual
void
setIsGravelRoad(
bool
onOff);
347
virtual
bool
isGravelRoad()
const
;
348
349
// Set/Get whether the surface is paved road.
350
virtual
void
setIsPavedRoad(
bool
onOff);
351
virtual
bool
isPavedRoad()
const
;
352
353
// Set/Get whether the surface is Muddy road.
354
virtual
void
setIsMuddyRoad(
bool
onOff);
355
virtual
bool
isMuddyRoad()
const
;
356
357
// Set/Get whether the surface is asphalt or other hard
358
// surface.
359
virtual
void
setIsHardSurface(
bool
onOff);
360
virtual
bool
isHardSurface()
const
;
361
362
// Set/Get whether the surface is US rail road.
363
virtual
void
setIsUSRailRoad(
bool
onOff);
364
virtual
bool
isUSRailRoad()
const
;
365
366
// Set/Get whether the surface is Euro rail road.
367
virtual
void
setIsEuroRailRoad(
bool
onOff);
368
virtual
bool
isEuroRailRoad()
const
;
369
370
// Set/Get whether the surface is flimsy.
371
virtual
void
setIsFlimsy(
bool
onOff);
372
virtual
bool
isFlimsy()
const
;
373
374
// Set/Get whether the soiltype is undefined.
375
virtual
void
setIsUndefinedSoilType(
bool
onOff);
376
virtual
bool
isUndefinedSoilType()
const
;
377
378
// \deprecated Use standard version above.
379
// \see setIsUndefinedSoilType
380
// \see undefinedSoilType
381
virtual
void
setUndefinedSoilType(
bool
onOff);
382
virtual
bool
undefinedSoilType()
const
;
383
384
// Accessor/Mutator functions for body of water type.
385
387
// Set/Get whether the surface is ocean.
388
virtual
void
setIsOcean(
bool
onOff);
389
virtual
bool
isOcean()
const
;
390
391
// Set/Get whether the surface is lake.
392
virtual
void
setIsLake(
bool
onOff);
393
virtual
bool
isLake()
const
;
394
395
// Set/Get whether the surface is river.
396
virtual
void
setIsRiver(
bool
onOff);
397
virtual
bool
isRiver()
const
;
398
399
// Set/Get whether the surface is pond.
400
virtual
void
setIsPond(
bool
onOff);
401
virtual
bool
isPond()
const
;
402
403
// Set/Get whether the surface is stream.
404
virtual
void
setIsStream(
bool
onOff);
405
virtual
bool
isStream()
const
;
406
407
// Set/Get whether the surface is brook.
408
virtual
void
setIsBrook(
bool
onOff);
409
virtual
bool
isBrook()
const
;
410
411
// Set/Get whether the surface is part of a tree.
412
virtual
void
setIsTree(
bool
onOff);
413
virtual
bool
isTree()
const
;
414
415
// Set/Get whether the surface is part of a Building.
416
virtual
void
setIsBuilding(
bool
onOff);
417
virtual
bool
isBuilding()
const
;
419
420
421
// Set characteristics based on an exact match with a string.
422
virtual
bool
characteristicsFromString(std::string characteristicsString,
bool
warn =
true
);
423
424
// Set characteristics based on any match with a substring of the specified
425
// characteristics string.
426
// \note This may cause the incorrect surface characteristics to be set, if
427
// the specified string contains more than one of the substrings searched for.
428
virtual
bool
characteristicsFromSubString(std::string characteristicsString,
bool
warn =
true
);
429
430
// debugging aid
431
virtual
void
dump()
const
;
432
433
// \return The maximum color of the surface
434
virtual
void
maxColor(
DtColor
& theColor);
435
436
// \return The default color associated with the surface type
437
DtColor
colorForSurfaceType()
const
;
438
439
// input/output functions
440
virtual
bool
readFrom(FILE* fp);
441
// virtual bool readFromOldFormat(FILE* fp, DtTerrainDatabase* ptdb);
442
virtual
bool
writeTo(FILE* fp);
443
444
static
DtString
soilTypeToString(
DtRoughnessSoilType
type);
445
static
DtRoughnessSoilType
stringToSoilType(
const
DtString
&
string
);
446
447
public
:
448
449
static
DtSurface
& nullSurface();
450
451
static
void
setSurfaceToRoughnessMapper(
DtMapSurfaceToRoughness
&
452
surfaceToRoughnessMapper);
453
454
public
:
455
456
static
const
DtColor
theSoftSoilColor
;
457
static
const
DtColor
theSwampColor
;
458
static
const
DtColor
theMudColor
;
459
static
const
DtColor
theForestColor
;
460
static
const
DtColor
theGrassColor
;
461
static
const
DtColor
theCultivatedFieldColor
;
462
static
const
DtColor
theOrchardColor
;
463
static
const
DtColor
theRockColor
;
464
static
const
DtColor
theBoulderColor
;
465
static
const
DtColor
theSandColor
;
466
static
const
DtColor
theDirtRoadColor
;
467
static
const
DtColor
theGravelRoadColor
;
468
static
const
DtColor
thePavedRoadColor
;
469
static
const
DtColor
theMuddyRoadColor
;
470
static
const
DtColor
theHardSurfaceColor
;
471
static
const
DtColor
theRailRoadColor
;
472
static
const
DtColor
theFlimsySoilColor
;
473
static
const
DtColor
theOceanColor
;
474
static
const
DtColor
theLakeColor
;
475
static
const
DtColor
theRiverColor
;
476
static
const
DtColor
thePondColor
;
477
478
static
const
DtColor
theIceColor
;
479
static
const
DtColor
theTreeColor
;
480
static
const
DtColor
theBuildingColor
;
481
482
//Dted colors
483
static
const
DtColor
theDtedGroundCellColor
;
484
static
const
DtColor
theDtedWaterCellColor
;
485
486
static
const
char
DtSoilPavedRoad
[];
487
static
const
char
DtSoilHardPacked
[];
488
static
const
char
DtSoilRocks
[];
489
static
const
char
DtSoilSand
[];
490
static
const
char
DtSoilGravel
[];
491
static
const
char
DtSoilShallowWater
[];
492
static
const
char
DtSoilMuck
[];
493
static
const
char
DtSoilDeepWater
[];
494
495
protected
:
496
497
static
const
DtCharacteristics
theSoftSoilBitMask
;
498
static
const
DtCharacteristics
theSoftSoilComparator
;
499
500
static
const
DtCharacteristics
theSwampBitMask
;
501
static
const
DtCharacteristics
theSwampComparator
;
502
503
static
const
DtCharacteristics
theMudBitMask
;
504
static
const
DtCharacteristics
theMudComparator
;
505
506
static
const
DtCharacteristics
theForestBitMask
;
507
static
const
DtCharacteristics
theForestComparator
;
508
509
static
const
DtCharacteristics
theGrassBitMask
;
510
static
const
DtCharacteristics
theGrassComparator
;
511
512
static
const
DtCharacteristics
theCultivatedFieldBitMask
;
513
static
const
DtCharacteristics
theCultivatedFieldComparator
;
514
515
static
const
DtCharacteristics
theOrchardBitMask
;
516
static
const
DtCharacteristics
theOrchardComparator
;
517
518
static
const
DtCharacteristics
theRockBitMask
;
519
static
const
DtCharacteristics
theRockComparator
;
520
521
static
const
DtCharacteristics
theBoulderBitMask
;
522
static
const
DtCharacteristics
theBoulderComparator
;
523
524
static
const
DtCharacteristics
theSandBitMask
;
525
static
const
DtCharacteristics
theSandComparator
;
526
527
static
const
DtCharacteristics
theDirtRoadBitMask
;
528
static
const
DtCharacteristics
theDirtRoadComparator
;
529
530
static
const
DtCharacteristics
theGravelRoadBitMask
;
531
static
const
DtCharacteristics
theGravelRoadComparator
;
532
533
static
const
DtCharacteristics
thePavedRoadBitMask
;
534
static
const
DtCharacteristics
thePavedRoadComparator
;
535
536
static
const
DtCharacteristics
theMuddyRoadBitMask
;
537
static
const
DtCharacteristics
theMuddyRoadComparator
;
538
539
static
const
DtCharacteristics
theHardSurfaceBitMask
;
540
static
const
DtCharacteristics
theHardSurfaceComparator
;
541
542
static
const
DtCharacteristics
theUSRailRoadBitMask
;
543
static
const
DtCharacteristics
theUSRailRoadComparator
;
544
545
static
const
DtCharacteristics
theEuroRailRoadBitMask
;
546
static
const
DtCharacteristics
theEuroRailRoadComparator
;
547
548
static
const
DtCharacteristics
theFlimsySoilBitMask
;
549
static
const
DtCharacteristics
theFlimsySoilComparator
;
550
551
static
const
DtCharacteristics
theOceanBitMask
;
552
static
const
DtCharacteristics
theOceanComparator
;
553
554
static
const
DtCharacteristics
theLakeBitMask
;
555
static
const
DtCharacteristics
theLakeComparator
;
556
557
static
const
DtCharacteristics
theRiverBitMask
;
558
static
const
DtCharacteristics
theRiverComparator
;
559
560
static
const
DtCharacteristics
thePondBitMask
;
561
static
const
DtCharacteristics
thePondComparator
;
562
563
static
const
DtCharacteristics
theStreamBitMask
;
564
static
const
DtCharacteristics
theStreamComparator
;
565
566
static
const
DtCharacteristics
theBrookBitMask
;
567
static
const
DtCharacteristics
theBrookComparator
;
568
569
static
const
DtCharacteristics
theDeepWaterBitMask
;
570
static
const
DtCharacteristics
theDeepWaterComparator
;
571
572
static
const
DtCharacteristics
theBuildingBitMask
;
573
static
const
DtCharacteristics
theBuildingComparator
;
574
575
static
const
DtCharacteristics
theTreeBitMask
;
576
static
const
DtCharacteristics
theTreeComparator
;
577
578
protected
:
579
// Custom function to lower the case of a string. Necessary since the tolower
580
// function (from locale) needs to have a locale specified. Defaults to using
581
// the classic C locale, which is for ASCII.
582
std::string customToLower(
const
std::string& stringToConvert,
const
std::locale loc = std::locale::classic())
const
;
583
584
// Removes any white spaces on the right side of the string
585
std::string trimString(
const
std::string& strToTrim);
586
587
virtual
void
setRoughnessSoilType();
588
589
DtCharacteristics
myCharacteristics
;
590
DtColor
myColor
;
591
DtRoughnessSoilType
myRoughness
;
592
static
DtMapSurfaceToRoughness
*
theMapSurfaceToRoughness
;
593
};
594
595
inline
const
DtColor
&
DtSurface::color
()
const
596
{
597
return
myColor
;
598
}
599
600
inline
void
DtSurface::setColor
(
const
DtColor
& c)
601
{
602
myColor
= c;
603
}
604
605
inline
DtSurface::DtCharacteristics
DtSurface::characteristics
()
const
606
{
607
return
myCharacteristics
;
608
}
609
610
inline
void
DtSurface::setSurfaceCharacteristics
(
DtSurface::DtCharacteristics
surfChar)
611
{
612
myCharacteristics
= surfChar;
613
setRoughnessSoilType
();
614
}
615
616
#endif
Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (
www.mak.com
)