Commit 616b87fb authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

ART

- renamed many private/protected member variables
- fixed some missing ; for inline methods
parent 52a3cb30
......@@ -35,11 +35,11 @@ namespace ITAPropagationPathSim
class ITA_PROPAGATION_PATH_SIM_API CAdaptiveRayGrid : public CRayGrid
{
private:
double dMaxDeltaTheta = -1;
double dMaxDeltaPhi = -1;
std::set< std::shared_ptr<CRay> > vpNewRaysOfLastAdaptation;
double m_dMaxDeltaTheta = -1;
double m_dMaxDeltaPhi = -1;
std::set< std::shared_ptr<CRay> > m_vpNewRaysOfLastAdaptation;
public:
CAdaptiveRayGrid() {}
inline CAdaptiveRayGrid() {};
CAdaptiveRayGrid(const CRayGrid& rayGrid);
public:
......@@ -47,13 +47,13 @@ namespace ITAPropagationPathSim
void Reset(const CRayGrid& rayGrid);
//! Maximum angular resolution in degrees
const double& MaxAngularResolution() { return dMaxDeltaTheta < dMaxDeltaPhi ? dMaxDeltaPhi : dMaxDeltaTheta; }
inline const double& MaxAngularResolution() { return m_dMaxDeltaTheta < m_dMaxDeltaPhi ? m_dMaxDeltaPhi : m_dMaxDeltaTheta; };
//! Maximum elevation resolution in degrees
const double& MaxDeltaTheta() { return dMaxDeltaTheta; }
inline const double& MaxDeltaTheta() { return m_dMaxDeltaTheta; };
//! Maximum azimuth resolution in degrees
const double& MaxDeltaPhi() { return dMaxDeltaPhi; }
inline const double& MaxDeltaPhi() { return m_dMaxDeltaPhi; };
//! Returns a unique set of the rays which were adding during the last adaptation
const std::set< std::shared_ptr<CRay> >& NewRaysOfLastAdaptation() const { return vpNewRaysOfLastAdaptation; }
inline const std::set< std::shared_ptr<CRay> >& NewRaysOfLastAdaptation() const { return m_vpNewRaysOfLastAdaptation; };
//! Simple adaptation method: Setting the limits to neighboring rays and shoots additional rays to double the angular resolution of the grid.
void ZoomIntoRay(const std::shared_ptr<CRay> pRay);
......
......@@ -48,7 +48,7 @@ namespace ITAPropagationPathSim
Simulation::Settings simulationSettings;
public:
CEngine() {}
inline CEngine() {};
std::vector<std::shared_ptr<CRay>> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition);
};
......
......@@ -47,20 +47,20 @@ namespace ITAPropagationPathSim
typedef std::vector< RayPtr > RayVector;
typedef std::vector<RayVector> RayMatrix;
VistaVector3D v3SourcePos; //< Origin of all rays in this ray grid.
std::vector<double> vdThetaDeg; //< Sorted vector of elevation angles in degrees.
std::vector<double> vdPhiDeg; //< Sorted vector of azimuth angles in degrees.
VistaVector3D m_v3SourcePos; //< Origin of all rays in this ray grid.
std::vector<double> m_vdThetaDeg; //< Sorted vector of elevation angles in degrees.
std::vector<double> m_vdPhiDeg; //< Sorted vector of azimuth angles in degrees.
private:
RayMatrix vvpRayMatrix; //< Matrix of pointers to ray. First index refers to elevation (theta), second to azimuth (phi) angle.
RayVector vpRays; //< Vector of all rays contained by vvpRayMatrix. May contain duplicates at poles (theta = 0 or 180°).
std::set<RayPtr> vpUniqueRays; // Unique set of all rays contained by vvpRayMatrix.
bool bCircularPhi = false; //< Indicates whether the azimuth vector is considered to be circular (phi covers full 360 degrees) or not.
RayMatrix m_vvpRayMatrix; //< Matrix of pointers to ray. First index refers to elevation (theta), second to azimuth (phi) angle.
RayVector m_vpRays; //< Vector of all rays contained by vvpRayMatrix. May contain duplicates at poles (theta = 0 or 180°).
std::set<RayPtr> m_vpUniqueRays; // Unique set of all rays contained by vvpRayMatrix.
bool m_bCircularPhi = false; //< Indicates whether the azimuth vector is considered to be circular (phi covers full 360 degrees) or not.
private:
CRayGrid(const RayMatrix& rayMatrix, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi = false);
void UpdateDependentRayContainers();
protected:
inline CRayGrid(bool circularPhi = false) : bCircularPhi(circularPhi) {};
inline CRayGrid(bool circularPhi = false) : m_bCircularPhi(circularPhi) {};
//! Creates new rays using the angles of initial directions and inserts them into the ray matrix
void InitRays();
public:
......@@ -95,24 +95,24 @@ namespace ITAPropagationPathSim
bool HasPoleDirection(const std::shared_ptr<CRay> pRay) const;
public:
//! Returns true if the phi angles are defined circular (covering a full circle)
inline bool IsCircular() const { return bCircularPhi; };
inline bool IsCircular() const { return m_bCircularPhi; };
bool IsEmpty() const;
bool Is2D() const;
bool Contains(const std::shared_ptr<CRay> pRay) const;
//---GET Functions---
protected:
inline const std::vector<std::shared_ptr<CRay>>& Rays() const { return vpRays; };
inline const RayMatrix& Matrix() const { return vvpRayMatrix; };
inline const std::vector<std::shared_ptr<CRay>>& Rays() const { return m_vpRays; };
inline const RayMatrix& Matrix() const { return m_vvpRayMatrix; };
public:
inline const std::vector<double>& ThetaDeg() const { return vdThetaDeg; };
inline const std::vector<double>& PhiDeg() const { return vdPhiDeg; };
inline int NTheta() const { return vdThetaDeg.size(); };
inline int NPhi() const { return vdPhiDeg.size(); };
inline int NRays() const { return vpRays.size(); };
inline const VistaVector3D& SourcePosition() const { return v3SourcePos; };
inline const std::set<std::shared_ptr<CRay>>& UniqueRays() const { return vpUniqueRays; };
inline const std::shared_ptr<CRay> At(int idxTheta, int idxPhi) const { return vvpRayMatrix[idxTheta][idxPhi]; };
inline const std::vector<double>& ThetaDeg() const { return m_vdThetaDeg; };
inline const std::vector<double>& PhiDeg() const { return m_vdPhiDeg; };
inline int NTheta() const { return m_vdThetaDeg.size(); };
inline int NPhi() const { return m_vdPhiDeg.size(); };
inline int NRays() const { return m_vpRays.size(); };
inline const VistaVector3D& SourcePosition() const { return m_v3SourcePos; };
inline const std::set<std::shared_ptr<CRay>>& UniqueRays() const { return m_vpUniqueRays; };
inline const std::shared_ptr<CRay> At(int idxTheta, int idxPhi) const { return m_vvpRayMatrix[idxTheta][idxPhi]; };
//! Calculates and returns an approximation for the surface area of the wavefront at given time by spanning triangles between rays
double WavefrontSurface(const double& time) const;
......
......@@ -64,12 +64,12 @@ namespace ITAPropagationPathSim
{
private:
std::vector<int> iReflectionIndices;
double dSpreadingLoss = -1; //!< Spreadingloss at last point of ray (receiver), calculated at the end of Eigenray search.
std::vector<int> m_viReflectionIndices;
double m_dSpreadingLoss = -1; //!< Spreadingloss at last point of ray (receiver), calculated at the end of Eigenray search.
typedef const VistaVector3D* ReceiverPositionPtr;
typedef std::map<ReceiverPositionPtr, CRayReceiverData> ReceiverDistanceMap;
ReceiverDistanceMap mReceiverDistanceMap;
ReceiverDistanceMap m_mReceiverDistanceMap;
public:
CRay(const VistaVector3D& v3SourcePos, const double& thetaDeg, const double& phiDeg);
......@@ -78,9 +78,9 @@ namespace ITAPropagationPathSim
public:
#pragma region Get Functions
const std::vector<int>& ReflectionIndices() const { return iReflectionIndices; };
inline const std::vector<int>& ReflectionIndices() const { return m_viReflectionIndices; };
inline int NumPoints() const { return size(); }
inline int NumPoints() const { return size(); };
inline const VistaVector3D& SourcePoint() const { return front().position; };
inline const VistaVector3D& InitialDirection() const { return front().wavefrontNormal; };
......@@ -88,19 +88,19 @@ namespace ITAPropagationPathSim
inline const VistaVector3D& LastWavefrontNormal() const { return back().wavefrontNormal; };
inline const double& LastTimeStamp() const { return back().timeStamp; };
inline int ReflectionOrder() const { return iReflectionIndices.size(); };
inline int ReflectionOrder() const { return m_viReflectionIndices.size(); };
//! Returns the reflection order of the ray element with given index
int ReflectionOrder(const int idx) const;
//! Returns the spreading loss at end point of receiver. If this has not been calculated yet, this returns -1.
inline double SpreadingLoss() const { return dSpreadingLoss; };
inline double SpreadingLoss() const { return m_dSpreadingLoss; };
#pragma endregion
//! Appends a new element with position, wavefront normal and timestamp to the ray
void Append(const VistaVector3D& position, const VistaVector3D& wavefrontNormal, const double& timeStamp);
//! Appends a new element to the ray and adds its index to iReflectionIndices
void AppendReflection(const VistaVector3D& position, const VistaVector3D& wavefrontNormal, const double& timeStamp);
inline void SetSpreadingLoss(const double& spreadingLoss) { dSpreadingLoss = spreadingLoss; };
inline void SetSpreadingLoss(const double& spreadingLoss) { m_dSpreadingLoss = spreadingLoss; };
//! Returns true, if both rays have the same initial direction
bool SameDirection(const CRay& other) const;
......
......@@ -54,7 +54,7 @@ namespace ITAPropagationPathSim
inline CEngine(std::shared_ptr<IExternalWatcher> pWatcher) : pExternalWatcher(pWatcher) {};
public:
std::vector<std::shared_ptr<CRay>> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& v3SourcePosition, const std::vector<VistaVector3D>& v3RayDirections) const;
std::vector<std::shared_ptr<CRay>> Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const VistaVector3D& m_v3SourcePosition, const std::vector<VistaVector3D>& v3RayDirections) const;
void Run(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::set<std::shared_ptr<CRay>>& rays) const;
private:
void TraceRays(const ITAGeo::CStratifiedAtmosphere& atmosphere, const std::vector<std::shared_ptr<CRay>>& rays) const;
......
......@@ -38,13 +38,13 @@ namespace ITAPropagationPathSim
{
namespace Utils
{
ITAGeo::CPropagationPath ToPropagationPath(const CRay& ray)
ITA_PROPAGATION_PATH_SIM_API inline ITAGeo::CPropagationPath ToPropagationPath(const CRay& ray)
{
ITAGeo::CPropagationPath propagationPath;
propagationPath.reserve(ray.size());
VistaVector3D position, wavefrontNormal;
propagationPath.push_back( std::make_shared<ITAGeo::CEmitterInhomogeneous>(ray.SourcePoint(), ray.InitialDirection()) );
propagationPath.push_back(std::make_shared<ITAGeo::CEmitterInhomogeneous>(ray.SourcePoint(), ray.InitialDirection()));
for (int idx = 1; idx < ray.size(); idx++)
{
position = ray[idx].position;
......@@ -72,9 +72,9 @@ namespace ITAPropagationPathSim
}
return propagationPath;
}
};
ITAGeo::CPropagationPathList ToPropagationPath(const std::vector<std::shared_ptr<CRay>>& vpRays)
ITA_PROPAGATION_PATH_SIM_API inline ITAGeo::CPropagationPathList ToPropagationPath(const std::vector<std::shared_ptr<CRay>>& vpRays)
{
ITAGeo::CPropagationPathList propagationPathList;
propagationPathList.reserve(vpRays.size());
......@@ -83,11 +83,11 @@ namespace ITAPropagationPathSim
if (!pRay)
continue;
propagationPathList.push_back( ToPropagationPath(*pRay) );
propagationPathList.push_back(ToPropagationPath(*pRay));
}
return propagationPathList;
}
};
}
}
}
......
......@@ -17,21 +17,21 @@ EigenraySearch::CAdaptiveRayGrid::CAdaptiveRayGrid(const CRayGrid& rayGrid) : CR
void EigenraySearch::CAdaptiveRayGrid::Init()
{
vpNewRaysOfLastAdaptation.clear();
for (int idx = 1; idx < vdThetaDeg.size(); idx++)
m_vpNewRaysOfLastAdaptation.clear();
for (int idx = 1; idx < m_vdThetaDeg.size(); idx++)
{
double deltaTheta = vdThetaDeg[idx] - vdThetaDeg[idx - 1];
if (dMaxDeltaTheta < deltaTheta)
dMaxDeltaTheta = deltaTheta;
double deltaTheta = m_vdThetaDeg[idx] - m_vdThetaDeg[idx - 1];
if (m_dMaxDeltaTheta < deltaTheta)
m_dMaxDeltaTheta = deltaTheta;
}
for (int idx = 1; idx < vdPhiDeg.size(); idx++)
for (int idx = 1; idx < m_vdPhiDeg.size(); idx++)
{
double deltaPhi = vdPhiDeg[idx] - vdPhiDeg[idx - 1];
double deltaPhi = m_vdPhiDeg[idx] - m_vdPhiDeg[idx - 1];
if (deltaPhi < 0)
deltaPhi += 360;
if (dMaxDeltaPhi < deltaPhi)
dMaxDeltaPhi = deltaPhi;
if (m_dMaxDeltaPhi < deltaPhi)
m_dMaxDeltaPhi = deltaPhi;
}
}
......@@ -74,30 +74,30 @@ void CAdaptiveRayGrid::ZoomIntoRay(const std::shared_ptr<CRay> pZoomRay, const d
if (deltaTheta <= 0 || deltaPhi <= 0)
ITA_EXCEPT_INVALID_PARAMETER("Delta angles must be positive numbers > 0.");
const double thetaDeg = vdThetaDeg[ IndexToThetaIndex(idx) ];
const double phiDeg = vdPhiDeg[ IndexToPhiIndex(idx) ];
const double thetaDeg = m_vdThetaDeg[ IndexToThetaIndex(idx) ];
const double phiDeg = m_vdPhiDeg[ IndexToPhiIndex(idx) ];
int idxRayTheta = 1; int idxRayPhi = 1;
vdThetaDeg = { thetaDeg - deltaTheta, thetaDeg, thetaDeg + deltaTheta };
vdPhiDeg = { phiDeg - deltaPhi, phiDeg, phiDeg + deltaPhi };
if (vdThetaDeg.front() < 0)
m_vdThetaDeg = { thetaDeg - deltaTheta, thetaDeg, thetaDeg + deltaTheta };
m_vdPhiDeg = { phiDeg - deltaPhi, phiDeg, phiDeg + deltaPhi };
if (m_vdThetaDeg.front() < 0)
{
vdThetaDeg.erase(vdThetaDeg.begin());
m_vdThetaDeg.erase(m_vdThetaDeg.begin());
idxRayTheta = 0;
}
if (vdThetaDeg.back() > 180)
vdThetaDeg.pop_back();
if (m_vdThetaDeg.back() > 180)
m_vdThetaDeg.pop_back();
RayMatrix newRayMatrix(NTheta(), RayVector(NPhi()));
vpNewRaysOfLastAdaptation.clear();
for (int idxTheta = 0; idxTheta < vdThetaDeg.size(); idxTheta++)
m_vpNewRaysOfLastAdaptation.clear();
for (int idxTheta = 0; idxTheta < m_vdThetaDeg.size(); idxTheta++)
{
for (int idxPhi = 0; idxPhi < vdPhiDeg.size(); idxPhi++)
for (int idxPhi = 0; idxPhi < m_vdPhiDeg.size(); idxPhi++)
{
RayPtr pCurrentRay;
if (idxRayTheta == idxTheta && idxRayPhi == idxPhi)
pCurrentRay = pZoomRay;
else if ( IsPoleDirection(vdThetaDeg[idxTheta]) && (idxRayTheta==idxTheta || idxPhi > 0) )
else if ( IsPoleDirection(m_vdThetaDeg[idxTheta]) && (idxRayTheta==idxTheta || idxPhi > 0) )
{
if (idxTheta == idxRayTheta)
pCurrentRay = pZoomRay;
......@@ -106,8 +106,8 @@ void CAdaptiveRayGrid::ZoomIntoRay(const std::shared_ptr<CRay> pZoomRay, const d
}
else
{
pCurrentRay = std::make_shared<CRay>(v3SourcePos, vdThetaDeg[idxTheta], vdPhiDeg[idxPhi]);
vpNewRaysOfLastAdaptation.insert(pCurrentRay);
pCurrentRay = std::make_shared<CRay>(m_v3SourcePos, m_vdThetaDeg[idxTheta], m_vdPhiDeg[idxPhi]);
m_vpNewRaysOfLastAdaptation.insert(pCurrentRay);
}
newRayMatrix[idxTheta][idxPhi] = pCurrentRay;
......@@ -167,21 +167,21 @@ void CAdaptiveRayGrid::DoubleRayResolution()
DoublePhiResolution();
RayMatrix newRayMatrix( NTheta(), RayVector( NPhi() ) );
vpNewRaysOfLastAdaptation.clear();
m_vpNewRaysOfLastAdaptation.clear();
RayVector::const_iterator iteratorOldRays = Rays().cbegin();
for (int idxTheta = 0; idxTheta < vdThetaDeg.size(); idxTheta++)
for (int idxTheta = 0; idxTheta < m_vdThetaDeg.size(); idxTheta++)
{
const bool isNewTheta = (idxTheta % 2) == 1;
for (int idxPhi = 0; idxPhi < vdPhiDeg.size(); idxPhi++)
for (int idxPhi = 0; idxPhi < m_vdPhiDeg.size(); idxPhi++)
{
const bool isNewPhi = (idxPhi % 2) == 1;
RayPtr pRay;
if (IsPoleDirection(vdThetaDeg[idxTheta]))
if (IsPoleDirection(m_vdThetaDeg[idxTheta]))
pRay = Matrix()[idxTheta/2].front(); //Int-Division to convert to theta index of old matrix
else if (isNewTheta || isNewPhi)
{
pRay = std::make_shared<CRay>(v3SourcePos, vdThetaDeg[idxTheta], vdPhiDeg[idxPhi]);
vpNewRaysOfLastAdaptation.insert(pRay);
pRay = std::make_shared<CRay>(m_v3SourcePos, m_vdThetaDeg[idxTheta], m_vdPhiDeg[idxPhi]);
m_vpNewRaysOfLastAdaptation.insert(pRay);
}
else
pRay = *iteratorOldRays;
......@@ -197,36 +197,36 @@ void CAdaptiveRayGrid::DoubleRayResolution()
void CAdaptiveRayGrid::DoubleThetaResolution()
{
if (vdThetaDeg.size() < 2)
if (m_vdThetaDeg.size() < 2)
return;
std::vector<double> newAngleVector;
newAngleVector.reserve(2 * vdThetaDeg.size() - 1);
newAngleVector.push_back(vdThetaDeg.front());
for (int idxAngle = 1; idxAngle < vdThetaDeg.size(); idxAngle++)
newAngleVector.reserve(2 * m_vdThetaDeg.size() - 1);
newAngleVector.push_back(m_vdThetaDeg.front());
for (int idxAngle = 1; idxAngle < m_vdThetaDeg.size(); idxAngle++)
{
const double& angle1 = vdThetaDeg[idxAngle - 1];
const double& angle2 = vdThetaDeg[idxAngle];
const double& angle1 = m_vdThetaDeg[idxAngle - 1];
const double& angle2 = m_vdThetaDeg[idxAngle];
newAngleVector.push_back((angle1 + angle2) / 2);
newAngleVector.push_back(angle2);
}
vdThetaDeg = newAngleVector;
dMaxDeltaTheta /= 2;
m_vdThetaDeg = newAngleVector;
m_dMaxDeltaTheta /= 2;
}
void CAdaptiveRayGrid::DoublePhiResolution()
{
if (vdPhiDeg.size() < 2)
if (m_vdPhiDeg.size() < 2)
return;
std::vector<double> newAngleVector;
newAngleVector.reserve(2 * vdPhiDeg.size() - 1 + IsCircular());
newAngleVector.push_back(vdPhiDeg.front());
for (int idxAngle = 1; idxAngle < vdPhiDeg.size(); idxAngle++)
newAngleVector.reserve(2 * m_vdPhiDeg.size() - 1 + IsCircular());
newAngleVector.push_back(m_vdPhiDeg.front());
for (int idxAngle = 1; idxAngle < m_vdPhiDeg.size(); idxAngle++)
{
const double& angle1 = vdPhiDeg[idxAngle - 1];
const double& angle2 = vdPhiDeg[idxAngle];
const double& angle1 = m_vdPhiDeg[idxAngle - 1];
const double& angle2 = m_vdPhiDeg[idxAngle];
double newAngle = (angle1 + angle2) / 2;
if (angle2 < angle1)
newAngle = std::fmod(newAngle + 180, 360);
......@@ -235,13 +235,13 @@ void CAdaptiveRayGrid::DoublePhiResolution()
}
if (IsCircular())
{
double newAngle = (vdPhiDeg.front() + vdPhiDeg.back()) / 2;
if (vdPhiDeg.front() < vdPhiDeg.back())
double newAngle = (m_vdPhiDeg.front() + m_vdPhiDeg.back()) / 2;
if (m_vdPhiDeg.front() < m_vdPhiDeg.back())
newAngle = std::fmod(newAngle + 180, 360);
newAngleVector.push_back(newAngle);
}
vdPhiDeg = newAngleVector;
dMaxDeltaPhi /= 2;
m_vdPhiDeg = newAngleVector;
m_dMaxDeltaPhi /= 2;
}
#pragma endregion
\ No newline at end of file
......@@ -42,22 +42,22 @@ void EigenraySearch::CEigenraySearchWatcher::FinalizeRay(std::shared_ptr<CRay> p
#pragma region WORKERBASE
EigenraySearch::CWorkerBase::CWorkerBase(const VistaVector3D& sourcePosition, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const RayTracingAbortSettings& abortSettings)
: v3SourcePosition(sourcePosition)
, v3ReceiverPosition(receiverPosition)
, rayTracingAbortSettings(abortSettings)
, v3MirroredReceiverPosition(receiverPosition)
: m_v3SourcePosition(sourcePosition)
, m_v3ReceiverPosition(receiverPosition)
, m_rayTracingAbortSettings(abortSettings)
, m_v3MirroredReceiverPosition(receiverPosition)
{
simulationEngine.settings = simSettings;
v3MirroredReceiverPosition[Vista::Z] = -v3MirroredReceiverPosition[Vista::Z];
m_simulationEngine.settings = simSettings;
m_v3MirroredReceiverPosition[Vista::Z] = -m_v3MirroredReceiverPosition[Vista::Z];
}
const VistaVector3D& EigenraySearch::CWorkerBase::VirtualReceiverPosition(const int reflectionOrder) const
{
if (reflectionOrder % 2 != 0) //On uneven reflection order
return v3MirroredReceiverPosition;
return v3ReceiverPosition;
return m_v3MirroredReceiverPosition;
return m_v3ReceiverPosition;
}
EigenraySearch::RayPtr EigenraySearch::CWorkerBase::FindMinimumDistanceRay(const std::set<RayPtr>& rays, const int reflectionOrder)
EigenraySearch::RayPtr EigenraySearch::CWorkerBase::FindMinimumDistanceRay(const std::set<RayPtr>& rays, const int reflectionOrder) const
{
float dMin = FLT_MAX;
const VistaVector3D& receiverPos = VirtualReceiverPosition(reflectionOrder);
......@@ -82,21 +82,21 @@ EigenraySearch::CInitialWorker::CInitialWorker(const VistaVector3D& sourcePositi
: CWorkerBase(sourcePosition, receiverPosition, simSettings, abortSettings)
{
ReceiverDataVector receiverData = { CReceiverData(ReceiverPosition(), 0) , CReceiverData(MirroredReceiverPosition(), 1) };
m_pSimulationWatcher = std::make_shared<CEigenraySearchWatcher>(receiverData, rayTracingAbortSettings.maxTime);
simulationEngine.pExternalWatcher = m_pSimulationWatcher;
m_pSimulationWatcher = std::make_shared<CEigenraySearchWatcher>(receiverData, m_rayTracingAbortSettings.maxTime);
m_simulationEngine.pExternalWatcher = m_pSimulationWatcher;
}
std::vector<CRayGrid> EigenraySearch::CInitialWorker::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
CRayGrid rayGrid = InitRayGrid(atmosphere);
simulationEngine.Run(atmosphere, rayGrid.UniqueRays());
m_simulationEngine.Run(atmosphere, rayGrid.UniqueRays());
FindMinimumDistanceRays(rayGrid.UniqueRays());
return FinalizeResult(rayGrid);
}
CRayGrid EigenraySearch::CInitialWorker::InitRayGrid(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
return CEquiangularRayDistribution(v3SourcePosition, 7, 10);
return CEquiangularRayDistribution(m_v3SourcePosition, 7, 10);
//TODO: Set limits for additional directions according to atmosphere if possible
}
void EigenraySearch::CInitialWorker::FindMinimumDistanceRays(const std::set<RayPtr>& rays)
......@@ -115,16 +115,16 @@ void EigenraySearch::CInitialWorker::FindMinimumDistanceRays(const std::set<RayP
//}
//maxReflOrder = std::min(maxReflOrder, rayTracingAbortSettings.maxReflectionOrder);
int maxReflOrder = std::min(1, rayTracingAbortSettings.maxReflectionOrder);
int maxReflOrder = std::min(1, m_rayTracingAbortSettings.maxReflectionOrder);
vpMinDistanceRays.resize(maxReflOrder + 1);
m_vpMinDistanceRays.resize(maxReflOrder + 1);
for (int reflOrder = 0; reflOrder <= maxReflOrder; reflOrder++)
vpMinDistanceRays[reflOrder] = FindMinimumDistanceRay(rays, reflOrder);
m_vpMinDistanceRays[reflOrder] = FindMinimumDistanceRay(rays, reflOrder);
}
std::vector<CRayGrid> EigenraySearch::CInitialWorker::FinalizeResult(const CRayGrid& initialRayGrid)
{
std::vector<CRayGrid> rayGridsOfReflectionOrder;
for each (RayPtr pRay in vpMinDistanceRays)
for each (RayPtr pRay in m_vpMinDistanceRays)
rayGridsOfReflectionOrder.push_back(initialRayGrid.SurroundingGrid(pRay).CopyWithNewRays());
return rayGridsOfReflectionOrder;
......@@ -136,43 +136,43 @@ std::vector<CRayGrid> EigenraySearch::CInitialWorker::FinalizeResult(const CRayG
EigenraySearch::CAdaptiveWorker::CAdaptiveWorker(const CRayGrid& rayGrid, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const Settings& eigenraySettings, const int activeReflectionOrder)
: CWorkerBase(rayGrid.SourcePosition(), receiverPosition, simSettings, eigenraySettings.rayTracing),
adaptiveRayGrid(rayGrid), iActiveReflexionOrder(activeReflectionOrder), rayAdaptationSettings(eigenraySettings.rayAdaptation)
m_adaptiveRayGrid(rayGrid), m_iActiveReflexionOrder(activeReflectionOrder), m_rayAdaptationSettings(eigenraySettings.rayAdaptation)
{
const float sourceReceiverDistance = (VirtualReceiverPosition() - rayGrid.SourcePosition()).GetLength();
fReceiverRadius = tan(rayAdaptationSettings.accuracy.maxSourceReceiverAngle * M_PI/180.0) * sourceReceiverDistance;
fReceiverRadius = fmin(rayAdaptationSettings.accuracy.maxReceiverRadius, fReceiverRadius);
m_fReceiverRadius = tan(m_rayAdaptationSettings.accuracy.maxSourceReceiverAngle * M_PI/180.0) * sourceReceiverDistance;
m_fReceiverRadius = fmin(m_rayAdaptationSettings.accuracy.maxReceiverRadius, m_fReceiverRadius);
//TODO: Track whether distance increased and use this for abortion
ReceiverDataVector receiverData = { CReceiverData(VirtualReceiverPosition(), iActiveReflexionOrder) };
m_pSimulationWatcher = std::make_shared<CEigenraySearchWatcher>(receiverData, rayTracingAbortSettings.maxTime);
simulationEngine.pExternalWatcher = m_pSimulationWatcher;
ReceiverDataVector receiverData = { CReceiverData(VirtualReceiverPosition(), m_iActiveReflexionOrder) };
m_pSimulationWatcher = std::make_shared<CEigenraySearchWatcher>(receiverData, m_rayTracingAbortSettings.maxTime);
m_simulationEngine.pExternalWatcher = m_pSimulationWatcher;
}
EigenraySearch::RayPtr EigenraySearch::CAdaptiveWorker::Run(const ITAGeo::CStratifiedAtmosphere& atmosphere)
{
simulationEngine.Run(atmosphere, adaptiveRayGrid.UniqueRays());
pMinDistanceRay = FindMinimumDistanceRay(adaptiveRayGrid.UniqueRays(), iActiveReflexionOrder);
m_simulationEngine.Run(atmosphere, m_adaptiveRayGrid.UniqueRays());
m_pMinDistanceRay = FindMinimumDistanceRay(m_adaptiveRayGrid.UniqueRays(), m_iActiveReflexionOrder);
while (!EigenrayAccuracyReached())
{
adaptiveRayGrid.ZoomIntoRay(pMinDistanceRay);
simulationEngine.Run(atmosphere, adaptiveRayGrid.NewRaysOfLastAdaptation());
pMinDistanceRay = FindMinimumDistanceRay(adaptiveRayGrid.UniqueRays(), iActiveReflexionOrder);
nAdaptations++;
m_adaptiveRayGrid.ZoomIntoRay(m_pMinDistanceRay);
m_simulationEngine.Run(atmosphere, m_adaptiveRayGrid.NewRaysOfLastAdaptation());
m_pMinDistanceRay = FindMinimumDistanceRay(m_adaptiveRayGrid.UniqueRays(), m_iActiveReflexionOrder);
m_nAdaptations++;
}
PostProcessEigenray(atmosphere);
return pMinDistanceRay;
return m_pMinDistanceRay;
}
bool EigenraySearch::CAdaptiveWorker::EigenrayAccuracyReached()
{
const CRayReceiverData* receiverData = pMinDistanceRay->ReceiverDistanceData(VirtualReceiverPosition());
if (receiverData && receiverData->distance <= fReceiverRadius)
const CRayReceiverData* receiverData = m_pMinDistanceRay->ReceiverDistanceData(VirtualReceiverPosition());
if (receiverData && receiverData->distance <= m_fReceiverRadius)
return true;
bool abort = nAdaptations > rayAdaptationSettings.abort.maxNAdaptations
|| adaptiveRayGrid.MaxAngularResolution() < rayAdaptationSettings.abort.minAngleResolutionDeg;
bool abort = m_nAdaptations > m_rayAdaptationSettings.abort.maxNAdaptations
|| m_adaptiveRayGrid.MaxAngularResolution() < m_rayAdaptationSettings.abort.minAngleResolutionDeg;
if (abort)
std::cout << "WARNING: EigenraySearch::Engine: Could not find eigenray with proper accuracy. Abort criterion reached." << std::endl;
return abort;
......@@ -184,42 +184,42 @@ void EigenraySearch::CAdaptiveWorker::PostProcessEigenray(const ITAGeo::CStratif
}
void EigenraySearch::CAdaptiveWorker::SetEigenrayEndPoint()
{
const CRayReceiverData* receiverData = pMinDistanceRay->ReceiverDistanceData(VirtualReceiverPosition());
const CRayReceiverData* receiverData = m_pMinDistanceRay->ReceiverDistanceData(VirtualReceiverPosition());
const int idxBeforeMin = receiverData->idxMinDist;
const VistaVector3D& rMin = receiverData->posMinDist;
//Interpolate to new point of minimum
const VistaVector3D& r1 = pMinDistanceRay->at(idxBeforeMin).position;
const VistaVector3D& r2 = pMinDistanceRay->at(idxBeforeMin + 1).position;
const VistaVector3D& r1 = m_pMinDistanceRay->at(idxBeforeMin).position;
const VistaVector3D& r2 = m_pMinDistanceRay->at(idxBeforeMin + 1).position;
const float pathFraction = (rMin - r1).GetLength() / (r2 - r1).GetLength();
CRayElement newRayElement = pMinDistanceRay->at(idxBeforeMin).Interpolate(pMinDistanceRay->at(idxBeforeMin + 1), pathFraction);
CRayElement newRayElement = m_pMinDistanceRay->at(idxBeforeMin).Interpolate(m_pMinDistanceRay->at(idxBeforeMin + 1), pathFraction);
//Remove all points before and add new point
pMinDistanceRay->resize(idxBeforeMin + 2);
pMinDistanceRay->back() = newRayElement;