VR-Forces 4.1 Class Documentation
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>
14 #include "geometry/gdbColor.h"
15 #include <stdio.h>
16 #include <locale>
17 #include <string>
18 #include <vlutil/vlString.h>
19 
20 class DtTerrainDatabase;
22 
23 // enumeration DtSoilType is used to specify the soiltype
24 // associated with a surface
25 typedef enum
26 {
29  Mud,
47 } DtSoilType;
48 
49 typedef enum
50 {
59 
60 typedef enum
61 {
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,
76 } DtEnvState;
77 
79 {
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 
170 {
171 public:
172 
173  // enumeration DtMedium is used to specify where a surface
174  // is situated.
175  typedef enum
176  {
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;
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;
471  static const DtColor theRailRoadColor;
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
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 
499 
502 
505 
508 
511 
514 
517 
520 
523 
526 
529 
532 
535 
538 
541 
544 
547 
550 
553 
556 
559 
562 
565 
568 
571 
574 
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 
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 
606 {
607  return myCharacteristics;
608 }
609 
611 {
612  myCharacteristics = surfChar;
614 }
615 
616 #endif

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)