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
void Reset(const CRayGrid& rayGrid);
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; }
//! 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
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) {}
//! Creates new rays using the angles of initial directions and inserts them into the ray matrix
void InitRays();
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°.
/**
......@@ -66,8 +70,8 @@ namespace ITAPropagationPathSim
* 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() {}
//! Updates the ray matrix and depenent vectors/set of rays.
void SetRayMatrix(const RayMatrix& newRayMatrix);
//! Filters for certain rays using indices for theta and phi.
......@@ -104,7 +108,7 @@ namespace ITAPropagationPathSim
inline int NPhi() const { return vdPhiDeg.size(); }
inline int NRays() const { return vpRays.size(); }
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).
/**
......
......@@ -36,20 +36,7 @@ CRayGrid::CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& th
if ( (vdPhiDeg.back() - vdPhiDeg.front()) >= 360.0)
ITA_EXCEPT_INVALID_PARAMETER("Delta for azimuth angle phi is >= 360");
vvpRayMatrix.resize( NTheta() );
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();
InitRays();
}
......@@ -57,8 +44,10 @@ CRayGrid::CRayGrid(const VistaVector3D& sourcePos, const std::vector<double>& th
CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& sourcePos, const int 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);
const double deltaTheta = 180.0 / (nTheta - 1);
for (int idx = 0; idx < nTheta - 1; idx++)
......@@ -67,10 +56,10 @@ CEquiangularRayDistribution::CEquiangularRayDistribution(const VistaVector3D& so
vdPhiDeg.reserve(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);
CRayGrid(sourcePos, vdThetaDeg, vdPhiDeg, true);
InitRays();
}
#pragma endregion
......@@ -89,6 +78,22 @@ void CRayGrid::UpdateDependentRayContainers()
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
......
......@@ -15,7 +15,7 @@ CRay::CRay(const VistaVector3D& v3SourcePos, const double& thetaDeg, const doubl
const double phiRad = phiDeg * M_PI / 180;
const double cosTheta = std::cos(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)
{
......
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