WSF
WsfClusterManager.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#ifndef WSFCLUSTERMANAGER_HPP
13#define WSFCLUSTERMANAGER_HPP
14
15#include "wsf_mil_export.h"
16
17#include <limits>
18#include <vector>
19
20#include "UtCluster.hpp"
21class UtScript;
23class WsfDraw;
24class WsfGeoPoint;
25class WsfPlatform;
26class WsfTrack;
27#include "WsfObject.hpp"
28#include "WsfTrackList.hpp"
29
30
31class WSF_MIL_EXPORT WsfPlatformClusterObject : public UtClusterObject
32{
33public:
36 {
37 mPlatformPtr = nullptr;
38 } // do not delete the pointer, it the object is managed elsewhere
39 bool VelocityValid() override;
40 void GetLocationWCS(double aLocationWCS[3]) override;
41 void GetLocationLLA(double& aLat, double& aLon, double& aAlt) override;
42 void GetVelocityWCS(double aVelocityWCS[3]) override;
43 WsfPlatform* GetPlatform() { return mPlatformPtr; }
44 // creates new objects in memory, must be deleted by caller
45 static void GetObjects(const std::vector<WsfPlatform*>& platforms, std::vector<UtClusterObject*>& objects);
46 static void GetPlatforms(std::vector<UtClusterObject*>& objects, std::vector<WsfPlatform*>& platforms);
47
48private:
49 WsfPlatform* mPlatformPtr;
50};
51
52class WSF_MIL_EXPORT WsfTrackClusterObject : public UtClusterObject
53{
54public:
55 WsfTrackClusterObject(WsfTrack* aTrackPtr, double aSimTime);
57 {
58 mTrackPtr = nullptr;
59 } // do not delete the pointer, it the object is managed elsewhere
60 bool VelocityValid() override;
61 void GetLocationWCS(double aLocationWCS[3]) override;
62 void GetLocationLLA(double& aLat, double& aLon, double& aAlt) override;
63 void GetVelocityWCS(double aVelocityWCS[3]) override;
64 WsfTrack* GetTrack() { return mTrackPtr; }
65 // creates new objects in memory, must be deleted by caller
66 static void GetObjects(double aSimTime, const std::vector<WsfTrack*>& tracks, std::vector<UtClusterObject*>& objects);
67 static void GetObjects(double aSimTime, const std::vector<WsfLocalTrack*>& tracks, std::vector<UtClusterObject*>& objects);
68 static void GetObjects(double aSimTime, WsfTrackList& tracks, std::vector<UtClusterObject*>& objects);
69 static void GetObjects(double aSimTime, WsfLocalTrackList& tracks, std::vector<UtClusterObject*>& objects);
70 static void GetTracks(std::vector<UtClusterObject*>& objects, std::vector<WsfTrack*>& tracks);
71 static void GetTracks(std::vector<UtClusterObject*>& objects, std::vector<WsfLocalTrack*>& tracks);
72 double GetSimTime() { return mSimTime; }
73
74private:
75 WsfTrack* mTrackPtr;
76 double mSimTime;
77};
78
79class WSF_MIL_EXPORT WsfGeoPointClusterObject : public UtClusterObject
80{
81public:
84 {
85 mGeoPointPtr = nullptr;
86 } // do not delete the pointer, it the object is managed elsewhere
87 bool VelocityValid() override;
88 void GetLocationWCS(double aLocationWCS[3]) override;
89 void GetLocationLLA(double& aLat, double& aLon, double& aAlt) override;
90 void GetVelocityWCS(double aVelocityWCS[3]) override;
91 WsfGeoPoint* GetGeoPoint() { return mGeoPointPtr; }
92 // creates new objects in memory, must be deleted by caller
93 static void GetObjects(const std::vector<WsfGeoPoint*>& geoPoints, std::vector<UtClusterObject*>& objects);
94 static void GetGeoPoints(std::vector<UtClusterObject*>& objects, std::vector<WsfGeoPoint*>& geoPoints);
95
96private:
97 WsfGeoPoint* mGeoPointPtr;
98};
99
100class WSF_MIL_EXPORT WsfAssetClusterObject : public UtClusterObject
101{
102public:
105 {
106 mAssetPtr = nullptr;
107 } // do not delete the pointer, it the object is managed elsewhere
108 bool VelocityValid() override;
109 void GetLocationWCS(double aLocationWCS[3]) override;
110 void GetLocationLLA(double& aLat, double& aLon, double& aAlt) override;
111 void GetVelocityWCS(double aVelocityWCS[3]) override;
112 WsfAssetPerception* GetAsset() { return mAssetPtr; }
113 // creates new objects in memory, must be deleted by caller
114 static void GetObjects(const std::vector<WsfAssetPerception*>& assets, std::vector<UtClusterObject*>& objects);
115 static void GetAssets(std::vector<UtClusterObject*>& objects, std::vector<WsfAssetPerception*>& assets);
116
117private:
118 WsfAssetPerception* mAssetPtr;
119};
120
121
135class WSF_MIL_EXPORT WsfClusterManager : public UtClusterManager
136{
137public:
138 // typedef typename UtClusterManager::UtCluster UtCluster;
139
141 // see UtCluster : UtClusterManager::ClusteringMethod
142
144 // see UtCluster : UtClusterManager::DistanceFunction
145
146 WsfClusterManager(WsfSimulation& aSimulation,
147 size_t aNumClusters = 0,
148 UtClusterManager::ClusteringMethod aMethod = UtClusterManager::cK_MEANS,
149 UtClusterManager::DistanceFunction aDistType = UtClusterManager::cPOSITION_ONLY);
150
151 ~WsfClusterManager() override = default;
152
154
155 std::vector<std::vector<WsfTrack*>> GetTrackClusters(WsfTrackList& aList);
156 std::vector<std::vector<WsfLocalTrack*>> GetTrackClusters(WsfLocalTrackList& aList);
157 std::vector<std::vector<WsfTrack*>> GetTrackClusters(const std::vector<WsfTrack*>& aList);
158 std::vector<std::vector<WsfLocalTrack*>> GetTrackClusters(const std::vector<WsfLocalTrack*>& aList);
159 std::vector<std::vector<WsfPlatform*>> GetPlatformClusters(const std::vector<WsfPlatform*>& aList);
160 std::vector<std::vector<WsfGeoPoint*>> GetGeoPointClusters(const std::vector<WsfGeoPoint*>& aList);
161 std::vector<std::vector<WsfAssetPerception*>> GetAssetClusters(const std::vector<WsfAssetPerception*>& aList);
163
164 void Delete(std::vector<UtClusterObject*>& objects);
165
167
168 unsigned int UniqueId(const std::vector<WsfTrack*>& aList);
169 unsigned int UniqueId(const std::vector<WsfPlatform*>& aList);
170 unsigned int UniqueId(const std::vector<WsfGeoPoint*>& aList);
171 unsigned int UniqueId(const std::vector<WsfAssetPerception*>& aList);
172
173 std::vector<WsfTrack*> ConvexHull(const std::vector<WsfTrack*>& aList);
174 std::vector<WsfPlatform*> ConvexHull(const std::vector<WsfPlatform*>& aList);
175 std::vector<WsfGeoPoint*> ConvexHull(const std::vector<WsfGeoPoint*>& aList);
176 std::vector<WsfAssetPerception*> ConvexHull(const std::vector<WsfAssetPerception*>& aList);
177
178 WsfGeoPoint MeanLocation(const std::vector<WsfTrack*>& aList);
179 WsfGeoPoint MeanLocation(const std::vector<WsfPlatform*>& aList);
180 WsfGeoPoint MeanLocation(const std::vector<WsfGeoPoint*>& aList);
181 WsfGeoPoint MeanLocation(const std::vector<WsfAssetPerception*>& aList);
182
183 WsfTrack* NearestMember(const std::vector<WsfTrack*>& aList, WsfGeoPoint& toPoint);
184 WsfPlatform* NearestMember(const std::vector<WsfPlatform*>& aList, WsfGeoPoint& toPoint);
185 WsfGeoPoint* NearestMember(const std::vector<WsfGeoPoint*>& aList, WsfGeoPoint& toPoint);
186 WsfAssetPerception* NearestMember(const std::vector<WsfAssetPerception*>& aList, WsfGeoPoint& toPoint);
187
188 void NearestEdgePoint(const std::vector<WsfTrack*>& aList,
189 WsfGeoPoint& toPoint,
190 WsfGeoPoint& edgePoint,
191 size_t& edgeIndex1,
192 size_t& edgeIndex2);
193 void NearestEdgePoint(const std::vector<WsfPlatform*>& aList,
194 WsfGeoPoint& toPoint,
195 WsfGeoPoint& edgePoint,
196 size_t& edgeIndex1,
197 size_t& edgeIndex2);
198 void NearestEdgePoint(const std::vector<WsfGeoPoint*>& aList,
199 WsfGeoPoint& toPoint,
200 WsfGeoPoint& edgePoint,
201 size_t& edgeIndex1,
202 size_t& edgeIndex2);
203 void NearestEdgePoint(const std::vector<WsfAssetPerception*>& aList,
204 WsfGeoPoint& toPoint,
205 WsfGeoPoint& edgePoint,
206 size_t& edgeIndex1,
207 size_t& edgeIndex2);
208
209 void CrossLength(const std::vector<WsfTrack*>& aList,
210 WsfGeoPoint& refPoint,
211 double& dist1,
212 WsfGeoPoint& leftPt,
213 WsfGeoPoint& rightPt);
214 void CrossLength(const std::vector<WsfPlatform*>& aList,
215 WsfGeoPoint& refPoint,
216 double& dist1,
217 WsfGeoPoint& leftPt,
218 WsfGeoPoint& rightPt);
219 void CrossLength(const std::vector<WsfGeoPoint*>& aList,
220 WsfGeoPoint& refPoint,
221 double& dist1,
222 WsfGeoPoint& leftPt,
223 WsfGeoPoint& rightPt);
224 void CrossLength(const std::vector<WsfAssetPerception*>& aList,
225 WsfGeoPoint& refPoint,
226 double& dist1,
227 WsfGeoPoint& leftPt,
228 WsfGeoPoint& rightPt);
229
231 {
234 };
235 void Draw(const std::vector<WsfTrack*>& aList, double duration, UtVec3d& color, DrawType type = HULL);
236 void Draw(const std::vector<WsfPlatform*>& aList, double duration, UtVec3d& color, DrawType type = HULL);
237 void Draw(const std::vector<WsfGeoPoint*>& aList, double duration, UtVec3d& color, DrawType type = HULL);
238 void Draw(const std::vector<WsfAssetPerception*>& aList, double duration, UtVec3d& color, DrawType type = HULL);
239
240 void DrawHull(std::vector<UtClusterObject*>& cluster, double duration, UtVec3d& color);
241 void DrawStar(std::vector<UtClusterObject*>& cluster, double duration, UtVec3d& color);
242
244
245
247
248 bool SetUserDistanceFunction(UtScriptContext* aScriptContextPtr, const std::string& aScoringFunctionName);
249 bool UserDistanceFunction(UtClusterObject* aObjectPtr, UtClusterObject* aObject2Ptr, double& aDistance) override;
251
252 WsfSimulation* GetSimulation() const { return mSimulationPtr; }
253
254private:
255 WsfSimulation* mSimulationPtr;
256
258 WsfDraw* mDebugDrawPtr;
259
260 UtScriptContext* mScriptContextPtr;
261 UtScript* mScoringFunctionScriptPtr;
262};
263
264#endif
aObjectPtr GetLocationLLA(lla[0], lla[1], lla[2])
aObjectPtr GetVelocityWCS(vel.GetData())
WsfTrackListT< WsfLocalTrack > WsfLocalTrackList
Definition WsfTrackList.hpp:89
WsfTrackListT< WsfTrack > WsfTrackList
Definition WsfTrackList.hpp:88
WsfAssetPerception * GetAsset()
Definition WsfClusterManager.hpp:112
WsfAssetClusterObject(WsfAssetPerception *aAssetPtr)
Definition WsfClusterManager.cpp:320
~WsfAssetClusterObject() override
Definition WsfClusterManager.hpp:104
Definition WsfAssetPerception.hpp:32
WsfTrack * NearestMember(const std::vector< WsfTrack * > &aList, WsfGeoPoint &toPoint)
Definition WsfClusterManager.cpp:728
WsfSimulation * GetSimulation() const
Definition WsfClusterManager.hpp:252
std::vector< WsfTrack * > ConvexHull(const std::vector< WsfTrack * > &aList)
Definition WsfClusterManager.cpp:613
std::vector< std::vector< WsfTrack * > > GetTrackClusters(WsfTrackList &aList)
Definition WsfClusterManager.cpp:418
~WsfClusterManager() override=default
void Delete(std::vector< UtClusterObject * > &objects)
Definition WsfClusterManager.cpp:409
unsigned int UniqueId(const std::vector< WsfTrack * > &aList)
Definition WsfClusterManager.cpp:573
WsfGeoPoint MeanLocation(const std::vector< WsfTrack * > &aList)
Definition WsfClusterManager.cpp:684
std::vector< std::vector< WsfPlatform * > > GetPlatformClusters(const std::vector< WsfPlatform * > &aList)
Definition WsfClusterManager.cpp:507
std::vector< std::vector< WsfGeoPoint * > > GetGeoPointClusters(const std::vector< WsfGeoPoint * > &aList)
Definition WsfClusterManager.cpp:529
void CrossLength(const std::vector< WsfTrack * > &aList, WsfGeoPoint &refPoint, double &dist1, WsfGeoPoint &leftPt, WsfGeoPoint &rightPt)
Definition WsfClusterManager.cpp:840
WsfClusterManager(WsfSimulation &aSimulation, size_t aNumClusters=0, UtClusterManager::ClusteringMethod aMethod=UtClusterManager::cK_MEANS, UtClusterManager::DistanceFunction aDistType=UtClusterManager::cPOSITION_ONLY)
Definition WsfClusterManager.cpp:396
std::vector< std::vector< WsfAssetPerception * > > GetAssetClusters(const std::vector< WsfAssetPerception * > &aList)
Definition WsfClusterManager.cpp:551
void NearestEdgePoint(const std::vector< WsfTrack * > &aList, WsfGeoPoint &toPoint, WsfGeoPoint &edgePoint, size_t &edgeIndex1, size_t &edgeIndex2)
Definition WsfClusterManager.cpp:776
DrawType
Definition WsfClusterManager.hpp:231
@ HULL
Definition WsfClusterManager.hpp:232
@ STAR
Definition WsfClusterManager.hpp:233
Provides the capability to draw shapes into the WSF replay file.
Definition WsfDraw.hpp:35
WsfGeoPoint * GetGeoPoint()
Definition WsfClusterManager.hpp:91
WsfGeoPointClusterObject(WsfGeoPoint *aTrackPtr)
Definition WsfClusterManager.cpp:250
~WsfGeoPointClusterObject() override
Definition WsfClusterManager.hpp:83
Definition WsfGeoPoint.hpp:29
WsfPlatform * GetPlatform()
Definition WsfClusterManager.hpp:43
~WsfPlatformClusterObject() override
Definition WsfClusterManager.hpp:35
WsfPlatformClusterObject(WsfPlatform *aPlatformPtr)
Definition WsfClusterManager.cpp:38
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
The main controller for a simulation.
Definition WsfSimulation.hpp:109
double GetSimTime()
Definition WsfClusterManager.hpp:72
~WsfTrackClusterObject() override
Definition WsfClusterManager.hpp:56
WsfTrack * GetTrack()
Definition WsfClusterManager.hpp:64
WsfTrackClusterObject(WsfTrack *aTrackPtr, double aSimTime)
Definition WsfClusterManager.cpp:113
An object that represents an 'track' (perception) of something.
Definition WsfTrack.hpp:120
Copyrights Multiple, All Rights Reserved