3d_object.h 4.35 KB
Newer Older
Pascal Palenda's avatar
Pascal Palenda committed
1
2
3
4
5
6
7
8
9
#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>
10
#include <VistaAspects/VistaSerializable.h>
Pascal Palenda's avatar
Pascal Palenda committed
11
12
13

namespace ITA
{
14
	namespace SimulationScheduler
Pascal Palenda's avatar
Pascal Palenda committed
15
	{
Pascal Palenda's avatar
Pascal Palenda committed
16
		///
17
		/// \brief Models a source or receiver in 3D space.
Pascal Palenda's avatar
Pascal Palenda committed
18
		///
19
		class ITA_SIMULATION_SCHEDULER_API C3DObject : public IVistaSerializable
Pascal Palenda's avatar
Pascal Palenda committed
20
21
22
23
24
25
26
27
28
29
30
		{
		public:
			///
			/// \brief Types of C3DObjects.
			///
			enum class Type
			{
				source,
				receiver
			};

31
32
33
34
			/// 
			/// \brief Default constructor.
			///
			/// This constructor is primarily used for creating an object for deserialization.
35
			/// It does initializes the object with m_iID=-1 and m_eType=Type::source.
36
37
			/// 
			C3DObject ( ) = default;
Pascal Palenda's avatar
Pascal Palenda committed
38
39
40
41
42

			///
			/// \brief Constructor of a C3DObject.
			///
			/// C3DObject represent objects tracked in a virtual 3D environment.
43
44
			/// These can be either a source or a receiver.
			/// \param position position of the C3DObject.
Pascal Palenda's avatar
Pascal Palenda committed
45
46
47
48
			/// \param orientation orientation of the C3DObject.
			/// \param type the Type of C3DObject.
			/// \param id an identification number for the object.
			///
49
			C3DObject ( const VistaVector3D& position, const VistaQuaternion& orientation, Type type, int id );
Pascal Palenda's avatar
Pascal Palenda committed
50

51
52
53
54
55
56
57
			
			///
			/// \brief Copy constructor.
			/// \param obj object to copy from.
			/// 
			C3DObject ( const C3DObject& obj ) = default;
			
Pascal Palenda's avatar
Pascal Palenda committed
58
			///
59
			/// \brief Get the position of the C3DObject.
Pascal Palenda's avatar
Pascal Palenda committed
60
61
			/// \return a const ref to the position.
			///
62
			const VistaVector3D& GetPosition ( ) const;
Pascal Palenda's avatar
Pascal Palenda committed
63
64
65
66
67

			///
			/// \brief Get the orientation of the C3DObject.
			/// \return a const ref to the orientation.
			///
68
			const VistaQuaternion& GetOrientation ( ) const;
Pascal Palenda's avatar
Pascal Palenda committed
69
70
71
72
73

			///
			/// \brief Get the ID of the object.
			/// \return the ID of the C3DObject.
			///
74
			unsigned int GetId ( ) const;
Pascal Palenda's avatar
Pascal Palenda committed
75
76
77
78
79

			///
			/// \brief Get the Type of the object.
			/// \return the Type of the C3DObject.
			///
80
			Type GetType ( ) const;
Pascal Palenda's avatar
Pascal Palenda committed
81
82
83
84
85
86
87
88

			///
			/// \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.
89
			/// \return true if the given object is the same as this with the given tolerance.
Pascal Palenda's avatar
Pascal Palenda committed
90
			///
91
			bool IsEqualTolerance ( const C3DObject& obj, double dTolerance ) const;
Pascal Palenda's avatar
Pascal Palenda committed
92

93
94
95
96
97
			///
			/// \brief Serialize the object.
			/// \param pSerializer the IVistaSerializer to use.
			/// \return the number of bytes written or -1 on failure.
			///
98
			int Serialize ( IVistaSerializer& pSerializer ) const override;
99
100
101

			///
			/// \brief DeSerialize the object.
102
			/// \param pDeserializer the IVistaDeSerializer to use.
103
104
			/// \return the number of bytes written or -1 on failure.
			///
105
			int DeSerialize ( IVistaDeSerializer& pDeserializer ) override;
106
107
108
109
110

			///
			/// \brief Return a unique identifier for the object for serialization.
			/// \return "CUpdateConfig".
			/// 
111
			virtual std::string GetSignature ( ) const override;
112

Pascal Palenda's avatar
Pascal Palenda committed
113
114
115
116
		private:
			///
			/// \brief Identification number of the C3DObject.
			///
117
			int m_iID = -1;
Pascal Palenda's avatar
Pascal Palenda committed
118
119
120
121

			///
			/// \brief The type of the C3DObject.
			///
122
			Type m_eType = Type::source;
Pascal Palenda's avatar
Pascal Palenda committed
123
124
125
126
127
128
129
130
131
132
133

			///
			/// \brief The position of the C3DObject.
			///
			/// The postion is encoded in a 3D Vector.
			///
			VistaVector3D m_v3Position;

			///
			/// \brief The orientation of the C3DObject.
			///
134
			/// The orientation is encoded in Quaternion notation.
Pascal Palenda's avatar
Pascal Palenda committed
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
			///
			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 )
		{
150
151
152
153
			return lhs.GetType ( ) == rhs.GetType ( ) &&
				lhs.GetId ( ) == rhs.GetId ( ) &&
				lhs.GetPosition ( ) == rhs.GetPosition ( ) &&
				lhs.GetOrientation ( ) == rhs.GetOrientation ( );
Pascal Palenda's avatar
Pascal Palenda committed
154
155
		}

156
	} // namespace SimulationScheduler
Pascal Palenda's avatar
Pascal Palenda committed
157
158
159
} // namespace ITA

#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_3D_OBJECT