Refactoring done

parent b6c08b03
*.exe
*.bat
......@@ -8,3 +8,77 @@ include( VistaCommon )
# dependencies
vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITAGeo REQUIRED FIND_DEPENDENCIES )
# includes
include_directories( "include" )
# sources
set( ITAPropagationModelHeader
"include/ITAPropagationModelsBase.h"
"include/ITAPropagationModelsDefinitions.h"
"include/ITADiffractionFilter.h"
"include/ITAPropagationModelFilterGenerator.h"
"include/ITAPropagationModelKirchhoff.h"
"include/ITAPropagationModelSvensson.h"
"include/ITAPropagationModelUTD.h"
)
set( ITAPropagationModelSources
"src/ITAPropagationModelFilterGenerator.cpp"
"src/ITAPropagationModelKirchhoff.cpp"
"src/ITAPropagationModelSvensson.cpp"
"src/ITAPropagationModelUTD.cpp"
)
# preprocessor
if( BUILD_SHARED_LIBS )
add_definitions( -DITA_PROPAGATION_MODELS_EXPORT )
else( )
add_definitions( -DITA_PROPAGATION_MODELS_STATIC )
endif( )
if( ITA_CORE_LIBS_BUILD_STATIC )
add_definitions( -DITA_BASE_STATIC )
endif( )
if( ITA_VISTA_BUILD_STATIC )
add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC )
endif( )
if( NOT WIN32 )
add_definitions( -std=gnu++11 )
endif( )
add_definitions( -D_USE_MATH_DEFINES -DNOMINMAX )
# linker
add_library( ITAPropagationModels ${ITAPropagationModelHeader} ${ITAPropagationModelSources} )
target_link_libraries( ITAPropagationModels ${VISTA_USE_PACKAGE_LIBRARIES} )
# config
vista_configure_lib( ITAPropagationModels )
vista_install( ITAPropagationModels )
set( ITAPROPAGATIONMODELS_INCLUDE_OUTDIR "${CMAKE_CURRENT_SOURCE_DIR}/include" )
vista_create_cmake_configs( ITAPropagationModels )
vista_create_default_info_file( ITAPropagationModels )
set_property( TARGET ITAPropagationModels PROPERTY FOLDER "ITAGeometricalAcoustics" )
# benchmarks
if( ITA_GEOMETRICAL_ACOUSTICS_WITH_BENCHMARKS OR ITA_PROPAGATION_MODELS_WITH_BENCHMARKS )
set( ITAPROPAGATIONMODELS_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/benchmarks" )
endif( )
# tests
if( ITA_GEOMETRICAL_ACOUSTICS_WITH_TESTS OR ITA_PROPAGATION_MODEL_WITH_TESTS )
set( ITAPROPAGATIONMODELS_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
endif( )
cmake_minimum_required( VERSION 3.0 )
project( ITAPropagationModelsBenchmarks )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITAPropagationModels REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITAPropagationPathSim REQUIRED FIND_DEPENDENCIES ) # @todo remove
if( ITA_CORE_LIBS_BUILD_STATIC )
add_definitions( -DITA_BASE_STATIC )
endif( )
if( ITA_GEOMETRICAL_ACOUSTICS_BUILD_STATIC )
add_definitions( -DITA_PROPAGATION_MODELS_STATIC -DITA_GEO_STATIC )
endif( )
add_executable( DiffractionModelsBenchmark DiffractionModelsBenchmark.cpp )
target_link_libraries( DiffractionModelsBenchmark ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( DiffractionModelsBenchmark )
vista_install( DiffractionModelsBenchmark )
vista_create_default_info_file( DiffractionModelsBenchmark )
set_property( TARGET DiffractionModelsBenchmark PROPERTY FOLDER "ITAGeometricalAcoustics/Benchmarks/ITAPropagationModels" )
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
* Benchmark implementations of available diffraction models.
*
* ----------------------------------------------------------------
*/
#include <ITAPropagationModelsBase.h>
#include <ITAPropagationModelKirchhoff.h>
#include <ITAPropagationModelUTD.h>
#include <ITAPropagationModelSvensson.h>
#include <ITAGeoBase.h>
#include <ITAGeoModelBase.h>
#include <ITAGeoScene.h>
#include <ITAGeoUtils.h>
#include <ITAGeoHalfedgeMeshModel.h>
#include <ITAException.h>
#include <ITAStopWatch.h>
#include <ITAStringUtils.h>
#include <ITAHDFTSpectrum.h>
#include <ITAThirdOctaveMagnitudeSpectrum.h>
#include <ITAFiniteImpulseResponse.h>
#include <VistaBase/VistaVector3D.h>
#include <VistaMath/VistaGeometries.h>
#include <VistaTools/VistaFileSystemFile.h>
#include <iostream>
using namespace std;
float g_fSpeedOfSound = 344.0f;
float g_fSampleRate = 44.1e3;
int g_iFilterLength = 64;
void benchmark_single_wedge();
int main( int, char* )
{
try
{
benchmark_single_wedge();
}
catch( ITAException& e )
{
cerr << e << endl;
return 255;
}
return 0;
}
void benchmark_single_wedge()
{
cout << "Benchmarking diffraction models" << endl;
auto oSource = std::make_shared< ITAGeo::CEmitter >();
oSource->sName = "Benchmark 1 source";
oSource->qOrient = VistaQuaternion( 0, -1, 0, 0 );
oSource->vPos.SetValues( 1.1f, .9f, .9f );
auto oReceiver = std::make_shared< ITAGeo::CSensor >();
oReceiver->sName = "Benchmark 1 receiver";
oReceiver->qOrient = VistaQuaternion( 0, 1, 0, 0 );
oReceiver->vPos.SetValues( -.4f, .6f, .1f );
auto oWedge = std::make_shared< ITAGeo::CITADiffractionWedgeAperture >();
oWedge->v3MainWedgeFaceNormal = VistaVector3D( 1.0f, 1.0f, .0f ).GetNormalized();
oWedge->v3OppositeWedgeFaceNormal = VistaVector3D( -1.0f, 1.0f, .0f ).GetNormalized();
oWedge->v3VertextStart.SetValues( .0f, 1.0f, -1.0f );
oWedge->v3VertextEnd.SetValues( .0f, 1.0f, 1.0f );
ITAGeoUtils::CalculateDiffractionAperturePoint( oWedge->GetEdgeRay(), oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, oWedge->v3AperturePoint );
if( !ITAGeoUtils::IsDiffractionAperturePointInRange( oWedge->v3VertextStart, oWedge->v3VertextEnd, oWedge->v3AperturePoint ) )
ITA_EXCEPT_INVALID_PARAMETER( "Aperture point over wedge is outside edge vertices" );
if( !oWedge->IsOutsideWedge( oSource->v3InteractionPoint ) )
ITA_EXCEPT_INVALID_PARAMETER( "Source point is inside wedge (solid part)" );
if( !oWedge->IsOutsideWedge( oReceiver->v3InteractionPoint ) )
ITA_EXCEPT_INVALID_PARAMETER( "Receiver point is inside wedge (solid part)" );
ITAGeo::CPropagationPath oPropPath;
oPropPath.push_back( oSource );
oPropPath.push_back( oWedge );
oPropPath.push_back( oReceiver );
cout << "Path: " << oPropPath << endl;
// Kirchhoff
if( !ITADiffractionKirchhoff::IsApplicable( oPropPath ) )
ITA_EXCEPT_INVALID_PARAMETER( "Kirchhoff model can not be applied for this propagation path." );
ITAStopWatch sw;
cout << "Starting Kirchoff model benchmark:" << endl;
double dStartTime = ITAClock::getDefaultClock()->getTime();
ITABase::CHDFTSpectrum oTF( g_fSampleRate, g_iFilterLength, true );
for( int i = 0; i < 1e8; i++ )
{
sw.start();
ITADiffractionKirchhoff::CalculateDiffractionFilter( oPropPath, oTF, g_fSpeedOfSound );
sw.stop();
}
double dStopTime = ITAClock::getDefaultClock()->getTime();
double dProcessingTime = dStopTime - dStartTime;
cout << "\tBenchmark took " << timeToString( dProcessingTime ) << endl;
cout << "\tStatistics:" << sw << endl;
cout << "\tResult:" << oTF.ToString() << endl;
cout << endl;
sw.reset();
cout << "Starting UTD model benchmark:" << endl;
dStartTime = ITAClock::getDefaultClock()->getTime();
const int iMethod = ITADiffractionUTD::UTD_APPROX_KAWAI_KOUYOUMJIAN;
for( int i = 0; i < 1e6; i++ )
{
sw.start();
ITADiffractionUTD::CalculateDiffractionFilter(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, oWedge, oTF, iMethod, g_fSpeedOfSound);
sw.stop();
}
dStopTime = ITAClock::getDefaultClock()->getTime();
dProcessingTime = dStopTime - dStartTime;
cout << "\tBenchmark took " << timeToString( dProcessingTime ) << endl;
cout << "\tStatistics:" << sw << endl;
cout << "\tResult:" << oTF.ToString() << endl;
cout << endl;
sw.reset();
cout << "Starting Biot-Tolstoy-Medwin-Svensson model benchmark:" << endl;
dStartTime = ITAClock::getDefaultClock()->getTime();
const float fMinDelay = oWedge->GetMinimumWavefrontDelayTime(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, g_fSpeedOfSound);
const float fMaxDelay = oWedge->GetMaximumWavefrontDelayTime(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, g_fSpeedOfSound);
const int iIRLength = ( int ) ceil( float( fMaxDelay - fMinDelay ) * g_fSampleRate );
ITABase::CFiniteImpulseResponse oIR( iIRLength, g_fSampleRate, true );
for( int i = 0; i < 1e4; i++ )
{
sw.start();
ITADiffractionSvensson::CalculateDiffractionIR(oSource->v3InteractionPoint, oReceiver->v3InteractionPoint, oWedge, oIR, g_fSpeedOfSound);
sw.stop();
}
dStopTime = ITAClock::getDefaultClock()->getTime();
dProcessingTime = dStopTime - dStartTime;
cout << "\tBenchmark took " << timeToString( dProcessingTime ) << endl;
cout << "\tStatistics:" << sw << endl;
cout << "\tResult:" << oIR.toString() << endl;
cout << endl;
}
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER
#include <ITAPropagationModelsDefinitions.h>
// ITA includes
#include <ITASampleBuffer.h>
//! Diffraction filter impulse response in time domain
class ITA_PROPAGATION_MODELS_API CITADiffractionFilter
{
CITADiffractionFilter();
ITASampleBuffer sbFIRFilter;
int nLeadingZeros;
int nFilterLength;
};
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER_GENERATOR
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER_GENERATOR
#include <ITAPropagationModelsDefinitions.h>
#include <ITADiffractionFilter.h>
#include <ITAPropagationModelsBase.h>
// ITA includes
#include <ITAGeoBase.h>
// STL includes
#include <vector>
//! Diffraction filter generator for propagation paths with diffraction anchors
class ITA_PROPAGATION_MODELS_API CITADiffractionFilterGenerator
{
public:
enum AcousticDiffractionModel
{
MODEL_MAEKAWA = 1,
MODEL_KIRCHOFF,
MODEL_BIOT_TOLSTOY,
MODEL_BIOT_TOLSTOY_MEDWIN,
};
CITADiffractionFilterGenerator( int iModel = MODEL_BIOT_TOLSTOY_MEDWIN );
// @todo move CITADiffractionWedgeAperture to ITABase
//void GenerateFIR( const ITAGeo::CPropagationAnchor& oSource, const ITAGeo::CPropagationAnchor& oDestination, CITADiffractionWedgeAperture& oWedge, CITADiffractionFilter& oFilter );
private:
int m_iModel;
};
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_FILTER_GENERATOR
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
* Diffraction simulation mode using the Kirchhoff
* approximation based on detour.
*
*/
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_KIRCHHOFF
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_KIRCHHOFF
#include <ITAPropagationModelsDefinitions.h>
// ITA includes
#include <ITAConstants.h>
#include <ITAGeoBase.h>
#include <ITAHDFTSpectrum.h>
#include <ITASampleBuffer.h>
// STL includes
#include <cassert>
//! Diffraction calculation based on Kirchhoff approximation
/**
* @sa Pierce, A. D.; Diffraction of sound around corners and over wide barriers; J. Acoust. Soc. Am., 1974, 55, 941-955
*/
namespace ITADiffractionKirchhoff
{
//! Validates if Kirchhoff diffraction method can be applied
/**
* The Kirchhoff detour method only makes sense if the source is
* occluded by obstacles in it's way to the receiver (or vice versa).
* This may include specular reflections, but inverse wedges (corners) have to
* be excluded because they can not occlude entities.
*
* @param[in] oPropPath Propagation path to be simulated
* @return True, if Kirchhoff can be used (makes sense for this path)
*
* @sa KirchhoffDetourAndLength
* @sa KirchhoffDiffractionFilter
*
* @note Throws ITAException on error
*
*/
bool ITA_PROPAGATION_MODELS_API IsApplicable( const ITAGeo::CPropagationPath& oPropPath );
//! Calculates the detour of a propagation path for the Kirchhoff method
/**
* Calculates the direct path vs. detour path by taking diffraction anchors into account.
* It is recommended to validate the path, first. Otherwise unpredictable results will occur.
*
* 1. Specular reflections will increase the direct path length AND detour length
* 2. Only diffraction around a wedge are treated (diffraction angle greater \pi, where 0 would be back-scattering and \pi is gracing angle)
*
* @param[in] oPropPath Propagation path to be simulated
* @param[out] dPropagationLengthDirect Propagation path length without occlusion [m]
* @param[out] dPropagationLengthDetour Propagation path detour length with occlusion [m]
*
* @sa IsKirchhoffApplicable
*
* @note Throws ITAException on error
*
*/
void ITA_PROPAGATION_MODELS_API GetDirectLengthAndDetourLength( const ITAGeo::CPropagationPath& oPropPath, double& dPropagationLengthDirect, double& dPropagationLengthDetour );
//! Calculates the detour-and-direct-path difference of a propagation path for the Kirchhoff method
/**
* @param[in] dPropagationLengthDirect Direct path length [m] (sometimes referred to as 'd')
* @param[in] dPropagationLengthDetour Detour path length [m] (sometimes referred to as 'A+B')
*
* @return Kirchhoff delta (difference) [m] (\delta, sometimes referred to as 'A+B-d')
*
* @note Throws ITAException on error
*
*/
double ITA_PROPAGATION_MODELS_API KirchhoffDelta( const double dPropagationLengthDirect, const double dPropagationLengthDetour );
//! Calculates the detour-and-direct-path inverse difference factor of a propagation path for the Kirchhoff method
/**
* @return Kirchhoff delta factor (ratio), always greater or equal 1.0
*
* @note Throws ITAException on error
*
*/
inline double KirchhoffDeltaInverseFactor( const double dPropagationLengthDirect, const double dPropagationLengthDetour )
{
const double dKirchhoffDelta = ITADiffractionKirchhoff::KirchhoffDelta( dPropagationLengthDirect, dPropagationLengthDetour );
const double dKirchhoffDeltaInverseFactor = ( dPropagationLengthDirect + dKirchhoffDelta ) / dPropagationLengthDirect;
return dKirchhoffDeltaInverseFactor;
};
//! Calculate diffraction filter (frequency domain) based on the Kirchhoff detour method
/**
* This function calculates the Kirchhoff diffraction filter based on detour length around a wedge obstacle
* and the direct path length with and withont any obstacles.
*
* @param[in] dPropagationLengthDirect Direct path length [m]
* @param[in] dPropagationLengthDetour Detour path length [m]
* @param[out] oTransferFunction Destination filter of simulation (zero-phase frequency domain magnitude spectrum)
*
*/
void ITA_PROPAGATION_MODELS_API CalculateDiffractionFilter( const double dPropagationLengthDirect, const double dPropagationLengthDetour, ITABase::CHDFTSpectrum& oTransferFunction, const float fSpeedOfSound = 344.0f );
//! Calculate diffraction filter (frequency domain) based on the Kirchhoff detour method for a single wedge
/**
* This function calculates the Kirchhoff diffraction filter based on detour length around a wedge obstacle
* and the direct path length with and without any obstacles.
*
* @param[in] oPropPath Propagation path
* @param[out] oTransferFunction Destination filter of simulation (frequency domain)
*
* @return True, if Kirchhoff method could be applied
*
* @note Throws ITAException on error
*
*/
inline bool CalculateDiffractionFilter( const ITAGeo::CPropagationPath& oPropPath, ITABase::CHDFTSpectrum& oTransferFunction, const float fSpeedOfSound = 344.0f )
{
if( !ITADiffractionKirchhoff::IsApplicable( oPropPath ) )
return false;
double dDirect, dDetour;
ITADiffractionKirchhoff::GetDirectLengthAndDetourLength( oPropPath, dDirect, dDetour );
ITADiffractionKirchhoff::CalculateDiffractionFilter( dDirect, dDetour, oTransferFunction, fSpeedOfSound );
return true;
};
//! Calculate diffraction filter (frequency domain) based on the Kirchhoff detour method for a single wedge
/**
* This function calculates the Kirchhoff diffraction filter based on detour length around a wedge obstacle
* and the direct path length with and without any obstacles.
*
* @param[in] pSource Source of propagation (previous anchor point of path)
* @param[in] pWedge Diffraction wedge of propagation
* @param[in] pTarget Target of propagation (next anchor point of path)
* @param[out] oTransferFunction Destination filter of simulation (frequency domain)
*
* @return True, if Kirchhoff method could be applied
*
* @note Throws ITAException on error
*
*/
inline bool CalculateDiffractionFilter( std::shared_ptr< ITAGeo::CPropagationAnchor > pSource, std::shared_ptr< ITAGeo::CITADiffractionWedgeAperture > pWedge, std::shared_ptr< ITAGeo::CPropagationAnchor > pTarget, ITABase::CHDFTSpectrum& oTransferFunction, const float fSpeedOfSound = 344.0f )
{
if( !pWedge->IsOccluding( pSource, pTarget ) )
return false;
// A little dirty removing const, but we know what we are doing, here.
ITAGeo::CPropagationPath oPropPath;
oPropPath.push_back( pSource );
oPropPath.push_back( pWedge );
oPropPath.push_back( pTarget );
const ITAGeo::CPropagationPath& oConstPropPath( oPropPath ); // Not necessary, just making a point
return CalculateDiffractionFilter( oConstPropPath, oTransferFunction, fSpeedOfSound );
};
}
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_KIRCHHOFF
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
* Svensson diffraction model based on Biot-Tolstoy exact
* solution and the extension by Medwin.
*
*/
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_SVENSSON
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_SVENSSON
#include <ITAPropagationModelsDefinitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAConstants.h>
#include <ITAGeoBase.h>
#include <ITASampleBuffer.h>
#include <ITAFiniteImpulseResponse.h>
namespace ITADiffractionSvensson
{
//! Calculates the impulse response of Svensson diffraction model for a given constellation
/**
* @sa Svensson, P.; Fred, R. & Vanderkooy, J.; An analytic secondary source model of edge diffraction impulse responses; J. Acoust. Soc. Am., 1999, 106, 2331
*
* @param[in] v3SourcePos Source position (outside wedge), rojected position may have to be used for correct distances!
* @param[in] v3TargetPos target position (outside wedge)
* @param[in] pApex Aperture point including wedge parameters (angles, etc)
* @param[out] oEffectiveDiffractionIR Effective impulse response for diffraction part of sound path from source to target (not including delay)
*
* @sa GetMinimumWavefrontDelayTime, GetMaximumWavefrontDelayTime
*/
ITA_PROPAGATION_MODELS_API bool CalculateDiffractionIR( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeAperture > pApex, ITABase::CFiniteImpulseResponse& oEffectiveDiffractionIR, const float fSpeedOfSound = 344.0f );
};
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_SVENSSON
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
* Uniform Theory of Diffraction (UTD) approximation
*
*/
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_UTD
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_UTD
#include <ITAPropagationModelsDefinitions.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
// ITA includes
#include <ITAConstants.h>
#include <ITAGeoBase.h>
#include <ITAHDFTSpectrum.h>
#include <ITASampleBuffer.h>
// STL includes
#include <ccomplex>
namespace ITADiffractionUTD
{
//! UTD diffraction coefficient calculation methods (only approximation implemented yet!)
enum UTD_DIFFRACTION_ALGORITHM
{
UTD_FRESNEL_INTEGRAL_FORM = 1, //!< Solve Fresnel integral over komplex value (not implemented yet!)
UTD_APPROX_KAWAI_KOUYOUMJIAN = 2, //!< Skip integral solution and use approximations
};
//ITA_PROPAGATION_MODELS_API bool GenerateUTDDiffractionFilter( const CITAGeoPropagationPath& vPath, ITAHDFTSpectrum& oDiffractionAttenuationSpectrum );
//ITA_PROPAGATION_MODELS_API bool GenerateUTDDiffractionFilter( const CITAGeoPropagationAnchor& oSource, const CITAGeoPropagationAnchor& oTarget, const CITADiffractionWedgeAperture& oApex, ITAHDFTSpectrum& oDiffractionAttenuationSpectrum );
//! Calculates the complex valued UTD diffraction coefficient for a given constellation and wave number
/**
* @sa Tsingos, N.; Funkhouser, T.; Ngan, A. & Carlbom, I.; Modeling Acoustics in Virtual Environments Using the Uniform Theory of Diffraction; Proceedings of the 28th Annual Conference on Computer Graphics and Interactive Techniques, ACM, 2001, 545-552
* @sa Kouyoumjian, R. G. & Pathak, P. H.; A uniform geometrical theory of diffraction for an edge in a perfectly conducting surface; Proceedings of the IEEE, IEEE, 1974, 62, 1448-1461
* @sa Kawai, T.; Sound diffraction by a many-sided barrier or pillar; Journal of Sound Vibration, 1981, 79, 229-242
*
* @param[in] v3SourcePos Source position (outside wedge), rojected position may have to be used for correct distances!
* @param[in] v3TargetPos target position (outside wedge)
* @param[in] pApex Aperture point including wedge parameters (angles, etc)
* @param[in] fWaveNumber Wave number ( k )
* @param[out] cfCoeff Complex-valued diffraction coefficient ( D( n, k,\rho, r, \phi_i, \alpha_i, \alpha_d ) )
* @param[in] iMethod Approximation algorithm
*/
ITA_PROPAGATION_MODELS_API bool CalculateDiffractionCoefficient( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeAperture > pApex, const float fWaveNumber, std::complex< float >& cfCoeff, const int iMethod = UTD_APPROX_KAWAI_KOUYOUMJIAN );
//! Calculates the UTD diffraction filter in frequency domain for a given constellation
/**
* @sa Tsingos, N.; Funkhouser, T.; Ngan, A. & Carlbom, I.; Modeling Acoustics in Virtual Environments Using the Uniform Theory of Diffraction; Proceedings of the 28th Annual Conference on Computer Graphics and Interactive Techniques, ACM, 2001, 545-552
* @sa Kouyoumjian, R. G. & Pathak, P. H.; A uniform geometrical theory of diffraction for an edge in a perfectly conducting surface; Proceedings of the IEEE, IEEE, 1974, 62, 1448-1461
* @sa Kawai, T.; Sound diffraction by a many-sided barrier or pillar; Journal of Sound Vibration, 1981, 79, 229-242
*
* @param[in] v3SourcePos Source position (outside wedge), rojected position may have to be used for correct distances!
* @param[in] v3TargetPos target position (outside wedge)
* @param[in] pApex Aperture point including wedge parameters (angles, etc)
* @param[out] oTF Diffraction transfer function / filter in frequency domain
* @param[in] iMethod Approximation algorithm
* @param[in] fSpeedOfSound Sound speed
*/
ITA_PROPAGATION_MODELS_API void CalculateDiffractionFilter( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos, std::shared_ptr< const ITAGeo::CITADiffractionWedgeAperture > pApex, ITABase::CHDFTSpectrum& oTF, const int iMethod = UTD_APPROX_KAWAI_KOUYOUMJIAN, const float fSpeedOfSound = 344.0f );
};