raven_scene.h 7.36 KB
Newer Older
1
2
3
#ifndef INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_ROOM_ACOUSTICS_RAVEN_RAVEN_SCENE
#define INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_ROOM_ACOUSTICS_RAVEN_RAVEN_SCENE

4
5
#ifdef WITH_RAVEN

6
7
// std includes
#include <string>
8
9
#include <vector>
#include <map>
10
11
12
13
14

// API includes
#include <ITA/simulation_scheduler/definitions.h>

// simulation scheduler includes
15
#include "../src/ITA/simulation_scheduler/utils.h"
16
17
18
19
20
21

// RAVEN includes
#include "RG_Vector.h"

namespace ITA
{
22
	namespace SimulationScheduler
23
	{
24
		namespace RoomAcoustics
25
		{
26
			namespace Raven
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
			{
				///
				/// \brief Scene class for Raven instances.
				///
				/// Implements a Raven scene and provides functionality to compare two scenes.
				/// 
				class ITA_SIMULATION_SCHEDULER_API CRavenScene
				{
				public:
					///
					/// \brief Data type indicating the difference of number of objects from two scenes.
					/// 
					struct ITA_SIMULATION_SCHEDULER_API CSceneDifference
					{
						///
						/// \brief Data type saving the object IDs of all new, modified and removed objects.
						/// 
						struct DifferenceVectors
						{
							std::vector< int > viNewObjects; ///< New objects.
							std::vector< int > viModObjects; ///< Modified objects.
							std::vector< int > viDelObjects; ///< Removed objects.
						};

						DifferenceVectors receiverDifferences; ///< Differences for receivers.
						DifferenceVectors sourceDifferences;   ///< Differences for sources.

						///
						/// \brief Test of entities have changed.
						/// \return true if a difference was detected.
						/// 
58
						virtual bool EntitiesChanged ( ) const;
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
					};

					///
					/// \brief Data type for the state of a sound source.
					/// 
					struct ITA_SIMULATION_SCHEDULER_API CSourceState
					{
						CSourceState ( ) = default;

						///
						/// Flags indicating the difference between two CSourceState%s.
						/// 
						enum class DifferenceFlags : int
						{
							none = 0,
							position = 1,    ///< Difference in position.
							orientation = 2, ///< Difference in orientation.
						};

						RG_Vector vPos = RG_Vector ( 0, 0, 0 );  ///< Vector indicating the position.
						RG_Vector vView = RG_Vector ( 0, 0, 0 ); ///< Vector indicating the view direction.
						RG_Vector vUp = RG_Vector ( 0, 0, 0 );   ///< Vector indicating the up direction.

						///
						/// \brief Compare with another CSourceState.
						/// \return the DifferenceFlags indicating the differences.
						/// 
86
						DifferenceFlags Compare ( const CSourceState& oState ) const;
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
					};

					///
					/// \brief Data type for the state of a sound receiver.
					/// 
					class ITA_SIMULATION_SCHEDULER_API CReceiverState
					{
					public:
						CReceiverState ( ) = default;

						///
						/// Flags indicating the difference between two CReceiverState%s.
						/// 
						enum class DifferenceFlags : int
						{
							none = 0,
							position = 1,    ///< Difference in position.
							orientation = 2, ///< Difference in orientation.
						};

						RG_Vector vPos = RG_Vector ( 0, 0, 0 );  ///< Vector indicating the position.
						RG_Vector vView = RG_Vector ( 0, 0, 0 ); ///< Vector indicating the view direction.
						RG_Vector vUp = RG_Vector ( 0, 0, 0 );   ///< Vector indicating the up direction.

						///
						/// \brief Compare with another CReceiverState.
						/// \return the DifferenceFlags indicating the differences.
						/// 
115
						DifferenceFlags Compare ( const CReceiverState& oState ) const;
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
					};

					CRavenScene ( ) = default;

					CRavenScene ( const CRavenScene& other ) = default;
					
					CRavenScene& operator=(const CRavenScene& other) = default;
					
					///
					/// \brief Destructor of CRavenScene.
					/// 
					virtual ~CRavenScene ( );

					///
					/// \brief Clears the scene.
					///
					/// Removes all objects.
					/// 
134
					virtual void Reset ( );
135
136
137
138
139

					///
					/// \{
					/// \brief Methods for adding, removing, setting and getting of source and receiver states via the ID system.
					///
140
141
142
143
					virtual void AddSource ( int iSoundSourceID );
					virtual void RemoveSource ( int iSoundSourceID );
					virtual void SetSourceState ( int iSoundSourceID, const CSourceState& oState );
					virtual const CSourceState& GetSourceState ( int iSoundSourceID ) const;
144

145
146
147
148
					virtual void AddReceiver ( int iReceiverID );
					virtual void RemoveReceiver ( int iReceiverID );
					virtual void SetReceiverState ( int iReceiverID, const CReceiverState& oState );
					virtual const CReceiverState& GetReceiverState ( int iReceiverID ) const;
149
150
151
152
153
154
155
156
					///
					/// \}
					///

					///
					/// \brief Determine difference to another scene (entities only).
					/// \retrun the difference of both scenes.
					/// 
157
					CSceneDifference Difference ( const CRavenScene& oScene ) const;
158
159
160
161
162
163

					///
					/// \brief Compare two scenes for equality.
					/// \param oScene the CRavenScene to compare against.
					/// \return true if the scenes are equal.
					/// 
164
					bool IsEqual ( const CRavenScene& oScene ) const;
165
166
167
168
169

					///
					/// \brief Formats the scene content into string.
					/// \return the scene contents as a string. 
					/// 
170
					std::string ToString ( ) const;
171
172
173
174
175

					///
					/// \brief Load a INI file containing a CRavenScene.
					/// \param sPath path to the INI file.
					/// 
176
					void LoadFormIni ( const std::string& sPath );
177
178
179
180
181
182

					///
					/// \brief Store a INI file containing a CRavenScene.
					/// \param sPath path to where the INI file should be stored.
					/// \param iFloatingPointPrecision the  with which the floats will be stored. 
					/// 
183
					void StoreToIni ( const std::string& sPath, int iFloatingPointPrecision = 2 ) const;
184
185
186
187
188

					///
					/// \brief Get the source map.
					/// \return the source map.
					/// 
189
					const std::map<int, CSourceState>& GetSourceMap ( ) const;
190
191
192
193
194

					///
					/// \brief Get the receiver map.
					/// \return the receiver map.
					/// 
195
					const std::map<int, CReceiverState>& GetReceiverMap ( ) const;
196
197
198
199
200
201
202
203
204
205

				private:

					///
					/// \brief Compute the difference for the receivers.
					/// \param mOld the reference receiver map.
					/// \param mNew the new receiver map.
					/// \return a DifferenceVector object containing the difference for receivers.
					/// 
					static CSceneDifference::DifferenceVectors
206
						DifferenceReceiver ( const std::map< int, CReceiverState >& mOld,
207
208
209
210
211
212
213
214
215
											 const std::map< int, CReceiverState >& mNew );

					///
					/// \brief Compute the difference for the sources.
					/// \param mOld the reference source map.
					/// \param mNew the new source map.
					/// \retrun a DifferenceVector object containing the difference for sources.
					/// 
					static CSceneDifference::DifferenceVectors
216
						DifferenceSource ( const std::map< int, CSourceState >& mOld,
217
218
219
220
221
222
223
224
225
226
227
228
229
230
										   const std::map< int, CSourceState >& mNew );

					///
					/// \{
					/// \brief Map containing the states of sources and receivers, keyed by their ID.
					/// 
					std::map< int, CReceiverState > m_mReceivers;
					std::map< int, CSourceState > m_mSources;
					///
					/// \}
					/// 

				};

231
232
				ENABLE_BITMASK_OPERATORS ( RoomAcoustics::Raven::CRavenScene::CReceiverState::DifferenceFlags );
				ENABLE_BITMASK_OPERATORS ( RoomAcoustics::Raven::CRavenScene::CSourceState::DifferenceFlags );
233

234
235
236
			} // namespace Raven
		} // namespace RoomAcoustics
	} // namespace SimulationScheduler
237
238
} // namespace ITA

239
240
#endif

241
#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_ROOM_ACOUSTICS_RAVEN_RAVEN_SCENE