/***************************************************************************
*                                                                          *
*  Copyright (C) Golaem S.A.  All Rights Reserved.                         *
*                                                                          *
***************************************************************************/

#pragma once

#include "glmSDKAPI.h"
#include "glmPathDefinitions.h"
#include <glmSegment2.h>
#include <glmTriangle3.h>

namespace glm
{
	class Vector2;

	/**
	* \defgroup Utils Utils
	*
	* \ingroup Environment
	*
	* \author Golaem <dev@golaem.com>
	*
	* \brief Various utilities.
	*/

	/** 
	* \brief Compute the minimum distance between a point and a list of segments.
	*
	* \ingroup Utils
	*
	* \param point The point.
	* \param segments The segments.
	* \return The distance.
	*
	* \author Golaem <dev@golaem.com>
	*/
	extern GLM_SDK_API float distance(const Vector2 & point, glm::Array<Segment2> const & segments);

	/** 
	* \brief Compute the minimum distance between a segment and a list of segments.
	*
	* \ingroup Utils
	*
	* \param segment The segment.
	* \param segments The segments.
	* \return The distance.
	*
	* \author Golaem <dev@golaem.com>
	*/
	extern GLM_SDK_API float distance(const Segment2 & segment, glm::Array<Segment2> const & segmentSet);

	/** 
	* \brief Check the coplanarity of two triangles comparing their normals
	*
	* \ingroup Utils
	*
	* \param triangle1 The first triangle.
	* \param triangle2 The second triangle.
	* \param angularThreshold The value of the normals angle under which the triangles are considered coplanar.
	* \return True if the triangles are coplanar.
	*
	* \author Golaem <dev@golaem.com>
	*/
	extern GLM_SDK_API bool checkTriangleCoplanarityUsingNormals(const Triangle3 & triangle1, const Triangle3 & triangle2, Angle angularThreshold);

	/** 
	* \brief Check the coplanarity of two triangles using an altitude threshold.
	*
	* \ingroup Utils
	*
	* The second triangle is projected on the plane of the first, we then compare the altitude difference 
	* between the first triangle's vertices and the its projection's. 
	*
	* Due to the method, this call is not reflective ( i.e. checkTriangleCoplanarityUsingAltitude(t1,t2) might 
	* return a different result than checkTriangleCoplanarityUsingAltitude(t2,t1) ).
	*
	* \param triangle1 The first triangle (reference triangle).
	* \param triangle2 The second triangle.
	* \param altitudeThreshold The altitude threshold.
	* \return True if the triangles are coplanar.
	*
	* \author Golaem <dev@golaem.com>
	*/
	extern GLM_SDK_API bool checkTriangleCoplanarityUsingAltitude(const Triangle3 & triangle1, const Triangle3 & triangle2, float altitudeThreshold);

	/**
	* \brief Adds arrows to indicate the direction of segments.
	*
	* \ingroup Utils
	*
	* \author Golaem <dev@golaem.com>
	*
	* \param[in,out] geometry The segments to which extermities, arrow will be added.
	* \param[in] size The size of the added arrow (the arrow will fit in a square having this length).
	*/
	void GLM_SDK_API addArrows(glm::Array<Segment3>& geometry, const float size);
}
