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

ART - Rays

- bugfixes in ReceiverDistanceData
- added reflection index to receiver distance data

ART - Eigenray Worker
- now uses max / active reflection order + 1 as abort criterion for ray tracing
parent 898f071b
......@@ -53,10 +53,11 @@ namespace ITAPropagationPathSim
public:
float distance;
int idxMinDist;
int reflectionOrder;
VistaVector3D posMinDist;
inline CRayReceiverData() : idxMinDist(-1), distance(-1), posMinDist(VistaVector3D()) {}
inline CRayReceiverData(const int iMin, const float dMin, const VistaVector3D& rMin = VistaVector3D()) : idxMinDist(iMin), distance(dMin), posMinDist(rMin) {}
inline CRayReceiverData() : idxMinDist(-1), distance(-1), reflectionOrder(-1), posMinDist(VistaVector3D()) {}
inline CRayReceiverData(const int iMin, const float dMin, const int reflOrder, const VistaVector3D& rMin = VistaVector3D()) : idxMinDist(iMin), distance(dMin), reflectionOrder(reflOrder), posMinDist(rMin) {}
};
class ITA_PROPAGATION_PATH_SIM_API CRay : public std::vector<CRayElement>
......@@ -66,7 +67,8 @@ namespace ITAPropagationPathSim
std::vector<unsigned int> iReflectionIndices;
typedef const VistaVector3D* ReceiverPositionPtr;
std::map<ReceiverPositionPtr, CRayReceiverData> mReceiverDistanceMap;
typedef std::map<ReceiverPositionPtr, CRayReceiverData> ReceiverDistanceMap;
ReceiverDistanceMap mReceiverDistanceMap;
public:
CRay(const VistaVector3D& v3SourcePos, const double& thetaDeg, const double& phiDeg);
......@@ -86,6 +88,8 @@ namespace ITAPropagationPathSim
const double& LastTimeStamp() const { return back().timeStamp; }
unsigned int ReflectionOrder() const { return iReflectionIndices.size(); }
//! Returns the reflection order of the ray element with given index
int ReflectionOrder(const int idx) const;
#pragma endregion
//! Appends a new element with position, wavefront normal and timestamp to the ray
......@@ -110,7 +114,8 @@ namespace ITAPropagationPathSim
//MINIMUM RECEIVER DISTANCE
public:
//! Returns a pointer to ray receiver distance data for the given receiver position. Returns nullptr if data does not exist.
const CRayReceiverData* ReceiverDistanceData(const VistaVector3D& receiverPos);
const CRayReceiverData* ReceiverDistanceData(const VistaVector3D& receiverPos) const;
//! Updates the distance to given receiver using the last point of the ray. Returns true if distance became smaller.
/**
* To be called after each integration step.
......
......@@ -102,7 +102,7 @@ EigenraySearch::RayPtr EigenraySearch::CWorkerBase::FindMinimumDistanceRay(const
bool EigenraySearch::CInitialWorker::AbortRequested(const RayPtr& pRay) const
{
return pRay->LastTimeStamp() >= rayTracingAbortSettings.maxTime || pRay->ReflectionOrder() > rayTracingAbortSettings.maxReflectionOrder;
return pRay->LastTimeStamp() >= rayTracingAbortSettings.maxTime || pRay->ReflectionOrder() > rayTracingAbortSettings.maxReflectionOrder+1;
}
void EigenraySearch::CInitialWorker::UpdateMinimumReceiverDistance(RayPtr& pRay) const
{
......@@ -119,6 +119,7 @@ std::vector<CRayGrid> EigenraySearch::CInitialWorker::Run(const ITAGeo::CStratif
{
CRayGrid rayGrid = InitRayGrid(atmosphere);
simulationEngine.Run(atmosphere, rayGrid.UniqueRays());
//FindMinimumDistanceRays(rayGrid.UniqueRays()); //TODO: convert to std::set
return FinalizeResult(rayGrid);
}
CRayGrid EigenraySearch::CInitialWorker::InitRayGrid(const ITAGeo::CStratifiedAtmosphere& atmosphere)
......@@ -128,12 +129,15 @@ CRayGrid EigenraySearch::CInitialWorker::InitRayGrid(const ITAGeo::CStratifiedAt
}
void EigenraySearch::CInitialWorker::FindMinimumDistanceRays(const RayVector& rays)
{
unsigned int maxReflOrder = 0;
int maxReflOrder = 0;
for each (const RayPtr & ray in rays)
maxReflOrder = std::max( ray->ReflectionOrder(), maxReflOrder );
maxReflOrder = std::min(maxReflOrder, rayTracingAbortSettings.maxReflectionOrder);
{
maxReflOrder = std::max( ray->ReceiverDistanceData( ReceiverPosition() )->reflectionOrder, maxReflOrder);
maxReflOrder = std::max( ray->ReceiverDistanceData( MirroredReceiverPosition() )->reflectionOrder, maxReflOrder);
}
maxReflOrder = std::min((unsigned int)maxReflOrder, rayTracingAbortSettings.maxReflectionOrder);
maxReflOrder = std::min(1U, rayTracingAbortSettings.maxReflectionOrder);
//maxReflOrder = std::min(1U, rayTracingAbortSettings.maxReflectionOrder);
vpMinDistanceRays.resize(maxReflOrder + 1);
for (int reflOrder = 0; reflOrder <= maxReflOrder; reflOrder++)
......@@ -154,7 +158,7 @@ std::vector<CRayGrid> EigenraySearch::CInitialWorker::FinalizeResult(const CRayG
bool EigenraySearch::CAdaptiveWorker::AbortRequested(const RayPtr& pRay) const
{
return pRay->LastTimeStamp() >= rayTracingAbortSettings.maxTime || pRay->ReflectionOrder() > rayTracingAbortSettings.maxReflectionOrder;
return pRay->LastTimeStamp() >= rayTracingAbortSettings.maxTime || pRay->ReflectionOrder() > iActiveReflexionOrder+1;
}
EigenraySearch::CAdaptiveWorker::CAdaptiveWorker(const CRayGrid& rayGrid, const VistaVector3D& receiverPosition, const Simulation::Settings& simSettings, const Settings& eigenraySettings, const int activeReflectionOrder)
......
......@@ -32,6 +32,19 @@ CRay::CRay(const VistaVector3D& v3SourcePos, const VistaVector3D& v3Direction)
Append(v3SourcePos, v3Direction.GetNormalized(), 0.0);
}
//int CRay::ReflectionOrder(const int idx) const
//{
// if (idx < 0 || idx >= NumPoints())
// return -1;
//
// auto reflOrderIt = std::lower_bound(iReflectionIndices.cbegin(), iReflectionIndices.cend(), idx);
// if (reflOrderIt == iReflectionIndices.cend())
// return NumPoints() - 1;
// return *reflOrderIt;
//}
void CRay::Append(const VistaVector3D& position, const VistaVector3D& wavefrontNormal, const double& timeStamp)
{
push_back( CRayElement(position, wavefrontNormal, timeStamp) );
......@@ -105,11 +118,13 @@ CRay::const_iterator CRay::IteratorAfterTime(const double& time) const
// ----RECEIVER DISTANCE----
// -------------------------
#pragma region Receiver distance
const CRayReceiverData* CRay::ReceiverDistanceData(const VistaVector3D& receiverPos)
const CRayReceiverData* CRay::ReceiverDistanceData(const VistaVector3D& receiverPos) const
{
if (mReceiverDistanceMap.find(&receiverPos) == mReceiverDistanceMap.cend()) //Receiver not yet in map
ReceiverDistanceMap::const_iterator receiverDataIt = mReceiverDistanceMap.find(&receiverPos);
if (receiverDataIt == mReceiverDistanceMap.cend()) //Receiver not yet in map
return nullptr;
return &mReceiverDistanceMap[&receiverPos];
return &receiverDataIt->second;
}
......@@ -118,15 +133,17 @@ bool CRay::UpdateMinimumReceiverDistance(const VistaVector3D& receiverPos)
float distance = (LastPoint() - receiverPos).GetLength();
if (mReceiverDistanceMap.find(&receiverPos) == mReceiverDistanceMap.cend()) //Receiver not yet in map
{
mReceiverDistanceMap[&receiverPos] = CRayReceiverData(NumPoints() - 1, distance);
mReceiverDistanceMap[&receiverPos] = CRayReceiverData(NumPoints() - 1, distance, ReflectionOrder());
return true;
}
if (distance >= mReceiverDistanceMap[&receiverPos].distance)
CRayReceiverData& receiverDistanceData = mReceiverDistanceMap[&receiverPos];
if (distance >= receiverDistanceData.distance)
return false;
mReceiverDistanceMap[&receiverPos].distance = distance;
mReceiverDistanceMap[&receiverPos].idxMinDist = NumPoints() - 1;
receiverDistanceData.distance = distance;
receiverDistanceData.idxMinDist = NumPoints() - 1;
receiverDistanceData.reflectionOrder = ReflectionOrder();
return true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment