Switching to shared pointer concept for acoustic material handlich

parent e1685b2d
......@@ -53,7 +53,7 @@ namespace ITAGeo
class ITA_GEO_API IAcousticMaterial
{
public:
enum
enum Type
{
NONE = 0, //!< No data type specified
VISUALIZATION, //!< Visualization material (colors, textures, etc)
......@@ -76,8 +76,12 @@ namespace ITAGeo
{
return GetIdentifier();
};
//! Get material type as string
std::string GetTypeStr() const;
};
class ITA_GEO_API CVisualizationMaterial : public IAcousticMaterial
{
public:
......@@ -215,18 +219,18 @@ namespace ITAGeo
return *this;
};
inline const IAcousticMaterial* GetMaterial() const
inline std::shared_ptr< IAcousticMaterial > GetMaterial() const
{
return m_pMaterial;
};
inline void SetMaterial( const IAcousticMaterial* pMaterial )
inline void SetMaterial( std::shared_ptr< IAcousticMaterial > pMaterial )
{
m_pMaterial = pMaterial;
};
private:
const IAcousticMaterial* m_pMaterial; //! Pointer to complex material
std::shared_ptr< IAcousticMaterial > m_pMaterial; //! Shared pointer to complex material
};
}
......
......@@ -22,6 +22,7 @@
// ITAGeo includes
#include <ITAGeoDefinitions.h>
#include <ITAException.h>
#include <ITAGeoMaterialManager.h>
// Vista includes
#include <VistaBase/VistaQuaternion.h>
......@@ -54,17 +55,18 @@ namespace ITAGeo
public:
enum EAnchorType
{
ITA_ANCHOR_INVALID = 0,
ITA_ACOUSTIC_EMITTER,
ITA_ACOUSTIC_SENSOR,
ITA_SPECULAR_REFLECTION,
ITA_DIFFUSE_REFLECTION,
ITA_TRANSMISSION,
ITA_EDGE_DIFFRACTION,
GENERIC_ANCHOR = 0, //!< Propagation anchor without specified type
ACOUSTIC_EMITTER, //!< Sound-emitting anchor (acoustic source, vibrating plane)
ACOUSTIC_SENSOR, //!< Sound-sensing anchor (microphone, sensivitive area, listener, portal)
SPECULAR_REFLECTION, //!< Specular reflection occurrance point (on boundary surface)
ITA_DIFFUSE_REFLECTION, //!< Diffuse reflection occurrance point (on plane or virtual)
TRANSMISSION_APEX, //!< Transmission occurrance point (e.g. through a solid wall)
DIFFRACTION_APEX, //!< Diffraction occurrance point (at a boundary edge)
MIRROR_IMAGE, //!< (Virtual) Mirror image in medium
} iAnchorType; //! Type of anchor
VistaVector3D v3InteractionPoint; //!< Point of geometric interaction, has to be further defined by deriving class
IAcousticMaterial* pAcousticMaterial; //!< Acoustic material connection, i.e. absorption coefficient
std::shared_ptr< IAcousticMaterial > pAcousticMaterial; //!< Acoustic material connection, i.e. absorption coefficient
bool bProtected; //!< Protect this anchor from destruction in DeleteAnchorsAndClear function
CPropagationAnchor();
......@@ -92,19 +94,19 @@ namespace ITAGeo
: CPropagationAnchor( vPos_ )
, vPos( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_EMITTER;
CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_EMITTER;
};
inline CEmitter( const CEmitter& oSrc )
: CPropagationAnchor( oSrc )
, vPos( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_EMITTER;
CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_EMITTER;
};
inline CEmitter() : vPos( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_EMITTER;
CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_EMITTER;
};
VistaVector3D& vPos; //!< Position point / geometric interaction point
......@@ -127,14 +129,14 @@ namespace ITAGeo
inline CSensor() : vPos( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_SENSOR;
CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_SENSOR;
};
inline CSensor( VistaVector3D vPos_ )
: CPropagationAnchor( vPos_ )
, vPos( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_SENSOR;
CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_SENSOR;
};
VistaVector3D& vPos; //!< Position point / geometric interaction point
......@@ -149,11 +151,11 @@ namespace ITAGeo
};
};
//! Specular reflection order on a plane
//! Specular reflection / diffraction order on a plane
enum Order
{
ORDER_0 = 0, //!< Zero's or non-order (usually only direct paths recognized)
ORDER_1, //!< First order interaction, i.e one refection or one diffraction
ORDER_1, //!< First order interaction, i.e one reflection or one diffraction
ORDER_2, //!< Second order interaction, i.e. one reflection and one diffraction
ORDER_3, //!< ...
ORDER_4, //!< ...
......@@ -163,6 +165,10 @@ namespace ITAGeo
ORDER_8, //!< ...
};
//! Mirror image
/**
* @note Do not mix a mirror image (virtual point in medium) with a specular reflection (point on a boundary)
*/
class ITA_GEO_API CMirrorImage : public CPropagationAnchor
{
public:
......@@ -179,7 +185,7 @@ namespace ITAGeo
, iOrder( -1 )
, v3MirrorPosition( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_SPECULAR_REFLECTION;
CPropagationAnchor::iAnchorType = CPropagationAnchor::MIRROR_IMAGE;
};
inline explicit CMirrorImage( const CPropagationAnchor& oAnchor )
......@@ -189,7 +195,7 @@ namespace ITAGeo
, pUserData( nullptr )
, v3MirrorPosition( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_SPECULAR_REFLECTION;
CPropagationAnchor::iAnchorType = CPropagationAnchor::SPECULAR_REFLECTION;
};
inline virtual ~CMirrorImage() {};
......@@ -199,10 +205,8 @@ namespace ITAGeo
bProtected = oOther.bProtected;
v3InteractionPoint = oOther.v3InteractionPoint;
/* @todo jst implement material manager logic (switch to shared ptr?)
if( pManager )
pManager->AssignMaterial( *this, oOther.pAcousticMaterial->GetIdentifier(), pAcousticMaterial );
*/
pManager->AddMaterial( oOther.pAcousticMaterial->GetIdentifier(), pAcousticMaterial );
};
private:
inline const CMirrorImage operator=( const CMirrorImage& )
......@@ -219,8 +223,12 @@ namespace ITAGeo
{
public:
inline CSpecularReflection() {};
inline CSpecularReflection( const VistaVector3D& v3SpecularReflectionPoint )
: CPropagationAnchor( v3SpecularReflectionPoint ) {};
inline CSpecularReflection( const VistaVector3D& v3SpecularReflectionPoint )
: CPropagationAnchor( v3SpecularReflectionPoint )
{
iAnchorType = CPropagationAnchor::SPECULAR_REFLECTION;
};
inline virtual ~CSpecularReflection() {};
};
......
......@@ -132,7 +132,7 @@ namespace ITAGeo
bool TriangulateMesh();
//! Add acoustic material to a face of mesh
bool SetFaceAcousticMaterial( int iFaceID, IAcousticMaterial* pMaterial );
bool SetFaceAcousticMaterial( int iFaceID, std::shared_ptr< IAcousticMaterial > pMaterial );
//! Invert normal direction vector of all faces
/**
......
......@@ -46,7 +46,7 @@ namespace ITAGeo
* @param[in] sMaterialIdentifier Text-based material identifier (usually the name of the material)
* @return Pointer to material or nullptr, if not available
*/
virtual const ITAGeo::IAcousticMaterial* GetMaterial( const std::string& sMaterialIdentifier ) const = 0;
virtual std::shared_ptr< ITAGeo::IAcousticMaterial > GetMaterial( const std::string& sMaterialIdentifier ) const = 0;
//! Checks if material can be found
virtual bool HasMaterial( const std::string& sMaterialIdentifier ) const;
......@@ -55,7 +55,7 @@ namespace ITAGeo
/**
* @return True, if possible, false if already existing or manager is read-only
*/
virtual bool AddMaterialCopy( const std::string& sIdentifier, const ITAGeo::IAcousticMaterial* pMat ) = 0;
virtual bool AddMaterial( const std::string& sIdentifier, std::shared_ptr< ITAGeo::IAcousticMaterial > pMat ) = 0;
virtual bool GetReadOnly() const = 0;
};
......@@ -71,15 +71,15 @@ namespace ITAGeo
std::vector< std::string > GetPaths() const;
void AddMaterialsFromFolder( const std::string& sFolderPath, const bool bRecursive = false );
const ITAGeo::IAcousticMaterial* GetMaterial( const std::string& sMaterialIdentifier ) const;
std::shared_ptr< ITAGeo::IAcousticMaterial > GetMaterial( const std::string& sMaterialIdentifier ) const;
int GetNumMaterials() const;
std::vector< std::string > GetMaterialIdentifier() const;
bool AddMaterialCopy( const std::string&, const ITAGeo::IAcousticMaterial* );
bool AddMaterial( const std::string&, std::shared_ptr< ITAGeo::IAcousticMaterial > );
bool GetReadOnly() const;
private:
std::map< std::string, ITAGeo::IAcousticMaterial* > m_mMaterials;
std::map< std::string, std::shared_ptr< ITAGeo::IAcousticMaterial > > m_mMaterials;
std::vector< std::string > m_vsPaths;
};
......
......@@ -27,6 +27,10 @@
#include <VistaBase/VistaVector3D.h>
#include <VistaMath/VistaGeometries.h>
// STL
#include <string>
//! Namespace of utility functions for geometrical acoustics
/**
* The utility functions implemented are usually returning true if calculation was successfull
......@@ -114,6 +118,8 @@ namespace ITAGeoUtils
* @return Numer of required images (not necessarily audible)
*/
ITA_GEO_API unsigned long int CalculateNumberOfImages( const int iFaceCount, const int iOrder );
ITA_GEO_API std::string GetAcousticMaterialTypeString( const int iType );
};
#endif // INCLUDE_WATCHER_ITA_GEO_UTILS
......@@ -6,19 +6,19 @@ std::string ITAGeo::CPropagationAnchor::GetAnchorTypeStr( ITAGeo::CPropagationAn
{
switch( iType )
{
case ITA_ACOUSTIC_EMITTER:
case ACOUSTIC_EMITTER:
return "Source";
case ITA_ACOUSTIC_SENSOR:
case ACOUSTIC_SENSOR:
return "Receiver";
case ITA_SPECULAR_REFLECTION:
case SPECULAR_REFLECTION:
return "SpecularReflection";
case ITA_DIFFUSE_REFLECTION:
return "DiffuseReflection";
case ITA_TRANSMISSION:
case TRANSMISSION_APEX:
return "Transmission";
case ITA_EDGE_DIFFRACTION:
case DIFFRACTION_APEX:
return "EdgeDiffraction";
case ITA_ANCHOR_INVALID:
case GENERIC_ANCHOR:
return "InvalidAnchor";
default:
return "Unkown";
......@@ -26,7 +26,7 @@ std::string ITAGeo::CPropagationAnchor::GetAnchorTypeStr( ITAGeo::CPropagationAn
}
ITAGeo::CPropagationAnchor::CPropagationAnchor()
: iAnchorType( ITA_ANCHOR_INVALID )
: iAnchorType( GENERIC_ANCHOR )
, pAcousticMaterial( NULL )
, bProtected( false )
{
......@@ -34,7 +34,7 @@ ITAGeo::CPropagationAnchor::CPropagationAnchor()
}
ITAGeo::CPropagationAnchor::CPropagationAnchor( const VistaVector3D& v3InteractionPoint )
: iAnchorType( ITA_ANCHOR_INVALID )
: iAnchorType( GENERIC_ANCHOR )
, pAcousticMaterial( NULL )
, bProtected( false )
, v3InteractionPoint( v3InteractionPoint )
......@@ -51,7 +51,7 @@ void ITAGeo::DeleteAnchorsAndClear( ITAGeo::CPropagationPath& oDestructiblePath
{
for( size_t n = 0; n < oDestructiblePath.size(); n++ )
if( !oDestructiblePath[ n ]->bProtected )
oDestructiblePath[ n ];
delete oDestructiblePath[ n ];
oDestructiblePath.clear();
}
......@@ -175,7 +175,7 @@ bool ITAGeo::CHalfedgeMeshModel::TriangulateMesh()
return true;
}
bool ITAGeo::CHalfedgeMeshModel::SetFaceAcousticMaterial( int iFaceID, IAcousticMaterial* pMaterial )
bool ITAGeo::CHalfedgeMeshModel::SetFaceAcousticMaterial( int iFaceID, std::shared_ptr< IAcousticMaterial > pMaterial )
{
CITAMesh* pMesh = static_cast< CITAMesh* >( m_prModelMeshData->pTopLevelMesh );
CITAMesh::FaceIter f_it = pMesh->faces_begin();
......
......@@ -151,6 +151,14 @@ bool CITAGeoHalfedgeSketchUpReader::read( const std::string& sFilePath, OpenMesh
// Add face
CITAMesh::FaceHandle hFace = oBaseImporter.add_face( vhVertices );
if( !hFace.is_valid() )
{
std::cerr << "Invalid face handle, could not add face from vertices list during SketchUp file import. Vertices index list: [ ";
for( auto v : vhVertices )
std::cout << v.idx() << " ";
std::cout << " ]" << std::endl;
continue;
}
// Material / textures
......@@ -171,7 +179,6 @@ bool CITAGeoHalfedgeSketchUpReader::read( const std::string& sFilePath, OpenMesh
oBaseImporter.set_face_texindex( hFace, mTextures[ sMaterialName ] );
}
}
// Add material information
......
......@@ -32,6 +32,8 @@ bool ITAGeo::CMaterialManager::HasMaterial( const std::string& sMaterialIdentifi
struct CMATFileMaterial
{
inline CMATFileMaterial() {};
CMATFileMaterial( const std::string& sFilePath );
void LoadFromFile( const std::string& sFilePath );
std::string sName;
......@@ -54,8 +56,6 @@ ITAGeo::CMaterialDirectory::CMaterialDirectory( const std::string& sFolderPath,
ITAGeo::CMaterialDirectory::~CMaterialDirectory()
{
for( auto m : m_mMaterials )
delete m.second;
}
std::vector< std::string > ITAGeo::CMaterialDirectory::GetPaths() const
......@@ -83,10 +83,10 @@ void ITAGeo::CMaterialDirectory::AddMaterialsFromFolder( const std::string& sFol
if( sExtension == "mat" )
{
const std::string sIdentifier = *( vsFileNameParts.begin() );
CMATFileMaterial oMaterial;
oMaterial.LoadFromFile( pNode->GetName() );
CThirdOctaveMaterial* pMaterial = new CThirdOctaveMaterial();
CMATFileMaterial oMaterial( pNode->GetName() );
auto pMaterial = std::make_shared< CThirdOctaveMaterial >();
pMaterial->sName = oMaterial.sName;
pMaterial->oAbsorptionCoefficients.SetMagnitudes( oMaterial.vfAbsorptionCoefficients );
......@@ -97,7 +97,7 @@ void ITAGeo::CMaterialDirectory::AddMaterialsFromFolder( const std::string& sFol
}
}
const ITAGeo::IAcousticMaterial* ITAGeo::CMaterialDirectory::GetMaterial( const std::string& sMaterialIdentifier ) const
std::shared_ptr< ITAGeo::IAcousticMaterial > ITAGeo::CMaterialDirectory::GetMaterial( const std::string& sMaterialIdentifier ) const
{
if( m_mMaterials.find( sMaterialIdentifier ) == m_mMaterials.end() )
return nullptr;
......@@ -113,13 +113,13 @@ int ITAGeo::CMaterialDirectory::GetNumMaterials() const
std::vector< std::string > ITAGeo::CMaterialDirectory::GetMaterialIdentifier() const
{
std::vector< std::string > vsIDs;
std::map< std::string, IAcousticMaterial* >::const_iterator cit = m_mMaterials.begin();
std::map< std::string, std::shared_ptr< IAcousticMaterial > >::const_iterator cit = m_mMaterials.begin();
while( cit != m_mMaterials.end() )
vsIDs.push_back( cit++->first );
return vsIDs;
}
bool ITAGeo::CMaterialDirectory::AddMaterialCopy( const std::string&, const ITAGeo::IAcousticMaterial* )
bool ITAGeo::CMaterialDirectory::AddMaterial( const std::string&, std::shared_ptr< ITAGeo::IAcousticMaterial > )
{
return !GetReadOnly();
}
......@@ -129,6 +129,11 @@ bool ITAGeo::CMaterialDirectory::GetReadOnly() const
return true;
}
CMATFileMaterial::CMATFileMaterial( const std::string& sFilePath )
{
LoadFromFile( sFilePath );
}
void CMATFileMaterial::LoadFromFile( const std::string& sFilePath )
{
INIFileUseFile( sFilePath );
......
......@@ -25,7 +25,7 @@ void AddAcousticFacePropertyToMesh( CITAMesh* pMesh )
pMesh->add_property( tAcousticFaceProp );
}
bool AssignFaceMaterial( CITAMesh* pMesh, const ITAGeo::IAcousticMaterial* pMaterial, CITAMesh::FaceHandle hFace )
bool AssignFaceMaterial( CITAMesh* pMesh, std::shared_ptr< ITAGeo::IAcousticMaterial > pMaterial, CITAMesh::FaceHandle hFace )
{
assert( pMesh );
assert( pMaterial );
......@@ -34,7 +34,7 @@ bool AssignFaceMaterial( CITAMesh* pMesh, const ITAGeo::IAcousticMaterial* pMate
return true;
}
bool SUColorToOneDimAcousticMaterial( ITAGeo::CScalarMaterial* pMaterial, const SUColor& tColor )
bool SUColorToOneDimAcousticMaterial( std::shared_ptr< ITAGeo::CScalarMaterial > pMaterial, const SUColor& tColor )
{
assert( pMaterial );
pMaterial->cdTransmissionFactor = tColor.alpha / 255.0f; // T, complex
......@@ -43,10 +43,10 @@ bool SUColorToOneDimAcousticMaterial( ITAGeo::CScalarMaterial* pMaterial, const
return true;
}
bool AcousticMaterialToSUMaterial( CITAMesh* pMesh, CITAMesh::FaceHandle hFace, SUMaterialRef* pSUFaceMaterial, ITAGeo::CMaterialManager* pManager )
bool AcousticMaterialToSUMaterial( CITAMesh* pMesh, CITAMesh::FaceHandle hFace, SUMaterialRef* pSUFaceMaterial, ITAGeo::CMaterialManager* )
{
assert( pMesh );
const IAcousticMaterial* pMaterial = pMesh->property( tAcousticFaceProp, hFace ).GetMaterial();
auto pMaterial = pMesh->property( tAcousticFaceProp, hFace ).GetMaterial();
if( pMaterial == nullptr )
return false;
......@@ -57,7 +57,7 @@ bool AcousticMaterialToSUMaterial( CITAMesh* pMesh, CITAMesh::FaceHandle hFace,
{
case IAcousticMaterial::VISUALIZATION:
{
const CVisualizationMaterial* pVisMaterial = static_cast< const CVisualizationMaterial* >( pMaterial );
std::shared_ptr< CVisualizationMaterial > pVisMaterial = std::dynamic_pointer_cast< CVisualizationMaterial >( pMaterial );
assert( pVisMaterial );
oSUColor.red = ( unsigned char ) ( pVisMaterial->dRed * 255.0f );
oSUColor.green = ( unsigned char ) ( pVisMaterial->dGreen * 255.0f );
......@@ -107,27 +107,23 @@ SUResult SUMaterialToAcousticMaterial( CITAMesh* pMesh, CITAMesh::FaceHandle hFa
pMesh->property( tAcousticFaceProp, hFace ).sName = sMaterialName;
std::string sTextureFileName;
SUStringRef rTextureFileName = SU_INVALID;
SUStringCreate( &rTextureFileName );
// If the manager has an acoustic material with the name of the
// face material, it will be assigned, otherwise created and assigned if possible
if( pManager->HasMaterial( sMaterialName ) )
{
const IAcousticMaterial* pMat = pManager->GetMaterial( sMaterialName );
auto pMat = pManager->GetMaterial( sMaterialName );
pMesh->property( tAcousticFaceProp, hFace ).SetMaterial( pMat );
}
else if( pManager->GetReadOnly() == false )
{
SUTextureRef rTexture;
SUColor tColor;
CScalarMaterial* pNewMat = nullptr;
std::shared_ptr< CScalarMaterial > pNewMat = nullptr;
switch( tMaterial )
{
case( SUMaterialType_ColorizedTexture ) : // Only entered if material by name not found
case( SUMaterialType_Colored ) :
{
sur = SUMaterialGetColor( rMaterial, &tColor );
......@@ -135,33 +131,15 @@ SUResult SUMaterialToAcousticMaterial( CITAMesh* pMesh, CITAMesh::FaceHandle hFa
return sur;
// Create Material
pNewMat = new CScalarMaterial;
pNewMat = std::make_shared< CScalarMaterial >();
SUColorToOneDimAcousticMaterial( pNewMat, tColor );
break;
}
case( SUMaterialType_ColorizedTexture ) :
{
// Texture stronger than material, fallback if not available in database
bool bMaterialFound = false;
sur = SUMaterialGetColor( rMaterial, &tColor );
if( sur != SU_ERROR_NONE )
return sur;
SUMaterialGetTexture( rMaterial, &rTexture );
if( SUTextureGetFileName( rTexture, &rTextureFileName ) == SU_ERROR_NONE )
sTextureFileName = SUStringToStdString( rTextureFileName );
// Create material
pNewMat = new CScalarMaterial;
SUColorToOneDimAcousticMaterial( pNewMat, tColor );
break;
}
}
if( pNewMat && pManager->AddMaterialCopy( sMaterialName, pNewMat ) )
if( pNewMat && pManager->AddMaterial( sMaterialName, pNewMat ) )
pMesh->property( tAcousticFaceProp, hFace ).SetMaterial( pManager->GetMaterial( sMaterialName ) );
delete pNewMat;
}
}
......
......@@ -43,7 +43,7 @@ typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
void AddAcousticFacePropertyToMesh( CITAMesh* pMesh );
//! Adds acoustic material to a mesh face
bool AssignFaceMaterial( CITAMesh* pMesh, const ITAGeo::IAcousticMaterial* pMaterial, CITAMesh::FaceHandle hFace );
bool AssignFaceMaterial( CITAMesh* pMesh, std::shared_ptr< ITAGeo::IAcousticMaterial > pMaterial, CITAMesh::FaceHandle hFace );
//! Converts a color to a one-dimensional acoustic material
bool SUColorToOneDimAcousticMaterial( ITAGeo::CScalarMaterial* pMaterial, const SUColor& tColor );
......
#include <ITAGeoUtils.h>
#include <ITAGeoAcousticMaterial.h>
#include <ITAException.h>
#include <ITAConstants.h>
......@@ -56,13 +58,14 @@ bool ITAGeoUtils::IsPointInConvexPolygon( const VistaVector3D& v3Point, VistaPol
for( size_t i = 0; i < vv3PolyPoints.size() - 1; i++ )
{
const size_t iCurrentIdx = i;
const size_t iNextIdx = ( i + 1 ) % vv3PolyPoints.size();
const size_t iNextNextIdx = ( i + 2 ) % vv3PolyPoints.size();
const float fDotProduct1 = ( *vv3PolyPoints[ iNextIdx ] - *vv3PolyPoints[ i ] ).Dot( v3Point - *vv3PolyPoints[ i ] );
const float fDotProduct2 = ( *vv3PolyPoints[ iNextNextIdx ] - *vv3PolyPoints[ iNextIdx ] ).Dot( v3Point - *vv3PolyPoints[ iNextIdx ] );
const VistaVector3D v3CrossProd1 = ( *vv3PolyPoints[ iNextIdx ] - *vv3PolyPoints[ iCurrentIdx ] ).Cross( v3Point - *vv3PolyPoints[ iCurrentIdx ] );
const VistaVector3D v3CrossProd2 = ( *vv3PolyPoints[ iNextNextIdx ] - *vv3PolyPoints[ iNextIdx ] ).Cross( v3Point - *vv3PolyPoints[ iNextIdx ] );
// Compare signs between pairs
if( std::copysignf( 1.0f, fDotProduct1 ) != std::copysignf( 1.0f, fDotProduct2 ) )
if( v3CrossProd1.Dot( v3CrossProd2 ) <= 0.0f )
return false;
}
......@@ -220,3 +223,27 @@ unsigned long int ITAGeoUtils::CalculateNumberOfImages( const int iFaceCount, co
return CalculateNumberOfImages( iFaceCount, iOrder - 1 ) + iFaceCount * ( unsigned long int ) std::pow( ( iFaceCount - 1 ), ( iOrder - 1 ) );
}
std::string ITAGeoUtils::GetAcousticMaterialTypeString( const int iType )
{
switch( iType )
{
case ITAGeo::IAcousticMaterial::VISUALIZATION:
return "Visualization";
case ITAGeo::IAcousticMaterial::SCALAR:
return "Scalar";
case ITAGeo::IAcousticMaterial::COMPLEX_SPECTRUM:
return "Complex spectrum";
case ITAGeo::IAcousticMaterial::MAGNITUDE_SPECTRUM:
return "Magnitude spectrum";
case ITAGeo::IAcousticMaterial::THIRD_OCTAVE:
return "Third octave band spectrum";
case ITAGeo::IAcousticMaterial::WHOLE_OCTAVE:
return "Octave band spectrum";
case ITAGeo::IAcousticMaterial::TRI_BAND:
return "Tri-band spectrum";
case ITAGeo::IAcousticMaterial::NONE:
default:
return "Unspecified";
}
}
#include <ITAGeoMaterialManager.h>
#include <ITAGeoUtils.h>
#include <ITAException.h>
......@@ -20,7 +21,10 @@ int main( int, char** )
for( auto s : oMaterialDirectory.GetPaths() )
cout << s << endl;
const IAcousticMaterial* pMaterial = oMaterialDirectory.GetMaterial( "stonewall" );
auto pMaterial = oMaterialDirectory.GetMaterial( "stonewall" );
cout << "Material name: " << pMaterial->GetName() << endl;
cout << "Material type: " << ITAGeoUtils::GetAcousticMaterialTypeString( pMaterial->GetType() ) << endl;
return 0;
}
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