VR-Forces 4.0.4 Class Documentation
include/geometry/surface.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2003 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 /*******************************************************************************
00006 ** $RCSfile: surface.h,v $ $Revision: 1.21 $ $State: Exp $
00007 *******************************************************************************/
00008 
00009 #ifndef surface_H_
00010 #define surface_H_
00011 
00012 #include <vlutil/vlConfig.h>
00013 #include "geometry/geometryDefines.h"
00014 #include "geometry/gdbColor.h"
00015 #include <stdio.h>
00016 #include <locale>
00017 #include <string>
00018 #include <vlutil/vlString.h>
00019 
00020 class DtTerrainDatabase;
00021 class DtMapSurfaceToRoughness;
00022 
00023 // enumeration DtSoilType is used to specify the soiltype
00024 // associated with a surface 
00025 typedef enum
00026 {
00027    SoftSoil,
00028    Swamp,
00029    Mud,
00030    Forest,
00031    Grass,
00032    CultivatedFields,
00033    Orchards,
00034    Rock,
00035    Boulder,
00036    Sand,
00037    DirtRoad,
00038    GravelRoad,
00039    PavedRoad,
00040    MuddyRoad,
00041    AsphaltOrOtherHardSurface,
00042    USRailRoad,
00043    EuroRailRoad,
00044    Flimsy,
00045    BodyOfWater,
00046    UndefinedSoilType
00047 } DtSoilType;
00048 
00049 typedef enum
00050 {
00051    Ocean,
00052    Lake,
00053    River, 
00054    Pond,
00055    Stream,
00056    Brook,
00057    UnspecifiedBodyOfWater   
00058 } DtBodyOfWaterType;
00059 
00060 typedef enum
00061 {
00062    CfBuilding,
00063    CfTree,
00064    UnspecifiedCulturalFeature
00065 } DtCulturalFeatureType;
00066 
00067 // enumeration DtEnvState is used to specify the prevailing 
00068 // environmental condition over a surface.
00069 typedef enum
00070 {
00071    Dry,
00072    Wet,
00073    Icy,
00074    Snow,
00075    UnspecifiedEnvState
00076 } DtEnvState;
00077 
00078 enum DtRoughnessSoilType
00079 {
00080    DtPavedRoad = 0,
00081    DtHardPacked,
00082    DtRocks,
00083    DtSand,
00084    DtGravel,
00085    DtShallowWater,   
00086    DtMuck,
00087    DtDeepWater
00088 };
00089 
00090 // class DtSurface:
00091 //
00092 // DtSurface has two member variables, a color specification and an
00093 // unsigned 32-bit vector that specifies its characteristics - medium 
00094 // the surface is in, soil type, environmental state, etc.
00095 //
00096 // The characteristics vector is laid out as follows (Note: we refer to the 
00097 // most significant bit as bit-0 and the least significant bit as bit-31):
00098 //
00099 //  bit           interpretation when the bit is set
00100 //  ---           ----------------------------------
00101 //
00102 //  medium specification. Initially, we only envision Ground and Water Surface
00103 //  being used. 
00104 //
00105 // bit 0 -- surface is Ground (is equivalent to IsTerrainSkin in 
00106 //                             earlier version)
00107 //     1 -- surface is above ground
00108 //     2 -- surface is under ground
00109 //     3 -- top surface of a body of water
00110 //     4 -- surface is above water
00111 //     5 -- surface is under water
00112 //   6,7 -- unused
00113 // 
00114 //  environment specification; the default is dry, unless otherwise specified.
00115 //
00116 //     8 -- surface is dry
00117 //     9 -- surface is wet
00118 //    10 -- surface is icy
00119 //    11 -- surface is (covered with?) snow
00120 //
00121 //  12-15 -- unspecified
00122 //
00123 // soiltype specification
00124 //    when medium is ground 
00125 //    16 -- improved/unimproved
00126 //    when medium is WaterSurface
00127 //    16 -- deep/shallow
00128 //    when medium is above ground
00129 //     16 -- surface is / is not part of cultural feature 
00130 //  17-23 -- currently unused
00131 //    
00132 //    bits 24-31 are laid out as follows 
00133 //    0000 0000  -- unspecified soil type
00134 //    0000 0001  -- softsoil  (ground/unimproved)
00135 //    0000 0010  -- swamp     (ground/unimproved)
00136 //    0000 0011  -- mud       (ground/unimproved) 
00137 //    0000 0100  -- forest    (ground/unimproved)
00138 //    0000 0101  -- grass                (ground)
00139 //    0000 0110  -- Cultivated Fields    (ground)
00140 //    0000 0111  -- Orchards             (ground)
00141 //    0000 1000  -- Rock      (ground/unimproved)               
00142 //    0000 1001  -- Boulder   (ground/unimproved)
00143 //    0000 1010  -- Sand      (ground/unimproved)
00144 //    0000 1011  -- Dirt Road   (ground/improved)
00145 //    0000 1100  -- Gravel Road (ground/improved)
00146 //    0000 1101  -- paved road  (ground/improved)
00147 //    0000 1110  -- asphalt/other hard surface (ground/improved)
00148 //    0000 1111  -- Railroad US (ground/improved)
00149 //    0001 0000  -- RailRoad Euro (ground/improved)
00150 //    0001 0001  -- flimsy (to map from ctdb soil types)
00151 //    0001 0010  -- muddy road (ground/unimproved)
00152 //
00153 // body of water specification
00154 //
00155 //    bits 24-31 are laid out as follows 
00156 //    0000 0001    -- ocean (water surface)
00157 //    0000 0010    -- lake  (water surface)
00158 //    0000 0011    -- river (water surface)
00159 //    0000 0100    -- pond  (water surface)
00160 //    0000 0101    -- stream(water surface)
00161 //    0000 0110    -- brook (water surface)
00162 //
00163 // cultural feature specification
00164 //
00165 //    bits 24-31 are laid out as follows 
00166 //    0000 0001    -- building (above ground)
00167 //    0000 0010    -- tree     (above ground)
00168 
00169 class DT_DLL_geometry DtSurface
00170 {
00171 public:
00172 
00173    // enumeration DtMedium is used to specify where a surface 
00174    // is situated.
00175    typedef enum
00176    {
00177       Ground,
00178       AboveGround,
00179       UnderGround,
00180       WaterSurface,
00181       AboveWater,
00182       UnderWater,
00183       UnspecifiedMedium
00184    } DtMedium;
00185 
00186    typedef unsigned int DtCharacteristics;
00187 
00188 public:
00189 
00190    // default constructor
00191    DtSurface();
00192 
00193    // destructor
00194    virtual ~DtSurface();
00195 
00196    // copy constructor
00197    DtSurface(const DtSurface& orig);
00198 
00199    // assignment operator
00200    DtSurface& operator=(const DtSurface& orig);
00201 
00202    // comparison operators
00203    bool operator==(const DtSurface& orig) const;
00204    bool operator!=(const DtSurface& orig) const;
00205 
00206    // accessor / mutator functions
00207    virtual const DtColor& color() const;
00208    virtual void setColor(const DtColor& c);
00209 
00210    // Set/Get the surface characteristics field.
00211    virtual void setSurfaceCharacteristics(DtCharacteristics surfChar);
00212    virtual DtCharacteristics characteristics() const;
00213 
00214    // \return A string that describes the surface characteristic.
00215    DtString surfaceCharacteristicsString() const;
00216 
00217    // functions to return medium, environmental 
00218    // state, soil type, body of water type, and cultural feature type. 
00219    virtual DtMedium whereSurface() const;
00220    virtual DtEnvState envState() const;
00221    virtual DtSoilType soilType() const;
00222    virtual DtBodyOfWaterType bodyOfWaterType() const;
00223    virtual DtCulturalFeatureType culturalFeatureType() const;
00224 
00225    // functions to return medium, environmental 
00226    // state, soil type, body of water type, and 
00227    // cultural feature type as a string. 
00228    virtual DtString mediumString() const;
00229    virtual DtString envStateString() const;
00230    virtual DtString soilTypeString() const;
00231    virtual DtString bodyOfWaterTypeString() const;
00232    virtual DtString culturalFeatureTypeString() const;
00233 
00234    virtual DtRoughnessSoilType roughnessSoilType() const;
00235    virtual DtString roughnessSoilTypeString() const;
00236 
00237    // Set/Get whether the surface is ground.
00238    virtual void setIsGround(bool onOff); 
00239    virtual bool isGround() const;
00240 
00242 
00243    // Set/Get whether the surface is above ground.
00244    virtual void setAboveGround(bool onOff); 
00245    virtual bool aboveGround() const;
00246 
00247    // Set/Get whether the surface is under ground.
00248    virtual void setUnderGround(bool onOff); 
00249    virtual bool underGround() const;
00250 
00251    // Set/Get whether the surface is water.
00252    virtual void setIsWaterSurface(bool onOff); 
00253    virtual bool isWaterSurface() const;
00254 
00255    // Set/Get whether the surface is above water.
00256    virtual void setAboveWater(bool onOff); 
00257    virtual bool aboveWater() const;
00258 
00259    // Set/Get whether the surface is under water.
00260    virtual void setUnderWater(bool onOff); 
00261    virtual bool underWater() const;
00262 
00264 
00265    // Set/Get whether the surface is dry.
00266    virtual void setIsDry(bool onOff); 
00267    virtual bool isDry() const;
00268 
00269    // Set/Get whether the surface is wet.
00270    virtual void setIsWet(bool onOff); 
00271    virtual bool isWet() const;
00272 
00273    // Set/Get whether the surface is icy.
00274    virtual void setIsIcy(bool onOff); 
00275    virtual bool isIcy() const;
00276    
00277    // Set/Get whether the surface is covered by snow.
00278    virtual void setIsCoveredBySnow(bool onOff); 
00279    virtual bool isCoveredBySnow() const;
00280 
00281    
00282    // Set/Get whether the surface is improved. 
00283    // The medium is required to be Ground.
00284    virtual void setIsImproved(bool onOff); 
00285    virtual bool isImproved() const;
00286    virtual bool isUnimproved() const;
00287 
00288   // Set/Get whether the surface is a body of water
00289   // and is deep.
00290    virtual void setIsDeep(bool onOff); 
00291    virtual bool isDeep() const;
00292    virtual bool isShallow() const;
00293 
00294   // Set/Get whether the surface is a part of a cultural
00295   // feature. The medium is required to be AboveGround.
00296    virtual void setIsCulturalFeature(bool onOff); 
00297    virtual bool isCulturalFeature() const;
00298    
00299    // Accessor/Mutator functions for soil type
00300 
00301    // Set/Get whether the surface is soft soil.
00302    virtual void setIsSoftSoil(bool onOff); 
00303    virtual bool isSoftSoil() const;
00304 
00305    // Set/Get whether the surface is swamp.
00306    virtual void setIsSwamp(bool onOff); 
00307    virtual bool isSwamp() const;
00308 
00309    // Set/Get whether the surface is mud.
00310    virtual void setIsMud(bool onOff); 
00311    virtual bool isMud() const;
00312 
00313    // Set/Get whether the surface is forest.
00314    virtual void setIsForest(bool onOff); 
00315    virtual bool isForest() const;
00316 
00317    // Set/Get whether the surface is grass.
00318    virtual void setIsGrass(bool onOff); 
00319    virtual bool isGrass() const; 
00320 
00321    // Set/Get whether the surface is grass.
00322    virtual void setIsCultivatedField(bool onOff); 
00323    virtual bool isCultivatedField() const; 
00324 
00325    // Set/Get whether the surface is grass.
00326    virtual void setIsOrchard(bool onOff); 
00327    virtual bool isOrchard() const; 
00328 
00329    // Set/Get whether the surface is rock.
00330    virtual void setIsRock(bool onOff); 
00331    virtual bool isRock() const;
00332 
00333    // Set/Get whether the surface is boulder.
00334    virtual void setIsBoulder(bool onOff); 
00335    virtual bool isBoulder() const;
00336 
00337    // Set/Get whether the surface is sand.
00338    virtual void setIsSand(bool onOff); 
00339    virtual bool isSand() const;
00340 
00341    // Set/Get whether the surface is dirt road.
00342    virtual void setIsDirtRoad(bool onOff); 
00343    virtual bool isDirtRoad() const;
00344 
00345    // Set/Get whether the surface is gravel road.
00346    virtual void setIsGravelRoad(bool onOff); 
00347    virtual bool isGravelRoad() const;
00348 
00349    // Set/Get whether the surface is paved road.
00350    virtual void setIsPavedRoad(bool onOff); 
00351    virtual bool isPavedRoad() const;
00352 
00353   // Set/Get whether the surface is Muddy road.
00354    virtual void setIsMuddyRoad(bool onOff); 
00355    virtual bool isMuddyRoad() const;
00356 
00357    // Set/Get whether the surface is asphalt or other hard
00358    // surface.
00359    virtual void setIsHardSurface(bool onOff); 
00360    virtual bool isHardSurface() const;
00361 
00362    // Set/Get whether the surface is US rail road.
00363    virtual void setIsUSRailRoad(bool onOff); 
00364    virtual bool isUSRailRoad() const;
00365 
00366    // Set/Get whether the surface is Euro rail road.
00367    virtual void setIsEuroRailRoad(bool onOff); 
00368    virtual bool isEuroRailRoad() const;
00369 
00370    // Set/Get whether the surface is flimsy.
00371    virtual void setIsFlimsy(bool onOff); 
00372    virtual bool isFlimsy() const;
00373 
00374   // Set/Get whether the soiltype is undefined.
00375    virtual void setIsUndefinedSoilType(bool onOff);
00376    virtual bool isUndefinedSoilType() const;
00377 
00378    // \deprecated Use standard version above.
00379    // \see setIsUndefinedSoilType
00380    // \see undefinedSoilType
00381    virtual void setUndefinedSoilType(bool onOff);
00382    virtual bool undefinedSoilType() const;
00383 
00384    // Accessor/Mutator functions for body of water type.
00385  
00387    // Set/Get whether the surface is ocean.
00388    virtual void setIsOcean(bool onOff); 
00389    virtual bool isOcean() const;
00390 
00391    // Set/Get whether the surface is lake.
00392    virtual void setIsLake(bool onOff); 
00393    virtual bool isLake() const;
00394 
00395    // Set/Get whether the surface is river.
00396    virtual void setIsRiver(bool onOff); 
00397    virtual bool isRiver() const;
00398 
00399    // Set/Get whether the surface is pond.
00400    virtual void setIsPond(bool onOff); 
00401    virtual bool isPond() const;
00402 
00403    // Set/Get whether the surface is stream.
00404    virtual void setIsStream(bool onOff); 
00405    virtual bool isStream() const;
00406 
00407    // Set/Get whether the surface is brook.
00408    virtual void setIsBrook(bool onOff); 
00409    virtual bool isBrook() const;
00410 
00411    // Set/Get whether the surface is part of a tree.
00412    virtual void setIsTree(bool onOff); 
00413    virtual bool isTree() const;
00414 
00415    // Set/Get whether the surface is part of a Building.
00416    virtual void setIsBuilding(bool onOff); 
00417    virtual bool isBuilding() const;
00419 
00420 
00421    // Set characteristics based on an exact match with a string.
00422    virtual bool characteristicsFromString(std::string characteristicsString, bool warn = true);
00423 
00424    // Set characteristics based on any match with a substring of the specified 
00425    // characteristics string.  
00426    // \note This may cause the incorrect surface characteristics to be set, if 
00427    // the specified string contains more than one of the substrings searched for.
00428    virtual bool characteristicsFromSubString(std::string characteristicsString, bool warn = true);
00429 
00430    // debugging aid
00431    virtual void dump() const;
00432 
00433    // \return The maximum color of the surface
00434    virtual void maxColor(DtColor& theColor);
00435 
00436    // \return The default color associated with the surface type
00437    DtColor colorForSurfaceType() const;
00438 
00439    // input/output functions
00440    virtual bool readFrom(FILE* fp);
00441   // virtual bool readFromOldFormat(FILE* fp, DtTerrainDatabase* ptdb);
00442    virtual bool writeTo(FILE* fp);
00443 
00444    static DtString soilTypeToString(DtRoughnessSoilType type);
00445    static DtRoughnessSoilType stringToSoilType(const DtString& string);
00446 
00447 public:
00448 
00449    static DtSurface& nullSurface();
00450 
00451    static void setSurfaceToRoughnessMapper(DtMapSurfaceToRoughness&
00452       surfaceToRoughnessMapper);
00453 
00454 public:
00455 
00456    static const DtColor theSoftSoilColor;
00457    static const DtColor theSwampColor;
00458    static const DtColor theMudColor;
00459    static const DtColor theForestColor;
00460    static const DtColor theGrassColor;
00461    static const DtColor theCultivatedFieldColor;
00462    static const DtColor theOrchardColor;
00463    static const DtColor theRockColor;
00464    static const DtColor theBoulderColor;
00465    static const DtColor theSandColor;
00466    static const DtColor theDirtRoadColor;
00467    static const DtColor theGravelRoadColor;
00468    static const DtColor thePavedRoadColor;
00469    static const DtColor theMuddyRoadColor;
00470    static const DtColor theHardSurfaceColor;
00471    static const DtColor theRailRoadColor;
00472    static const DtColor theFlimsySoilColor;
00473    static const DtColor theOceanColor;
00474    static const DtColor theLakeColor;
00475    static const DtColor theRiverColor;
00476    static const DtColor thePondColor;
00477 
00478    static const DtColor theIceColor;
00479    static const DtColor theTreeColor;
00480    static const DtColor theBuildingColor;
00481 
00482    //Dted colors
00483    static const DtColor theDtedGroundCellColor;
00484    static const DtColor theDtedWaterCellColor;
00485 
00486    static const char DtSoilPavedRoad[];
00487    static const char DtSoilHardPacked[];
00488    static const char DtSoilRocks[];
00489    static const char DtSoilSand[];
00490    static const char DtSoilGravel[];
00491    static const char DtSoilShallowWater[];
00492    static const char DtSoilMuck[];
00493    static const char DtSoilDeepWater[];
00494 
00495 protected:
00496 
00497    static const DtCharacteristics theSoftSoilBitMask;
00498    static const DtCharacteristics theSoftSoilComparator;
00499 
00500    static const DtCharacteristics theSwampBitMask;
00501    static const DtCharacteristics theSwampComparator;
00502 
00503    static const DtCharacteristics theMudBitMask;
00504    static const DtCharacteristics theMudComparator;
00505 
00506    static const DtCharacteristics theForestBitMask;
00507    static const DtCharacteristics theForestComparator;
00508 
00509    static const DtCharacteristics theGrassBitMask;
00510    static const DtCharacteristics theGrassComparator;
00511 
00512    static const DtCharacteristics theCultivatedFieldBitMask;
00513    static const DtCharacteristics theCultivatedFieldComparator;
00514 
00515    static const DtCharacteristics theOrchardBitMask;
00516    static const DtCharacteristics theOrchardComparator;
00517 
00518    static const DtCharacteristics theRockBitMask;
00519    static const DtCharacteristics theRockComparator;
00520 
00521    static const DtCharacteristics theBoulderBitMask;
00522    static const DtCharacteristics theBoulderComparator;
00523 
00524    static const DtCharacteristics theSandBitMask;
00525    static const DtCharacteristics theSandComparator;
00526 
00527    static const DtCharacteristics theDirtRoadBitMask;
00528    static const DtCharacteristics theDirtRoadComparator;
00529 
00530    static const DtCharacteristics theGravelRoadBitMask;
00531    static const DtCharacteristics theGravelRoadComparator;
00532 
00533    static const DtCharacteristics thePavedRoadBitMask;
00534    static const DtCharacteristics thePavedRoadComparator;
00535  
00536    static const DtCharacteristics theMuddyRoadBitMask;
00537    static const DtCharacteristics theMuddyRoadComparator;
00538 
00539    static const DtCharacteristics theHardSurfaceBitMask;
00540    static const DtCharacteristics theHardSurfaceComparator;
00541 
00542    static const DtCharacteristics theUSRailRoadBitMask;
00543    static const DtCharacteristics theUSRailRoadComparator;
00544 
00545    static const DtCharacteristics theEuroRailRoadBitMask;
00546    static const DtCharacteristics theEuroRailRoadComparator;
00547 
00548    static const DtCharacteristics theFlimsySoilBitMask;
00549    static const DtCharacteristics theFlimsySoilComparator;
00550 
00551    static const DtCharacteristics theOceanBitMask;
00552    static const DtCharacteristics theOceanComparator;
00553 
00554    static const DtCharacteristics theLakeBitMask;
00555    static const DtCharacteristics theLakeComparator;
00556 
00557    static const DtCharacteristics theRiverBitMask;
00558    static const DtCharacteristics theRiverComparator;
00559 
00560    static const DtCharacteristics thePondBitMask;
00561    static const DtCharacteristics thePondComparator;
00562 
00563    static const DtCharacteristics theStreamBitMask;
00564    static const DtCharacteristics theStreamComparator;
00565  
00566    static const DtCharacteristics theBrookBitMask;
00567    static const DtCharacteristics theBrookComparator;
00568 
00569    static const DtCharacteristics theDeepWaterBitMask;
00570    static const DtCharacteristics theDeepWaterComparator;
00571 
00572    static const DtCharacteristics theBuildingBitMask;
00573    static const DtCharacteristics theBuildingComparator;
00574 
00575    static const DtCharacteristics theTreeBitMask;
00576    static const DtCharacteristics theTreeComparator;
00577 
00578 protected:
00579    // Custom function to lower the case of a string.  Necessary since the tolower
00580    // function (from locale) needs to have a locale specified.  Defaults to using 
00581    // the classic C locale, which is for ASCII.
00582    std::string customToLower(const std::string& stringToConvert, const std::locale loc = std::locale::classic()) const;
00583 
00584    // Removes any white spaces on the right side of the string
00585    std::string trimString(const std::string& strToTrim);
00586 
00587    virtual void setRoughnessSoilType();
00588 
00589    DtCharacteristics myCharacteristics;
00590    DtColor                  myColor;
00591    DtRoughnessSoilType      myRoughness;
00592    static DtMapSurfaceToRoughness* theMapSurfaceToRoughness;   
00593 };
00594 
00595 inline const DtColor& DtSurface::color() const
00596 {
00597    return myColor;
00598 }
00599 
00600 inline void DtSurface::setColor(const DtColor& c)
00601 {
00602    myColor = c;
00603 }
00604 
00605 inline DtSurface::DtCharacteristics DtSurface::characteristics() const
00606 {
00607    return myCharacteristics;
00608 }
00609 
00610 inline void DtSurface::setSurfaceCharacteristics(DtSurface::DtCharacteristics surfChar)
00611 {
00612    myCharacteristics = surfChar;
00613    setRoughnessSoilType();
00614 }
00615 
00616 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)