Commit 3f90400f authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Mostly style, comment translation to en and minor code improvements

parent 7a4895e1
......@@ -2,14 +2,14 @@
*
* VVV VVV A
* VVV VVV AAA Acoustics
* VVV VVV AAA Real-time auralisation for reality
* VVV VVV AAA Real-time auralisation for reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institut fr Technische Akustik (ITA)
* VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*
* Datei: VARoomAcousticsScheduler.h
* Datei: VARoomAcousticsScheduler.h
*
* Zweck: Room acoustics scheduler interface and container for tasks and results
*
......@@ -18,7 +18,7 @@
*
* ---------------------------------------------------------------------------------
*/
// $Id: $
#ifndef __VA_ROOMACOUSTICSSCHEDULER__
......@@ -26,7 +26,7 @@
#if (VACORE_WITH_RENDERER_BINAURAL_ROOM_ACOUSTICS==1)
#include <VAObjectPool.h>
#include <VAPoolObject.h>
#include <R_Raven.h>
......@@ -56,7 +56,7 @@ public:
};
private:
IRavenSimulationSchedulerInterface* m_pScheduler; // Achtung immer nur ein Scheduler, Baby!
IRavenSimulationSchedulerInterface* m_pScheduler; //!< Scheduler pointer (only one possible)
};
......@@ -65,12 +65,13 @@ private:
* Hiermit knnen eigene Unterklassen von Task erstellt werden, welche
* zustzliche Informationen fr die Zielanwendung enthalten.
*/
class IVARoomAcousticsSimulationTaskCreator {
class IVARoomAcousticsSimulationTaskCreator
{
public:
virtual ~IVARoomAcousticsSimulationTaskCreator() {};
virtual inline ~IVARoomAcousticsSimulationTaskCreator() {};
//! Erzeugt einen neuen Simulationsauftrag
virtual CVARoomAcousticsSimulationTask* CreateTask()=0;
virtual CVARoomAcousticsSimulationTask* CreateTask() = 0;
};
#endif // (VACORE_WITH_RENDERER_BINAURAL_ROOM_ACOUSTICS==1)
......
/*
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institut fr Technische Akustik (ITA)
* VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*
* Datei: VAListState.cpp
*
* Zweck: Klassen fr Zustnde von Listen mit IDs (z.B. Quellen)
*
* Autor(en): Frank Wefers (Frank.Wefers@akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*/
// $Id: VAContainerState.cpp 3629 2014-08-13 12:23:44Z fwefers $
#include "VAContainerState.h"
#include <VACore.h>
......@@ -29,15 +7,16 @@
#include <cassert>
#include <iterator>
#if (ALGORITHM == 1)
#ifdef VA_CONTAINER_STATE_USE_STD_SET_ALGORITHM
void CVAContainerState::Initialize(double dModificationTime) {
void CVAContainerState::Initialize( const double dModificationTime )
{
data.sElements.clear();
SetModificationTime(dModificationTime);
SetModificationTime( dModificationTime );
}
void CVAContainerState::Copy(const CVAContainerState* pSrc, double dModificationTime)
void CVAContainerState::Copy( const CVAContainerState* pSrc, const double dModificationTime )
{
assert( pSrc );
// Zusatz-Check: Kopieren nur von fixierten Zustnden erlauben
......@@ -45,12 +24,14 @@ void CVAContainerState::Copy(const CVAContainerState* pSrc, double dModification
// Daten kopieren
data = pSrc->data;
SetModificationTime(dModificationTime);
SetModificationTime( dModificationTime );
}
void CVAContainerState::Fix() {
void CVAContainerState::Fix()
{
// Alle enthaltenen Objekte fixieren
for (std::vector<ElemType>::iterator it=data.vElements.begin(); it!=data.vElements.end(); ++it) {
for( std::vector<ElemType>::iterator it = data.vElements.begin(); it != data.vElements.end(); ++it )
{
assert( it->second );
it->second->Fix();
}
......@@ -59,9 +40,11 @@ void CVAContainerState::Fix() {
CVASceneStateBase::Fix();
}
void CVAContainerState::PreRelease() {
void CVAContainerState::PreRelease()
{
// Alle Referenzen auf abhngige Objekte entfernen
for (std::vector<ElemType>::iterator it=data.vElements.begin(); it!=data.vElements.end(); ++it) {
for( std::vector<ElemType>::iterator it = data.vElements.begin(); it != data.vElements.end(); ++it )
{
assert( it->second );
it->second->RemoveReference();
}
......@@ -70,7 +53,7 @@ void CVAContainerState::PreRelease() {
CVASceneStateBase::PreRelease();
}
void CVAContainerState::Diff(const CVAContainerState* pComp, CVAContainerDiff* pDiff) const
void CVAContainerState::Diff( const CVAContainerState* pComp, CVAContainerDiff* pDiff ) const
{
assert( pComp && pDiff );
......@@ -80,81 +63,81 @@ void CVAContainerState::Diff(const CVAContainerState* pComp, CVAContainerDiff* p
pDiff->liCom.clear();
pDiff->liNew.clear();
pDiff->liDel.clear();
std::insert_iterator< std::vector<int> > iCom( pDiff->liCom, pDiff->liCom.begin() );
std::insert_iterator< std::vector<int> > iNew( pDiff->liNew, pDiff->liNew.begin() );
std::insert_iterator< std::vector<int> > iDel( pDiff->liDel, pDiff->liDel.begin() );
/*
std::back_insert_iterator< std::vector<int> > iCom( pDiff->liCom, pDiff->liCom.begin() );
std::back_insert_iterator< std::vector<int> > iNew( pDiff->liNew, pDiff->liNew.begin() );
std::back_insert_iterator< std::vector<int> > iDel( pDiff->liDel, pDiff->liDel.begin() );
*/
std::insert_iterator< std::vector<int> > iNew( pDiff->liNew, pDiff->liNew.begin() );
std::insert_iterator< std::vector<int> > iDel( pDiff->liDel, pDiff->liDel.begin() );
// Elemente in beiden Kontainern
std::set_intersection(A.begin(), A.end(), B.begin(), B.end(), iCom);
std::set_intersection( A.begin(), A.end(), B.begin(), B.end(), iCom );
// Elemente nur in diesem Kontainer
std::set_difference(B.begin(), B.end(), A.begin(), A.end(), iNew);
std::set_difference( B.begin(), B.end(), A.begin(), A.end(), iNew );
// Elemente nur im Vergleichskontainer
std::set_difference(A.begin(), A.end(), B.begin(), B.end(), iDel);
std::set_difference( A.begin(), A.end(), B.begin(), B.end(), iDel );
}
void CVAContainerState::GetIDs(std::vector<int>* pviDest) const {
void CVAContainerState::GetIDs( std::vector<int>* pviDest ) const
{
pviDest->reserve( data.sElements.size() );
pviDest->clear();
std::copy( data.sElements.begin(), data.sElements.end(), pviDest->begin() );
}
void CVAContainerState::GetIDs(std::list<int>* pliDest) const {
void CVAContainerState::GetIDs( std::list<int>* pliDest ) const
{
pliDest->clear();
std::copy( data.sElements.begin(), data.sElements.end(), std::back_inserter( *pliDest ) );
}
void CVAContainerState::GetIDs(std::set<int>* psiDest) const {
void CVAContainerState::GetIDs( std::set<int>* psiDest ) const
{
psiDest->clear();
std::copy( data.sElements.begin(), data.sElements.end(), std::inserter( *psiDest, psiDest->end() ) );
}
void CVAContainerState::AddObject(int iID, CVASceneStateBase* pObject)
void CVAContainerState::AddObject( const int iID, CVASceneStateBase* pObject )
{
data.sElements.insert( iID );
}
void CVAContainerState:: RemoveObject(int iID)
void CVAContainerState::RemoveObject( const int iID )
{
data.sElements.erase( iID );
}
#endif // ALGORITHM == 1
#else
#if (ALGORITHM == 2)
void CVAContainerState::Initialize(double dModificationTime) {
void CVAContainerState::Initialize( const double dModificationTime )
{
data.vElements.clear();
data.bDirty = false;
SetModificationTime(dModificationTime);
SetModificationTime( dModificationTime );
}
void CVAContainerState::Copy(const CVAContainerState* pSrc, double dModificationTime)
void CVAContainerState::Copy( const CVAContainerState* pSrc, const double dModificationTime )
{
assert( pSrc );
// Abhngige Objekte des Vorlagenobjektes autonom referenzieren
for (std::vector<ElemType>::iterator it=pSrc->data.vElements.begin(); it!=pSrc->data.vElements.end(); ++it) {
for( std::vector<ElemType>::iterator it = pSrc->data.vElements.begin(); it != pSrc->data.vElements.end(); ++it )
{
assert( it->second );
it->second->AddReference();
}
// Daten kopieren
data = pSrc->data;
SetFixed(false);
SetModificationTime(dModificationTime);
SetFixed( false );
SetModificationTime( dModificationTime );
}
void CVAContainerState::Fix() {
void CVAContainerState::Fix()
{
// Alle enthaltenen Objekte fixieren
for (std::vector<ElemType>::iterator it=data.vElements.begin(); it!=data.vElements.end(); ++it) {
for( std::vector<ElemType>::iterator it = data.vElements.begin(); it != data.vElements.end(); ++it )
{
assert( it->second );
it->second->Fix();
}
......@@ -163,9 +146,11 @@ void CVAContainerState::Fix() {
CVASceneStateBase::Fix();
}
void CVAContainerState::PreRelease() {
void CVAContainerState::PreRelease()
{
// Alle Referenzen auf abhngige Objekte entfernen
for (std::vector<ElemType>::iterator it=data.vElements.begin(); it!=data.vElements.end(); ++it) {
for( std::vector<ElemType>::iterator it = data.vElements.begin(); it != data.vElements.end(); ++it )
{
assert( it->second );
it->second->RemoveReference();
}
......@@ -174,32 +159,32 @@ void CVAContainerState::PreRelease() {
CVASceneStateBase::PreRelease();
}
void CVAContainerState::Diff(const CVAContainerState* pComp,
std::vector<int>& viNew,
std::vector<int>& viDel,
std::vector<int>& viCom) const
void CVAContainerState::Diff( const CVAContainerState* pComp, std::vector<int>& viNew, std::vector<int>& viDel, std::vector<int>& viCom ) const
{
viNew.clear();
viDel.clear();
viCom.clear();
// Vergleichszustand Leer => Alles Neu
if (pComp == nullptr) {
if( pComp == nullptr )
{
for (std::vector<ElemType>::const_iterator it = data.vElements.begin(); it != data.vElements.end(); ++it)
for( std::vector<ElemType>::const_iterator it = data.vElements.begin(); it != data.vElements.end(); ++it )
viNew.push_back( it->first );
return;
}
// Resort arrays when necessary
if (pComp->data.bDirty) {
std::sort( pComp->data.vElements.begin(), pComp->data.vElements.end(), ElemCompare() );
if( pComp->data.bDirty )
{
std::sort( pComp->data.vElements.begin(), pComp->data.vElements.end(), ElemCompare() );
pComp->data.bDirty = false;
}
if (data.bDirty) {
std::sort( data.vElements.begin(), data.vElements.end(), ElemCompare() );
if( data.bDirty )
{
std::sort( data.vElements.begin(), data.vElements.end(), ElemCompare() );
data.bDirty = false;
}
......@@ -209,37 +194,42 @@ void CVAContainerState::Diff(const CVAContainerState* pComp,
std::vector<ElemType>::iterator ai = A.begin();
std::vector<ElemType>::iterator bi = B.begin();
while (true) {
while( true )
{
// Keine weiteren Elemente in A
if (ai == A.end()) {
if( ai == A.end() )
{
// Alle weiteren Elemente in B => neue Elemente
//std::copy(bi, B.end(), pDiff->liNew.end());
for (;bi!=B.end(); ++bi) viNew.push_back(bi->first);
for( ; bi != B.end(); ++bi )
viNew.push_back( bi->first );
return;
}
// Keine weiteren Elemente in B
if (bi == B.end()) {
if( bi == B.end() )
{
// Alle weiteren Elemente in A => gelschte Elemente
// Alle weiteren Elemente in B => neue Elemente
//std::copy(ai, A.end(), pDiff->liDel.end());
for (;ai!=A.end(); ++ai) viDel.push_back(ai->first);
for( ; ai != A.end(); ++ai )
viDel.push_back( ai->first );
return;
}
if (ai->first < bi->first) {
if( ai->first < bi->first )
{
// A Element fehlt in B
viDel.push_back(ai->first);
viDel.push_back( ai->first );
// Weiter in A bis B erreicht
ai++;
continue;
}
if (ai->first > bi->first) {
if( ai->first > bi->first )
{
// B Element fehlt in A
viNew.push_back(bi->first);
viNew.push_back( bi->first );
// Weiter in B bis A erreicht
bi++;
......@@ -247,117 +237,111 @@ void CVAContainerState::Diff(const CVAContainerState* pComp,
}
// *ai = *bi => Element in beiden und weiter
viCom.push_back(ai->first);
viCom.push_back( ai->first );
ai++;
bi++;
}
/* Alt und langsam:
std::insert_iterator< std::vector<int> > iCom( pDiff->liCom, pDiff->liCom.begin() );
std::insert_iterator< std::vector<int> > iNew( pDiff->liNew, pDiff->liNew.begin() );
std::insert_iterator< std::vector<int> > iDel( pDiff->liDel, pDiff->liDel.begin() );
// Elemente in beiden Kontainern
std::set_intersection(pComp->data.vElements.begin(), pComp->data.vElements.end(), data.vElements.begin(), data.vElements.end(), iCom);
// Elemente nur in diesem Kontainer
std::set_difference(data.vElements.begin(), data.vElements.end(), pComp->data.vElements.begin(), pComp->data.vElements.end(), iNew);
// Elemente nur im Vergleichskontainer
std::set_difference(pComp->data.vElements.begin(), pComp->data.vElements.end(), data.vElements.begin(), data.vElements.end(), iDel);
*/
}
int CVAContainerState::GetSize() const {
return (int) data.vElements.size();
int CVAContainerState::GetSize() const
{
return ( int ) data.vElements.size();
}
void CVAContainerState::GetIDs(std::vector<int>* pviDest) const {
void CVAContainerState::GetIDs( std::vector<int>* pviDest ) const
{
pviDest->reserve( data.vElements.size() );
pviDest->clear();
for (std::vector<ElemType>::iterator i=data.vElements.begin(); i!=data.vElements.end(); ++i)
pviDest->push_back(i->first);
for( std::vector<ElemType>::iterator i = data.vElements.begin(); i != data.vElements.end(); ++i )
pviDest->push_back( i->first );
}
void CVAContainerState::GetIDs(std::list<int>* pliDest) const {
void CVAContainerState::GetIDs( std::list<int>* pliDest ) const
{
pliDest->clear();
for (std::vector<ElemType>::iterator i=data.vElements.begin(); i!=data.vElements.end(); ++i)
pliDest->push_back(i->first);
for( std::vector<ElemType>::iterator i = data.vElements.begin(); i != data.vElements.end(); ++i )
pliDest->push_back( i->first );
}
void CVAContainerState::GetIDs(std::set<int>* psiDest) const {
void CVAContainerState::GetIDs( std::set<int>* psiDest ) const
{
psiDest->clear();
for (std::vector<ElemType>::iterator i=data.vElements.begin(); i!=data.vElements.end(); ++i)
psiDest->insert(i->first);
for( std::vector<ElemType>::iterator i = data.vElements.begin(); i != data.vElements.end(); ++i )
psiDest->insert( i->first );
}
bool CVAContainerState::HasObject(int iID) const {
for (std::vector<ElemType>::iterator i=data.vElements.begin(); i!=data.vElements.end(); ++i)
if (i->first == iID) return true;
bool CVAContainerState::HasObject( const int iID ) const
{
for( std::vector<ElemType>::iterator i = data.vElements.begin(); i != data.vElements.end(); ++i )
if( i->first == iID ) return true;
return false;
}
CVASceneStateBase* CVAContainerState::GetObject(int iID) const {
for (std::vector<ElemType>::iterator i=data.vElements.begin(); i!=data.vElements.end(); ++i)
if (i->first == iID) {
CVASceneStateBase* CVAContainerState::GetObject( const int iID ) const
{
for( std::vector<ElemType>::iterator i = data.vElements.begin(); i != data.vElements.end(); ++i )
{
if( i->first == iID )
{
// Wenn Objekt in der Liste, dann darf es nicht nullptr sein
assert( i->second );
return i->second;
}
}
// Should not happen ...
assert( true );
return nullptr;
}
void CVAContainerState::AddObject(int iID, CVASceneStateBase* pObject)
void CVAContainerState::AddObject( const int iID, CVASceneStateBase* pObject )
{
assert( pObject );
pObject->AddReference();
data.vElements.push_back( std::make_pair(iID, pObject) );
data.vElements.push_back( std::make_pair( iID, pObject ) );
data.bDirty = true;
}
void CVAContainerState::RemoveObject(int iID)
void CVAContainerState::RemoveObject( const int iID )
{
/*
std::vector<int>::iterator i = std::find(data.vElements.begin(), data.vElements.end(), iID);
if (i != data.vElements.end())
data.vElements.erase(i);
else
assert( true );
*/
for (std::vector<ElemType>::iterator i=data.vElements.begin(); i!=data.vElements.end(); ++i)
if (i->first == iID) {
for( std::vector<ElemType>::iterator i = data.vElements.begin(); i != data.vElements.end(); ++i )
{
if( i->first == iID )
{
assert( i->second );
i->second->RemoveReference();
data.vElements.erase(i);
data.vElements.erase( i );
return;
}
}
// Should not happen ...
assert( true );
}
void CVAContainerState::SetObject(int iID, CVASceneStateBase* pObject) {
void CVAContainerState::SetObject( const int iID, CVASceneStateBase* pObject )
{
assert( pObject );
for (std::vector<ElemType>::iterator i=data.vElements.begin(); i!=data.vElements.end(); ++i)
if (i->first == iID) {
for( std::vector<ElemType>::iterator i = data.vElements.begin(); i != data.vElements.end(); ++i )
{
if( i->first == iID )
{
// Referenz auf altem Objekt entfernen und bei neuem Objekt hinzufgen
pObject->AddReference();
if (i->second) i->second->RemoveReference();
if( i->second )
i->second->RemoveReference();
i->second = pObject;
return;
}
}
// Should not happen ...
assert( true );
}
#endif // ALGORITHM == 2
\ No newline at end of file
#endif // VA_CONTAINER_STATE_USE_STD_SET_ALGORITHM
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics
* VVV VVV AAA Virtual Acoustics (VA)
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institut fr Technische Akustik (ITA)
* VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de)
* VVVVVV AAA (c) Copyright Institute of Technical Acoustics (ITA), 2015-2017
* VVVV AAA RWTH Aachen University (http://www.akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*
* Datei: VAListState.h
*
* Zweck: Klassen fr Zustnde von Listen mit IDs (z.B. Quellen)
*
* Autor(en): Frank Wefers (Frank.Wefers@akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
* --------------------------------------------------------------------------------------------
*/
// $Id: VAContainerState.h 3629 2014-08-13 12:23:44Z fwefers $
#ifndef __VA_CONTAINERSTATE_H__
#define __VA_CONTAINERSTATE_H__
#ifndef IW_VA_CONTAINER_STATE
#define IW_VA_CONTAINER_STATE
#include "VASceneStateBase.h"
......@@ -29,109 +20,126 @@
#include <set>
#include <vector>
// Datenklasse welche Unterschiede zwischen Kontainern beschreibt
// (Sichtweise = Different A => B, welche neue Elemente in B, welche Elemente gelscht in B, usw.)
//! Data class with differences between containers
/**
* View: difference between sets A and B is defined as differences in B, e.g. deletes objects
* that are not available anymore in _B_.
*/
class CVAContainerDiff
{
public:
std::vector<int> liNew; // Neue Elemente (in B und nicht in A)
std::vector<int> liDel; // Gelschte Elemente (in A und nicht in B)
std::vector<int> liCom; // Erhalten gebliebene Elemente (in A und in A)
std::vector< int > liNew; //!< New elements (in B but not in A)
std::vector< int > liDel; //!< Removed elements (in A but not in B)
std::vector< int > liCom; //!< Mutual elements (in A and in B)
};
// Implementierungsvarianten
// 1 == set::set, 2 == std::vector, 3 == std::vector + turbo-vergleich
#define ALGORITHM 2
// Diese Klasse bescheibt eine dynamische! (versionierten) Liste von Objekten gegeben durch IDs
// Wichtig ist vorallem, das Mengenoperationen schnell implementiert werden knnen
//! Base implementation of scene state
/**
* This class describes a dynamic versioned list of objects handled by the element's IDs.
* @note Set operations are implemented in an efficient way.
*/
class CVAContainerState : public CVASceneStateBase
{
public:
// Initialisieren (in Grundzustand versetzen)
// (Zustand danach: Nicht-finialisiert, Referenzzhler = 0)
void Initialize( double dModificationTime );
//! Initialize to a non-finalized base state
/**