Applying class changes from ITAGeo; Also improving filter enginge, still WIP

parent cd2695d0
......@@ -13,6 +13,7 @@
#include <ITAException.h>
#include <ITAISO9613.h>
#include <ITAFiniteImpulseResponse.h>
// Vista includes
#include <VistaMath/VistaGeometries.h>
......@@ -193,6 +194,7 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA
double dScalarMagnitude; //For the combination of all scalar filter components
ITABase::CThirdOctaveFactorMagnitudeSpectrum oThirdOctFactors; // For the combination of all third octave filter components
ITABase::CFiniteImpulseResponse oIR(oHDFTSpectra.GetDFTSize(), (float)oHDFTSpectra.GetSampleRate(), false);
for (auto& oPath : oPathList)
{
......@@ -202,7 +204,7 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA
ITA_EXCEPT_INVALID_PARAMETER("Encountered a path with no geometrical distance, could not generate filter");
//Include sound energy decrease due to the length of the path @todo this might get more complex with diffraction
dScalarMagnitude = 1/dPathLength;
dScalarMagnitude = 1 / dPathLength;
// Air attenuation according to ISO9613-1 (overrides third octaves, so no resetting required, do not change order!)
ITABase::ISO9613::AtmosphericAbsorption(oThirdOctFactors, (float)dPathLength, oEnvironmentState.dTemperature, oEnvironmentState.dHumidity);
......@@ -228,7 +230,7 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA
if (pEmitter->pDirectivity)
{
const VistaVector3D v3Dir( pNextAnchor->v3InteractionPoint - pEmitter->v3InteractionPoint);
const VistaVector3D v3Dir(pNextAnchor->v3InteractionPoint - pEmitter->v3InteractionPoint);
ITAGeo::Coordinates::CSpherical oDirection(v3Dir, m_iCoordinateSystemConvention);
switch (pEmitter->pDirectivity->GetFormat())
{
......@@ -243,32 +245,60 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA
}
}
}
/*
if (pAnchor->pAcousticMaterial->GetType() == ITAGeo::Material::IMaterial::SCALAR)
}
case(ITAGeo::CPropagationAnchor::ACOUSTIC_SENSOR):
{
auto pSensor = std::dynamic_pointer_cast<const ITAGeo::CSensor>(pAnchor);
if (i > 0)
ITA_EXCEPT_INVALID_PARAMETER("Propagation path invalid: detected a sensor anchor point at the beginning of the path (without a predecessor).");
auto pPreviousAnchor(oPath[i - 1]);
if (pSensor->pDirectivity)
{
//Type cast of the acoustic material
auto pScalarMaterial = std::dynamic_pointer_cast<ITAGeo::Material::CScalarMaterial>(pAnchor->pAcousticMaterial);
const VistaVector3D v3Dir(pPreviousAnchor->v3InteractionPoint - pSensor->v3InteractionPoint);
ITAGeo::Coordinates::CSpherical oDirection(v3Dir, m_iCoordinateSystemConvention);
switch (pSensor->pDirectivity->GetFormat())
{
case(ITAGeo::Directivity::IDirectivity::OPENDAFF):
{
auto pDAFFDirectivity = std::dynamic_pointer_cast<const ITAGeo::Directivity::CDAFF_Format>(pSensor->pDirectivity);
if (pDAFFDirectivity->GetDomain() == ITADomain::ITA_FREQUENCY_DOMAIN)
{
auto pDAFFDirectivityMS = std::dynamic_pointer_cast<const ITAGeo::Directivity::CDAFF_MagnitudeSpectrum>(pSensor->pDirectivity);
pDAFFDirectivityMS->MultiplyNearestNeighbourMagnitudeSpectrum(oDirection, oThirdOctFactors);
}
else if (pDAFFDirectivity->GetDomain() == ITADomain::ITA_TIME_DOMAIN)
{
auto pDAFFDirectivityIR = std::dynamic_pointer_cast<const ITAGeo::Directivity::CDAFF_ImpulseResponse>(pSensor->pDirectivity);
// @todo jst
/*
pDAFFDirectivityIR->GetNearestNeighbourImpulseResponse(oDirection, oIR);
if (pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION)
fScalarMagnitude *= (float)abs(pScalarMaterial->cdReflectionFactor);
else
fScalarMagnitude *= (float)abs(pScalarMaterial->cdTransmissionFactor);
*/
}
}
//case(ITAGeo::Directivity::IDirectivity::???):
}
}
*/
}
/*
if( pAnchor->pAcousticMaterial->GetType() == ITAGeo::Material::IMaterial::THIRD_OCTAVE )
case(ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION):
{
//Type cast of the acoustic material
auto pThirdOctaveMaterial = std::dynamic_pointer_cast< ITAGeo::Material::CThirdOctaveMaterial >( pAnchor->pAcousticMaterial );
//Multiply the scale values of the respective bands
for( int i = 0; i < pThirdOctaveMaterial->GetNumBands(); i++ )
auto pReflection = std::dynamic_pointer_cast<const ITAGeo::CSpecularReflection>(pAnchor);
if (pReflection->pMaterial)
{
oThirdOctFactors[ i ] *= pThirdOctaveMaterial->GetTransmissionFactor( i );
// @todo jst: switch() case: include octave resolution
if (pReflection->pMaterial->GetType() == ITAGeo::Material::IMaterial::THIRD_OCTAVE)
{
//Type cast of the acoustic material
auto pThirdOctaveMaterial = std::dynamic_pointer_cast<ITAGeo::Material::CThirdOctaveMaterial>(pReflection->pMaterial);
//Multiply the scale values of the respective bands
for (int j = 0; j < pThirdOctaveMaterial->GetNumBands(); j++)
oThirdOctFactors[j] *= pThirdOctaveMaterial->GetTransmissionFactor(j);
}
}
}
*/
}
}
......
......@@ -32,8 +32,8 @@ float ITAPropagationModels::Utils::EstimateFilterLengthSamples(const ITAGeo::CPr
case ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION:
{
auto p = std::dynamic_pointer_cast<const ITAGeo::CSpecularReflection>(a);
if (p->pAcousticMaterial)
fEstimatedFilterLengthSamples += ITAGeo::Material::Utils::EstimateFilterLengthSamples(p->pAcousticMaterial, fSampleRate, fSpeedOfSound);
if (p->pMaterial)
fEstimatedFilterLengthSamples += ITAGeo::Material::Utils::EstimateFilterLengthSamples(p->pMaterial, fSampleRate, fSpeedOfSound);
break;
}
default:
......
......@@ -49,7 +49,7 @@ int main( int, char** )
auto pMaterialDirectory = std::make_shared< Material::CDirectory >( "./" );
auto pReflection = make_shared< CSpecularReflection >( VistaVector3D( 0.0f, 2.0f, 0.0f ) );
pReflection->pAcousticMaterial = pMaterialDirectory->GetMaterial( "stonewall" );
pReflection->pMaterial = pMaterialDirectory->GetMaterial( "stonewall" );
auto pW = std::make_shared< CITADiffractionOuterWedgeAperture >();
pW->v3AperturePoint.SetValues( 0.0f, 1.0f, 0.0f );
......
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