Aufgrund eines Security Updates wird GitLab heute zwischen 14:00 und 14:30 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to a security update GitLab will be temporarily unavailable between 2 and 2:30 today.

Switching to shared pointer concept for acoustic material handlich

parent e1685b2d
...@@ -53,7 +53,7 @@ namespace ITAGeo ...@@ -53,7 +53,7 @@ namespace ITAGeo
class ITA_GEO_API IAcousticMaterial class ITA_GEO_API IAcousticMaterial
{ {
public: public:
enum enum Type
{ {
NONE = 0, //!< No data type specified NONE = 0, //!< No data type specified
VISUALIZATION, //!< Visualization material (colors, textures, etc) VISUALIZATION, //!< Visualization material (colors, textures, etc)
...@@ -76,8 +76,12 @@ namespace ITAGeo ...@@ -76,8 +76,12 @@ namespace ITAGeo
{ {
return GetIdentifier(); return GetIdentifier();
}; };
//! Get material type as string
std::string GetTypeStr() const;
}; };
class ITA_GEO_API CVisualizationMaterial : public IAcousticMaterial class ITA_GEO_API CVisualizationMaterial : public IAcousticMaterial
{ {
public: public:
...@@ -215,18 +219,18 @@ namespace ITAGeo ...@@ -215,18 +219,18 @@ namespace ITAGeo
return *this; return *this;
}; };
inline const IAcousticMaterial* GetMaterial() const inline std::shared_ptr< IAcousticMaterial > GetMaterial() const
{ {
return m_pMaterial; return m_pMaterial;
}; };
inline void SetMaterial( const IAcousticMaterial* pMaterial ) inline void SetMaterial( std::shared_ptr< IAcousticMaterial > pMaterial )
{ {
m_pMaterial = pMaterial; m_pMaterial = pMaterial;
}; };
private: private:
const IAcousticMaterial* m_pMaterial; //! Pointer to complex material std::shared_ptr< IAcousticMaterial > m_pMaterial; //! Shared pointer to complex material
}; };
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
// ITAGeo includes // ITAGeo includes
#include <ITAGeoDefinitions.h> #include <ITAGeoDefinitions.h>
#include <ITAException.h> #include <ITAException.h>
#include <ITAGeoMaterialManager.h>
// Vista includes // Vista includes
#include <VistaBase/VistaQuaternion.h> #include <VistaBase/VistaQuaternion.h>
...@@ -54,17 +55,18 @@ namespace ITAGeo ...@@ -54,17 +55,18 @@ namespace ITAGeo
public: public:
enum EAnchorType enum EAnchorType
{ {
ITA_ANCHOR_INVALID = 0, GENERIC_ANCHOR = 0, //!< Propagation anchor without specified type
ITA_ACOUSTIC_EMITTER, ACOUSTIC_EMITTER, //!< Sound-emitting anchor (acoustic source, vibrating plane)
ITA_ACOUSTIC_SENSOR, ACOUSTIC_SENSOR, //!< Sound-sensing anchor (microphone, sensivitive area, listener, portal)
ITA_SPECULAR_REFLECTION, SPECULAR_REFLECTION, //!< Specular reflection occurrance point (on boundary surface)
ITA_DIFFUSE_REFLECTION, ITA_DIFFUSE_REFLECTION, //!< Diffuse reflection occurrance point (on plane or virtual)
ITA_TRANSMISSION, TRANSMISSION_APEX, //!< Transmission occurrance point (e.g. through a solid wall)
ITA_EDGE_DIFFRACTION, DIFFRACTION_APEX, //!< Diffraction occurrance point (at a boundary edge)
MIRROR_IMAGE, //!< (Virtual) Mirror image in medium
} iAnchorType; //! Type of anchor } iAnchorType; //! Type of anchor
VistaVector3D v3InteractionPoint; //!< Point of geometric interaction, has to be further defined by deriving class 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 bool bProtected; //!< Protect this anchor from destruction in DeleteAnchorsAndClear function
CPropagationAnchor(); CPropagationAnchor();
...@@ -92,19 +94,19 @@ namespace ITAGeo ...@@ -92,19 +94,19 @@ namespace ITAGeo
: CPropagationAnchor( vPos_ ) : CPropagationAnchor( vPos_ )
, vPos( v3InteractionPoint ) , vPos( v3InteractionPoint )
{ {
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_EMITTER; CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_EMITTER;
}; };
inline CEmitter( const CEmitter& oSrc ) inline CEmitter( const CEmitter& oSrc )
: CPropagationAnchor( oSrc ) : CPropagationAnchor( oSrc )
, vPos( v3InteractionPoint ) , vPos( v3InteractionPoint )
{ {
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_EMITTER; CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_EMITTER;
}; };
inline CEmitter() : vPos( v3InteractionPoint ) inline CEmitter() : vPos( v3InteractionPoint )
{ {
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_EMITTER; CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_EMITTER;
}; };
VistaVector3D& vPos; //!< Position point / geometric interaction point VistaVector3D& vPos; //!< Position point / geometric interaction point
...@@ -127,14 +129,14 @@ namespace ITAGeo ...@@ -127,14 +129,14 @@ namespace ITAGeo
inline CSensor() : vPos( v3InteractionPoint ) inline CSensor() : vPos( v3InteractionPoint )
{ {
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_SENSOR; CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_SENSOR;
}; };
inline CSensor( VistaVector3D vPos_ ) inline CSensor( VistaVector3D vPos_ )
: CPropagationAnchor( vPos_ ) : CPropagationAnchor( vPos_ )
, vPos( v3InteractionPoint ) , vPos( v3InteractionPoint )
{ {
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_SENSOR; CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_SENSOR;
}; };
VistaVector3D& vPos; //!< Position point / geometric interaction point VistaVector3D& vPos; //!< Position point / geometric interaction point
...@@ -149,11 +151,11 @@ namespace ITAGeo ...@@ -149,11 +151,11 @@ namespace ITAGeo
}; };
}; };
//! Specular reflection order on a plane //! Specular reflection / diffraction order on a plane
enum Order enum Order
{ {
ORDER_0 = 0, //!< Zero's or non-order (usually only direct paths recognized) 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_2, //!< Second order interaction, i.e. one reflection and one diffraction
ORDER_3, //!< ... ORDER_3, //!< ...
ORDER_4, //!< ... ORDER_4, //!< ...
...@@ -163,6 +165,10 @@ namespace ITAGeo ...@@ -163,6 +165,10 @@ namespace ITAGeo
ORDER_8, //!< ... 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 class ITA_GEO_API CMirrorImage : public CPropagationAnchor
{ {
public: public:
...@@ -179,7 +185,7 @@ namespace ITAGeo ...@@ -179,7 +185,7 @@ namespace ITAGeo
, iOrder( -1 ) , iOrder( -1 )
, v3MirrorPosition( v3InteractionPoint ) , v3MirrorPosition( v3InteractionPoint )
{ {
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_SPECULAR_REFLECTION; CPropagationAnchor::iAnchorType = CPropagationAnchor::MIRROR_IMAGE;
}; };
inline explicit CMirrorImage( const CPropagationAnchor& oAnchor ) inline explicit CMirrorImage( const CPropagationAnchor& oAnchor )
...@@ -189,7 +195,7 @@ namespace ITAGeo ...@@ -189,7 +195,7 @@ namespace ITAGeo
, pUserData( nullptr ) , pUserData( nullptr )
, v3MirrorPosition( v3InteractionPoint ) , v3MirrorPosition( v3InteractionPoint )
{ {
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_SPECULAR_REFLECTION; CPropagationAnchor::iAnchorType = CPropagationAnchor::SPECULAR_REFLECTION;
}; };
inline virtual ~CMirrorImage() {}; inline virtual ~CMirrorImage() {};
...@@ -199,10 +205,8 @@ namespace ITAGeo ...@@ -199,10 +205,8 @@ namespace ITAGeo
bProtected = oOther.bProtected; bProtected = oOther.bProtected;
v3InteractionPoint = oOther.v3InteractionPoint; v3InteractionPoint = oOther.v3InteractionPoint;
/* @todo jst implement material manager logic (switch to shared ptr?)
if( pManager ) if( pManager )
pManager->AssignMaterial( *this, oOther.pAcousticMaterial->GetIdentifier(), pAcousticMaterial ); pManager->AddMaterial( oOther.pAcousticMaterial->GetIdentifier(), pAcousticMaterial );
*/
}; };
private: private:
inline const CMirrorImage operator=( const CMirrorImage& ) inline const CMirrorImage operator=( const CMirrorImage& )
...@@ -219,8 +223,12 @@ namespace ITAGeo ...@@ -219,8 +223,12 @@ namespace ITAGeo
{ {
public: public:
inline CSpecularReflection() {}; inline CSpecularReflection() {};
inline CSpecularReflection( const VistaVector3D& v3SpecularReflectionPoint ) inline CSpecularReflection( const VistaVector3D& v3SpecularReflectionPoint )
: CPropagationAnchor( v3SpecularReflectionPoint ) {}; : CPropagationAnchor( v3SpecularReflectionPoint )
{
iAnchorType = CPropagationAnchor::SPECULAR_REFLECTION;
};
inline virtual ~CSpecularReflection() {}; inline virtual ~CSpecularReflection() {};
}; };
......
...@@ -132,7 +132,7 @@ namespace ITAGeo ...@@ -132,7 +132,7 @@ namespace ITAGeo
bool TriangulateMesh(); bool TriangulateMesh();
//! Add acoustic material to a face of mesh //! 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 //! Invert normal direction vector of all faces
/** /**
......
...@@ -46,7 +46,7 @@ namespace ITAGeo ...@@ -46,7 +46,7 @@ namespace ITAGeo
* @param[in] sMaterialIdentifier Text-based material identifier (usually the name of the material) * @param[in] sMaterialIdentifier Text-based material identifier (usually the name of the material)
* @return Pointer to material or nullptr, if not available * @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 //! Checks if material can be found
virtual bool HasMaterial( const std::string& sMaterialIdentifier ) const; virtual bool HasMaterial( const std::string& sMaterialIdentifier ) const;
...@@ -55,7 +55,7 @@ namespace ITAGeo ...@@ -55,7 +55,7 @@ namespace ITAGeo
/** /**
* @return True, if possible, false if already existing or manager is read-only * @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; virtual bool GetReadOnly() const = 0;
}; };
...@@ -71,15 +71,15 @@ namespace ITAGeo ...@@ -71,15 +71,15 @@ namespace ITAGeo
std::vector< std::string > GetPaths() const; std::vector< std::string > GetPaths() const;
void AddMaterialsFromFolder( const std::string& sFolderPath, const bool bRecursive = false ); 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; int GetNumMaterials() const;
std::vector< std::string > GetMaterialIdentifier() 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; bool GetReadOnly() const;
private: 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; std::vector< std::string > m_vsPaths;
}; };
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
#include <VistaBase/VistaVector3D.h> #include <VistaBase/VistaVector3D.h>
#include <VistaMath/VistaGeometries.h> #include <VistaMath/VistaGeometries.h>
// STL
#include <string>
//! Namespace of utility functions for geometrical acoustics //! Namespace of utility functions for geometrical acoustics
/** /**
* The utility functions implemented are usually returning true if calculation was successfull * The utility functions implemented are usually returning true if calculation was successfull
...@@ -114,6 +118,8 @@ namespace ITAGeoUtils ...@@ -114,6 +118,8 @@ namespace ITAGeoUtils
* @return Numer of required images (not necessarily audible) * @return Numer of required images (not necessarily audible)
*/ */
ITA_GEO_API unsigned long int CalculateNumberOfImages( const int iFaceCount, const int iOrder ); 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 #endif // INCLUDE_WATCHER_ITA_GEO_UTILS
...@@ -6,19 +6,19 @@ std::string ITAGeo::CPropagationAnchor::GetAnchorTypeStr( ITAGeo::CPropagationAn ...@@ -6,19 +6,19 @@ std::string ITAGeo::CPropagationAnchor::GetAnchorTypeStr( ITAGeo::CPropagationAn
{ {
switch( iType ) switch( iType )
{ {
case ITA_ACOUSTIC_EMITTER: case ACOUSTIC_EMITTER:
return "Source"; return "Source";
case ITA_ACOUSTIC_SENSOR: case ACOUSTIC_SENSOR:
return "Receiver"; return "Receiver";
case ITA_SPECULAR_REFLECTION: case SPECULAR_REFLECTION:
return "SpecularReflection"; return "SpecularReflection";
case ITA_DIFFUSE_REFLECTION: case ITA_DIFFUSE_REFLECTION:
return "DiffuseReflection"; return "DiffuseReflection";
case ITA_TRANSMISSION: case TRANSMISSION_APEX:
return "Transmission"; return "Transmission";
case ITA_EDGE_DIFFRACTION: case DIFFRACTION_APEX:
return "EdgeDiffraction"; return "EdgeDiffraction";
case ITA_ANCHOR_INVALID: case GENERIC_ANCHOR:
return "InvalidAnchor"; return "InvalidAnchor";
default: default:
return "Unkown"; return "Unkown";
...@@ -26,7 +26,7 @@ std::string ITAGeo::CPropagationAnchor::GetAnchorTypeStr( ITAGeo::CPropagationAn ...@@ -26,7 +26,7 @@ std::string ITAGeo::CPropagationAnchor::GetAnchorTypeStr( ITAGeo::CPropagationAn
} }
ITAGeo::CPropagationAnchor::CPropagationAnchor() ITAGeo::CPropagationAnchor::CPropagationAnchor()
: iAnchorType( ITA_ANCHOR_INVALID ) : iAnchorType( GENERIC_ANCHOR )
, pAcousticMaterial( NULL ) , pAcousticMaterial( NULL )
, bProtected( false ) , bProtected( false )
{ {
...@@ -34,7 +34,7 @@ ITAGeo::CPropagationAnchor::CPropagationAnchor() ...@@ -34,7 +34,7 @@ ITAGeo::CPropagationAnchor::CPropagationAnchor()
} }
ITAGeo::CPropagationAnchor::CPropagationAnchor( const VistaVector3D& v3InteractionPoint ) ITAGeo::CPropagationAnchor::CPropagationAnchor( const VistaVector3D& v3InteractionPoint )
: iAnchorType( ITA_ANCHOR_INVALID ) : iAnchorType( GENERIC_ANCHOR )
, pAcousticMaterial( NULL ) , pAcousticMaterial( NULL )
, bProtected( false ) , bProtected( false )
, v3InteractionPoint( v3InteractionPoint ) , v3InteractionPoint( v3InteractionPoint )
...@@ -51,7 +51,7 @@ void ITAGeo::DeleteAnchorsAndClear( ITAGeo::CPropagationPath& oDestructiblePath ...@@ -51,7 +51,7 @@ void ITAGeo::DeleteAnchorsAndClear( ITAGeo::CPropagationPath& oDestructiblePath
{ {
for( size_t n = 0; n < oDestructiblePath.size(); n++ ) for( size_t n = 0; n < oDestructiblePath.size(); n++ )
if( !oDestructiblePath[ n ]->bProtected ) if( !oDestructiblePath[ n ]->bProtected )
oDestructiblePath[ n ]; delete oDestructiblePath[ n ];
oDestructiblePath.clear(); oDestructiblePath.clear();
} }
...@@ -175,7 +175,7 @@ bool ITAGeo::CHalfedgeMeshModel::TriangulateMesh() ...@@ -175,7 +175,7 @@ bool ITAGeo::CHalfedgeMeshModel::TriangulateMesh()
return true; 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* pMesh = static_cast< CITAMesh* >( m_prModelMeshData->pTopLevelMesh );
CITAMesh::FaceIter f_it = pMesh->faces_begin(); CITAMesh::FaceIter f_it = pMesh->faces_begin();
......
...@@ -151,6 +151,14 @@ bool CITAGeoHalfedgeSketchUpReader::read( const std::string& sFilePath, OpenMesh ...@@ -151,6 +151,14 @@ bool CITAGeoHalfedgeSketchUpReader::read( const std::string& sFilePath, OpenMesh
// Add face // Add face
CITAMesh::FaceHandle hFace = oBaseImporter.add_face( vhVertices ); 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 // Material / textures
...@@ -171,7 +179,6 @@ bool CITAGeoHalfedgeSketchUpReader::read( const std::string& sFilePath, OpenMesh ...@@ -171,7 +179,6 @@ bool CITAGeoHalfedgeSketchUpReader::read( const std::string& sFilePath, OpenMesh
oBaseImporter.set_face_texindex( hFace, mTextures[ sMaterialName ] ); oBaseImporter.set_face_texindex( hFace, mTextures[ sMaterialName ] );
} }
} }
// Add material information // Add material information
......
...@@ -32,6 +32,8 @@ bool ITAGeo::CMaterialManager::HasMaterial( const std::string& sMaterialIdentifi ...@@ -32,6 +32,8 @@ bool ITAGeo::CMaterialManager::HasMaterial( const std::string& sMaterialIdentifi
struct CMATFileMaterial struct CMATFileMaterial
{ {
inline CMATFileMaterial() {};
CMATFileMaterial( const std::string& sFilePath );
void LoadFromFile( const std::string& sFilePath ); void LoadFromFile( const std::string& sFilePath );
std::string sName; std::string sName;
...@@ -54,8 +56,6 @@ ITAGeo::CMaterialDirectory::CMaterialDirectory( const std::string& sFolderPath, ...@@ -54,8 +56,6 @@ ITAGeo::CMaterialDirectory::CMaterialDirectory( const std::string& sFolderPath,
ITAGeo::CMaterialDirectory::~CMaterialDirectory() ITAGeo::CMaterialDirectory::~CMaterialDirectory()
{ {
for( auto m : m_mMaterials )
delete m.second;
} }
std::vector< std::string > ITAGeo::CMaterialDirectory::GetPaths() const std::vector< std::string > ITAGeo::CMaterialDirectory::GetPaths() const
...@@ -83,10 +83,10 @@ void ITAGeo::CMaterialDirectory::AddMaterialsFromFolder( const std::string& sFol ...@@ -83,10 +83,10 @@ void ITAGeo::CMaterialDirectory::AddMaterialsFromFolder( const std::string& sFol
if( sExtension == "mat" ) if( sExtension == "mat" )
{ {
const std::string sIdentifier = *( vsFileNameParts.begin() ); 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->sName = oMaterial.sName;
pMaterial->oAbsorptionCoefficients.SetMagnitudes( oMaterial.vfAbsorptionCoefficients ); pMaterial->oAbsorptionCoefficients.SetMagnitudes( oMaterial.vfAbsorptionCoefficients );
...@@ -97,7 +97,7 @@ void ITAGeo::CMaterialDirectory::AddMaterialsFromFolder( const std::string& sFol ...@@ -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() ) if( m_mMaterials.find( sMaterialIdentifier ) == m_mMaterials.end() )
return nullptr; return nullptr;
...@@ -113,13 +113,13 @@ int ITAGeo::CMaterialDirectory::GetNumMaterials() const ...@@ -113,13 +113,13 @@ int ITAGeo::CMaterialDirectory::GetNumMaterials() const
std::vector< std::string > ITAGeo::CMaterialDirectory::GetMaterialIdentifier() const std::vector< std::string > ITAGeo::CMaterialDirectory::GetMaterialIdentifier() const
{ {
std::vector< std::string > vsIDs; 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() ) while( cit != m_mMaterials.end() )
vsIDs.push_back( cit++->first ); vsIDs.push_back( cit++->first );
return vsIDs; 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(); return !GetReadOnly();
} }
...@@ -129,6 +129,11 @@ bool ITAGeo::CMaterialDirectory::GetReadOnly() const ...@@ -129,6 +129,11 @@ bool ITAGeo::CMaterialDirectory::GetReadOnly() const
return true; return true;
} }
CMATFileMaterial::CMATFileMaterial( const std::string& sFilePath )
{
LoadFromFile( sFilePath );
}
void CMATFileMaterial::LoadFromFile( const std::string& sFilePath ) void CMATFileMaterial::LoadFromFile( const std::string& sFilePath )
{ {
INIFileUseFile( sFilePath ); INIFileUseFile( sFilePath );
......
...@@ -25,7 +25,7 @@ void AddAcousticFacePropertyToMesh( CITAMesh* pMesh ) ...@@ -25,7 +25,7 @@ void AddAcousticFacePropertyToMesh( CITAMesh* pMesh )
pMesh->add_property( tAcousticFaceProp ); 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( pMesh );
assert( pMaterial ); assert( pMaterial );
...@@ -34,7 +34,7 @@ bool AssignFaceMaterial( CITAMesh* pMesh, const ITAGeo::IAcousticMaterial* pMate ...@@ -34,7 +34,7 @@ bool AssignFaceMaterial( CITAMesh* pMesh, const ITAGeo::IAcousticMaterial* pMate
return true; return true;
} }
bool SUColorToOneDimAcousticMaterial( ITAGeo::CScalarMaterial* pMaterial, const SUColor& tColor ) bool SUColorToOneDimAcousticMaterial( std::shared_ptr< ITAGeo::CScalarMaterial > pMaterial, const SUColor& tColor )
{ {
assert( pMaterial ); assert( pMaterial );
pMaterial->cdTransmissionFactor = tColor.alpha / 255.0f; // T, complex pMaterial->cdTransmissionFactor = tColor.alpha / 255.0f; // T, complex
...@@ -43,10 +43,10 @@ bool SUColorToOneDimAcousticMaterial( ITAGeo::CScalarMaterial* pMaterial, const ...@@ -43,10 +43,10 @@ bool SUColorToOneDimAcousticMaterial( ITAGeo::CScalarMaterial* pMaterial, const
return true; 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 ); assert( pMesh );
const IAcousticMaterial* pMaterial = pMesh->property( tAcousticFaceProp, hFace ).GetMaterial(); auto pMaterial = pMesh->property( tAcousticFaceProp, hFace ).GetMaterial();
if( pMaterial == nullptr ) if( pMaterial == nullptr )
return false; return false;
...@@ -57,7 +57,7 @@ bool AcousticMaterialToSUMaterial( CITAMesh* pMesh, CITAMesh::FaceHandle hFace, ...@@ -57,7 +57,7 @@ bool AcousticMaterialToSUMaterial( CITAMesh* pMesh, CITAMesh::FaceHandle hFace,
{ {
case IAcousticMaterial::VISUALIZATION: case IAcousticMaterial::VISUALIZATION:
{ {
const CVisualizationMaterial* pVisMaterial = static_cast< const CVisualizationMaterial* >( pMaterial ); std::shared_ptr< CVisualizationMaterial > pVisMaterial = std::dynamic_pointer_cast< CVisualizationMaterial >( pMaterial );
assert( pVisMaterial ); assert( pVisMaterial );
oSUColor.red = ( unsigned char ) ( pVisMaterial->dRed * 255.0f ); oSUColor.red = ( unsigned char ) ( pVisMaterial->dRed * 255.0f );
oSUColor.green = ( unsigned char ) ( pVisMaterial->dGreen * 255.0f ); oSUColor.green = ( unsigned char ) ( pVisMaterial->dGreen * 255.0f );
...@@ -107,27 +107,23 @@ SUResult SUMaterialToAcousticMaterial( CITAMesh* pMesh, CITAMesh::FaceHandle hFa ...@@ -107,27 +107,23 @@ SUResult SUMaterialToAcousticMaterial( CITAMesh* pMesh, CITAMesh::FaceHandle hFa
pMesh->property( tAcousticFaceProp, hFace ).sName = sMaterialName; 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 // If the manager has an acoustic material with the name of the
// face material, it will be assigned, otherwise created and assigned if possible // face material, it will be assigned, otherwise created and assigned if possible
if( pManager->HasMaterial( sMaterialName ) ) if( pManager->HasMaterial( sMaterialName ) )
{ {
const IAcousticMaterial* pMat = pManager->GetMaterial( sMaterialName ); auto pMat = pManager->GetMaterial( sMaterialName );
pMesh->property( tAcousticFaceProp, hFace ).SetMaterial( pMat ); pMesh->property( tAcousticFaceProp, hFace ).SetMaterial( pMat );
} }
else if( pManager->GetReadOnly() == false ) else if( pManager->GetReadOnly() == false )
{ {
SUTextureRef rTexture;
SUColor tColor; SUColor tColor;
CScalarMaterial* pNewMat = nullptr; std::shared_ptr< CScalarMaterial > pNewMat = nullptr;