VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtDynamicTerrainRasterLibrary.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
11 #include <vrvOsg/vrvOsg.h>
12 
14 
15 #include <matrix/vlVector.h>
16 
17 #include<osg/ref_ptr>
18 
19 #include <tbb/spin_rw_mutex.h>
20 #include <string>
21 #include <map>
22 
23 // Forward declarations
24 namespace osg
25 {
26  class Image;
27 }
28 
29 namespace osgEarth
30 {
31  class LandCoverDictionary;
32  class GeoExtent;
33  class SpatialReference;
34 }
35 
36 namespace makVrv
37 {
38  typedef enum
39  {
44 
45  class DtDe;
46  class DtVrfSoilTypeToOsgEarthLandCoverMap;
47 
94 
96  : public DtVirtualBaseClass
97  {
98  protected:
99 
103 
107 
108  public:
109  // Type string
110  static const std::string DEFORMATION_CRATER;
111  static const std::string DEFORMATION_SCRAPE;
112 
115 
120  virtual void init();
121 
133  virtual osg::ref_ptr <osg::Image> getLandCoverRaster(
134  osgEarth::LandCoverDictionary* landCoverDictionary, double& scaleFactorX, double& scaleFactorY,
135  const std::string& deformationType, const std::string& craterType, int soilType, double heading = 0.0);
136 
145  virtual osg::ref_ptr <osg::Image> getElevationRaster(double& scaleFactorX,
146  double & scaleFactorY, const std::string& deformationType, const std::string& craterType, double heading = 0.0);
147 
158  virtual osg::ref_ptr <osg::Image> getElevationOtwImage(double& scaleFactorX,
159  double & scaleFactorY, const std::string& deformationType, const std::string& craterType, int soilType, double heading = 0.0);
160 
171  virtual osg::ref_ptr <osg::Image> getLandCoverOtwImage(double& scaleFactorX, double & scaleFactorY,
172  const std::string& deformationType, const std::string& craterType, int soilType, double heading = 0.0);
173 
184  virtual osg::ref_ptr <osg::Image> getElevationAndLandCoverOtwImage(double& scaleFactorX,
185  double& scaleFactorY, const std::string& deformationType, const std::string& craterType, int soilType, double heading = 0.0);
186 
196  osgEarth::GeoExtent calculateNewExtent(const DtVector& centerPoint,
197  osg::ref_ptr<const osgEarth::SpatialReference> srs, double minorAxis, double majorAxis,
198  double heading, double scaleFactorX, double scaleFactorY);
199 
200  public:
202  static std::string defaultCraterType();
204  static std::string defaultCraterImageFilename();
205  static std::string defaultCraterElevationFilename();
206  static std::string craterTypeToElevationMapFilename();
207  static std::string craterTypeToLandCoverMapFilename();
208  static std::string elevationOtwMapFilename();
209  static std::string landCoverOtwMapFilename();
210  static std::string elevationAndLandCoverOtwMapFilename();
212 
219  virtual osg::ref_ptr <osg::Image> createLandCoverFromSdfElevationImage(
220  osgEarth::LandCoverDictionary* landCoverDictionary, osg::ref_ptr <osg::Image> img,
221  const std::string& landCover) const;
222 
223  protected:
224 
225  typedef std::map<std::string, osg::ref_ptr <osg::Image> > StrToImgMap;
226  typedef std::map<std::string, std::string> StrToStrMap;
227 
228  // The key is the crater type. The StrToStrMap maps
229  // soil type names to filenames
230  typedef std::map<std::string, StrToStrMap> OtwImageMap;
231 
239  virtual osg::ref_ptr<osg::Image> rotateImage(double & scaleFactorX, double & scaleFactorY,
240  const osg::ref_ptr<osg::Image> & templateImg, double heading, RasterImageType imgType = RasterElevation);
241 
247  virtual osg::ref_ptr<osg::Image> allocateImageAndInitialize(int s, int t, RasterImageType imgType);
248 
256  virtual osg::ref_ptr <osg::Image> loadRasterToCache(StrToImgMap& rasterCache,
257  const std::string& deformationType, const std::string& craterType, const StrToStrMap& keyToFilenameMap);
258 
267  virtual osg::ref_ptr <osg::Image> loadOtwImageToCache(StrToImgMap& imageCache,
268  const std::string& deformationType, const std::string& craterType, const std::string& soilTypeName,
269  const OtwImageMap& keysToFilenameMap);
270 
275  virtual osg::ref_ptr <osg::Image> createLandCoverFromImage(
276  osgEarth::LandCoverDictionary* landCoverDictionary, osg::ref_ptr <osg::Image> img,
277  const std::string& landCover, bool terrainDeformation=false) const;
278 
282  virtual osg::ref_ptr <osg::Image> getOtwImage(StrToImgMap& imgCache,
283  const OtwImageMap& keysToFilenameMap, double& scaleFactorX, double & scaleFactorY,
284  const std::string& deformationType, const std::string& craterType, int soilType, double heading);
285 
292  virtual std::string lookupRasterFileAndResolvePath(const std::string& deformationType,
293  const std::string& craterType, const StrToStrMap& keyToFilenameMap) const;
294 
302  virtual std::string lookupOtwImageFileAndResolvePath(const std::string& deformationType,
303  const std::string& craterType, const std::string& soilTypeName, const OtwImageMap& keysToFilenameMap) const;
304 
310  virtual bool populateRasterMap(const std::string& deformationType, StrToStrMap & mapToPopulate, const std::string& rasterFilename);
311 
317  virtual bool populateImageMap(const std::string& deformationType, OtwImageMap& mapToPopulate, const std::string& imageMapFilename);
318 
324  virtual std::string otwImageCacheKey(const std::string& deformationType,
325  const std::string& craterType, const std::string& soilTypeName) const;
326 
327  private:
328 
331 
334 
337 
338  protected:
339 
340  static const std::string theDefaultCraterType;
341  static const std::string theDefaultCraterImageFilename;
342  static const std::string theDefaultCraterElevationFilename;
343  // Craters
344  static const std::string theCraterTypeToElevationMapFilename;
345  static const std::string theCraterTypeToLandCoverMapFilename;
346  static const std::string theElevationOtwMapFilename;
347  static const std::string theLandCoverOtwMapFilename;
348  static const std::string theElevationAndLandCoverOtwMapFilename;
349  // Scrapes
350  static const std::string theScrapeTypeToElevationMapFilename;
351  static const std::string theScrapeTypeToLandCoverMapFilename;
352  static const std::string theScrapeElevationOtwMapFilename;
353  static const std::string theScrapeLandCoverOtwMapFilename;
355  protected:
356 
358 
359  tbb::spin_rw_mutex myLandCoverCacheMutex;
360  tbb::spin_rw_mutex myElevationRasterCacheMutex;
361  tbb::spin_rw_mutex myOtwImageCacheMutex;
362  tbb::spin_rw_mutex myInitMutex;
363 
364  // Used to cache ref_ptrs to images that were created for specific types of land cover codes
365  // key is crater type + land cover code
367 
368  // Used to cache ref_ptrs to images for land cover that have not been modified for
369  // a specific land cover code.
371 
372  // Cache for ref_ptrs to images for elevation rasters
374 
375  // Cache for ref_ptrs to OTW images used with the elevation effect type
377 
378  // Cache for ref_ptrs to OTW images used with the soil type effect type
380 
381  // Cache for ref_ptrs to OTW images used with the elevation and soil type effect type
383 
384  // Map Deformation (crater, tank scrap) type to raster filenames for use with osgEarth decal elevation layer
386 
387  // Map Deformation (crater, tank scrap) type to raster filenames for use with osgEarth decal land cover layer
389 
390  // Map Deformation (crater, tank scrap) type and soil type to visual images for osgEarth decal image layer
391  // when effect type is DtTerrainCraterElevationEffect
393 
394  // Map Deformation (crater, tank scrap) type and soil type to visual images for osgEarth decal image layer
395  // when effect type is DtTerrainCraterSoilEffect
397 
398  // Map Deformation (crater, tank scrap) type and soil type to visual images for osgEarth decal image layer
399  // when effect type is DtTerrainCraterElevAndSoilEffect
401 
403 
404  // External soil type to osgEarth land cover name mapper
406  };
407 
408 
412  : public DtVirtualBaseClass
413  {
414  public:
415 
418 
421 
424  static DtDynamicTerrainRasterLibraryCreator& instance(DtDe& de);
425 
427  static void registerInstance(DtDe& de, DtDynamicTerrainRasterLibraryCreator* creatorInstance);
428 
431  virtual DtDynamicTerrainRasterLibrary* create(DtDe& de);
432  };
433 
434 }
StrToImgMap myElevationAndLandCoverOtwImageCache
Definition: DtDynamicTerrainRasterLibrary.h:382
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
static const std::string DEFORMATION_SCRAPE
Definition: DtDynamicTerrainRasterLibrary.h:111
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
static const std::string theScrapeElevationOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:352
static const std::string theDefaultCraterElevationFilename
Definition: DtDynamicTerrainRasterLibrary.h:342
std::map< std::string, std::string > StrToStrMap
Definition: DtDynamicTerrainRasterLibrary.h:226
OtwImageMap myDeformationTypeAndSoilTypeToOtwFilenameForElevationMap
Definition: DtDynamicTerrainRasterLibrary.h:392
Definition: DtDynamicTerrainRasterLibrary.h:41
static const std::string theElevationOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:346
bool myIsInitialized
Definition: DtDynamicTerrainRasterLibrary.h:357
DtDynamicTerrainRasterLibrary This class is used to managed rasters and out-the-window images appl...
Definition: DtDynamicTerrainRasterLibrary.h:95
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
tbb::spin_rw_mutex myInitMutex
Definition: DtDynamicTerrainRasterLibrary.h:362
static const std::string theCraterTypeToLandCoverMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:345
DtDe & myDe
Definition: DtDynamicTerrainRasterLibrary.h:402
static const std::string theDefaultCraterType
Definition: DtDynamicTerrainRasterLibrary.h:340
tbb::spin_rw_mutex myLandCoverCacheMutex
Definition: DtDynamicTerrainRasterLibrary.h:359
static const std::string theScrapeLandCoverOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:353
DtVrfSoilTypeToOsgEarthLandCoverMap * mySoilTypeToLandCoverMap
Definition: DtDynamicTerrainRasterLibrary.h:405
static const std::string theScrapeTypeToElevationMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:350
StrToImgMap myLandCoverOtwImageCache
Definition: DtDynamicTerrainRasterLibrary.h:379
RasterImageType
Definition: DtDynamicTerrainRasterLibrary.h:38
StrToImgMap myLandCoverElevationRasterCache
Definition: DtDynamicTerrainRasterLibrary.h:370
Definition: DtDynamicTerrainRasterLibrary.h:40
static const std::string theDefaultCraterImageFilename
Definition: DtDynamicTerrainRasterLibrary.h:341
StrToImgMap myLandCoverImageCache
Definition: DtDynamicTerrainRasterLibrary.h:366
std::map< std::string, StrToStrMap > OtwImageMap
Definition: DtDynamicTerrainRasterLibrary.h:230
Used to map VR-Forces soil types to OSG Earth Landcover names.
Definition: DtVrfSoilTypeToOsgEarthLandCoverMap.h:23
Contains makVrv::DtVirtualBaseClass class.
StrToImgMap myElevationRasterCache
Definition: DtDynamicTerrainRasterLibrary.h:373
Creator for the DtDynamicTerrainRasterLibrary.
Definition: DtDynamicTerrainRasterLibrary.h:411
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &uv0=ImVec2(0, 0), const ImVec2 &uv1=ImVec2(1, 1), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1), const ImVec4 &border_col=ImVec4(0, 0, 0, 0))
StrToStrMap myDeformationTypeToElevationFilenameMap
Definition: DtDynamicTerrainRasterLibrary.h:385
std::map< std::string, osg::ref_ptr< osg::Image > > StrToImgMap
Definition: DtDynamicTerrainRasterLibrary.h:225
tbb::spin_rw_mutex myOtwImageCacheMutex
Definition: DtDynamicTerrainRasterLibrary.h:361
OtwImageMap myDeformationTypeAndSoilTypeToOtwFilenameForLandCoverMap
Definition: DtDynamicTerrainRasterLibrary.h:396
static const std::string theLandCoverOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:347
static const std::string DEFORMATION_CRATER
Definition: DtDynamicTerrainRasterLibrary.h:110
static const std::string theElevationAndLandCoverOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:348
StrToImgMap myElevationOtwImageCache
Definition: DtDynamicTerrainRasterLibrary.h:376
OtwImageMap myDeformationTypeAndSoilTypeToOtwFilenameForElevationAndLandCoverMap
Definition: DtDynamicTerrainRasterLibrary.h:400
static const std::string theCraterTypeToElevationMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:344
Contains DLL export macros.
tbb::spin_rw_mutex myElevationRasterCacheMutex
Definition: DtDynamicTerrainRasterLibrary.h:360
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:72
static const std::string theScrapeTypeToLandCoverMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:351
StrToStrMap myDeformationTypeToLandCoverFilenameMap
Definition: DtDynamicTerrainRasterLibrary.h:388
Definition: DtDynamicTerrainRasterLibrary.h:42
static const std::string theScrapeElevationAndLandCoverOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:354

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)