WSF
WsfTerrainPathFinder.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11// ****************************************************************************
12// Updated by Infoscitex, a DCS Company.
13// ****************************************************************************
14//* PURPOSE:
15//* This class is used to find a path from A to B in a 3D environment with
16//* weighted nodes. It uses the UtGraph class to build a set of nodes that
17//* hold the weights for each square in a lat/lon grid. Squares are measured
18//* in arc degrees rather than meters because the class needs to work on a
19//* spherical earth. Extending from WsfPathfinder, this class makes use of
20//* available terrain data and analyzes the height data as well. The class
21//* makes use of the Restricted Quadtree Triangulation algorithm
22//* to reduce the amount of nodes used to represent the pathing grid.
23//*
24//* AUTHOR
25//* Nick Chinnici
26//*
27//* NOTES:
28//* For more information about the Restricted Quadtree Triangulation algorithm
29//* visit: http://portal.acm.org/citation.cfm?id=288216.288219
30//***************************************************************************
31
32#ifndef WSFTERRAINPATHFINDER_HPP
33#define WSFTERRAINPATHFINDER_HPP
34
35#include "wsf_export.h"
36
37#include "WsfObject.hpp"
38#include "WsfPathFinder.hpp"
39
41{
42public:
43 WsfTerrainPathFinder(WsfScenario* aScenarioPtr);
44 ~WsfTerrainPathFinder() override = default;
45 bool Initialize(WsfSimulation* aSimulationPtr) override;
46 const WsfPFNode* GetClosestNode(const WsfGeoPoint& aPointPtr) override;
47 const WsfPFNode* GetClosestNodePos(float x, const WsfGeoPoint& aPointPtr);
48 bool ProcessInput(UtInput& aInput) override;
49
50 typedef struct
51 {
52 double Lat;
53 double Lon;
55
62
64
65private:
66 void RQTRefineMesh(float aMetric);
67 void RQTRefineMesh();
68
69 std::string ConvertToDegMinSec(double aLoc);
70 void RQTEvaluateLine(int x, int y, float metric, int stride);
71 void RQTMarkPointDependants(int x, int y, int stride);
72 double RQTPointLineDistance(WsfPFNode* APtr, WsfPFNode* BPtr, WsfPFNode* PPtr);
73 void ComputeNodeNormals();
74 void GeneratePathFinderLight();
75 void WriteOutAsZones();
76 void LoadGridInfo();
77
78 bool shortest_path(const_node_iterator aSrcNodeIter,
79 const_node_iterator aDstNodeIter,
80 NodeList& aPath,
81 double& aCost,
82 const cost_func* aCostFuncPtr) const override;
83
84
85 float mRQTMetric;
86 int mChunkSize; // used in the RQT algorithm to define the minimum chunk size (i.e. 3x3, 5x5, etc.) during calculation.
87 std::string mRQTFile;
88 bool mUseRQTFile;
89 std::string mNavMeshZonesFile;
90 float mMaxNormalAngle;
91
92
93 class pf_cost_func : public PFGraph::cost_func
94 {
95 public:
96 double operator()(const WsfPFEdge& aEdge, const WsfPFNode& aNode1, const WsfPFNode& aNode2) const override
97 {
98 if (aNode2.mWeight == std::numeric_limits<double>::max())
99 {
100 return std::numeric_limits<double>::max();
101 }
102
103 double cost = (aEdge.mLength * 2) + aNode2.mWeight; // scale the distance to make it more influential
104 return cost;
105 }
106
107 double operator()(const WsfPFNode& aNode1, const WsfPFNode& aNode2) const override
108 {
109 double estimate = aNode2.mLoc.GetDistanceFrom(aNode1.mLoc);
110 return estimate;
111 }
112
113 // adding consider_node function to the cost_func. This will flag a node to be ignored during path-finding.
114 bool consider_node(const WsfPFNode& aNode1) const override
115 {
116 // NO_FLY_ZONES are marked as DBL_MAX and won't be considered in path-finding
117 return (aNode1.mWeight == std::numeric_limits<double>::max() ? false : true);
118 }
119 };
120};
121
122#endif
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfGeoPoint.hpp:29
double GetDistanceFrom(double aLocationWCS[3]) const
Definition WsfGeoPoint.cpp:151
Definition WsfPathFinder.hpp:58
WsfGeoPoint mLoc
Definition WsfPathFinder.hpp:79
double mWeight
Definition WsfPathFinder.hpp:77
WsfPathFinder(WsfScenario *aScenarioPtr, WsfGeoPoint &aUpperLeftPtr, WsfGeoPoint &aLowerRightPtr, double aGridSizeDegrees)
Definition WsfPathFinder.cpp:64
bool ProcessInput(UtInput &aInput) override
Definition WsfPathFinder.cpp:465
bool shortest_path(const_node_iterator aSrcNodeIter, const_node_iterator aDstNodeIter, NodeList &aPath, double &aCost, const cost_func *aCostFuncPtr=nullptr) const override
Definition WsfPathFinder.cpp:395
virtual bool Initialize(WsfSimulation *aSimulationPtr)
Definition WsfPathFinder.cpp:102
virtual const WsfPFNode * GetClosestNode(const WsfGeoPoint &aPointPtr)
Definition WsfPathFinder.cpp:292
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
The main controller for a simulation.
Definition WsfSimulation.hpp:109
const WsfPFNode * GetClosestNodePos(float x, const WsfGeoPoint &aPointPtr)
Definition WsfTerrainPathFinder.cpp:747
bool ComparePoints(sTerrainLatLon aPt1, sTerrainLatLon aPt2)
Definition WsfTerrainPathFinder.cpp:1657
~WsfTerrainPathFinder() override=default
WsfTerrainPathFinder(WsfScenario *aScenarioPtr)
Definition WsfTerrainPathFinder.cpp:49
Definition WsfPathFinder.hpp:87
double mLength
Definition WsfPathFinder.hpp:102
Definition WsfTerrainPathFinder.hpp:51
double Lat
Definition WsfTerrainPathFinder.hpp:52
double Lon
Definition WsfTerrainPathFinder.hpp:53
Definition WsfTerrainPathFinder.hpp:57
sTerrainLatLon Pt2
Definition WsfTerrainPathFinder.hpp:59
sTerrainLatLon Pt1
Definition WsfTerrainPathFinder.hpp:58
sTerrainLatLon Pt3
Definition WsfTerrainPathFinder.hpp:60
Copyrights Multiple, All Rights Reserved