VR-Forces 5.0.3 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) 2020 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 
112 
117  virtual void init();
118 
129  virtual osg::ref_ptr <osg::Image> getLandCoverRaster(
130  osgEarth::LandCoverDictionary* landCoverDictionary, double& scaleFactorX, double& scaleFactorY,
131  const std::string& craterType, int soilType, double heading = 0.0);
132 
140  virtual osg::ref_ptr <osg::Image> getElevationRaster(double& scaleFactorX,
141  double & scaleFactorY, const std::string& craterType, double heading = 0.0);
142 
152  virtual osg::ref_ptr <osg::Image> getElevationOtwImage(double& scaleFactorX,
153  double & scaleFactorY, const std::string& craterType, int soilType, double heading = 0.0);
154 
164  virtual osg::ref_ptr <osg::Image> getLandCoverOtwImage(double& scaleFactorX, double & scaleFactorY,
165  const std::string& craterType, int soilType, double heading = 0.0);
166 
176  virtual osg::ref_ptr <osg::Image> getElevationAndLandCoverOtwImage(double& scaleFactorX,
177  double& scaleFactorY, const std::string& craterType, int soilType, double heading = 0.0);
178 
188  osgEarth::GeoExtent calculateNewExtent(const DtVector& centerPoint,
189  osg::ref_ptr<const osgEarth::SpatialReference> srs, double minorAxis, double majorAxis,
190  double heading, double scaleFactorX, double scaleFactorY);
191 
192  public:
194  static std::string defaultCraterType();
196  static std::string defaultCraterImageFilename();
197  static std::string defaultCraterElevationFilename();
198  static std::string craterTypeToElevationMapFilename();
199  static std::string craterTypeToLandCoverMapFilename();
200  static std::string elevationOtwMapFilename();
201  static std::string landCoverOtwMapFilename();
202  static std::string elevationAndLandCoverOtwMapFilename();
204 
205  protected:
206 
207  typedef std::map<std::string, osg::ref_ptr <osg::Image> > StrToImgMap;
208  typedef std::map<std::string, std::string> StrToStrMap;
209 
210  // The key is the crater type. The StrToStrMap maps
211  // soil type names to filenames
212  typedef std::map<std::string, StrToStrMap> OtwImageMap;
213 
221  virtual osg::ref_ptr<osg::Image> rotateImage(double & scaleFactorX, double & scaleFactorY,
222  const osg::ref_ptr<osg::Image> & templateImg, double heading, RasterImageType imgType = RasterElevation);
223 
229  virtual osg::ref_ptr<osg::Image> allocateImageAndInitialize(int s, int t, RasterImageType imgType);
230 
237  virtual osg::ref_ptr <osg::Image> loadRasterToCache(StrToImgMap& rasterCache,
238  const std::string& craterType, const StrToStrMap& keyToFilenameMap);
239 
247  virtual osg::ref_ptr <osg::Image> loadOtwImageToCache(StrToImgMap& imageCache,
248  const std::string& craterType, const std::string& soilTypeName,
249  const OtwImageMap& keysToFilenameMap);
250 
255  virtual osg::ref_ptr <osg::Image> createLandCoverFromImage(
256  osgEarth::LandCoverDictionary* landCoverDictionary, osg::ref_ptr <osg::Image> img,
257  const std::string& landCover) const;
258 
262  virtual osg::ref_ptr <osg::Image> getOtwImage(StrToImgMap& imgCache,
263  const OtwImageMap& keysToFilenameMap, double& scaleFactorX, double & scaleFactorY,
264  const std::string& craterType, int soilType, double heading);
265 
271  virtual std::string lookupRasterFileAndResolvePath(const std::string& craterType,
272  const StrToStrMap& keyToFilenameMap) const;
273 
280  virtual std::string lookupOtwImageFileAndResolvePath(const std::string& craterType,
281  const std::string& soilTypeName, const OtwImageMap& keysToFilenameMap) const;
282 
287  virtual bool populateRasterMap(StrToStrMap & mapToPopulate, const std::string& rasterFilename);
288 
293  virtual bool populateImageMap(OtwImageMap& mapToPopulate, const std::string& imageMapFilename);
294 
299  virtual std::string otwImageCacheKey(const std::string& craterType,
300  const std::string& soilTypeName) const;
301 
302  private:
303 
306 
309 
312 
313  protected:
314 
315  static const std::string theDefaultCraterType;
316  static const std::string theDefaultCraterImageFilename;
317  static const std::string theDefaultCraterElevationFilename;
318  static const std::string theCraterTypeToElevationMapFilename;
319  static const std::string theCraterTypeToLandCoverMapFilename;
320  static const std::string theElevationOtwMapFilename;
321  static const std::string theLandCoverOtwMapFilename;
322  static const std::string theElevationAndLandCoverOtwMapFilename;
323 
324  protected:
325 
327 
328  tbb::spin_rw_mutex myLandCoverCacheMutex;
329  tbb::spin_rw_mutex myElevationRasterCacheMutex;
330  tbb::spin_rw_mutex myOtwImageCacheMutex;
331  tbb::spin_rw_mutex myInitMutex;
332 
333  // Used to cache ref_ptrs to images that were created for specific types of land cover codes
334  // key is crater type + land cover code
336 
337  // Used to cache ref_ptrs to images for land cover that have not been modified for
338  // a specific land cover code.
340 
341  // Cache for ref_ptrs to images for elevation rasters
343 
344  // Cache for ref_ptrs to OTW images used with the elevation effect type
346 
347  // Cache for ref_ptrs to OTW images used with the soil type effect type
349 
350  // Cache for ref_ptrs to OTW images used with the elevation and soil type effect type
352 
353  // Map crater type to raster filenames for use with osgEarth decal elevation layer
355 
356  // Map crater type to raster filenames for use with osgEarth decal land cover layer
358 
359  // Map crater type and soil type to visual images for osgEarth decal image layer
360  // when effect type is DtTerrainCraterElevationEffect
362 
363  // Map crater type and soil type to visual images for osgEarth decal image layer
364  // when effect type is DtTerrainCraterSoilEffect
366 
367  // Map crater type and soil type to visual images for osgEarth decal image layer
368  // when effect type is DtTerrainCraterElevAndSoilEffect
370 
372 
373  // External soil type to osgEarth land cover name mapper
375  };
376 
377 
381  : public DtVirtualBaseClass
382  {
383  public:
384 
387 
390 
393  static DtDynamicTerrainRasterLibraryCreator& instance(DtDe& de);
394 
396  static void registerInstance(DtDe& de, DtDynamicTerrainRasterLibraryCreator* creatorInstance);
397 
400  virtual DtDynamicTerrainRasterLibrary* create(DtDe& de);
401  };
402 
403 }
StrToImgMap myElevationAndLandCoverOtwImageCache
Definition: DtDynamicTerrainRasterLibrary.h:351
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
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 theDefaultCraterElevationFilename
Definition: DtDynamicTerrainRasterLibrary.h:317
std::map< std::string, std::string > StrToStrMap
Definition: DtDynamicTerrainRasterLibrary.h:208
Definition: DtDynamicTerrainRasterLibrary.h:41
static const std::string theElevationOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:320
bool myIsInitialized
Definition: DtDynamicTerrainRasterLibrary.h:326
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:331
static const std::string theCraterTypeToLandCoverMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:319
DtDe & myDe
Definition: DtDynamicTerrainRasterLibrary.h:371
static const std::string theDefaultCraterType
Definition: DtDynamicTerrainRasterLibrary.h:315
tbb::spin_rw_mutex myLandCoverCacheMutex
Definition: DtDynamicTerrainRasterLibrary.h:328
DtVrfSoilTypeToOsgEarthLandCoverMap * mySoilTypeToLandCoverMap
Definition: DtDynamicTerrainRasterLibrary.h:374
StrToImgMap myLandCoverOtwImageCache
Definition: DtDynamicTerrainRasterLibrary.h:348
RasterImageType
Definition: DtDynamicTerrainRasterLibrary.h:38
StrToImgMap myLandCoverElevationRasterCache
Definition: DtDynamicTerrainRasterLibrary.h:339
OtwImageMap myCraterTypeAndSoilTypeToOtwFilenameForElevationMap
Definition: DtDynamicTerrainRasterLibrary.h:361
Definition: DtDynamicTerrainRasterLibrary.h:40
static const std::string theDefaultCraterImageFilename
Definition: DtDynamicTerrainRasterLibrary.h:316
StrToStrMap myCraterTypeToElevationFilenameMap
Definition: DtDynamicTerrainRasterLibrary.h:354
StrToImgMap myLandCoverImageCache
Definition: DtDynamicTerrainRasterLibrary.h:335
std::map< std::string, StrToStrMap > OtwImageMap
Definition: DtDynamicTerrainRasterLibrary.h:212
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:342
OtwImageMap myCraterTypeAndSoilTypeToOtwFilenameForLandCoverMap
Definition: DtDynamicTerrainRasterLibrary.h:365
Creator for the DtDynamicTerrainRasterLibrary.
Definition: DtDynamicTerrainRasterLibrary.h:380
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))
std::map< std::string, osg::ref_ptr< osg::Image > > StrToImgMap
Definition: DtDynamicTerrainRasterLibrary.h:207
tbb::spin_rw_mutex myOtwImageCacheMutex
Definition: DtDynamicTerrainRasterLibrary.h:330
static const std::string theLandCoverOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:321
StrToStrMap myCraterTypeToLandCoverFilenameMap
Definition: DtDynamicTerrainRasterLibrary.h:357
OtwImageMap myCraterTypeAndSoilTypeToOtwFilenameForElevationAndLandCoverMap
Definition: DtDynamicTerrainRasterLibrary.h:369
static const std::string theElevationAndLandCoverOtwMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:322
StrToImgMap myElevationOtwImageCache
Definition: DtDynamicTerrainRasterLibrary.h:345
static const std::string theCraterTypeToElevationMapFilename
Definition: DtDynamicTerrainRasterLibrary.h:318
Contains DLL export macros.
tbb::spin_rw_mutex myElevationRasterCacheMutex
Definition: DtDynamicTerrainRasterLibrary.h:329
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:70
Definition: DtDynamicTerrainRasterLibrary.h:42

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)