Base.h 22.6 KB
Newer Older
Jonas Stienen's avatar
Jonas Stienen committed
1
/*
Dipl.-Ing. Jonas Stienen's avatar
style  
Dipl.-Ing. Jonas Stienen committed
2 3
 * ----------------------------------------------------------------
 *
4
 *		ITA geometrical acoustics
Dipl.-Ing. Jonas Stienen's avatar
style  
Dipl.-Ing. Jonas Stienen committed
5
 *		(c) Copyright Institute of Technical Acoustics (ITA)
6
 *		RWTH Aachen University, Germany, 2015-2018
Dipl.-Ing. Jonas Stienen's avatar
style  
Dipl.-Ing. Jonas Stienen committed
7 8 9 10 11 12 13 14 15 16 17
 *
 * ----------------------------------------------------------------
 *				    ____  __________  _______
 *				   //  / //__   ___/ //  _   |
 *				  //  /    //  /    //  /_|  |
 *				 //  /    //  /    //  ___   |
 *				//__/    //__/    //__/   |__|
 *
 * ----------------------------------------------------------------
 *
 */
Jonas Stienen's avatar
Jonas Stienen committed
18 19 20 21 22

#ifndef INCLUDE_WATCHER_ITA_GEO_BASE
#define INCLUDE_WATCHER_ITA_GEO_BASE

// ITAGeo includes
23
#include <ITAGeo/Definitions.h>
24 25 26
#include <ITAGeo/ResourceManager.h>
#include <ITAGeo/Material/Material.h>
#include <ITAGeo/Directivity/Base.h>
27
#include <ITAGeo/Material/Manager.h>
28 29 30 31
#include <ITAGeo/Directivity/Manager.h>

// ITABase includes
#include <ITAException.h>
Jonas Stienen's avatar
Jonas Stienen committed
32 33 34 35

// Vista includes
#include <VistaBase/VistaQuaternion.h>
#include <VistaBase/VistaVector3D.h>
36 37 38
#pragma warning( disable : 4100 )
#include <VistaMath/VistaGeometries.h>
#pragma warning( default : 4100 )
Jonas Stienen's avatar
Jonas Stienen committed
39 40 41

// STL includes
#include <complex>
42 43
#include <iomanip>
#include <iostream>
44
#include <fstream>
Jonas Stienen's avatar
Jonas Stienen committed
45 46 47 48
#include <memory>
#include <string>
#include <vector>

