#ifndef FUNC2DOVERVEC3D_H
#define FUNC2DOVERVEC3D_H

#include <typedefs.h>

/*!
\brief  Apply a 2D function to each element in a primitive
  vector of 3D points.

  The class is first instantiated, then apply the function 
  to the choosen dimension.  

  The function is passed as a functional object which writes 
  to the first argument and reads the values of the next to 
  as the surface.
*/
template< typename T >
class func2Dovervec3D
{
public:

  /** The primitive vector. */
  T * const pt;
  /** The size of pt. */
  uintc size;

  /** Initialize the vector. */
  func2Dovervec3D(T* pt_, uintc size_)
    : pt(pt_), size(size_) {}

  /** The y and z axes are the surface. */
  template< typename F >
  void evalX( F & fn)
  {
    for (uint i=0; i<size; ++i)
      fn(pt[i].x,pt[i].y,pt[i].z);
  }

  /** The x and z axes are the surface. */
  template< typename F >
  void evalY( F & fn)
  {
    for (uint i=0; i<size; ++i)
      fn(pt[i].y,pt[i].x,pt[i].z);
  }

  /** The x and y axes are the surface. */
  template< typename F >
  void evalZ( F & fn)
  {
    for (uint i=0; i<size; ++i)
      fn(pt[i].z,pt[i].x,pt[i].y);
  }

};



#endif



