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

ART - RayGrid & Ray

- removed multiple bugs where base constructors where called within constructor body

ART - RayGrid & AdaptiveRayGrid
- UniqueRays() now returns const reference
parent 8302fc6e
...@@ -44,7 +44,7 @@ namespace ITAPropagationPathSim ...@@ -44,7 +44,7 @@ namespace ITAPropagationPathSim
void Reset(const CRayGrid& rayGrid); void Reset(const CRayGrid& rayGrid);
CRayGrid RayGrid() { return *this; } CRayGrid RayGrid() { return *this; }
std::set< std::shared_ptr<CRay> > UniqueRays() { return CRayGrid::UniqueRays(); } const std::set< std::shared_ptr<CRay> >& UniqueRays() { return CRayGrid::UniqueRays(); }
const std::set< std::shared_ptr<CRay> >& NewRaysOfLastAdaptation() { return vpNewRaysOfLastAdaptation; } const std::set< std::shared_ptr<CRay> >& NewRaysOfLastAdaptation() { return vpNewRaysOfLastAdaptation; }
//! Simple adaptation method: Setting the limits to neighboring rays and shoots additional rays to double the angular resolution of the grid. //! Simple adaptation method: Setting the limits to neighboring rays and shoots additional rays to double the angular resolution of the grid.
......
...@@ -59,6 +59,10 @@ namespace ITAPropagationPathSim ...@@ -59,6 +59,10 @@ namespace ITAPropagationPathSim
private: private:
CRayGrid(const RayMatrix& rayMatrix, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi = false); CRayGrid(const RayMatrix& rayMatrix, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi = false);
void UpdateDependentRayContainers(); void UpdateDependentRayContainers();
protected:
inline CRayGrid(bool circularPhi = false) : bCircularPhi(circularPhi) {}
//! Creates new rays using the angles of initial directions and inserts them into the ray matrix
void InitRays();
public: 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°. //! 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°.
/** /**
...@@ -66,8 +70,8 @@ namespace ITAPropagationPathSim ...@@ -66,8 +70,8 @@ namespace ITAPropagationPathSim
* Note, that both vectors with angles will be sorted before creating the rays. * 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); CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& thetaDeg, const std::vector<double>& phiDeg, const bool circularPhi = false);
protected: protected:
CRayGrid() {}
//! Updates the ray matrix and depenent vectors/set of rays. //! Updates the ray matrix and depenent vectors/set of rays.
void SetRayMatrix(const RayMatrix& newRayMatrix); void SetRayMatrix(const RayMatrix& newRayMatrix);
//! Filters for certain rays using indices for theta and phi. //! Filters for certain rays using indices for theta and phi.
...@@ -104,7 +108,7 @@ namespace ITAPropagationPathSim ...@@ -104,7 +108,7 @@ namespace ITAPropagationPathSim
inline int NPhi() const { return vdPhiDeg.size(); } inline int NPhi() const { return vdPhiDeg.size(); }
inline int NRays() const { return vpRays.size(); } inline int NRays() const { return vpRays.size(); }
inline const VistaVector3D& SourcePosition() const { return v3SourcePos; } inline const VistaVector3D& SourcePosition() const { return v3SourcePos; }
inline std::set<std::shared_ptr<CRay>> UniqueRays() const { return vpUniqueRays; } inline const std::set<std::shared_ptr<CRay>>& UniqueRays() const { return vpUniqueRays; }
//! Returns a ray grid containing the rays surrounding the given ray (including this ray). //! Returns a ray grid containing the rays surrounding the given ray (including this ray).
/** /**
......
...@@ -36,20 +36,7 @@ CRayGrid::CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& th ...@@ -36,20 +36,7 @@ CRayGrid::CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& th
if ( (vdPhiDeg.back() - vdPhiDeg.front()) >= 360.0) if ( (vdPhiDeg.back() - vdPhiDeg.front()) >= 360.0)
ITA_EXCEPT_INVALID_PARAMETER("Delta for azimuth angle phi is >= 360"); ITA_EXCEPT_INVALID_PARAMETER("Delta for azimuth angle phi is >= 360");
vvpRayMatrix.resize( NTheta() ); InitRays();
for (int idxTheta = 0; idxTheta < NTheta(); idxTheta++)
{
vvpRayMatrix[idxTheta] = std::vector< std::shared_ptr<CRay>>( NPhi());
bool isPoleDirection = (abs(vdThetaDeg[idxTheta]) < DBL_EPSILON || abs(vdThetaDeg[idxTheta] - 180.0) < DBL_EPSILON);
for (int idxPhi = 0; idxPhi < NPhi(); idxPhi++)
{
if (isPoleDirection && idxPhi > 0) //At poles: Insert same ray multiple times
vvpRayMatrix[idxTheta][idxPhi] = vvpRayMatrix[idxTheta].front();
else
vvpRayMatrix[idxTheta][idxPhi] = std::make_shared<CRay>(sourcePos, vdThetaDeg[idxTheta], vdPhiDeg[idxPhi]);
}
}
UpdateDependentRayContainers();
} }
...@@ -57,8 +44,10 @@ CRayGrid::CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& th ...@@ -57,8 +44,10 @@ CRayGrid::CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& th
CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nAngles) CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nAngles)
: CEquiangularRayDistribution(sourcePos, nAngles, nAngles) {} : CEquiangularRayDistribution(sourcePos, nAngles, nAngles) {}
CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nTheta, const int nPhi) CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int nTheta, const int nPhi) : CRayGrid(true)
{ {
v3SourcePos = sourcePos;
vdThetaDeg.reserve(nTheta); vdThetaDeg.reserve(nTheta);
const double deltaTheta = 180.0 / (nTheta - 1); const double deltaTheta = 180.0 / (nTheta - 1);
for (int idx = 0; idx < nTheta - 1; idx++) for (int idx = 0; idx < nTheta - 1; idx++)
...@@ -67,10 +56,10 @@ CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& so ...@@ -67,10 +56,10 @@ CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& so
vdPhiDeg.reserve(nPhi); vdPhiDeg.reserve(nPhi);
const double deltaPhi = 360.0 / nPhi; const double deltaPhi = 360.0 / nPhi;
for (int idx = 0; idx < nPhi - 1; idx++) for (int idx = 0; idx < nPhi; idx++)
vdPhiDeg.push_back(idx * deltaPhi); vdPhiDeg.push_back(idx * deltaPhi);
CRayGrid(sourcePos, vdThetaDeg, vdPhiDeg, true); InitRays();
} }
#pragma endregion #pragma endregion
...@@ -89,6 +78,22 @@ void CRayGrid::UpdateDependentRayContainers() ...@@ -89,6 +78,22 @@ void CRayGrid::UpdateDependentRayContainers()
vpUniqueRays = std::set<RayPtr>(vpRays.begin(), vpRays.end()); vpUniqueRays = std::set<RayPtr>(vpRays.begin(), vpRays.end());
} }
void CRayGrid::InitRays()
{
vvpRayMatrix.resize(NTheta(), RayVector(NPhi()));
for (int idxTheta = 0; idxTheta < NTheta(); idxTheta++)
{
const bool isPoleDirection = IsPoleDirection(vdThetaDeg[idxTheta]);
for (int idxPhi = 0; idxPhi < NPhi(); idxPhi++)
{
if (isPoleDirection && idxPhi > 0) //At poles: Insert same ray multiple times
vvpRayMatrix[idxTheta][idxPhi] = vvpRayMatrix[idxTheta].front();
else
vvpRayMatrix[idxTheta][idxPhi] = std::make_shared<CRay>(v3SourcePos, vdThetaDeg[idxTheta], vdPhiDeg[idxPhi]);
}
}
UpdateDependentRayContainers();
}
#pragma endregion #pragma endregion
......
...@@ -15,7 +15,7 @@ CRay::CRay(const VistaVector3D& v3SourcePos, const double& thetaDeg, const doubl ...@@ -15,7 +15,7 @@ CRay::CRay(const VistaVector3D& v3SourcePos, const double& thetaDeg, const doubl
const double phiRad = phiDeg * M_PI / 180; const double phiRad = phiDeg * M_PI / 180;
const double cosTheta = std::cos(thetaRad); const double cosTheta = std::cos(thetaRad);
auto v3Direction = VistaVector3D(cosTheta * std::cos(phiRad), cosTheta * std::sin(phiRad), std::sin(thetaRad)); auto v3Direction = VistaVector3D(cosTheta * std::cos(phiRad), cosTheta * std::sin(phiRad), std::sin(thetaRad));
CRay(v3SourcePos, v3Direction); Append(v3SourcePos, v3Direction.GetNormalized(), 0.0);
} }
CRay::CRay(const VistaVector3D& v3SourcePos, const VistaVector3D& v3Direction) CRay::CRay(const VistaVector3D& v3SourcePos, const VistaVector3D& v3Direction)
{ {
......
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