
#ifndef _SMESHLIB_OPERATIONS_COMPUTEEDGELENGTH_H_
#define _SMESHLIB_OPERATIONS_COMPUTEEDGELENGTH_H_

namespace SMeshLib   {
namespace Operations {
;

// The ComputeEdgeLength is a functor (delegate) to compute the length of a halfedge in CGAL::Polyhdeon_3.
// ComputeEdgeLength is thread-safe.
// TPolyhedron is a type of CGAL::Polyhdeon_3.
template<class TPolyhedron>
struct ComputeEdgeLength
{
public:
	
	// Redefine types from TPolyhedron for convenience.
	typedef typename TPolyhedron::Point_3  Point3;
	typedef typename TPolyhedron::Halfedge Halfedge;
	
	// Return type of operator() required by QtConcurrent.
	typedef double result_type;
	
public:
	
	// Compute edge length of a given half edge.
	inline double operator () (const Halfedge& h)
	{
		const Point3& p = h.prev()->vertex()->point();
		const Point3& q = h.vertex()->point();
		return CGAL::sqrt(CGAL::squared_distance(p, q));
	}
};

};	// End namespace Operations.
};	// End namespace SMeshLib.

#endif // _SMESHLIB_OPERATIONS_COMPUTEEDGELENGTH_H_
