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

ART - CRay

- added bool to ray receiver data which indicates whether receiver distance was updated during last integration step
- added function check whether any receiver data was updated on last time step
parent dae2bf62
......@@ -51,13 +51,14 @@ namespace ITAPropagationPathSim
class ITA_PROPAGATION_PATH_SIM_API CRayReceiverData {
public:
bool bDistanceUpdatedInLastIt; //< indicates whether receiver distance was updated in last during last integration step
float distance;
int idxMinDist;
int reflectionOrder;
VistaVector3D posMinDist;
inline CRayReceiverData() : idxMinDist(-1), distance(-1), reflectionOrder(-1), posMinDist(VistaVector3D()) {};
inline CRayReceiverData(int iMin, float dMin, int reflOrder, const VistaVector3D& rMin = VistaVector3D()) : idxMinDist(iMin), distance(dMin), reflectionOrder(reflOrder), posMinDist(rMin) {};
inline CRayReceiverData() : idxMinDist(-1), distance(-1), reflectionOrder(-1), posMinDist(VistaVector3D()), bDistanceUpdatedInLastIt(false) {};
inline CRayReceiverData(int iMin, float dMin, int reflOrder, const VistaVector3D& rMin = VistaVector3D()) : idxMinDist(iMin), distance(dMin), reflectionOrder(reflOrder), posMinDist(rMin), bDistanceUpdatedInLastIt(true){};
};
class ITA_PROPAGATION_PATH_SIM_API CRay : public std::vector<CRayElement>
......@@ -90,7 +91,7 @@ namespace ITAPropagationPathSim
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;
//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 m_dSpreadingLoss; };
......@@ -125,7 +126,11 @@ namespace ITAPropagationPathSim
/**
* To be called after each integration step.
*/
bool UpdateMinimumReceiverDistance(const VistaVector3D& receiverPos);
void UpdateMinimumReceiverDistance(const VistaVector3D& receiverPos);
//! Returns true if the receiver distance has been updated for at least one receiver during the last integration time step.
bool ReceiverDistanceUpdatedOnLastTimeStep();
//! Increases the accuracy of each receiver distance using a linear interpolation to adjacent ray points.
/**
* To be called after the ray tracing has been finished.
......
......@@ -128,23 +128,38 @@ const CRayReceiverData* CRay::ReceiverDistanceData(const VistaVector3D& receiver
}
bool CRay::UpdateMinimumReceiverDistance(const VistaVector3D& receiverPos)
void CRay::UpdateMinimumReceiverDistance(const VistaVector3D& receiverPos)
{
float distance = (LastPoint() - receiverPos).GetLength();
if (m_mReceiverDistanceMap.find(&receiverPos) == m_mReceiverDistanceMap.cend()) //Receiver not yet in map
{
m_mReceiverDistanceMap[&receiverPos] = CRayReceiverData(NumPoints() - 1, distance, ReflectionOrder());
return true;
return;
}
CRayReceiverData& receiverDistanceData = m_mReceiverDistanceMap[&receiverPos];
if (distance >= receiverDistanceData.distance)
return false;
{
receiverDistanceData.bDistanceUpdatedInLastIt = false;
}
else
{
receiverDistanceData.distance = distance;
receiverDistanceData.idxMinDist = NumPoints() - 1;
receiverDistanceData.reflectionOrder = ReflectionOrder();
receiverDistanceData.bDistanceUpdatedInLastIt = true;
}
}
receiverDistanceData.distance = distance;
receiverDistanceData.idxMinDist = NumPoints() - 1;
receiverDistanceData.reflectionOrder = ReflectionOrder();
return true;
bool CRay::ReceiverDistanceUpdatedOnLastTimeStep()
{
for (auto const& element : m_mReceiverDistanceMap)
{
const CRayReceiverData receiverData = element.second;
if (receiverData.bDistanceUpdatedInLastIt)
return true;
}
return false;
}
void CRay::FinalizeMinimumReceiverDistances()
......
Markdown is supported
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