/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017 Raytrix GmbH. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "DllInterface.h"

#include "RxArray2DDouble.h"
#include "RxArrayDouble.h"
#include "RxArray.h"

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// namespace: Rx
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace Rx
{
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>
	/// 	Representation for particles estimated in Rx.Flow algorithms. Provides 3D position, quality information,
	/// 	time track ID and involved 2D particles (position and size).
	/// </summary>
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	struct RXCOREEX_API SParticle
	{
		/// <summary> Time index of image this was detected in. Index in image sequence if applicable, else count over estimations. </summary>
		unsigned iTimeIndex;

		/// <summary> Unique identifier for track corresponding to this. Track might have length 1, i.e. only this particle. </summary>
		long iTrackUID;

		/// <summary> Estimated 3D particle position in MM in global object space. </summary>
		Rx::CRxArrayDouble vecPoint3D_Obj_MM_g;

		/// <summary> Maximum of re-projection errors to all 2D features. </summary>
		double dMaxReprojectionError_PIX;

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Maximal angle between all lens baselines during matching. Values in [0...pi/2].
		/// 	\leq 0.8 indicates instable 3D position.
		/// </summary>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		double dMaxBaselineAngle_RAD;

		/// <summary> Quality measure for 3D particle in [0..1]. Determined by depth, match-count and re-projection error. </summary>
		double dOverallQuality;

		/// <summary> The average luminance over all 2D particles. Determined in blob matching not from pixel array. </summary>
		double dLuminance;

		/// <summary>
		///		Array providing involved 2D particles by position and size. I.e. components
		///			(i,0) : position of particle i in image x-axis in PX on pxa
		///			(i,1) : position of particle i in image y-axis in PX on pxa
		///			(i,2) : radius. </summary>
		Rx::CRxArray2DDouble xParticles2D_PX_pxa;

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Equality operator (tests iTimeIndex and iTrackUID).
		/// </summary>
		///
		/// <param name="xParticle"> The particle. </param>
		///
		/// <returns> True if the parameters are considered equivalent. </returns>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		bool operator==(const SParticle& xParticle) const
		{
			return iTimeIndex == xParticle.iTimeIndex && iTrackUID == xParticle.iTrackUID;
		}
	};
}

/************************************************************************/
/* Explicit Exports                                                     */
/************************************************************************/
template class RXCOREEX_API Rx::CRxArray<Rx::SParticle>;
