VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
terrainUtil.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
14 #include <osg/BoundingSphere>
19 
20 #include <terrainCS/geodeticCS.h>
21 
22 #include <vector>
23 #include <osg/BoundingBox>
24 #include <osgEarth/Config>
25 #include <osgEarth/URI>
26 #include <osgEarth/GeoData>
27 
28 class DtSphere;
29 class Coordinate_System;
32 
33 DtSphere boundingSphere2DtSphere(const osg::BoundingSphere& boundingSphere);
34 
35 DtExtent boundingBox2DtExtent(const osg::BoundingBoxd& boundingBox);
36 
37 
40 void convertGeometry(
41  const DtTerrainPagingGeometryPtr& geometry, const Coordinate_System* CS,
42  const double worldWidth, std::vector<DtTerrainPagingGeometryPtr>& output);
43 
46 
49 
51 void convertFromOsgEarthCoordSys(DtVector& p, CS_Type cstype);
52 
55 
59 void unwrap(double width, DtLocalVertexList& list, std::vector<DtTerrainPagingGeometryPtr>& output);
60 
62 
64  const DtVector& min1 /*rhs sw*/, const DtVector& max1 /*rhs ne*/,
65  const DtVector& min2 /*mysw*/, const DtVector& max2 /*myne*/);
66 
67 bool boundariesOverlap(double min1, double max1, double min2, double max2);
68 
69 DtExtent sphereExtent(const DtSphere& sphere);
70 
72  const DtLocalVertexList& shape,
73  const DtVector& lower, const DtVector& upper);
74 
76  const DtVector& p,
77  const DtVector& lower, const DtVector& upper);
78 
79 bool doubleEqual(double d1, double d2);
80 
84  const DtVrfChordIntersectionRecord& record,
86 
89 {
90 public:
92  static std::unique_ptr<IndexInputInterface> Create(const DtFilename&);
93 
94  virtual ~IndexInputInterface();
95 
96  virtual bool read(unsigned& lod, unsigned& x, unsigned& y, double& min, double& max, bool& valid) = 0;
97 };
98 
100 template <class T>
102 {
103  std::string name;
104  osgEarth::URI file;
105  bool isDefault;
106  double minTolerance, maxTolerance;
107  unsigned minlod, maxlod;
108  osgEarth::GeoExtent extent;
109 
111  const T& tracker,
112  const osgEarth::Config& cfg)
113  : name(cfg.value<std::string>("name", ""))
114  , isDefault(false)
115  , minTolerance(cfg.value<double>("min_tolerance", 0))
116  , maxTolerance(cfg.value<double>("max_tolerance", 0))
117  , minlod(cfg.value<unsigned>("min_lod", 0))
118  , maxlod(cfg.value<unsigned>("max_lod", tracker.maxLOD()))
119  , extent(tracker.profile()->getExtent())
120  {
121  double xmin = extent.xMin();
122  double ymin = extent.yMin();
123  double xmax = extent.xMax();
124  double ymax = extent.yMax();
125 
126  if (tracker.localCS()->getCS_Type() == CS_DIS)
127  {
128  xmin = cfg.value<double>("min_lon", xmin);
129  ymin = cfg.value<double>("min_lat", ymin);
130  xmax = cfg.value<double>("max_lon", xmax);
131  ymax = cfg.value<double>("max_lat", ymax);
132  }
133  else
134  {
135  xmin = cfg.value<double>("min_x", xmin);
136  ymin = cfg.value<double>("min_y", ymin);
137  xmax = cfg.value<double>("max_x", xmax);
138  ymax = cfg.value<double>("max_y", ymax);
139  }
140 
141  extent.set(xmin, ymin, xmax, ymax);
142  }
143 
145  const T& tracker)
146  : isDefault(true)
147  , minTolerance(0)
148  , maxTolerance(0)
149  , minlod(0)
150  , maxlod(tracker.maxLOD())
151  , extent(tracker.mapNode()->getMap()->getProfile()->getExtent())
152  {
153  }
154 };
155 
158 {
159  double min, max;
160 
162  void update(const DtPoint& p)
163  {
164  double value = p.x();
165 
166  if (value > max)
167  {
168  max = value;
169  }
170 
171  if (value < min)
172  {
173  min = value;
174  }
175  }
176 
178  bool wrapsAround(double width) const
179  {
181  return max - min > width / 2;
182  }
183 
185  : min(std::numeric_limits<double>::infinity())
186  , max(-std::numeric_limits<double>::infinity())
187  {
188  }
189 };
bool shapeIntersectsAABB(const DtLocalVertexList &shape, const DtVector &lower, const DtVector &upper)
Convert geometry to internal coordinate system.
const double & x() const
Definition: point.h:188
void convertToOsgEarthCoordSys(DtPoint &p, CS_Type cstype)
convert to coordinate system used by osgEarth tiles
DtVrfChordIntersectionRecord represents a list of DtChordIntersectRecords. This is useful for followi...
Definition: vrfChordIntersectRecordList.h:31
Definition: sphere.h:22
double minTolerance
Definition: terrainUtil.h:106
void update(const DtPoint &p)
update min and max values
Definition: terrainUtil.h:162
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
Information about each individual index file.
Definition: terrainUtil.h:101
bool isDefault
Definition: terrainUtil.h:105
bool doubleEqual(double d1, double d2)
Convert geometry to internal coordinate system.
Definition: coordSystem.h:54
DtSphere boundingSphere2DtSphere(const osg::BoundingSphere &boundingSphere)
std::shared_ptr< DtTerrainPagingGeometry > DtTerrainPagingGeometryPtr
Definition: terrainPagingGeometry.h:46
osgEarth::URI file
Definition: terrainUtil.h:104
code for checking if a geometry wraps around the borders of the world map
Definition: terrainUtil.h:157
void unwrap(double width, DtLocalVertexList &list, std::vector< DtTerrainPagingGeometryPtr > &output)
unwrap moves points lower one world width if they are on the upper half side of the world this is so ...
Definition: coordSystem.h:40
DtVrfChordIntersectionRecord * insertRecordAlongChord(const DtVrfChordIntersectionRecord &record, DtVrfChordIntersectRecordList &intList)
inserts points inter intersection record list checks each point against the one before and after and ...
bool wrapsAround(double width) const
check is points analyzed so far indicate shape wraps around the world
Definition: terrainUtil.h:178
std::string name
Definition: terrainUtil.h:103
osgEarth::GeoExtent extent
Definition: terrainUtil.h:108
Definition: vrfChordIntersectionRecord.h:19
CS_Type
Definition: coordSystem.h:35
void convertFromOsgEarthCoordSys(DtPoint &p, CS_Type cstype)
convert from coordinate system used by osgEarth tiles
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
double min
Definition: terrainUtil.h:159
void convertGeometry(const DtTerrainPagingGeometryPtr &geometry, const Coordinate_System *CS, const double worldWidth, std::vector< DtTerrainPagingGeometryPtr > &output)
Convert geometry to internal coordinate system.
unsigned minlod
Definition: terrainUtil.h:107
IndexConfig(const T &tracker, const osgEarth::Config &cfg)
Definition: terrainUtil.h:110
bool extentIntersectsAABB(const DtVector &min1, const DtVector &max1, const DtVector &min2, const DtVector &max2)
TODO ALL functions below should be inline.
Generic interface for reading from index.
Definition: terrainUtil.h:88
class DtLocalVertexList:
Definition: localVertexList.h:20
bool pointIntersectsAABB(const DtVector &p, const DtVector &lower, const DtVector &upper)
Convert geometry to internal coordinate system.
MinMaxInfo()
Definition: terrainUtil.h:184
DtExtent sphereExtent(const DtSphere &sphere)
Convert geometry to internal coordinate system.
bool boundariesOverlap(double min1, double max1, double min2, double max2)
Convert geometry to internal coordinate system.
DtExtent boundingBox2DtExtent(const osg::BoundingBoxd &boundingBox)
Definition: point.h:34
IndexConfig(const T &tracker)
Definition: terrainUtil.h:144
double max
Definition: terrainUtil.h:159

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)