Applying major changes in directivity and material managers

parent b1f7c2c7
...@@ -136,10 +136,10 @@ namespace ITAPropagationModels ...@@ -136,10 +136,10 @@ namespace ITAPropagationModels
}; };
//! Sets a connection to the material manager //! Sets a connection to the material manager
void SetMaterialManager(const ITAGeo::Material::IManager* pMaterialManager); void SetMaterialManager( std::shared_ptr< const ITAGeo::Material::IManager > );
// Returns pointer to material manager or null // Returns pointer to material manager or null
const ITAGeo::Material::IManager* GetMaterialManager() const; std::shared_ptr< const ITAGeo::Material::IManager > GetMaterialManager() const;
private: private:
......
...@@ -39,8 +39,7 @@ int CFilterEngine::GetNumSensorChannels(const ITAGeo::CPropagationPathList& oPat ...@@ -39,8 +39,7 @@ int CFilterEngine::GetNumSensorChannels(const ITAGeo::CPropagationPathList& oPat
//Cast the sensor that is always the last propagation anchor of a path //Cast the sensor that is always the last propagation anchor of a path
auto pSensor = std::dynamic_pointer_cast<ITAGeo::CSensor>(oPathList[0][oPathList[0].size() - 1]); auto pSensor = std::dynamic_pointer_cast<ITAGeo::CSensor>(oPathList[0][oPathList[0].size() - 1]);
return pSensor->GetNumChannels();
return pSensor->iNumChannels;
} }
bool CFilterEngine::ValidateSameSensor(const ITAGeo::CPropagationPathList& oPathList) bool CFilterEngine::ValidateSameSensor(const ITAGeo::CPropagationPathList& oPathList)
...@@ -124,9 +123,9 @@ void CFilterEngine::ApplyDiffractionModel(ITAGeo::CPropagationPathList & oPathLi ...@@ -124,9 +123,9 @@ void CFilterEngine::ApplyDiffractionModel(ITAGeo::CPropagationPathList & oPathLi
{ {
auto pApex = std::dynamic_pointer_cast<ITAGeo::CITADiffractionWedgeApertureBase>(pCurrentAnchor); auto pApex = std::dynamic_pointer_cast<ITAGeo::CITADiffractionWedgeApertureBase>(pCurrentAnchor);
if (iDiffractionModelResolution == ITAGeo::IMaterial::THIRD_OCTAVE) if (iDiffractionModelResolution == ITAGeo::Material::IMaterial::THIRD_OCTAVE)
{ {
auto pAcousticMaterial = make_shared<ITAGeo::CThirdOctaveMaterial>(); auto pAcousticMaterial = make_shared<ITAGeo::Material::CThirdOctaveMaterial>();
auto vfFrequencies = pAcousticMaterial->oAbsorptionCoefficients.GetCenterFrequencies(); auto vfFrequencies = pAcousticMaterial->oAbsorptionCoefficients.GetCenterFrequencies();
...@@ -170,10 +169,10 @@ void CFilterEngine::ApplyReflectionModel(ITAGeo::CPropagationPathList & oPathLis ...@@ -170,10 +169,10 @@ void CFilterEngine::ApplyReflectionModel(ITAGeo::CPropagationPathList & oPathLis
//If the anchor is a reflection and the acoustic material is not set yet, set it to default values //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 ((pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION) && (pAnchor->pAcousticMaterial == NULL))
{ {
if (iReflectionModel == ITAGeo::IMaterial::SCALAR) if (iReflectionModel == ITAGeo::Material::IMaterial::SCALAR)
{ {
//Set material with default values(current reflection factor: 0.7. See constructor of CScalarMaterial) //Set material with default values(current reflection factor: 0.7. See constructor of CScalarMaterial)
pAnchor->pAcousticMaterial = make_shared<ITAGeo::CScalarMaterial>(); pAnchor->pAcousticMaterial = make_shared<ITAGeo::Material::CScalarMaterial>();
} }
else //if (m_DefaultValues::iReflectionModel == ITAGeo::IAcousticMaterial::THIRD_OCTAVE) else //if (m_DefaultValues::iReflectionModel == ITAGeo::IAcousticMaterial::THIRD_OCTAVE)
{ {
...@@ -200,10 +199,10 @@ void ITAPropagationModels::CFilterEngine::ApplyEmitterModel(ITAGeo::CPropagation ...@@ -200,10 +199,10 @@ void ITAPropagationModels::CFilterEngine::ApplyEmitterModel(ITAGeo::CPropagation
{ {
if (oPath[0]->pAcousticMaterial == NULL) if (oPath[0]->pAcousticMaterial == NULL)
{ {
if (iEmitterModel == ITAGeo::IMaterial::SCALAR) if( iEmitterModel == ITAGeo::Material::IMaterial::SCALAR )
{ {
//Set material with factor 1.0 //Set material with factor 1.0
auto pAcousticMaterial = make_shared<ITAGeo::CScalarMaterial>(); auto pAcousticMaterial = make_shared<ITAGeo::Material::CScalarMaterial>();
pAcousticMaterial->cdTransmissionFactor = 1.0f; pAcousticMaterial->cdTransmissionFactor = 1.0f;
pAcousticMaterial->cdReflectionFactor = 0.0f; pAcousticMaterial->cdReflectionFactor = 0.0f;
...@@ -228,7 +227,7 @@ void ITAPropagationModels::CFilterEngine::ApplyEmitterModel(ITAGeo::CPropagation ...@@ -228,7 +227,7 @@ void ITAPropagationModels::CFilterEngine::ApplyEmitterModel(ITAGeo::CPropagation
void ITAPropagationModels::CFilterEngine::ApplySensorModel(ITAGeo::CPropagationPathList & oPathList, int iModel) void ITAPropagationModels::CFilterEngine::ApplySensorModel(ITAGeo::CPropagationPathList & oPathList, int iModel)
{ {
//Check for correct structur of oPathList //Check for correct structur of oPathList
if (!HasSameSensorAnchor(oPathList)) if (!ValidateSameSensor(oPathList))
ITA_EXCEPT1(INVALID_PARAMETER, "The propagation path list has multiple sensor anchors or last anchor of paths is not a sensor."); ITA_EXCEPT1(INVALID_PARAMETER, "The propagation path list has multiple sensor anchors or last anchor of paths is not a sensor.");
int iSensorModel; int iSensorModel;
...@@ -236,8 +235,6 @@ void ITAPropagationModels::CFilterEngine::ApplySensorModel(ITAGeo::CPropagationP ...@@ -236,8 +235,6 @@ void ITAPropagationModels::CFilterEngine::ApplySensorModel(ITAGeo::CPropagationP
iSensorModel = m_oDefaultResolutions.iSensorModel; iSensorModel = m_oDefaultResolutions.iSensorModel;
else else
iSensorModel = iModel; iSensorModel = iModel;
} }
void ITAPropagationModels::CFilterEngine::SetMaterialManager( std::shared_ptr< const ITAGeo::Material::IManager > pMaterialManager) void ITAPropagationModels::CFilterEngine::SetMaterialManager( std::shared_ptr< const ITAGeo::Material::IManager > pMaterialManager)
...@@ -245,7 +242,7 @@ void ITAPropagationModels::CFilterEngine::SetMaterialManager( std::shared_ptr< c ...@@ -245,7 +242,7 @@ void ITAPropagationModels::CFilterEngine::SetMaterialManager( std::shared_ptr< c
m_pMaterialManager = pMaterialManager; m_pMaterialManager = pMaterialManager;
} }
const ITAGeo::Material::IManager* ITAPropagationModels::CFilterEngine::GetMaterialManager() const std::shared_ptr< const ITAGeo::Material::IManager > ITAPropagationModels::CFilterEngine::GetMaterialManager() const
{ {
return m_pMaterialManager; return m_pMaterialManager;
} }
...@@ -305,10 +302,10 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA ...@@ -305,10 +302,10 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA
//Set scalar and third octave filter components of the propagation anchors //Set scalar and third octave filter components of the propagation anchors
for (auto& pAnchor : oPath) for (auto& pAnchor : oPath)
{ {
if (pAnchor->pAcousticMaterial->GetType() == ITAGeo::IMaterial::SCALAR) if (pAnchor->pAcousticMaterial->GetType() == ITAGeo::Material::IMaterial::SCALAR)
{ {
//Type cast of the acoustic material //Type cast of the acoustic material
auto pScalarMaterial = dynamic_pointer_cast<ITAGeo::CScalarMaterial>(pAnchor->pAcousticMaterial); auto pScalarMaterial = std::dynamic_pointer_cast<ITAGeo::Material::CScalarMaterial>(pAnchor->pAcousticMaterial);
if (pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION) if (pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION)
fScalarMagnitude *= (float)abs(pScalarMaterial->cdReflectionFactor); fScalarMagnitude *= (float)abs(pScalarMaterial->cdReflectionFactor);
...@@ -316,10 +313,10 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA ...@@ -316,10 +313,10 @@ void CFilterEngine::Generate(const ITAGeo::CPropagationPathList & oPathList, ITA
fScalarMagnitude *= (float)abs(pScalarMaterial->cdTransmissionFactor); fScalarMagnitude *= (float)abs(pScalarMaterial->cdTransmissionFactor);
} }
if (pAnchor->pAcousticMaterial->GetType() == ITAGeo::IMaterial::THIRD_OCTAVE) if (pAnchor->pAcousticMaterial->GetType() == ITAGeo::Material::IMaterial::THIRD_OCTAVE)
{ {
//Type cast of the acoustic material //Type cast of the acoustic material
auto pThirdOctaveMaterial = dynamic_pointer_cast<ITAGeo::CThirdOctaveMaterial>(pAnchor->pAcousticMaterial); auto pThirdOctaveMaterial = std::dynamic_pointer_cast<ITAGeo::Material::CThirdOctaveMaterial>(pAnchor->pAcousticMaterial);
//Multiply the scale values of the respective bands //Multiply the scale values of the respective bands
for (int i = 0; i < pThirdOctaveMaterial->GetNumBands(); i++) for (int i = 0; i < pThirdOctaveMaterial->GetNumBands(); i++)
......
...@@ -47,9 +47,9 @@ int main( int, char** ) ...@@ -47,9 +47,9 @@ int main( int, char** )
auto pSender = make_shared< CEmitter >( VistaVector3D( -2.0f, 0.0f, 0.0f ) ); auto pSender = make_shared< CEmitter >( VistaVector3D( -2.0f, 0.0f, 0.0f ) );
auto pReceiver = make_shared< CSensor >( VistaVector3D( 2.0f, 0.0f, 0.0f ) ); auto pReceiver = make_shared< CSensor >( VistaVector3D( 2.0f, 0.0f, 0.0f ) );
CMaterialDirectory oMaterialDirectory( "./" ); auto pMaterialDirectory = std::make_shared< Material::CDirectory >( "./" );
auto pReflection = make_shared< CSpecularReflection >( VistaVector3D( 0.0f, 2.0f, 0.0f ) ); auto pReflection = make_shared< CSpecularReflection >( VistaVector3D( 0.0f, 2.0f, 0.0f ) );
pReflection->pAcousticMaterial = oMaterialDirectory.GetMaterial( "stonewall" ); pReflection->pAcousticMaterial = pMaterialDirectory->GetMaterial( "stonewall" );
auto pW = std::make_shared< CITADiffractionOuterWedgeAperture >(); auto pW = std::make_shared< CITADiffractionOuterWedgeAperture >();
pW->v3AperturePoint.SetValues( 0.0f, 1.0f, 0.0f ); pW->v3AperturePoint.SetValues( 0.0f, 1.0f, 0.0f );
...@@ -80,7 +80,7 @@ int main( int, char** ) ...@@ -80,7 +80,7 @@ int main( int, char** )
oPathList.push_back(oPathDiffraction); oPathList.push_back(oPathDiffraction);
CFilterEngine oFilterEngine; CFilterEngine oFilterEngine;
oFilterEngine.SetMaterialManager( &oMaterialDirectory ); oFilterEngine.SetMaterialManager( pMaterialDirectory );
// Set filter length according to the maximum path length // Set filter length according to the maximum path length
const float fSpeedOfSound = SPEED_OF_SOUND_F; //Approximation of speed of sound at ~20C const float fSpeedOfSound = SPEED_OF_SOUND_F; //Approximation of speed of sound at ~20C
...@@ -88,7 +88,7 @@ int main( int, char** ) ...@@ -88,7 +88,7 @@ int main( int, char** )
int iFilterLengthSamples = ( int ) ( oPathList.GetMaxLength() / fSpeedOfSound * fSampleRate ); int iFilterLengthSamples = ( int ) ( oPathList.GetMaxLength() / fSpeedOfSound * fSampleRate );
iFilterLengthSamples = int( iFilterLengthSamples + 4096 ); iFilterLengthSamples = int( iFilterLengthSamples + 4096 );
ITABase::CHDFTSpectra oTransmissionFilter( fSampleRate, pReceiver->iNumChannels, iFilterLengthSamples ); ITABase::CHDFTSpectra oTransmissionFilter( fSampleRate, pReceiver->GetNumChannels(), iFilterLengthSamples );
bool bDFTDegreeTooSmallFlag; bool bDFTDegreeTooSmallFlag;
oFilterEngine.ApplyAcousticModels( oPathList ); // @todo aer remove / merge into Generate() oFilterEngine.ApplyAcousticModels( oPathList ); // @todo aer remove / merge into Generate()
oFilterEngine.Generate( oPathList, oTransmissionFilter, &bDFTDegreeTooSmallFlag ); oFilterEngine.Generate( oPathList, oTransmissionFilter, &bDFTDegreeTooSmallFlag );
......
...@@ -57,7 +57,7 @@ int main( int, char** ) ...@@ -57,7 +57,7 @@ int main( int, char** )
int iFilterLengthSamples = (int)(oPathFromLeft.GetLength() / fSpeedOfSound * fSampleRate); int iFilterLengthSamples = (int)(oPathFromLeft.GetLength() / fSpeedOfSound * fSampleRate);
iFilterLengthSamples = int(iFilterLengthSamples + 4096); iFilterLengthSamples = int(iFilterLengthSamples + 4096);
ITABase::CHDFTSpectra oTransmissionFilterLeft(fSampleRate, pReceiver->iNumChannels, iFilterLengthSamples); ITABase::CHDFTSpectra oTransmissionFilterLeft(fSampleRate, pReceiver->GetNumChannels(), iFilterLengthSamples);
bool bDFTDegreeTooSmallFlag; bool bDFTDegreeTooSmallFlag;
oFilterEngine.ApplyAcousticModels(oPathFromLeft); // @todo aer remove / merge into Generate() oFilterEngine.ApplyAcousticModels(oPathFromLeft); // @todo aer remove / merge into Generate()
oFilterEngine.Generate(oPathFromLeft, oTransmissionFilterLeft, &bDFTDegreeTooSmallFlag); oFilterEngine.Generate(oPathFromLeft, oTransmissionFilterLeft, &bDFTDegreeTooSmallFlag);
...@@ -71,7 +71,7 @@ int main( int, char** ) ...@@ -71,7 +71,7 @@ int main( int, char** )
iFilterLengthSamples = (int)(oPathFromRight.GetLength() / fSpeedOfSound * fSampleRate); iFilterLengthSamples = (int)(oPathFromRight.GetLength() / fSpeedOfSound * fSampleRate);
iFilterLengthSamples = int(iFilterLengthSamples + 4096); iFilterLengthSamples = int(iFilterLengthSamples + 4096);
ITABase::CHDFTSpectra oTransmissionFilterRight(fSampleRate, pReceiver->iNumChannels, iFilterLengthSamples); ITABase::CHDFTSpectra oTransmissionFilterRight(fSampleRate, pReceiver->GetNumChannels(), iFilterLengthSamples);
oFilterEngine.ApplyAcousticModels(oPathFromRight); // @todo aer remove / merge into Generate() oFilterEngine.ApplyAcousticModels(oPathFromRight); // @todo aer remove / merge into Generate()
oFilterEngine.Generate(oPathFromRight, oTransmissionFilterRight, &bDFTDegreeTooSmallFlag); oFilterEngine.Generate(oPathFromRight, oTransmissionFilterRight, &bDFTDegreeTooSmallFlag);
......
...@@ -47,9 +47,9 @@ int main( int, char** ) ...@@ -47,9 +47,9 @@ int main( int, char** )
auto pSender = make_shared< CEmitter >( VistaVector3D( -2.0f, 0.0f, 0.0f ) ); auto pSender = make_shared< CEmitter >( VistaVector3D( -2.0f, 0.0f, 0.0f ) );
auto pReceiver = make_shared< CSensor >( VistaVector3D( 2.0f, 0.0f, 0.0f ) ); auto pReceiver = make_shared< CSensor >( VistaVector3D( 2.0f, 0.0f, 0.0f ) );
CMaterialDirectory oMaterialDirectory( "./" ); auto pMaterialDirectory = std::make_shared< Material::CDirectory >( "./" );
auto pReflection = make_shared< CSpecularReflection >( VistaVector3D( 0.0f, 2.0f, 0.0f ) ); auto pReflection = make_shared< CSpecularReflection >( VistaVector3D( 0.0f, 2.0f, 0.0f ) );
pReflection->pAcousticMaterial = oMaterialDirectory.GetMaterial( "stonewall" ); pReflection->pAcousticMaterial = pMaterialDirectory->GetMaterial( "stonewall" );
auto pW = std::make_shared< CITADiffractionOuterWedgeAperture >(); auto pW = std::make_shared< CITADiffractionOuterWedgeAperture >();
pW->v3AperturePoint.SetValues( 0.0f, 1.0f, 0.0f ); pW->v3AperturePoint.SetValues( 0.0f, 1.0f, 0.0f );
...@@ -80,7 +80,7 @@ int main( int, char** ) ...@@ -80,7 +80,7 @@ int main( int, char** )
oPathList.push_back(oPathDiffraction); oPathList.push_back(oPathDiffraction);
CFilterEngine oFilterEngine; CFilterEngine oFilterEngine;
oFilterEngine.SetMaterialManager( &oMaterialDirectory ); oFilterEngine.SetMaterialManager( pMaterialDirectory );
// Set filter length according to the maximum path length // Set filter length according to the maximum path length
const float fSpeedOfSound = SPEED_OF_SOUND_F; //Approximation of speed of sound at ~20C const float fSpeedOfSound = SPEED_OF_SOUND_F; //Approximation of speed of sound at ~20C
...@@ -88,7 +88,7 @@ int main( int, char** ) ...@@ -88,7 +88,7 @@ int main( int, char** )
int iFilterLengthSamples = ( int ) ( oPathList.GetMaxLength() / fSpeedOfSound * fSampleRate ); int iFilterLengthSamples = ( int ) ( oPathList.GetMaxLength() / fSpeedOfSound * fSampleRate );
iFilterLengthSamples = int( iFilterLengthSamples + 4096 ); iFilterLengthSamples = int( iFilterLengthSamples + 4096 );
ITABase::CHDFTSpectra oTransmissionFilter( fSampleRate, pReceiver->iNumChannels, iFilterLengthSamples ); ITABase::CHDFTSpectra oTransmissionFilter( fSampleRate, pReceiver->GetNumChannels(), iFilterLengthSamples );
bool bDFTDegreeTooSmallFlag; bool bDFTDegreeTooSmallFlag;
oFilterEngine.ApplyAcousticModels( oPathList ); // @todo aer remove / merge into Generate() oFilterEngine.ApplyAcousticModels( oPathList ); // @todo aer remove / merge into Generate()
oFilterEngine.Generate( oPathList, oTransmissionFilter, &bDFTDegreeTooSmallFlag ); oFilterEngine.Generate( oPathList, oTransmissionFilter, &bDFTDegreeTooSmallFlag );
......
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