Commit c6132419 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Add C3DObject class - WIP

parent 1e6d6481
#ifndef INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_3D_OBJECT
#define INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_3D_OBJECT
// API includes
#include <ITA/simulation_scheduler/definitions.h>
// VISTA includes
#include <VistaBase/VistaVector3D.h>
#include <VistaBase/VistaQuaternion.h>
namespace ITA
{
namespace simulation_scheduler
{
class ITA_SIMULATION_SCHEDULER_API C3DObject
{
public:
///
/// \brief Types of C3DObjects.
///
enum class Type
{
source,
receiver
};
C3DObject ( ) = delete;
///
/// \brief Constructor of a C3DObject.
///
/// C3DObject represent objects tracked in a virtual 3D environment.
/// These can be either a source or a reciever.
/// \param postion position of the C3DObject.
/// \param orientation orientation of the C3DObject.
/// \param type the Type of C3DObject.
/// \param id an identification number for the object.
///
C3DObject ( const VistaVector3D& postion, const VistaQuaternion& orientation, Type type, unsigned int id );
///
/// \brief Get the postion of the C3DObject.
/// \return a const ref to the position.
///
const VistaVector3D& getPosition ( ) const;
///
/// \brief Get the orientation of the C3DObject.
/// \return a const ref to the orientation.
///
const VistaQuaternion& getOrientation ( ) const;
///
/// \brief Get the ID of the object.
/// \return the ID of the C3DObject.
///
unsigned int getID ( ) const;
///
/// \brief Get the Type of the object.
/// \return the Type of the C3DObject.
///
Type getType ( ) const;
///
/// \brief Compare two C3DObjects, with a given tolerance.
///
/// Similar to operator==(), this function compares two C3DObjects.
/// However, this comparison allows for a tolerance for the comparison of #position and #orientation.
/// \param obj the object to check against.
/// \param dTolerance the allowed tolerance.
/// \return true if the given object is exactly the same as this.
///
bool isEqualTolerance ( const C3DObject& obj, double dTolerance ) const;
private:
///
/// \brief Identification number of the C3DObject.
///
unsigned int m_uiID;
///
/// \brief The type of the C3DObject.
///
Type m_eType;
///
/// \brief The position of the C3DObject.
///
/// The postion is encoded in a 3D Vector.
///
VistaVector3D m_v3Position;
///
/// \brief The orientation of the C3DObject.
///
/// The orientation is encoded in Quadternion notation.
///
VistaQuaternion m_qOrientation;
};
///
/// \brief Compare two C3DObjects.
///
/// Check if \p lhs and \p rhs are exactly the same.
/// For this all members have to match.
/// \param lhs the first object to check.
/// \param rhs the second object to check.
/// \return true if the given objects are exactly the same.
///
inline bool operator==( const C3DObject& lhs, const C3DObject& rhs )
{
return lhs.getType ( ) == rhs.getType ( ) &&
lhs.getID ( ) == rhs.getID ( ) &&
lhs.getPosition ( ) == rhs.getPosition ( ) &&
lhs.getOrientation ( ) == rhs.getOrientation ( );
}
} // namespace simulation_scheduler
} // namespace ITA
#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_3D_OBJECT
set( RelativeDir "include/ITA/simulation_scheduler" )
set( RelativeSourceGroup "Header Files\\ITA\\SimulationScheduler" )
set( SubDirs
#audibility_filter
#network_interface
#room_acoustics
)
set( DirFiles
definitions.h
3d_object.h
#_SourceFiles.cmake
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
set( LocalSourceGroupFiles )
foreach( File ${DirFiles} )
list( APPEND LocalSourceGroupFiles "${RelativeDir}/${File}" )
list( APPEND ProjectSources "${RelativeDir}/${File}" )
endforeach()
source_group( ${DirFiles_SourceGroup} FILES ${LocalSourceGroupFiles} )
set( SubDirFiles "" )
foreach( Dir ${SubDirs} )
list( APPEND SubDirFiles "${RelativeDir}/${Dir}/_SourceFiles.cmake" )
endforeach()
foreach( SubDirFile ${SubDirFiles} )
include( ${SubDirFile} )
endforeach()
/*
* ----------------------------------------------------------------
*
* ITA simulation scheduler
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2019-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_DEFINITIONS
#define INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_DEFINITIONS
#if ( defined WIN32 ) && !( defined ITA_SIMULATION_SCHEDULER_STATIC )
#ifdef ITA_SIMULATION_SCHEDULER_EXPORT
#define ITA_SIMULATION_SCHEDULER_API __declspec( dllexport )
#else
#define ITA_SIMULATION_SCHEDULER_API __declspec( dllimport )
#endif
#else
#define ITA_SIMULATION_SCHEDULER_API
#endif
#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_DEFINITIONS
set( RelativeDir "include" )
set( RelativeSourceGroup "Header Files" )
set( SubDirs ITASimulationScheduler )
set( SubDirs
ITASimulationScheduler
ITA/simulation_scheduler
)
set( DirFiles
#_SourceFiles.cmake
......
// Header include
#include <ITA/simulation_scheduler/3d_object.h>
// std includes
#include <cmath>
namespace ITA
{
namespace simulation_scheduler
{
C3DObject::C3DObject ( const VistaVector3D& postion,
const VistaQuaternion& orientation,
Type type,
unsigned int id ) :
m_v3Position ( postion ),
m_qOrientation ( orientation ),
m_eType ( type ),
m_uiID ( id )
{ }
const VistaVector3D& C3DObject::getPosition ( ) const
{
return m_v3Position;
}
const VistaQuaternion& C3DObject::getOrientation ( ) const
{
return m_qOrientation;
}
unsigned int C3DObject::getID ( ) const
{
return m_uiID;
}
C3DObject::Type C3DObject::getType ( ) const
{
return m_eType;
}
bool C3DObject::isEqualTolerance ( const C3DObject& obj, double dTolerance ) const
{
if ( obj.m_eType == m_eType &&
obj.m_uiID == m_uiID )
{
return ( abs ( m_v3Position [0] - obj.m_v3Position [0] ) <= dTolerance &&
abs ( m_v3Position [1] - obj.m_v3Position [1] ) <= dTolerance &&
abs ( m_v3Position [2] - obj.m_v3Position [2] ) <= dTolerance &&
abs ( m_v3Position [3] - obj.m_v3Position [3] ) <= dTolerance ) &&
( abs ( m_qOrientation [0] - obj.m_qOrientation [0] ) <= dTolerance &&
abs ( m_qOrientation [1] - obj.m_qOrientation [1] ) <= dTolerance &&
abs ( m_qOrientation [2] - obj.m_qOrientation [2] ) <= dTolerance &&
abs ( m_qOrientation [3] - obj.m_qOrientation [3] ) <= dTolerance );
}
return false;
}
} // namespace simulation_scheduler
} // namespace ITA
set( RelativeDir "src/ITA/simulation_scheduler" )
set( RelativeSourceGroup "Source Files\\ITA\\SimulationScheduler" )
set( SubDirs
#audibility_filter
#network_interface
#room_acoustics
)
set( DirFiles
3d_object.cpp
#_SourceFiles.cmake
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
set( LocalSourceGroupFiles )
foreach( File ${DirFiles} )
list( APPEND LocalSourceGroupFiles "${RelativeDir}/${File}" )
list( APPEND ProjectSources "${RelativeDir}/${File}" )
endforeach()
source_group( ${DirFiles_SourceGroup} FILES ${LocalSourceGroupFiles} )
set( SubDirFiles "" )
foreach( Dir ${SubDirs} )
list( APPEND SubDirFiles "${RelativeDir}/${Dir}/_SourceFiles.cmake" )
endforeach()
foreach( SubDirFile ${SubDirFiles} )
include( ${SubDirFile} )
endforeach()
set( RelativeDir "src" )
set( RelativeSourceGroup "Source Files" )
set( SubDirs ITASimulationScheduler )
set( SubDirs
ITASimulationScheduler
ITA/simulation_scheduler
)
set( DirFiles
#_SourceFiles.cmake
......
Supports Markdown
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