Commit 5ac6a9b6 authored by Armin Erraji's avatar Armin Erraji

Merge remote-tracking branch 'remotes/origin/develop' into ma_2018/erraji

parents 6d459b4b 6ad43c16
......@@ -353,7 +353,7 @@ namespace ITAGeo
static inline std::string GetTypeStr()
{
return "PropagationPath";
return "propagation_path";
};
//! Calculates the propagation path lenghts
......
......@@ -41,7 +41,11 @@ namespace ITAGeo
float GetFilterLengthSamples() const;
void GetNearestNeighbourImpulseResponse( const ITAGeo::Coordinates::CSpherical& oDirection, ITABase::CFiniteImpulseResponse& oFIR, const int iChannelIndex = 0 ) const;
void GetNearestNeighbourImpulseResponse( const ITAGeo::Coordinates::CSpherical& oDirection, ITASampleBuffer& sbFIR, const int iChannelIndex = 0 ) const;
void GetNearestNeighbourImpulseResponse( const ITAGeo::Coordinates::CSpherical& oDirection, ITABase::CMultichannelFiniteImpulseResponse& oFIR ) const;
//! Rerturns the mean value of the TOA in seconds (for adjustements of delay
float GetMeanTimeOfArrival() const;
};
}
}
......
......@@ -7,20 +7,20 @@
ITAGeo::Directivity::CDAFF_ImpulseResponse::CDAFF_ImpulseResponse()
: CDAFF_Format()
{
SetDomain(ITADomain::ITA_TIME_DOMAIN);
SetDomain( ITADomain::ITA_TIME_DOMAIN );
}
ITAGeo::Directivity::CDAFF_ImpulseResponse::CDAFF_ImpulseResponse(const std::string & sFilePath)
ITAGeo::Directivity::CDAFF_ImpulseResponse::CDAFF_ImpulseResponse( const std::string & sFilePath )
: CDAFF_ImpulseResponse()
{
LoadFromFile(sFilePath);
LoadFromFile( sFilePath );
}
float ITAGeo::Directivity::CDAFF_ImpulseResponse::GetFilterLengthSamples() const
{
auto p = dynamic_cast<DAFFContentIR*>(m_pDAFFReader->getContent());
if (p)
return (float)p->getFilterLength();
auto p = dynamic_cast< DAFFContentIR* >( m_pDAFFReader->getContent() );
if( p )
return ( float ) p->getFilterLength();
else
return 0.0f;
}
......@@ -31,10 +31,49 @@ ITAGeo::Directivity::CDAFF_ImpulseResponse::~CDAFF_ImpulseResponse()
void ITAGeo::Directivity::CDAFF_ImpulseResponse::GetNearestNeighbourImpulseResponse( const ITAGeo::Coordinates::CSpherical& oDirection, ITABase::CFiniteImpulseResponse& oFIR, const int iChannelIndex ) const
{
ITA_EXCEPT_NOT_IMPLEMENTED;
auto p = dynamic_cast< DAFFContentIR* >( m_pDAFFReader->getContent() );
if( p->getSamplerate() != oFIR.GetSampleRate() )
ITA_EXCEPT_INVALID_PARAMETER( "DAFF impulse response and target finite impulse response filter have mismatching sampling ranges." );
if( p->getFilterLength() > oFIR.GetLength() )
ITA_EXCEPT_INVALID_PARAMETER( "DAFF impulse response is longer than target finite impulse response filter." );
int iRecordIndex = -1;
p->getNearestNeighbour( DAFF_VIEWS::DAFF_OBJECT_VIEW, oDirection.GetAzimuthDegree(), oDirection.GetElevationDegree(), iRecordIndex );
p->getFilterCoeffs( iRecordIndex, iChannelIndex, &oFIR[ 0 ] );
}
void ITAGeo::Directivity::CDAFF_ImpulseResponse::GetNearestNeighbourImpulseResponse( const ITAGeo::Coordinates::CSpherical& oDirection, ITASampleBuffer& oFIR, const int iChannelIndex ) const
{
auto p = dynamic_cast< DAFFContentIR* >( m_pDAFFReader->getContent() );
if( p->getFilterLength() > oFIR.GetLength() )
ITA_EXCEPT_INVALID_PARAMETER( "DAFF impulse response is longer than target finite impulse response filter." );
int iRecordIndex = -1;
p->getNearestNeighbour( DAFF_VIEWS::DAFF_OBJECT_VIEW, oDirection.GetAzimuthDegree(), oDirection.GetElevationDegree(), iRecordIndex );
p->getFilterCoeffs( iRecordIndex, iChannelIndex, &oFIR[ 0 ] );
}
void ITAGeo::Directivity::CDAFF_ImpulseResponse::GetNearestNeighbourImpulseResponse( const ITAGeo::Coordinates::CSpherical& oDirection, ITABase::CMultichannelFiniteImpulseResponse& oFIR ) const
{
ITA_EXCEPT_NOT_IMPLEMENTED;
for( int n = 0; n < m_pDAFFReader->getProperties()->getNumberOfChannels(); n++ )
{
GetNearestNeighbourImpulseResponse( oDirection, oFIR[ n ], n );
}
}
float ITAGeo::Directivity::CDAFF_ImpulseResponse::GetMeanTimeOfArrival() const
{
auto p = dynamic_cast< DAFFContentIR* >( m_pDAFFReader->getContent() );
if( m_pDAFFReader->getMetadata()->hasKey( "delay_samples" ) )
{
if( m_pDAFFReader->getMetadata()->getKeyType( "delay_samples" ) == DAFFMetadata::DAFF_FLOAT )
return m_pDAFFReader->getMetadata()->getKeyFloat( "delay_samples" ) / p->getSamplerate();
else if( m_pDAFFReader->getMetadata()->getKeyType( "delay_samples" ) == DAFFMetadata::DAFF_INT )
return m_pDAFFReader->getMetadata()->getKeyInt( "delay_samples" ) / p->getSamplerate();
}
return p->getMinEffectiveFilterOffset() / p->getSamplerate();
}
......@@ -15,7 +15,7 @@
#include <VistaTools/VistaFileSystemFile.h>
#include <algorithm>
// Typedefs
typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
......@@ -398,16 +398,6 @@ bool CModel::Store( const std::string& sSKPFilePath, bool bOverwite/*=true*/ ) c
SU_EXC( SULayerSetName( rPropLayer, sPropLayerName.c_str() ) );
SU_EXC( SUModelAddLayers( rModel, 1, &rPropLayer ) );
SUMaterialRef rMaterial = SU_INVALID;
SU_EXC( SUMaterialCreate( &rMaterial ) );
SUColor oSUColor;
oSUColor.red = SUByte( 255.0f );
oSUColor.green = SUByte( 0.0f );
oSUColor.blue = SUByte( 0.0f );
SU_EXC( SUMaterialSetColor( rMaterial, &oSUColor ) );
SUMaterialSetName( rMaterial, "ITA_Acoustics_DefaultPropagationPath" );
SUModelAddMaterials( rModel, 1, &rMaterial );
std::vector< SUCurveRef > vrCurves( voGeoPropPathsVisualization.size() );
for( size_t n = 0; n < voGeoPropPathsVisualization.size(); n++ )
{
......@@ -415,6 +405,16 @@ bool CModel::Store( const std::string& sSKPFilePath, bool bOverwite/*=true*/ ) c
if( oPath.size() <= 1 )
continue;
SUMaterialRef rMaterial = SU_INVALID;
SU_EXC( SUMaterialCreate( &rMaterial ) );
SUColor oSUColor;
oSUColor.red = SUByte( 255.0f ); // direktschall
oSUColor.green = SUByte( 0.0f ); // reflex, yellow (red+green) = diffr
oSUColor.blue = SUByte( 0.0f ); // late reverb
oSUColor.alpha = SUByte( 255.0f * ( 1.0f - min( (float) oPath.GetLength(), 1000.0f ) / 1000.0f ) ); // @todo get max first, then map from 0 to max length (10% alpha)
SU_EXC( SUMaterialSetColor( rMaterial, &oSUColor ) );
SUModelAddMaterials( rModel, 1, &rMaterial );
std::vector< SUEdgeRef > vrEdges( oPath.size() - 1 );
for( size_t m = 0; m < vrEdges.size(); m++ )
......@@ -425,7 +425,10 @@ bool CModel::Store( const std::string& sSKPFilePath, bool bOverwite/*=true*/ ) c
if( pSourceAnchor == pTargetAnchor )
ITA_EXCEPT_INVALID_PARAMETER( "A propagation path can not have the same anchors in a row." );
if( pSourceAnchor->v3InteractionPoint == pTargetAnchor->v3InteractionPoint )
ITA_EXCEPT_INVALID_PARAMETER( "Source and target anchor of propagation path have same interaction point." );
{
std::cout << "During SketchUp model export: source and target anchor of propagation path have same interaction point at " << pSourceAnchor->v3InteractionPoint << ", skipping this segment." << std::endl;
continue;
}
SUPoint3D v3SUStart = VistaVectorToSUPoint( pSourceAnchor->v3InteractionPoint );
SUPoint3D v3SUEnd = VistaVectorToSUPoint( pTargetAnchor->v3InteractionPoint );
......
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