49
namespace ITAGeo
Jonas Stienen's avatar
Jonas Stienen committed
50
{
51 52 53 54 55 56 57 58
	
	//! Culling switches
	enum ECulling
	{
		NONE = -1, //!< Never consideres face normal
		BACKFACE = 0, //!< Skips / culls when direction faces backside of a polygon / face
		FRONTFACE = 1, //!< Skips / culls when direction faces frontside of a polygon / face
	};
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
59

60 61 62 63 64 65 66 67
	enum EIntersecting
	{
		NOINTERSECTION = -1, //!< Line segment doesn't intersect
		ATSTART = 0, //!< Intersection at the start point of line segment
		ATEND = 1, //!< Intersection at the end point of line segment
		BETWEEN = 2 //!< Intersection between the start and the end of line segment
	};

68 69 70 71 72 73 74
	enum ECoordinateSystemConvention
	{
		UNDEFINED = -1,
		OPENGL = 0,
		ISO = 1,
	};

75 76 77 78 79 80 81 82
	//! 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
83
	{
84 85 86
	public:
		enum EAnchorType
		{
87
			INVALID = -1, //!< Invalid anchor
88 89 90 91 92 93
			GENERIC_ANCHOR = 0, //!< Propagation anchor without specified type
			ACOUSTIC_EMITTER, //!< Sound-emitting anchor (acoustic source, vibrating plane)
			ACOUSTIC_SENSOR, //!< Sound-sensing anchor (microphone, sensivitive area, listener, portal)
			SPECULAR_REFLECTION, //!< Specular reflection occurrance point (on boundary surface)
			ITA_DIFFUSE_REFLECTION, //!< Diffuse reflection occurrance point (on plane or virtual)
			TRANSMISSION_APEX, //!< Transmission occurrance point (e.g. through a solid wall)
94 95
			DIFFRACTION_OUTER_APEX, //!< Diffraction occurrance point (at a boundary outer edge, e.g. house corner)
			DIFFRACTION_INNER_APEX, //!< Diffraction occurrance point (at a boundary outer edge, e.g. room corner)
96
			MIRROR_IMAGE, //!< (Virtual) Mirror image in medium
97 98

			LAST_ELEMENT //!< Last element of EAnchorType to iterate over EAnchorType
99 100 101 102 103
		} iAnchorType; //! Type of anchor

		VistaVector3D v3InteractionPoint; //!< Point of geometric interaction, has to be further defined by deriving class

		CPropagationAnchor();
104
		CPropagationAnchor(const VistaVector3D& v3Pos);
105 106 107 108 109 110
		virtual ~CPropagationAnchor();

		//! Returns anchor type as a string
		/**
		  * @param[in] iType Anchor type
		  */
111
		static std::string GetAnchorTypeStr(CPropagationAnchor::EAnchorType iType);
112 113 114 115
		static EAnchorType ParseAnchorType(const std::string& sTypeStr);

		//! Returns type string of the class
		static std::string GetTypeStr();
116 117

		//! Output stream operator for console formatting etc.
118
		friend std::ostream& operator<<(std::ostream&, const CPropagationAnchor&);
119

120
		//! Returns a string with the properties of the object
121
		virtual std::string ToString() const;
122
		virtual std::stringstream ToJSON(std::shared_ptr< const CResourceManager > pResourceManager = nullptr) const;
123 124

		//! Load properties from JSON formatted string
125
		virtual void LoadFromJSONString(const std::string& sContent, std::shared_ptr< CResourceManager > pResourceManager = nullptr);
Jonas Stienen's avatar
Jonas Stienen committed
126 127 128
	};


129
	//! A sound source propagation anchor
130
	class ITA_GEO_API CEmitter : public CPropagationAnchor
131
	{
132 133
	public:
		std::string sName;	//!< Versatile source name (for debugging)
134 135
		VistaVector3D& vPos; //!< Position point / geometric interaction point
		VistaQuaternion qOrient; //!< Orientation of object (if applicable)
136
		std::shared_ptr< Directivity::IDirectivity > pDirectivity;
137

138 139 140
		inline CEmitter(VistaVector3D vPos_)
			: CPropagationAnchor(vPos_)
			, vPos(v3InteractionPoint)
141
		{
142
			CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_EMITTER;
143
		};
144
		
145 146 147
		inline CEmitter(const CEmitter& oSrc)
			: CPropagationAnchor(oSrc)
			, vPos(v3InteractionPoint)
148
		{
149
			CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_EMITTER;
150 151
		};

152
		inline CEmitter() : vPos(v3InteractionPoint)
153
		{
154
			CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_EMITTER;
155
		};
156 157

		inline const CEmitter& operator=(const CEmitter& oOther)
158 159 160 161 162 163
		{
			sName = oOther.sName;
			v3InteractionPoint = oOther.v3InteractionPoint;
			qOrient = oOther.qOrient;
			return *this;
		};
164

165 166 167
		//! Returns number of channels from the directivity or "1" if no directivity has been assigned
		int GetNumChannels() const;

168
		//! Returns a string with the properties of the object
169
		std::string ToString() const;
170
		std::stringstream ToJSON(std::shared_ptr< const CResourceManager > pResourceManager) const;
171 172

		//! Load properties from JSON formatted string
173
		void LoadFromJSONString(const std::string& sContent, std::shared_ptr< CResourceManager > pResourceManager = nullptr);
174 175
	};

176 177
	//! A sensor / sound receiver / listener
	class ITA_GEO_API CSensor : public CPropagationAnchor
Jonas Stienen's avatar
Jonas Stienen committed
178
	{
179 180
	public:
		std::string sName;	//! Versatile receiver name (for debugging)
181 182
		VistaVector3D& vPos; //!< Position point / geometric interaction point
		VistaQuaternion qOrient;
183
		std::shared_ptr< Directivity::IDirectivity > pDirectivity;
184

185 186
		inline CSensor() 
			: vPos( v3InteractionPoint )
187
		{
188
			CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_SENSOR;
189 190
		};

191 192 193
		inline CSensor(VistaVector3D vPos_)
			: CPropagationAnchor(vPos_)
			, vPos(v3InteractionPoint)
194
		{
195
			CPropagationAnchor::iAnchorType = CPropagationAnchor::ACOUSTIC_SENSOR;
196 197
		};

198
		inline const CSensor& operator=(const CSensor& oOther)
199 200 201 202 203 204
		{
			sName = oOther.sName;
			v3InteractionPoint = oOther.v3InteractionPoint;
			qOrient = oOther.qOrient;
			return *this;
		};
205

206
		//! Returns a string with the properties of the object
207
		std::string ToString() const;
208
		std::stringstream ToJSON(std::shared_ptr< const CResourceManager > pResourceManager = nullptr) const;
209 210

		//! Load properties from JSON formatted string
211
		void LoadFromJSONString(const std::string& sContent, std::shared_ptr< CResourceManager > pResourceManager = nullptr);
212 213

		int GetNumChannels() const;
Jonas Stienen's avatar
Jonas Stienen committed
214 215
	};

216
	//! Edge diffraction order with respect to source and listener
217
	enum DiffractionOrder
218 219 220 221 222 223 224 225 226 227 228
	{
		DIFFRACTION_ORDER_INF = -1,	//!< Unkown /  infinit order, e.g. probably not reached
		DIFFRACTION_ORDER_0 = 0,	//!< Entity in same halfspace of halfedge, not a valid diffraction order
		DIFFRACTION_ORDER_1,		//!< Entities connected by first order diffraction path
		DIFFRACTION_ORDER_2,		//!< ... by second order ..
		DIFFRACTION_ORDER_3,		//!< ... and so on ...
		DIFFRACTION_ORDER_4,
		DIFFRACTION_ORDER_5,
	};

	//! Specular reflection order on a plane
229
	enum ReflectionOrder
230 231 232 233 234 235 236
	{
		SPECULAR_REFLECTION_ORDER_0 = 0,	//!< Entity in same halfspace
		SPECULAR_REFLECTION_ORDER_1,		//!< Entities connected by first order specular reflection
		SPECULAR_REFLECTION_ORDER_2,		//! ... by second order ... and so on.
	};


237
	//! Specular reflection / diffraction order on a plane
238 239 240
	enum Order
	{
		ORDER_0 = 0,	//!< Zero's or non-order (usually only direct paths recognized)
241
		ORDER_1,		//!< First order interaction, i.e one reflection or one diffraction
242 243
		ORDER_2,		//!< Second order interaction, i.e. one reflection and one diffraction
		ORDER_3,		//!< ... 
244 245 246 247 248
		ORDER_4,		//!< ... 
		ORDER_5,		//!< ... 
		ORDER_6,		//!< ... 
		ORDER_7,		//!< ... 
		ORDER_8,		//!< ... 
249 250
	};

251 252 253 254
	//! Mirror image
	/**
	  * @note Do not mix a mirror image (virtual point in medium) with a specular reflection (point on a boundary)
	  */
255 256 257
	class ITA_GEO_API CMirrorImage : public CPropagationAnchor
	{
	public:
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
258 259

		VistaVector3D v3MirrorNormal; //<! If normal is zero vector, image is invalid / was not reflected
260
		const VistaVector3D& v3MirrorPosition; //!< Mirror image position (alias for interaction point)
261 262
		int iPolygonIndex; //!< Polygon index helper (for recursive audibility test)
		int iOrder;
263
		void* pUserData; //!< User data pointer (for future use)		
264

265
		inline CMirrorImage()
266 267 268 269
			: iPolygonIndex(-1)
			, pUserData(nullptr)
			, iOrder(-1)
			, v3MirrorPosition(v3InteractionPoint)
270
		{
271
			CPropagationAnchor::iAnchorType = CPropagationAnchor::MIRROR_IMAGE;
272
		};
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
273

274 275 276 277 278 279
		inline explicit CMirrorImage(const CPropagationAnchor& oAnchor)
			: CPropagationAnchor(oAnchor)
			, iPolygonIndex(-1)
			, iOrder(-1)
			, pUserData(nullptr)
			, v3MirrorPosition(v3InteractionPoint)
280
		{
281
			CPropagationAnchor::iAnchorType = CPropagationAnchor::SPECULAR_REFLECTION;
282
		};
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
283

284 285
		inline virtual ~CMirrorImage() {};

286
		//! Copy data from another anchor (has to be overwritten by derived classes!)
287
		virtual void CopyFromAnchor(std::shared_ptr< const ITAGeo::CPropagationAnchor > pOther);
288 289 290

		//! Returns a string with the properties of the object
		std::string ToString() const;
291
		std::stringstream ToJSON( std::shared_ptr< const ITAGeo::CResourceManager > pResourceManager = nullptr ) const;
292

293
		//! Load properties from JSON formatted string
294
		void LoadFromJSONString( const std::string& sContent, std::shared_ptr< ITAGeo::CResourceManager > pResourceManager = nullptr );
295

296
	private:
297
		inline const CMirrorImage operator=(const CMirrorImage&)
298
		{
299
			ITA_EXCEPT1(INVALID_PARAMETER, "Copying not allowed");
300
		};
301 302
	};

303 304 305 306
	//! Geometrical propagation anchor with parameters of a specular reflection point
	/**
	  * A specular reflection point
	  */
307
	class ITA_GEO_API CSpecularReflection : public CPropagationAnchor
308 309
	{
	public:
310 311 312
		inline CSpecularReflection() 
		{
			iAnchorType = CPropagationAnchor::SPECULAR_REFLECTION;
313
			v3FaceNormal.SetToZeroVector();
314
		};
315 316
		inline CSpecularReflection(const VistaVector3D& v3SpecularReflectionPoint)
			: CPropagationAnchor(v3SpecularReflectionPoint)
317 318 319 320
		{
			iAnchorType = CPropagationAnchor::SPECULAR_REFLECTION;
		};

321
		inline virtual ~CSpecularReflection() {};
322 323 324

		//! Returns a string with the properties of the object
		std::string ToString() const;
325
		std::stringstream ToJSON(std::shared_ptr< const CResourceManager > pResourceManager = nullptr) const;
326 327

		//! Load properties from JSON formatted string
328
		void LoadFromJSONString(const std::string& sContent, std::shared_ptr< CResourceManager > pResourceManager = nullptr);
329

330 331
		VistaVector3D v3FaceNormal; //!< Face normal of reflection plane

332
		std::shared_ptr< Material::IMaterial > pMaterial; //!< Acoustic material connection, i.e. absorption coefficient
333 334
	};

335 336 337 338 339
	//! Propagation path list class
	/**
	  * Container to hold a list of propagation anchors, that form a propagation path.
	  * Supports file i/o, if XML or JSON is supported.
	  */
340
	class ITA_GEO_API CPropagationPath : public std::vector < std::shared_ptr< CPropagationAnchor > >
341 342 343
	{
	public:
		std::string sIdentifier; //!< Identifier hash
344

345 346 347 348
		//! Stores path to file (*.xml or *.json, if supported)
		/**
		  * Will throw @CITAException on error
		  */
349
		void Store(const std::string& sFilePath, bool bOverwrite = true, std::shared_ptr< const ITAGeo::CResourceManager > pResourceManager = nullptr) const;
350

351 352 353 354
		//! Loads path from file (*.xml or *.json, if supported)
		/**
		  * Will throw @CITAException on error
		  */
355
		void Load( const std::string& sFilePath, std::shared_ptr< ITAGeo::CResourceManager > pResourceManager = nullptr );
356

357 358
		static inline std::string GetTypeStr() 
		{
359
			return "propagation_path";
360 361
		};

362
		//! Calculates the propagation path lenghts
363 364 365 366 367 368 369 370 371 372 373
		inline double GetLength() const
		{
			double dLength = 0.0;
			for (size_t i = 1; i < this->size(); i++)
			{
				//Add length of sub path
				dLength += (at(i)->v3InteractionPoint - at(i - 1)->v3InteractionPoint).GetLength();
			}

			return dLength;
		};
374 375 376 377 378 379 380

		//! Get number of anchors
		inline int GetNumAnchors() const
		{
			return (int) this->size();
		};

381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
		//! Get number of reflections
		inline int GetNumReflections() const
		{

			int iNumReflections = 0;
			for (auto& pAnchor : *this)
			{
				if (pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::SPECULAR_REFLECTION)
					iNumReflections++;
			}

			return iNumReflections;
		};


		//! Get number of diffractions
		inline int GetNumDiffractions() const
		{

			int iNumDiffractions = 0;
			for (auto& pAnchor : *this)
			{

				if (pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::DIFFRACTION_OUTER_APEX
					|| pAnchor->iAnchorType == ITAGeo::CPropagationAnchor::DIFFRACTION_INNER_APEX)
				{
					iNumDiffractions++;
				}
			}

			return iNumDiffractions;
		};

414 415 416 417 418 419 420 421
		//! Calculates accumulated angles over diffracting anchors in radiants
		/**
		  * @return Accumulated angle in radiants
		  *
		  * @note Throws ITAException on error
		  *
		  */
		double GetAccumulatedDiffractionAnglesRad() const;
422 423

		//! Returns a json formatted stringstream with the properties of the object
424
		std::stringstream ToJSON( std::shared_ptr< const CResourceManager > pResourceManager = nullptr ) const;
425

426 427
		//! ( properties from JSON formatted string
		void LoadFromJSONString( const std::string& sContent, std::shared_ptr< CResourceManager > pResourceManager = nullptr );
428

429 430 431 432
	};


	//! List of propagation paths
433
	struct ITA_GEO_API CPropagationPathList : public std::vector < ITAGeo::CPropagationPath >
434
	{
435 436
		std::string sIdentifier; //!< Identifier hash

437 438
		inline int GetNumPaths() const
		{
439
			return (int) this->size();
440 441
		};

442 443 444 445 446 447 448 449 450 451
		inline double GetMaxLength() 
		{
			double dMaxLength = 0;
			for (int i = 0; i< GetNumPaths(); i++)
			{
				double dCurrentLength = this->at(i).GetLength();
				dMaxLength = fmax(dMaxLength, dCurrentLength);
			}
			return dMaxLength;
		};
452 453 454 455
		//! Stores path list to file (*.xml or *.json, if supported)
		/**
		  * Will throw @CITAException on error
		  */
456
		void Store( const std::string& sFilePath, bool bOverwrite = true, std::shared_ptr< const ITAGeo::CResourceManager > pResourceManager = nullptr ) const;
457 458 459 460 461

		//! Loads path list from file (*.xml or *.json, if supported)
		/**
		  * Will throw @CITAException on error
		  */
462
		void Load( const std::string& sFilePath, std::shared_ptr< ITAGeo::CResourceManager > pResourceManager = nullptr );
463

464 465 466 467 468 469
		//! Get type string of class.
		static inline std::string GetTypeStr()
		{
			return "PropagationPathList";
		};

470
		//! Returns a json formatted stringstream with the properties of the object
471
		std::stringstream ToJSON( std::shared_ptr< const ITAGeo::CResourceManager > pResourceManager = nullptr ) const;
472 473

		//! Load properties from JSON formatted string
474
		void LoadFromJSONString( const std::string& sContent, std::shared_ptr< ITAGeo::CResourceManager > pResourceManager = nullptr );
475

476
	};
477 478 479

	//! Geometrical propagation anchor with parameters of a diffraction wedge
	/**
480
	  * @todo: refactor: split into wedge class and aperturepoint class. wedge = geometrical definitions (not prop anchor), aperture point class is a combination of source and target prop anchors including apex point derived from anchor
481
	  */
482
	class ITA_GEO_API CITADiffractionWedgeApertureBase : public ITAGeo::CPropagationAnchor
483 484
	{
	public:
485
		
486 487 488 489 490 491
		VistaVector3D& v3AperturePoint;
		VistaVector3D v3VertextStart;
		VistaVector3D v3VertextEnd;
		VistaVector3D v3MainWedgeFaceNormal;
		VistaVector3D v3OppositeWedgeFaceNormal;

492 493
		CITADiffractionWedgeApertureBase();
		virtual inline ~CITADiffractionWedgeApertureBase() {};
494 495 496 497 498 499

		//! Validates wedge face normals and angles (not facing same or opposite direction)
		/**
		* @return True, if wedge is actually a wedge and not a plane or two-sided polygon
		*/
		bool IsValid() const;
500
		
501 502 503 504
		//! Returns the wedge angle (angle between faces within solid medium of wedge)
		/**
		* @return Wedge angle in radiants
		*/
505
		virtual double GetWedgeAngleRad() const = 0;
506 507 508 509 510

		//! Returns the wedge angle (angle between faces outside (around?) wedge)
		/**
		* @return Opening angle in radiants
		*/
511
		virtual double GetOpeningAngleRad() const = 0;
512 513 514 515 516 517 518

		//! Returns the direction from start to end as normalized vector
		VistaVector3D GetApertureDirection() const;

		//! Returns length of aperture
		float GetApertureLength() const;

519
		CITADiffractionWedgeApertureBase& operator=(const CITADiffractionWedgeApertureBase& oRHS);
520

521 522 523 524 525 526 527 528 529 530 531 532
		//! Checks if source and destination is occluded by wedge
		/**
		* Calculates if source or receiver is in positive half-space of wedge planes
		*
		* @param[in] v3SourcePos Source position
		* @param[in] v3TargetPos Target position
		*
		* @return True, if wedge is occluding and source and destination are not inside wedge
		*
		*/
		bool IsOccluding( const VistaVector3D& v3SourcePos, const VistaVector3D& v3TargetPos ) const;

533 534 535 536 537 538 539 540 541 542
		//! Checks if source and destination is occluded by wedge
		/**
		* Calculates if source or receiver is in positive half-space of wedge planes
		*
		* @param[in] pSource Source anchor
		* @param[in] pDest Source anchor
		*
		* @return True, if wedge is occluding and source and destination are not inside wedge
		*
		*/
543 544 545 546
		inline bool IsOccluding( std::shared_ptr< const ITAGeo::CPropagationAnchor > pSource, std::shared_ptr< const ITAGeo::CPropagationAnchor > pDest ) const
		{
			return IsOccluding( pSource->v3InteractionPoint, pDest->v3InteractionPoint );
		}
547 548 549 550 551 552

		//! Checks if a point is outside the wedge (and not inside the solid structure)
		/**
		* @param[in] Point in space to be checked
		* @return True, if outside or on plane, false if inside
		*/
553
		bool IsOutsideWedge(const VistaVector3D& v3Pos) const;
554 555

		//! Angle between edge vector and incident wave direction
556
		float GetIncidenceWaveAngleRad(const VistaVector3D& v3SourcePoint) const;
557 558 559 560 561 562

		//! Angle between edge vector and reciprocal incident wave direction
		/**
		* The counter-direction of wave propagation. Based on the reciprocity theorem of linear time-invariant
		* systems, it is the same for the target direction
		*/
563
		inline float GetReciprocalIncidenceWaveAngleRad(const VistaVector3D& v3TargetPoint) const
564
		{
565
			return GetIncidenceWaveAngleRad(v3TargetPoint);
566 567 568 569 570
		};

		//! Returns the ray from start vertex into end vertex direction
		inline VistaRay GetEdgeRay() const
		{
571
			return VistaRay(v3VertextStart, (v3VertextEnd - v3VertextStart).GetNormalized());
572 573 574 575 576 577 578 579
		};

		//! Returns the shortest path length a geometrical wavefront would take over aperture (over shortest-path aperture point) from source to target
		/**	  *
		* @param[in] v3SourcePoint Source point
		* @param[in] v3TargetPoint Target point
		* @return Shortest path length in meter
		*/
580
		float GetShortestPathLength(const VistaVector3D& v3SourcePoint, const VistaVector3D& v3TargetPoint) const;
581 582 583 584 585 586 587 588 589 590

		//! Returns the minimum delay a geometrical wavefront arrives at target over aperture (over shortest-path aperture point) from source to target
		/**
		* Before this time, no information can be propagated through the medium due to it's finite sound speed
		*
		* @param[in] v3SourcePoint Source point
		* @param[in] v3TargetPoint Target point
		* @param[in] fSpeedOfSound Sound speed in meter per second
		* @return Minimum wavefront delay time in seconds
		*/
591
		float GetMinimumWavefrontDelayTime(const VistaVector3D& v3SourcePoint, const VistaVector3D& vTargev3TargetPointtPoint, const float fSpeedOfSound = ITAConstants::DEFAULT_SPEED_OF_SOUND_F) const;
592 593 594 595 596 597 598 599 600 601 602 603 604

		//! Returns the maximum delay a geometrical wavefront arrives at target over aperture (over one of the vertices) from source to target
		/**
		* Before this time, no information can be propagated through the medium due to it's finite sound speed
		*
		* @param[in] v3SourcePoint Source point
		* @param[in] v3TargetPoint Target point
		* @param[in] fSpeedOfSound Sound speed in meter per second
		* @return Minimum wavefront delay time in seconds
		*
		* @note Requires homogeneous medium
		*
		*/
605
		float GetMaximumWavefrontDelayTime(const VistaVector3D& v3SourcePoint, const VistaVector3D& v3TargetPoint, const float fSpeedOfSound = ITAConstants::DEFAULT_SPEED_OF_SOUND_F) const;
606 607 608

		//! Returns a string with the properties of the object
		std::string ToString() const;
609
		std::stringstream ToJSON( std::shared_ptr< const ITAGeo::CResourceManager > pResourceManager = nullptr ) const;
610 611

		//! Load properties from JSON formatted string
612
		void LoadFromJSONString( const std::string& sContent, std::shared_ptr< ITAGeo::CResourceManager > pResourceManager = nullptr );
613

614 615
	};

616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
	//! Wedge class for an outer type (like a corner of a house)
	class ITA_GEO_API CITADiffractionOuterWedgeAperture : public ITAGeo::CITADiffractionWedgeApertureBase
	{
	public:
		CITADiffractionOuterWedgeAperture()
		: CITADiffractionWedgeApertureBase()
		{
			iAnchorType = ITAGeo::CPropagationAnchor::DIFFRACTION_OUTER_APEX;
		};
		inline ~CITADiffractionOuterWedgeAperture() {};

		double GetWedgeAngleRad() const;
		double GetOpeningAngleRad() const;
	};

	//! Wedge class for an inner type (like a corner in a room)
	class ITA_GEO_API CITADiffractionInnerWedgeAperture : public ITAGeo::CITADiffractionWedgeApertureBase
	{
	public:
		inline CITADiffractionInnerWedgeAperture()
			: CITADiffractionWedgeApertureBase()
		{
			iAnchorType = ITAGeo::CPropagationAnchor::DIFFRACTION_INNER_APEX;
		};
		inline ~CITADiffractionInnerWedgeAperture() {};

		double GetWedgeAngleRad() const;
		double GetOpeningAngleRad() const;
	};
645
};
Jonas Stienen's avatar
Jonas Stienen committed
646

