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

ART - RayGrid

- added function to filter for rays using indices for theta and phi
- also added functions to get rays of same theta/phi respectively
parent 8f92cfc6
......@@ -35,6 +35,10 @@ namespace ITAPropagationPathSim
{
namespace AtmosphericRayTracing
{
//! This class represents a set of rays which is ordered in a grid (matrix) referring to the angles of initial direction (theta and phi)
/**
* This special arrangement of rays allows to find the direct neigbors of any ray in this grid.
*/
class ITA_PROPAGATION_PATH_SIM_API CRayGrid
{
protected:
......@@ -53,14 +57,27 @@ namespace ITAPropagationPathSim
private:
CRayGrid(const RayMatrix& rayMatrix, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi = false);
public:
//! Creates a set of rays using a source position and the given elevation and azimuth angles [°] for the inital directions. An optional bool indicates whether the azimuth angle covers the full 360°.
/**
* For each combination of theta and phi, one ray is created and stored.
* Note, that both vectors with angles will be sorted before creating the rays.
*/
CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi = false);
protected:
CRayGrid() {}
void InitRayVectorFromRayMatrix();
//! Filters for certain rays using indices for theta and phi.
void FilterDirections(const std::vector<int>& thetaIdxVec, const std::vector<int>& phiIdxVec, const bool circularPhi = false);
//! Returns a vector with all rays having the same initial elevation as the given ray. Throws an exception if the ray is not part of this grid.
const RayVector& GetRaysWithSameTheta(const std::shared_ptr<CRay>& pRay);
//! Returns a vector with all rays having the same initial azimuth as the given ray. Throws an exception if the ray is not part of this grid.
RayVector GetRaysWithSamePhi(const std::shared_ptr<CRay>& pRay);
private:
int GetIndex(const std::shared_ptr<CRay>& pRay) const;
int IndexToThetaIndex(const int idx) const;
int IndexToPhiIndex(const int idx) const;
int GetIndex(const std::shared_ptr<CRay>& pRay) const;
void GetNeighboringAngleIndices(const std::shared_ptr<CRay>& pRay, std::vector<int>& thetaIdxVec, std::vector<int>& phiIdxVec) const;
bool HasPoleDirection(const std::shared_ptr<CRay>& pRay) const;
......@@ -92,10 +109,13 @@ namespace ITAPropagationPathSim
CRayGrid CopyWithNewRays() const;
};
//! A special CRayGrid with an equiangular distribution
class ITA_PROPAGATION_PATH_SIM_API CEquiangularRayDistribution : public CRayGrid
{
public:
CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nAngles) : CEquiangularRayDistribution(sourcePos, nAngles, nAngles) {}
//! Creates an equiangular ray distribution with N rays along elevation and azimuth respectively
CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nAngles);
//! Creates an equiangular ray distribution with N1 rays along elevation and N2 rays along azimuth
CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nTheta, const int nPhi);
};
}
......
......@@ -51,9 +51,6 @@ namespace ITAPropagationPathSim
{
private:
//std::vector<VistaVector3D> v3SamplingPoints;
//std::vector<VistaVector3D> v3WavefrontNormals;
//std::vector<double> dTimeStamps;
std::vector<unsigned int> iReflectionIndices;
public:
......
......@@ -52,6 +52,11 @@ CRayGrid::CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& th
InitRayVectorFromRayMatrix();
}
CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nAngles)
: CEquiangularRayDistribution(sourcePos, nAngles, nAngles) {}
CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nTheta, const int nPhi)
{
vdThetaDeg.reserve(nTheta);
......@@ -85,6 +90,52 @@ void CRayGrid::InitRayVectorFromRayMatrix()
#pragma endregion
void CRayGrid::FilterDirections(const std::vector<int>& thetaIdxVec, const std::vector<int>& phiIdxVec, const bool circularPhi /*= false*/)
{
auto newThetaDeg = std::vector<double>(thetaIdxVec.size());
auto newPhiDeg = std::vector<double>(phiIdxVec.size());
RayMatrix newRayMatrix = RayMatrix(thetaIdxVec.size(), RayVector(phiIdxVec.size()));
for each (int idxPhi in phiIdxVec)
newPhiDeg[idxPhi] = vdPhiDeg[idxPhi];
for each (int idxTheta in thetaIdxVec)
{
newThetaDeg[idxTheta] = vdThetaDeg[idxTheta];
for each (int idxPhi in phiIdxVec)
newRayMatrix[idxTheta][idxPhi] = vvpRayMatrix[idxTheta][idxPhi];
}
bCircularPhi = bCircularPhi & circularPhi;
vdThetaDeg = newThetaDeg;
vdPhiDeg = newPhiDeg;
vvpRayMatrix = newRayMatrix;
InitRayVectorFromRayMatrix();
}
const CRayGrid::RayVector& CRayGrid::GetRaysWithSameTheta(const std::shared_ptr<CRay>& pRay)
{
const int idxTheta = IndexToThetaIndex( GetIndex(pRay) );
if (idxTheta < 0)
ITA_EXCEPT_INVALID_PARAMETER("Given ray is not part of this ray grid.");
return vvpRayMatrix[idxTheta];
}
CRayGrid::RayVector CRayGrid::GetRaysWithSamePhi(const std::shared_ptr<CRay>& pRay)
{
const int idxPhi = IndexToPhiIndex(GetIndex(pRay));
if (idxPhi < 0)
ITA_EXCEPT_INVALID_PARAMETER("Given ray is not part of this ray grid.");
RayVector thetaRays(NTheta());
for (int idx = 0; idx < NTheta(); idx++)
thetaRays[idx] = vvpRayMatrix[idx][idxPhi];
return thetaRays;
}
// --- PUBLIC ---
// --------------
......@@ -92,7 +143,7 @@ void CRayGrid::InitRayVectorFromRayMatrix()
CRayGrid CRayGrid::GetSurroundingGrid(const std::shared_ptr<CRay>& pRay) const
{
if (!Contains(pRay))
return CRayGrid();
ITA_EXCEPT_INVALID_PARAMETER("Given ray is not part of this ray grid.");
std::vector<int> thetaIdxVec;
std::vector<int> phiIdxVec;
......@@ -131,6 +182,15 @@ CRayGrid CRayGrid::CopyWithNewRays() const
// --- PROTECTED HELPERS ---
// -------------------------
#pragma region INDICING
int CRayGrid::GetIndex(const std::shared_ptr<CRay>& pRay) const
{
auto it = std::find(vpRays.cbegin(), vpRays.cend(), pRay);
if (it == vpRays.cend())
return -1;
return std::distance(vpRays.cbegin(), it);
}
int CRayGrid::IndexToThetaIndex(const int idx) const
{
if (idx < 0 || idx >= vpRays.size())
......@@ -145,14 +205,6 @@ int CRayGrid::IndexToPhiIndex(const int idx) const
return idx % NPhi();
}
int CRayGrid::GetIndex(const std::shared_ptr<CRay>& pRay) const
{
auto it = std::find(vpRays.cbegin(), vpRays.cend(), pRay);
if (it == vpRays.cend())
return -1;
return std::distance(vpRays.cbegin(), it);
}
void CRayGrid::GetNeighboringAngleIndices(const std::shared_ptr<CRay>& pRay, std::vector<int>& thetaIdxVec, std::vector<int>& phiIdxVec) const
{
......
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