Refactoring: introducing ITAGeo namespace

parent c993b154
......@@ -28,16 +28,17 @@
#include <assert.h>
using namespace std;
using namespace ITAGeo;
int main( int argc, char** argv )
{
// Convert string from supported file formats
string s = CITAGeoHalfedgeMeshModel::GetSupportedInputFormats();
string s = CHalfedgeMeshModel::GetSupportedInputFormats();
size_t idx = s.find_first_of( ";;" );
if( idx < 13 + 2 )
cerr << "Could not retrieve supported input formats from OpenMesh" << endl;
string sSupportedImportFiles = s.substr( 13, idx - 2 - 13 );
s = CITAGeoHalfedgeMeshModel::GetSupportedInputFormats();
s = CHalfedgeMeshModel::GetSupportedInputFormats();
idx = s.find_first_of( ";;" );
if( idx < 13 + 2 )
cerr << "Could not retrieve supported input formats from OpenMesh" << endl;
......@@ -59,7 +60,7 @@ int main( int argc, char** argv )
cout << "Converting from input file '" << sModelFilePathIn << "' to '" << sModelFilePathOut << "'" << endl;
CITAGeoHalfedgeMeshModel oHEModel;
CHalfedgeMeshModel oHEModel;
try
{
......
......@@ -36,114 +36,115 @@
class IITAAcousticMaterial;
//! A boundary/interaction point in a geometrical acoustics context
/*
* A geometrical propagation anchor defines a point in 3D space where acoustic interaction appears,
* like a surface with a specular or diffuse reflection, a point on an edge where diffraction occurs
* or simply an acoustic actuator (sound source) or sensor (microphone).
*
*/
class ITA_GEO_API CITAGeoPropagationAnchor
{
public:
enum EAnchorType
{
ITA_ANCHOR_INVALID = 0,
ITA_ACOUSTIC_SOURCE,
ITA_ACOUSTIC_RECEIVER,
ITA_SPECULAR_REFLECTION,
ITA_DIFFUSE_REFLECTION,
ITA_TRANSMISSION,
ITA_EDGE_DIFFRACTION,
} iAnchorType; //! Type of anchor
VistaVector3D v3InteractionPoint; //!< Point of geometric interaction, has to be further defined by deriving class
IITAAcousticMaterial* pAcousticMaterial; //!< Acoustic material connection, i.e. absorption coefficient
bool bProtected; //!< Protect this anchor from destruction in DeleteAnchorsAndClear function
CITAGeoPropagationAnchor();
CITAGeoPropagationAnchor( const VistaVector3D& oPos );
virtual ~CITAGeoPropagationAnchor();
//! Returns anchor type as a string
/**
* @param[in] iType Anchor type
*/
static std::string GetAnchorTypeStr( EAnchorType iType );
//! Output stream operator for console formatting etc.
friend std::ostream& operator<<( std::ostream&, const CITAGeoPropagationAnchor& );
};
//! A sound source propagation anchor
class ITA_GEO_API CITASource : public CITAGeoPropagationAnchor
namespace ITAGeo
{
public:
std::string sName; //!< Versatile source name (for debugging)
inline CITASource( VistaVector3D vPos_ )
: CITAGeoPropagationAnchor( vPos_ )
, vPos( v3InteractionPoint )
//! A boundary/interaction point in a geometrical acoustics context
/*
* A geometrical propagation anchor defines a point in 3D space where acoustic interaction appears,
* like a surface with a specular or diffuse reflection, a point on an edge where diffraction occurs
* or simply an acoustic actuator (sound source) or sensor (microphone).
*
*/
class ITA_GEO_API CPropagationAnchor
{
CITAGeoPropagationAnchor::iAnchorType = CITAGeoPropagationAnchor::ITA_ACOUSTIC_SOURCE;
};
inline CITASource( const CITASource& oSrc )
: CITAGeoPropagationAnchor( oSrc )
, vPos( v3InteractionPoint )
{
CITAGeoPropagationAnchor::iAnchorType = CITAGeoPropagationAnchor::ITA_ACOUSTIC_SOURCE;
};
inline CITASource() : vPos( v3InteractionPoint )
{
CITAGeoPropagationAnchor::iAnchorType = CITAGeoPropagationAnchor::ITA_ACOUSTIC_SOURCE;
};
VistaVector3D& vPos; //!< Position point / geometric interaction point
VistaQuaternion qOrient; //!< Orientation of object (if applicable)
inline const CITASource& operator=( const CITASource& oOther )
{
sName = oOther.sName;
v3InteractionPoint = oOther.v3InteractionPoint;
qOrient = oOther.qOrient;
return *this;
public:
enum EAnchorType
{
ITA_ANCHOR_INVALID = 0,
ITA_ACOUSTIC_SOURCE,
ITA_ACOUSTIC_RECEIVER,
ITA_SPECULAR_REFLECTION,
ITA_DIFFUSE_REFLECTION,
ITA_TRANSMISSION,
ITA_EDGE_DIFFRACTION,
} iAnchorType; //! Type of anchor
VistaVector3D v3InteractionPoint; //!< Point of geometric interaction, has to be further defined by deriving class
IITAAcousticMaterial* pAcousticMaterial; //!< Acoustic material connection, i.e. absorption coefficient
bool bProtected; //!< Protect this anchor from destruction in DeleteAnchorsAndClear function
CPropagationAnchor();
CPropagationAnchor( const VistaVector3D& oPos );
virtual ~CPropagationAnchor();
//! Returns anchor type as a string
/**
* @param[in] iType Anchor type
*/
static std::string GetAnchorTypeStr( ITAGeo::CPropagationAnchor::EAnchorType iType );
//! Output stream operator for console formatting etc.
friend std::ostream& operator<<( std::ostream&, const ITAGeo::CPropagationAnchor& );
};
};
//! A sensor / sound receiver / listener
class ITA_GEO_API CITAReceiver : public CITAGeoPropagationAnchor
{
public:
std::string sName; //! Versatile receiver name (for debugging)
inline CITAReceiver() : vPos( v3InteractionPoint )
{
CITAGeoPropagationAnchor::iAnchorType = CITAGeoPropagationAnchor::ITA_ACOUSTIC_RECEIVER;
};
inline CITAReceiver( VistaVector3D vPos_ )
: CITAGeoPropagationAnchor( vPos_ )
, vPos( v3InteractionPoint )
//! A sound source propagation anchor
class ITA_GEO_API CEmitter : public ITAGeo::CPropagationAnchor
{
CITAGeoPropagationAnchor::iAnchorType = CITAGeoPropagationAnchor::ITA_ACOUSTIC_RECEIVER;
public:
std::string sName; //!< Versatile source name (for debugging)
inline CEmitter( VistaVector3D vPos_ )
: CPropagationAnchor( vPos_ )
, vPos( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_SOURCE;
};
inline CEmitter( const CEmitter& oSrc )
: CPropagationAnchor( oSrc )
, vPos( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_SOURCE;
};
inline CEmitter() : vPos( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_SOURCE;
};
VistaVector3D& vPos; //!< Position point / geometric interaction point
VistaQuaternion qOrient; //!< Orientation of object (if applicable)
inline const CEmitter& operator=( const CEmitter& oOther )
{
sName = oOther.sName;
v3InteractionPoint = oOther.v3InteractionPoint;
qOrient = oOther.qOrient;
return *this;
};
};
VistaVector3D& vPos; //!< Position point / geometric interaction point
VistaQuaternion qOrient;
inline const CITAReceiver& operator=( const CITAReceiver& oOther )
//! A sensor / sound receiver / listener
class ITA_GEO_API CSensor : public CPropagationAnchor
{
sName = oOther.sName;
v3InteractionPoint = oOther.v3InteractionPoint;
qOrient = oOther.qOrient;
return *this;
public:
std::string sName; //! Versatile receiver name (for debugging)
inline CSensor() : vPos( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_RECEIVER;
};
inline CSensor( VistaVector3D vPos_ )
: CPropagationAnchor( vPos_ )
, vPos( v3InteractionPoint )
{
CPropagationAnchor::iAnchorType = CPropagationAnchor::ITA_ACOUSTIC_RECEIVER;
};
VistaVector3D& vPos; //!< Position point / geometric interaction point
VistaQuaternion qOrient;
inline const CSensor& operator=( const CSensor& oOther )
{
sName = oOther.sName;
v3InteractionPoint = oOther.v3InteractionPoint;
qOrient = oOther.qOrient;
return *this;
};
};
};
namespace ITAGeo
{
//! Specular reflection order on a plane
enum Order
{
......@@ -153,50 +154,62 @@ namespace ITAGeo
ORDER_3, //!< ...
};
class ITA_GEO_API CMirrorImage : public CPropagationAnchor
{
public:
inline CMirrorImage() {};
inline virtual ~CMirrorImage() {};
VistaVector3D v3MirrorNormal;
};
//! Geometrical propagation anchor with parameters of a specular reflection point
/**
* A specular reflection point
*/
class ITA_GEO_API CSpecularReflection : public CITAGeoPropagationAnchor
class ITA_GEO_API CSpecularReflection : public CPropagationAnchor
{
public:
inline CSpecularReflection() {};
inline virtual ~CSpecularReflection() {};
};
}
ITA_GEO_API typedef std::vector< CITAGeoPropagationAnchor* > CITAGeoPropagationPath; //!< Geometric propagation path
ITA_GEO_API typedef std::vector< CPropagationAnchor* > CPropagationPath; //!< Geometric propagation path
namespace ITAGeo
{
//! Clears and deletes all anchors of path without protection flag enabled
/**
* @note Calls destructor on all anchors - make sure that no double deletion occurs!
*/
ITA_GEO_API void DeleteAnchorsAndClear( CITAGeoPropagationPath& oDestructiblePath );
ITA_GEO_API void DeleteAnchorsAndClear( CPropagationPath& oDestructiblePath );
}
//! STL stream output operator
inline std::ostream& operator<<( std::ostream& os, const CITAGeoPropagationAnchor* pAnchor )
inline std::ostream& operator<<( std::ostream& os, const ITAGeo::CPropagationAnchor& oAnchor )
{
os << *pAnchor;
os << "[ " << std::setw( 18 ) << ITAGeo::CPropagationAnchor::GetAnchorTypeStr( oAnchor.iAnchorType ) << " ] " << oAnchor.v3InteractionPoint;
return os;
};
inline std::ostream& operator<<( std::ostream& os, const CITAGeoPropagationAnchor& oAnchor )
/*
inline std::ostream& operator<<( std::ostream& os, const ITAGeo::CPropagationAnchor* pAnchor )
{
os << "[ " << std::setw( 18 ) << CITAGeoPropagationAnchor::GetAnchorTypeStr( oAnchor.iAnchorType ) << " ] " << oAnchor.v3InteractionPoint;
ITAGeo::CPropagationAnchor oAnchor( *pAnchor );
os << oAnchor; // error C2593 @todo solve
return os;
};
*/
inline std::ostream& operator<<( std::ostream& os, const CITAGeoPropagationPath& vPaths )
inline std::ostream& operator<<( std::ostream& os, const ITAGeo::CPropagationPath& vPaths )
{
os << "GeoPropagationPath: " << vPaths.size() << " anchors found" << std::endl;
for( size_t i = 0; i < vPaths.size(); i++ )
{
const CITAGeoPropagationAnchor* pAnchor( vPaths[ i ] );
const ITAGeo::CPropagationAnchor* pAnchor( vPaths[ i ] );
os << " GeoAnchor #" << std::setw( 3 ) << 1 + i << ": " << pAnchor << std::endl;
}
return os;
......
......@@ -22,6 +22,7 @@
#include <ITAGeoDefinitions.h>
#include <ITAGeoBase.h>
#include <ITAGeoModelBase.h>
#include <ITAGeoHalfedgeMeshModel.h>
// Vista includes
#include <VistaBase/VistaVector3D.h>
......@@ -29,55 +30,60 @@
// STL includes
#include <string>
struct CITACityGMLPtr;
//! CityGML input and output class
/**
* Interface that describes file I/O for CityGML files.
*
*/
class ITA_GEO_API CITAGeoCityGMLModel : public CITAGeoModelBase
namespace ITAGeo
{
public:
struct CCityBuilding
//! Helper struct forward declaration
struct CCityGMLPtr;
//! CityGML input and output class
/**
* Interface that describes file I/O for CityGML files.
*
*/
class ITA_GEO_API CCityGMLModel : public CModelBase
{
std::string id;
VistaVector3D v3CenterPos;
float fBoundingSphereRad;
};
public:
struct CCityBuilding
{
std::string id;
VistaVector3D v3CenterPos;
float fBoundingSphereRad;
};
CITAGeoCityGMLModel();
virtual ~CITAGeoCityGMLModel();
CCityGMLModel();
virtual ~CCityGMLModel();
//! Loads CityGML data from given file path
/*
* \note Throws ITAException (i.e. if file not found)
* \return True, if CityGML file can be translated into a scene
*
*/
bool Load( const std::string& sGMLFilePath );
//! Loads CityGML data from given file path
/*
* \note Throws ITAException (i.e. if file not found)
* \return True, if CityGML file can be translated into a scene
*
*/
bool Load( const std::string& sGMLFilePath );
//! Saves CityGML data to given file path
/*
* \note Throws ITAException (i.e. if file could not be written)
* \return True, if file could be exported
*/
bool Store( const std::string& sGMLFilePath, bool bOverwrite = true ) const;
//! Saves CityGML data to given file path
/*
* \note Throws ITAException (i.e. if file could not be written)
* \return True, if file could be exported
*/
bool Store( const std::string& sGMLFilePath, bool bOverwrite = true ) const;
void GetBuildingMesh(const CCityBuilding* pBuilding, CITAGeoHalfedgeMeshModel* pBuildingMesh);
void GetBuildingMesh( const CCityBuilding* pBuilding, ITAGeo::CHalfedgeMeshModel* pBuildingMesh );
void DistanceCulling(const double dDetourDistance, const CITASource& v3Source, const CITAReceiver& v3Receiver, std::vector< const CCityBuilding* >& vpResidualBuildings);
void DistanceCulling( const double dDetourDistance, const ITAGeo::CEmitter& v3Source, const ITAGeo::CSensor& v3Receiver, std::vector< const CCityBuilding* >& vpResidualBuildings );
protected:
CITACityGMLPtr* m_pCityModel; //!< Encapsuled pointer to the city GML instance
protected:
CCityGMLPtr* m_pCityModel; //!< Encapsuled pointer to the city GML instance
std::vector< CITAGeoHalfedgeMeshModel* > m_pBuildings;
std::vector< CCityBuilding> m_vOBuildings;
std::vector< ITAGeo::CHalfedgeMeshModel* > m_pBuildings;
std::vector< CCityBuilding> m_vOBuildings;
bool CenterInsideEllipse(const float coordinates[4], const float SemiMajorAxis, const float SemiMinorAxis);
bool CenterInsideEllipse( const float coordinates[ 4 ], const float SemiMajorAxis, const float SemiMinorAxis );
bool BoundingSphereInsideEllipse(const VistaVector3D v3centerpos, const float fBSradius, const float SemiMajorAxis, const float SemiMinorAxis);
};
bool BoundingSphereInsideEllipse( const VistaVector3D v3centerpos, const float fBSradius, const float SemiMajorAxis, const float SemiMinorAxis );
};
}
#endif // INCLUDE_WATCHER_ITA_GEO_CITYGML_MODEL
......@@ -22,6 +22,7 @@
// ITAGeo includes
#include <ITAGeoBase.h>
#include <ITAGeoDefinitions.h>
#include <ITAGeoModelBase.h>
// STL includes
#include <string>
......@@ -30,136 +31,136 @@
struct ITA_GEO_API CITAMeshPtr;
class IITAAcousticMaterial;
//! Halfedge mesh model using OpenMesh
/**
* The halfedge mesh model representation requires, that
* every edge is connected to one or maximum two faces, only. This
* structure, besides some problems, offers the use of
* a few easy geometric algorithm implementations. Especially
* waterproof models with a single enclosed volume (like
* indoor rooms and buildings with facades only) can
* be represented as valid halfedge meshes.
*/
class ITA_GEO_API CITAGeoHalfedgeMeshModel
namespace ITAGeo
{
public:
CITAGeoHalfedgeMeshModel();
~CITAGeoHalfedgeMeshModel();
//! Returns input file formats that can be loaded (forwards OpenMesh qt convenience function)
/*
* Format of return string is <c>;;</c> with further information on formats
*
* @return Filter string of supported import file formats
*
* @see Load()
*
*/
static std::string GetSupportedInputFormats();
//! Returns output file formats that can be stored (forwards OpenMesh qt convenience function)
/*
* Format of return string is <c>;;</c> with further information on formats
*
* @return List of supported export file formats (file extension list)
*
* @see Store()
*
*/
static std::string GetSupportedOutputFormats();
//! Checks if output format is supported
/**
* @sa GetSupportedOutputFormats()
* @param[in] sFormatID Format identifier, i.e. "obj" or "skp"
* @return True, if format recognized
*/
static bool GetSupportedOutputFormat( const std::string& sFormatID );
//! Checks if input format is supported
//! Halfedge mesh model using OpenMesh
/**
* @sa GetSupportedInputFormats()
* @param[in] sFormatID Format identifier, i.e. "obj" or "skp"
* @return True, if format recognized
* The halfedge mesh model representation requires, that
* every edge is connected to one or maximum two faces, only. This
* structure, besides some problems, offers the use of
* a few easy geometric algorithm implementations. Especially
* waterproof models with a single enclosed volume (like
* indoor rooms and buildings with facades only) can
* be represented as valid halfedge meshes.
*/
static bool GetSupportedInputFormat( const std::string& sFormatID );
//! Loads a model from given file path
/*
* Uses OpenMesh I/O manager to load geometries.
*
* @note Throws CITAException (i.e. if file not found)
*
* @see GetSupportedInputFormats()
*
* @sFilePath[in] sModelFilePath File path
* @return True, if successfull
*
* @return True, if content could be transformed into a valid halfedge mesh model.
*
*/
bool Load( const std::string& sModelFilePath );
//! Saves a SketchUp model to given file path
/*
* Uses OpenMesh I/O manager to store geometries to hard drive.
*
* @param[in] sModelFilePath Model file path
* @param[in] bOverwrite Flag to overwrite existing file
* @return True, if successfull
*
* @note Throws ITAException (i.e. if file could not be written)
*
* @see GetSupportedOutputFormats()
*
*/
bool Store( const std::string& sModelFilePath, bool bOverwrite = true ) const;
//! Name setter
void SetName( const std::string sName );
//! Name getter
std::string GetName() const;
//! Copy mesh model data
void CopyFrom( const CITAGeoHalfedgeMeshModel& );
//! Checks weather the mesh is a valid waterproof model (no holes)
bool IsWaterproofMesh() const;
//! Checks if mesh is a valid triangle representation (only 3-edge faces)
bool IsValidTriangleMesh() const;
//! Triangulates mesh, if possible
bool TriangulateMesh();
//! Add acoustic material to a face of mesh
bool SetFaceAcousticMaterial( int iFaceID, IITAAcousticMaterial* pMaterial );
//! Invert normal direction vector of all faces
/**
* @todo This does not work for SketchUp meshes.
*/
bool InvertFaceNormals();
//! Get pointer to underlying mesh (OpenMESH)
CITAMeshPtr* GetMesh();
//! Get pointer to underlying mesh (OpenMESH)
const CITAMeshPtr* GetMesh() const;
protected:
CITAMeshPtr* m_prModelMeshData; // CITAMesh pointer
// @todo jst: remove and use GetMesh()
friend class CITADiffractionEngineImpl;
friend class CITAGeoModelBase;
friend class CITAGeoSketchUpModel;
friend class CITAGeoCityGMLModel;
private:
std::string m_sName; //!< Mesh name (for verbatim output and debugging and auto layer naming)
};
class ITA_GEO_API CHalfedgeMeshModel : public CModelBase
{
public:
CHalfedgeMeshModel();
virtual ~CHalfedgeMeshModel();
//! Returns input file formats that can be loaded (forwards OpenMesh qt convenience function)
/*
* Format of return string is <c>;;</c> with further information on formats
*
* @return Filter string of supported import file formats
*
* @see Load()
*
*/
static std::string GetSupportedInputFormats();
//! Returns output file formats that can be stored (forwards OpenMesh qt convenience function)
/*
* Format of return string is <c>;;</c> with further information on formats
*
* @return List of supported export file formats (file extension list)
*
* @see Store()
*
*/
static std::string GetSupportedOutputFormats();
//! Checks if output format is supported
/**
* @sa GetSupportedOutputFormats()
* @param[in] sFormatID Format identifier, i.e. "obj" or "skp"
* @return True, if format recognized
*/
static bool GetSupportedOutputFormat( const std::string& sFormatID );
//! Checks if input format is supported
/**
* @sa GetSupportedInputFormats()
* @param[in] sFormatID Format identifier, i.e. "obj" or "skp"
* @return True, if format recognized
*/
static bool GetSupportedInputFormat( const std::string& sFormatID );
//! Loads a model from given file path
/*
* Uses OpenMesh I/O manager to load geometries.
*
* @note Throws CITAException (i.e. if file not found)
*
* @see GetSupportedInputFormats()
*
* @sFilePath[in] sModelFilePath File path
* @return True, if successfull
*
* @return True, if content could be transformed into a valid halfedge mesh model.
*
*/
bool Load( const std::string& sModelFilePath );
//! Saves a SketchUp model to given file path
/*
* Uses OpenMesh I/O manager to store geometries to hard drive.
*
* @param[in] sModelFilePath Model file path
* @param[in] bOverwrite Flag to overwrite existing file
* @return True, if successfull
*
* @note Throws ITAException (i.e. if file could not be written)
*
* @see GetSupportedOutputFormats()
*
*/
bool Store( const std::string& sModelFilePath, bool bOverwrite = true ) const;
//! Copy mesh model data
void CopyFrom( const ITAGeo::CHalfedgeMeshModel& );
//! Checks weather the mesh is a valid waterproof model (no holes)
bool IsWaterproofMesh() const;
//! Checks if mesh is a valid triangle representation (only 3-edge faces)
bool IsValidTriangleMesh() const;
//! Triangulates mesh, if possible
bool TriangulateMesh();
//! Add acoustic material to a face of mesh
bool SetFaceAcousticMaterial( int iFaceID, IITAAcousticMaterial* pMaterial );
//! Invert normal direction vector of all faces
/**
* @todo This does not work for SketchUp meshes.
*/
bool InvertFaceNormals();
//! Returns const pointer to top level mesh
//const ITAGeo::CHalfedgeMeshModel* GetTopLevelMeshModel() const;
//! Get pointer to underlying mesh (OpenMESH)
CITAMeshPtr* GetMesh();
//! Get pointer to underlying mesh (OpenMESH)
const CITAMeshPtr* GetMesh() const;
protected:
CITAMeshPtr* m_prModelMeshData; // CITAMesh pointer