647

Jonas Stienen's avatar
Jonas Stienen committed
648
//! STL stream output operator
649

650
inline std::ostream& operator<<(std::ostream& os, const ITAGeo::CPropagationAnchor& oAnchor)
651
{
652
	os << "[ " << std::setw(18) << ITAGeo::CPropagationAnchor::GetAnchorTypeStr(oAnchor.iAnchorType) << " ] " << oAnchor.v3InteractionPoint;
653 654 655
	return os;
};

656
inline std::ostream& operator<<(std::ostream& os, const ITAGeo::CPropagationPath& oPath)
657
{
658
	os << "GeoPropagationPath [" << oPath.sIdentifier << "]: num anchors " << oPath.size() << std::endl;
659
	for (size_t i = 0; i < oPath.size(); i++)
660
	{
661 662
		auto pAnchor(oPath[i]);
		os << "  GeoAnchor #" << std::setw(3) << 1 + i << ": " << pAnchor->ToString() << std::endl;
663 664 665
	}
	return os;
};
Jonas Stienen's avatar
Jonas Stienen committed
666

667 668 669 670 671 672 673 674 675 676
inline std::ostream& operator<<(std::ostream& os, const ITAGeo::CPropagationPathList& oPathList)
{
	os << "GeoPropagationPathList [" << oPathList.sIdentifier << "]: num paths " << oPathList.size() << std::endl;
	for (size_t i = 0; i < oPathList.size(); i++)
	{
		auto oPath(oPathList[i]);
		os << "  GeoPropagationPath #" << std::setw(3) << 1 + i << ": " << oPath << std::endl;
	}
	return os;
};
677

Jonas Stienen's avatar
Jonas Stienen committed
678
#endif // INCLUDE_WATCHER_ITA_GEO_BASE