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 
220  virtual osg::ref_ptr <osg::Image> createLandCoverFromSdfElevationImage(
221  osgEarth::LandCoverDictionary* landCoverDictionary, osg::ref_ptr <osg::Image> img,
222  const std::string& landCover) const;
223 
224  protected:
225 
226  typedef std::map<std::string, osg::ref_ptr <osg::Image> > StrToImgMap;
227  typedef std::map<std::string, std::string> StrToStrMap;
228 
229  // The key is the crater type. The StrToStrMap maps
230  // soil type names to filenames
231  typedef std::map<std::string, StrToStrMap> OtwImageMap;
232 
240  virtual osg::ref_ptr<osg::Image> rotateImage(double & scaleFactorX, double & scaleFactorY,
241  const osg::ref_ptr<osg::Image> & templateImg, double heading, RasterImageType imgType = RasterElevation);
242 
248  virtual osg::ref_ptr<osg::Image> allocateImageAndInitialize(int s, int t, RasterImageType imgType);
249 
257  virtual osg::ref_ptr <osg::Image> loadRasterToCache(StrToImgMap& rasterCache,
258  const std::string& deformationType, const std::string& craterType, const StrToStrMap& keyToFilenameMap);
259 
268  virtual osg::ref_ptr <osg::Image> loadOtwImageToCache(StrToImgMap& imageCache,
269  const std::string& deformationType, const std::string& craterType, const std::string& soilTypeName,
270  const OtwImageMap& keysToFilenameMap);
271 
278  virtual osg::ref_ptr <osg::Image> createLandCoverFromImage(
279  osgEarth::LandCoverDictionary* landCoverDictionary, osg::ref_ptr <osg::Image> img,
280  const std::string& landCover, bool terrainDeformation=false) const;
281 
285  virtual osg::ref_ptr <osg::Image> getOtwImage(StrToImgMap& imgCache,
286  const OtwImageMap& keysToFilenameMap, double& scaleFactorX, double & scaleFactorY,
287  const std::string& deformationType, const std::string& craterType, int soilType, double heading);
288 
295  virtual std::string lookupRasterFileAndResolvePath(const std::string& deformationType,
296  const std::string& craterType, const StrToStrMap& keyToFilenameMap) const;
297 
305  virtual std::string lookupOtwImageFileAndResolvePath(const std::string& deformationType,
306  const std::string& craterType, const std::string& soilTypeName, const OtwImageMap& keysToFilenameMap) const;
307 
313  virtual bool populateRasterMap(const std::string& deformationType, StrToStrMap & mapToPopulate, const std::string& rasterFilename);
314 
320  virtual bool populateImageMap(const std::string& deformationType, OtwImageMap& mapToPopulate, const std::string& imageMapFilename);
321 
327  virtual std::string otwImageCacheKey(const std::string& deformationType,
328  const std::string& craterType, const std::string& soilTypeName) const;
329 
330  private:
331 
334 
337 
340 
341  protected:
342 
343  static const std::string theDefaultCraterType;
344  static const std::string theDefaultCraterImageFilename;
345  static const std::string theDefaultCraterElevationFilename;
346  // Craters
347  static const std::string theCraterTypeToElevationMapFilename;
348  static const std::string theCraterTypeToLandCoverMapFilename;
349  static const std::string theElevationOtwMapFilename;
350  static const std::string theLandCoverOtwMapFilename;
351  static const std::string theElevationAndLandCoverOtwMapFilename;
352  // Scrapes
353  static const std::string theScrapeTypeToElevationMapFilename;
354  static const std::string theScrapeTypeToLandCoverMapFilename;
355  static const std::string theScrapeElevationOtwMapFilename;
356  static const std::string theScrapeLandCoverOtwMapFilename;
358  protected:
359 
361 
362  tbb::spin_rw_mutex myLandCoverCacheMutex;
363  tbb::spin_rw_mutex myElevationRasterCacheMutex;
364  tbb::spin_rw_mutex myOtwImageCacheMutex;
365  tbb::spin_rw_mutex myInitMutex;
366 
367  // Used to cache ref_ptrs to images that were created for specific types of land cover codes
368  // key is crater type + land cover code
370 
371  // Used to cache ref_ptrs to images for land cover that have not been modified for
372  // a specific land cover code.
374 
375  // Cache for ref_ptrs to images for elevation rasters
377 
378  // Cache for ref_ptrs to OTW images used with the elevation effect type
380 
381  // Cache for ref_ptrs to OTW images used with the soil type effect type
383 
384  // Cache for ref_ptrs to OTW images used with the elevation and soil type effect type
386 
387  // Map Deformation (crater, tank scrap) type to raster filenames for use with osgEarth decal elevation layer
389 
390  // Map Deformation (crater, tank scrap) type to raster filenames for use with osgEarth decal land cover layer
392 
393  // Map Deformation (crater, tank scrap) type and soil type to visual images for osgEarth decal image layer
394  // when effect type is DtTerrainCraterElevationEffect
396 
397  // Map Deformation (crater, tank scrap) type and soil type to visual images for osgEarth decal image layer
398  // when effect type is DtTerrainCraterSoilEffect
400 
401  // Map Deformation (crater, tank scrap) type and soil type to visual images for osgEarth decal image layer
402  // when effect type is DtTerrainCraterElevAndSoilEffect
404 
406 
407  // External soil type to osgEarth land cover name mapper
409  };
410 
411 
415  : public DtVirtualBaseClass
416  {
417  public:
418 
421 
424 
427  static DtDynamicTerrainRasterLibraryCreator& instance(DtDe& de);
428 
430  static void registerInstance(DtDe& de, DtDynamicTerrainRasterLibraryCreator* creatorInstance);
431 
434  virtual DtDynamicTerrainRasterLibrary* create(DtDe& de);
435  };
436 
437 }
StrToImgMap myElevationAndLandCoverOtwImageCache
Definition: DtDynamicTerrainRasterLibrary.h:385
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:355
static const std::string theDefaultCraterElevationFilename
Definition: DtDynamicTerrainRasterLibrary.h:345
std::map< std::string, std::string > StrToStrMap
Definition: DtDynamicTerrainRasterLibrary.h:227
OtwImageMap myDeformationTypeAndSoilTypeToOtwFilenameForElevationMap
Definition: DtDynamicTerrainRasterLibrary.h:395
Definition: DtDynamicTerrainRasterLibrary.h:41
static const std::string theElevationOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:349
bool myIsInitialized
Definition: DtDynamicTerrainRasterLibrary.h:360
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:365
static const std::string theCraterTypeToLandCoverMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:348
DtDe & myDe
Definition: DtDynamicTerrainRasterLibrary.h:405
static const std::string theDefaultCraterType
Definition: DtDynamicTerrainRasterLibrary.h:343
tbb::spin_rw_mutex myLandCoverCacheMutex
Definition: DtDynamicTerrainRasterLibrary.h:362
static const std::string theScrapeLandCoverOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:356
DtVrfSoilTypeToOsgEarthLandCoverMap * mySoilTypeToLandCoverMap
Definition: DtDynamicTerrainRasterLibrary.h:408
static const std::string theScrapeTypeToElevationMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:353
StrToImgMap myLandCoverOtwImageCache
Definition: DtDynamicTerrainRasterLibrary.h:382
RasterImageType
Definition: DtDynamicTerrainRasterLibrary.h:38
StrToImgMap myLandCoverElevationRasterCache
Definition: DtDynamicTerrainRasterLibrary.h:373
Definition: DtDynamicTerrainRasterLibrary.h:40
static const std::string theDefaultCraterImageFilename
Definition: DtDynamicTerrainRasterLibrary.h:344
StrToImgMap myLandCoverImageCache
Definition: DtDynamicTerrainRasterLibrary.h:369
std::map< std::string, StrToStrMap > OtwImageMap
Definition: DtDynamicTerrainRasterLibrary.h:231
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:376
Creator for the DtDynamicTerrainRasterLibrary.
Definition: DtDynamicTerrainRasterLibrary.h:414
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:388
std::map< std::string, osg::ref_ptr< osg::Image > > StrToImgMap
Definition: DtDynamicTerrainRasterLibrary.h:226
tbb::spin_rw_mutex myOtwImageCacheMutex
Definition: DtDynamicTerrainRasterLibrary.h:364
OtwImageMap myDeformationTypeAndSoilTypeToOtwFilenameForLandCoverMap
Definition: DtDynamicTerrainRasterLibrary.h:399
static const std::string theLandCoverOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:350
static const std::string DEFORMATION_CRATER
Definition: DtDynamicTerrainRasterLibrary.h:110
static const std::string theElevationAndLandCoverOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:351
StrToImgMap myElevationOtwImageCache
Definition: DtDynamicTerrainRasterLibrary.h:379
OtwImageMap myDeformationTypeAndSoilTypeToOtwFilenameForElevationAndLandCoverMap
Definition: DtDynamicTerrainRasterLibrary.h:403
static const std::string theCraterTypeToElevationMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:347
Contains DLL export macros.
tbb::spin_rw_mutex myElevationRasterCacheMutex
Definition: DtDynamicTerrainRasterLibrary.h:363
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:76
static const std::string theScrapeTypeToLandCoverMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:354
StrToStrMap myDeformationTypeToLandCoverFilenameMap
Definition: DtDynamicTerrainRasterLibrary.h:391
Definition: DtDynamicTerrainRasterLibrary.h:42
static const std::string theScrapeElevationAndLandCoverOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:357

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)