Commit 549dc7aa authored by Armin Erraji's avatar Armin Erraji

Added color coding according to the ratio of the number of diffractions and reflections.

parent 5ac6a9b6
......@@ -375,6 +375,39 @@ namespace ITAGeo
return (int) this->size();
};
//! Get number of reflections
inline int GetNumReflections() const
{
int iNumReflections = 0;
for (auto& pAnchor : *this)
{
if (pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION)
iNumReflections++;
}
return iNumReflections;
};
//! Get number of diffractions
inline int GetNumDiffractions() const
{
int iNumDiffractions = 0;
for (auto& pAnchor : *this)
{
if (pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::DIFFRACTION_OUTER_APEX
|| pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::DIFFRACTION_INNER_APEX)
{
iNumDiffractions++;
}
}
return iNumDiffractions;
};
//! Calculates accumulated angles over diffracting anchors in radiants
/**
* @return Accumulated angle in radiants
......
......@@ -176,7 +176,7 @@ namespace ITAGeo
std::map< std::string, std::map<std::string, ITAGeo::CPropagationAnchor > > m_mGeoEmittersVisualization; //!< Propagation anchors for visualization of acoustic emitters
std::map< std::string, std::map<std::string, ITAGeo::CPropagationAnchor > > m_mGeoSensorsVisualization; //!< Propagation anchors for visualization of acoustic sensors
std::map< std::string, std::vector< ITAGeo::CPropagationPath > > m_mGeoPropPathsVisualization; //!< Propagation paths for visualization of acoustic effects (never populated in Load() method)
std::map< std::string, ITAGeo::CPropagationPathList > m_mGeoPropPathsVisualization; //!< Propagation paths for visualization of acoustic effects (never populated in Load() method)
std::map< std::string, std::vector< const ITAGeo::Halfedge::CMeshModel* > > m_mAcousticVisualizationMeshes; //!< Mesh list with extra visualization data
std::vector< std::string > m_vsLayers; //!< Layer names (also unused layers)
......
......@@ -286,6 +286,11 @@ bool CModel::Store( const std::string& sSKPFilePath, bool bOverwite/*=true*/ ) c
SU_EXC( ITAMeshToSUEntities( pMesh, &rEntities ) );
//Set unit
SUModelUnits rUnits;
SU_EXC(SUModelGetUnits(rModel, &rUnits));
rUnits = SUModelUnits::SUModelUnits_Meters;
// Add Layers
std::vector< SULayerRef > vrLayer;
......@@ -389,7 +394,7 @@ bool CModel::Store( const std::string& sSKPFilePath, bool bOverwite/*=true*/ ) c
for( auto key : m_mGeoPropPathsVisualization )
{
std::vector< ITAGeo::CPropagationPath > voGeoPropPathsVisualization( key.second );
ITAGeo::CPropagationPathList voGeoPropPathsVisualization( key.second );
// Propagation path visualization
SULayerRef rPropLayer = SU_INVALID;
......@@ -409,10 +414,41 @@ bool CModel::Store( const std::string& sSKPFilePath, bool bOverwite/*=true*/ ) c
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)
//Color and alpha values
float fRed, fGreen, fBlue, fAlpha;
//Set alpha value according to length of path with 10% as minimum value and 255 as maximum value
float fMaxLength = voGeoPropPathsVisualization.GetMaxLength();
fAlpha = max(0.1f, 1.0f - (float)oPath.GetLength() / fMaxLength);
fAlpha = min(255.0f, fAlpha*255.0f);
//The blue value is always zero(reserved for late reverberations)
fBlue = 0.0f;
//Direct path (red)
if (oPath.GetNumAnchors() == 2)
{
fRed = 220.0f, fGreen = 0.0f;
}
else
{
int iNumDiffractions = oPath.GetNumDiffractions();
int iNumReflections = oPath.GetNumReflections();
float fRelNumDiffractions = (float)iNumDiffractions / (float)(iNumDiffractions + iNumReflections);
fRed = fRelNumDiffractions*255.0f;
fGreen = 155.0f + fRelNumDiffractions * 100.0f;
}
oSUColor.alpha = SUByte(fAlpha );
oSUColor.red = SUByte(fRed); // direktschall
oSUColor.green = SUByte(fGreen); // reflex, yellow (red+green) = diffr
oSUColor.blue = SUByte(fBlue); // late reverb
SU_EXC( SUMaterialSetColor( rMaterial, &oSUColor ) );
SUModelAddMaterials( rModel, 1, &rMaterial );
......
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