WSF
WsfSpaceOpticalSignature.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 2017 Infoscitex, a DCS 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 WSFSPACEOPTICALSIGNATURE_HPP
13#define WSFSPACEOPTICALSIGNATURE_HPP
14
15#include "wsf_space_export.h"
16
17#include <fstream>
18#include <list>
19#include <memory>
20#include <mutex>
21#include <string>
22#include <vector>
23
24#include "UtCalendar.hpp"
25#include "UtMat3.hpp"
26#include "UtVec3.hpp"
28
31class WSF_SPACE_EXPORT WsfSpaceOpticalSignature : public WsfOpticalSignature
32{
33public:
38 class MyMat3d
39 {
40 public:
41 MyMat3d() = default;
42 MyMat3d(const MyMat3d&) = default;
43 MyMat3d& operator=(const MyMat3d&) = default;
44
45 UtVec3d InverseMultiply(const UtVec3d& aRhs) const
46 {
47 UtVec3d result;
48 UtMat3d::InverseTransform(result.GetData(), mMat, aRhs.GetData());
49 return result;
50 }
51
52 double mMat[3][3];
53 };
54
58 struct Data
59 {
60 UtVec3d mUnit_po; // WCS vector from the platform to the observer
61 double mTemp_p; // Temperature of the platform (from ComputeThermalSignature)
62 };
63
69 class Surface
70 {
71 public:
73
75 struct RefData
76 {
78 double mWCS_ToECS_Transform[3][3]; // The WCS->ECS transform for the platform
80 UtVec3d mUnit_vel; // Platform velocity
81 UtVec3d mUnit_ps; // Platform->Sun
82 UtVec3d mUnit_pe; // Platform->Earth
83 UtVec3d mUnit_po; // Platform->Observer
86 };
87
89 : mListIndex(0)
90 , mReflectance(1.0)
91 , mTemperatureChangeRate(0.1) // deg-K / sec
92 , mMinimumTemperature(173.15) // deg-K
93 , mMaximumTemperature(393.15) // deg-K
94 {
95 }
96 virtual ~Surface() = default;
97
98 virtual bool ProcessInput(UtInput& aInput);
99 virtual double ProjectedArea(const MyMat3d& aWCS_ToSCS_Transform, const UtVec3d& aUnit_v) const;
100 virtual double Reflect(const MyMat3d& aWCS_ToSCS_Transform,
101 double aIntensity,
102 const UtVec3d& aUnit_i,
103 double aDist_i,
104 const UtVec3d& aUnit_v,
105 unsigned int aDebugLevel) const;
106 virtual void UpdateTransform(const RefData& aRefData, MyMat3d& aWCS_ToSCS_Transform) const;
107
108 size_t mListIndex; // Index of the surface in the list of surfaces for a state
113 };
114
115 static WsfOpticalSignature* ObjectFactory(const std::string& aTypeName);
116
119 ~WsfSpaceOpticalSignature() override = default;
121
122 WsfOpticalSignature* Clone() const override;
123
124 bool Initialize(double aSimTime, WsfPlatform* aPlatformPtr) override;
125
126 bool InitializeType() override;
127
128 std::vector<WsfStringId> GetStateNames() const override;
129
130 bool ProcessInput(UtInput& aInput) override;
131
132 float GetSignature(double aSimTime, WsfStringId aStateId, double aAzimuth, double aElevation) override;
133
134 bool GetProjectedArea(double aSimTime, WsfStringId aStateId, double aAzimuth, double aElevation, double& aProjectedArea) override;
135
136 bool GetRadiantIntensity(double aSimTime,
137 WsfStringId aStateId,
138 const BandList& aBands,
139 double aAzimuth,
140 double aElevation,
141 double& aRadiantIntensity) override;
142
143 static Surface* SurfaceFactory(const std::string& aType, const Surface& aDefaultData);
144
145private:
147 class State
148 {
149 public:
150 explicit State(WsfStringId aStateId)
151 : mStateId(aStateId)
152 , mSurfaces()
153 {
154 }
155 // This is never copied or assigned.
156 State(const State&) = delete;
157 State& operator=(const State&) = delete;
158
159 WsfStringId mStateId;
160 std::list<std::unique_ptr<Surface>> mSurfaces;
161 };
162
164 class SharedData
165 {
166 public:
167 SharedData();
168 // This is never copied or assigned.
169 SharedData(const SharedData&) = delete;
170 SharedData& operator=(const SharedData&) = delete;
171
172 bool InitializeType(WsfObject& aBase);
173
174 bool IsA_ValidState(WsfStringId aId) const;
175
176 bool ProcessInput(UtInput& aInput, WsfObject& aBase);
177
178 const State& SelectState(WsfStringId aId) const;
179
180 Surface mDefaultSurface;
181 WsfStringId mCurrentStateId;
182 const State* mDefaultStatePtr; // Pointer to the default state within the list of states
183 std::list<State> mStates;
184 size_t mMaxSurfaceCount; // Maximum number of surfaces in any state
185 };
186
187 double ComputeEarthReflectionSignature(double aSimTime, const BandList& aBands, const State& aState, Data& aData);
188 double ComputeSolarReflectionSignature(double aSimTime, const BandList& aBands, const State& aState, Data& aData);
189 double ComputeThermalSignature(double aSimTime, const BandList& aBands, const State& aState, Data& aData);
190
191 double ComputeReflection(double aSimTime,
192 const BandList& aBands,
193 const State& aState,
194 Data& aData,
195 double aIntensity,
196 const UtVec3d& aUnit_ps,
197 double aDist_ps);
198
199 void GetEclipseState(double aSimTime, Data& aData);
200 void UpdateEclipseTimes(double aSimTime, Data& aData);
201
202 void UpdateState(double aSimTime, const State& aState);
203
204 std::shared_ptr<SharedData> mSharedDataPtr;
205
206 // @name Input values
208 std::string mPlotFile;
209 std::string mPlotFieldDelimiter;
210 unsigned int mDebugLevel;
211 bool mHighResolutionEclipse;
213
217 std::recursive_mutex mStateUpdateMutex; // Protect the state update during multi-threading.
218 double mStateUpdateTime;
219 UtCalendar mCurrentTime; // The current simulation time, as a calendar object
220 // All locations and vectors are in WCS.
221 UtVec3d mLoc_s; // Location of the Sun
222 UtVec3d mLoc_p; // Location of the platform
223 UtVec3d mUnit_vel; // Unit vector of the platform velocity
224 UtVec3d mUnit_ps; // Unit vector from the platform to the Sun
225 UtVec3d mUnit_pe; // Unit vector from the platform to the Earth
226 UtVec3d mUnit_es; // Unit vector from the Earth to the Sun
227 double mDist_ps; // Distance from the platform to the Sun
228 double mDist_pe; // Distance from the platform to the Earth
229 double mDist_es; // Distance from the Earth to the Sun
230 std::vector<MyMat3d> mTransforms; // WCS->SCS transforms for each surface
231
232 // The time when the platform entered the current eclipse/not-eclipsed state.
233 // Note that this can be negative when called during the first orbit of a simulation.
234 double mEclipseEntryExitTime;
235 bool mIsEclipsed; // True if currently eclipsed, false if not.
237
240
241 std::recursive_mutex mEclipseUpdateMutex; // Protect the eclipse state update during multi-threading
242 double mNextEclipseUpdateTime;
243 double mEclipseEntryTime;
244 double mEclipseExitTime;
245 double mOrbitalPeriod; // Time to complete one orbit
246 // The following two are used only when the platform mover is not a space mover.
247 double mLastEclipseUpdateTime; // The time when last called
248 bool mLastEclipseState; // The eclipse state at the last call
250
251 std::ofstream mPlotOfs; // Analysis output stream.
252};
253
254#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
WsfOpticalSignature * Clone() const override=0
virtual bool GetRadiantIntensity(double aSimTime, WsfStringId aState, const BandList &aBands, double aAzimuth, double aElevation, double &aRadiantIntensity)
Definition WsfOpticalSignature.cpp:97
virtual float GetSignature(double aSimTime, WsfStringId aStateId, double aAzimuth, double aElevation)=0
std::vector< WsfEM_Types::OpticalBand > BandList
Definition WsfOpticalSignature.hpp:53
virtual bool GetProjectedArea(double aSimTime, WsfStringId aStateId, double aAzimuth, double aElevation, double &aProjectedArea)
Definition WsfOpticalSignature.cpp:87
WsfOpticalSignature()
Definition WsfOpticalSignature.cpp:32
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
bool ProcessInput(UtInput &aInput) override
Definition WsfSignature.cpp:74
virtual bool Initialize(double aSimTime, WsfPlatform *aPlatformPtr)
Definition WsfSignature.cpp:51
virtual bool InitializeType()
Definition WsfSignature.cpp:40
virtual std::vector< WsfStringId > GetStateNames() const
get the list of all valid states belonging to the signature
Definition WsfSignature.hpp:43
Definition WsfSpaceOpticalSignature.hpp:39
MyMat3d & operator=(const MyMat3d &)=default
UtVec3d InverseMultiply(const UtVec3d &aRhs) const
Definition WsfSpaceOpticalSignature.hpp:45
MyMat3d(const MyMat3d &)=default
double mMat[3][3]
Definition WsfSpaceOpticalSignature.hpp:52
Definition WsfSpaceOpticalSignature.hpp:70
virtual bool ProcessInput(UtInput &aInput)
Definition WsfSpaceOpticalSignature.cpp:1289
virtual double ProjectedArea(const MyMat3d &aWCS_ToSCS_Transform, const UtVec3d &aUnit_v) const
Definition WsfSpaceOpticalSignature.cpp:1344
Surface()
Definition WsfSpaceOpticalSignature.hpp:88
double mReflectance
Definition WsfSpaceOpticalSignature.hpp:109
double mMaximumTemperature
Definition WsfSpaceOpticalSignature.hpp:112
virtual double Reflect(const MyMat3d &aWCS_ToSCS_Transform, double aIntensity, const UtVec3d &aUnit_i, double aDist_i, const UtVec3d &aUnit_v, unsigned int aDebugLevel) const
Definition WsfSpaceOpticalSignature.cpp:1358
double mMinimumTemperature
Definition WsfSpaceOpticalSignature.hpp:111
double mTemperatureChangeRate
Definition WsfSpaceOpticalSignature.hpp:110
virtual void UpdateTransform(const RefData &aRefData, MyMat3d &aWCS_ToSCS_Transform) const
Definition WsfSpaceOpticalSignature.cpp:1372
size_t mListIndex
Definition WsfSpaceOpticalSignature.hpp:108
WsfSpaceOpticalSignature::MyMat3d MyMat3d
Definition WsfSpaceOpticalSignature.hpp:72
static Surface * SurfaceFactory(const std::string &aType, const Surface &aDefaultData)
Definition WsfSpaceOpticalSignature.cpp:2048
WsfSpaceOpticalSignature()
Definition WsfSpaceOpticalSignature.cpp:331
static WsfOpticalSignature * ObjectFactory(const std::string &aTypeName)
Factory method called by WsfOpticalSignatureTypes.
Definition WsfSpaceOpticalSignature.cpp:320
WsfSpaceOpticalSignature & operator=(const WsfSpaceOpticalSignature &)=delete
~WsfSpaceOpticalSignature() override=default
Definition WsfSpaceOpticalSignature.hpp:59
UtVec3d mUnit_po
Definition WsfSpaceOpticalSignature.hpp:60
double mTemp_p
Definition WsfSpaceOpticalSignature.hpp:61
This contains data needed to create the WCS->SCS.
Definition WsfSpaceOpticalSignature.hpp:76
int mDebugLevel
Definition WsfSpaceOpticalSignature.hpp:84
UtVec3d mUnit_ps
Definition WsfSpaceOpticalSignature.hpp:81
double mWCS_ToECS_Transform[3][3]
Definition WsfSpaceOpticalSignature.hpp:78
UtVec3d mUnit_pe
Definition WsfSpaceOpticalSignature.hpp:82
UtVec3d mUnit_vel
Definition WsfSpaceOpticalSignature.hpp:80
UtVec3d mUnit_po
Definition WsfSpaceOpticalSignature.hpp:83
WsfPlatform * mPlatformPtr
Definition WsfSpaceOpticalSignature.hpp:77
Copyrights Multiple, All Rights Reserved