Commit f0d68036 authored by Armin Erraji's avatar Armin Erraji

Added the function ApplyAcousticModels() and therefore the function...

Added the function ApplyAcousticModels() and therefore the function ApplyDiffractionModel() and ApplyReflectionModel().
parent 7238a84d
......@@ -68,10 +68,21 @@ namespace ITAPropagationModels
//! Applies all acoustic models like reflection diffraction models
void ApplyAcousticModels( ITAGeo::CPropagationPathList& oPathList );
void ApplyDiffractionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = 1 );
void ApplyReflectionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = 1 );
//!Applies diffraction models
/**
* @param[out] oPathList Propagation path list
* @param[in] iModel Acoustic material model type. If value is set to -1, the default material model is used.
*/
void ApplyDiffractionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = -1);
//!Applies reflection models
/**
* @param[out] oPathList Propagation path list
* @param[in] iModel Acoustic material model type. If value is set to -1, the default material model is used.
*/
void ApplyReflectionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = -1 );
void ApplyTransmissionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = 1 ); // @todo
void ApplyTransmissionModel( ITAGeo::CPropagationPathList& oPathList, int iModel = -1 ); // @todo
//! Generate multi-channel propagation path (for multi-channel receiver directivitiy)
/**
......@@ -92,9 +103,11 @@ namespace ITAPropagationModels
unique_ptr<ITABase::CHDFTSpectra> m_pAccumulatedSpectra; //!< Gathered propagation paths from list
unique_ptr<ITABase::CHDFTSpectra> m_pTempPropPathSpectra; //!< Single prop-path spectra
static struct m_DefaultReflectionModel //!< Default values for reflections
static struct m_DefaultModels //!< Default values
{
int iModel = 1;
static const int iReflectionModel = ITAGeo::IAcousticMaterial::SCALAR;
static const int iDiffractionModel = ITAGeo::IAcousticMaterial::THIRD_OCTAVE;
};
static struct m_DefaultDiffractionModel //!< Default values for diffractions
......
......@@ -3,6 +3,7 @@
// ITA includes
#include <ITAException.h>
#include <ITAGeo/Halfedge/MeshModel.h>
#include <ITAPropagationModels/UTD.h>
// Vista includes
#include <VistaMath/VistaGeometries.h>
......@@ -61,17 +62,80 @@ bool CFilterEngine::HasSameSensorAnchor(const ITAGeo::CPropagationPathList& oPat
void CFilterEngine::ApplyAcousticModels(ITAGeo::CPropagationPathList & oPathList)
{
ITA_EXCEPT_NOT_IMPLEMENTED;
//Apply reflection model
ApplyReflectionModel(oPathList);
//Apply diffraction model
ApplyDiffractionModel(oPathList);
}
void CFilterEngine::ApplyDiffractionModel(ITAGeo::CPropagationPathList & oPathList, int iModel)
{
ITA_EXCEPT_NOT_IMPLEMENTED;
for (auto& oPath : oPathList)
{
//Iterate over all anchors except the first and last anchor
for (size_t i = 1; i <= oPath.size() - 2; i++)
{
auto pLastAnchor = oPath[i - 1];
auto pCurrentAnchor = oPath[i];
auto pNextAnchor = oPath[i + 1];
//If the anchor is a reflection and the acoustic material is not set yet, set it to default values
if ((pCurrentAnchor->iAnchorType == ITAGeo::CPropagationAnchor::DIFFRACTION_APEX) && (pCurrentAnchor->pAcousticMaterial == NULL))
{
auto pApex = std::dynamic_pointer_cast<ITAGeo::CITADiffractionWedgeAperture>(pCurrentAnchor);
if (m_DefaultModels::iDiffractionModel == ITAGeo::IAcousticMaterial::THIRD_OCTAVE)
{
auto pAcousticMaterial = make_shared<ITAGeo::CThirdOctaveMaterial>();
auto vfFrequencies = pAcousticMaterial->oAbsorptionCoefficients.GetCenterFrequencies();
vector<float> vfAbsorptionCoeffs;
for (auto fFrequency : vfFrequencies)
{
const float fWaveNumberRad = 2.0f * ITAConstants::PI_F * fFrequency / 344.0; //TODO: Change speed of sound value
complex <float> cfDiffractionCoeff;
UTD::CalculateDiffractionCoefficient(pLastAnchor->v3InteractionPoint, pNextAnchor->v3InteractionPoint, pApex, fWaveNumberRad, cfDiffractionCoeff);
vfAbsorptionCoeffs.push_back(1.0f - abs(cfDiffractionCoeff));
}
pAcousticMaterial->oAbsorptionCoefficients.SetMagnitudes(vfAbsorptionCoeffs);
pApex->pAcousticMaterial = pAcousticMaterial;
}
else
{
ITA_EXCEPT_NOT_IMPLEMENTED;
}
}
}
}
}
void CFilterEngine::ApplyReflectionModel(ITAGeo::CPropagationPathList & oPathList, int iModel)
{
ITA_EXCEPT_NOT_IMPLEMENTED;
for (auto& oPath : oPathList)
{
for (auto& pAnchor : oPath)
{
//If the anchor is a reflection and the acoustic material is not set yet, set it to default values
if ((pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION) && (pAnchor->pAcousticMaterial == NULL))
{
if (m_DefaultModels::iReflectionModel == ITAGeo::IAcousticMaterial::SCALAR)
{
//Set material with default values(current reflection factor: 0.7. See constructor of CScalarMaterial)
pAnchor->pAcousticMaterial = make_shared<ITAGeo::CScalarMaterial>();
}
else //if (m_DefaultModels::iReflectionModel == ITAGeo::IAcousticMaterial::THIRD_OCTAVE)
{
ITA_EXCEPT_NOT_IMPLEMENTED;
}
}
}
}
}
void CFilterEngine::ApplyTransmissionModel(ITAGeo::CPropagationPathList & oPathList, int iModel)
......
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