#ifndef PLANEPOINTSURFACE_H
#define PLANEPOINTSURFACE_H

#include <plane.h>
#include <typedefs.h>

/*!
\brief Plane point surface.

This class is designed to be used with the pointsurface class.
 Essentially this class is a function which is a plane surface.

The client can set the scale and offset for the u and v 
 variables.  So when the operator () is called where on 
 the plane the rectangular patch is generated can be 
 controlled.

\par Example
\verbatim
  plane P1(nml,d); 
  ...
  planepointsurface f1(P1);
  // Say how many surface points to generate.
  pointsurface<> ps1(4000);
  // Color the points. 
  ps1.pre.push(new gobjglColor3ub(184,134,11) );
  ps1.addsurface2D(f1);
  gobjpush(&ps1);
\endverbatim
*/
class planepointsurface
{
  /** The current axis being considered. */
  uint state;
public:

  /** The plane this surface represents. */
  plane & pln;

  /** u is shifted before being scaled. */
  double uoffset;
  /** v is shifted before being scaled. */
  double voffset;
  /** u axis is scaled. */
  double uscale;
  /** v axis is scaled. */
  double vscale;

  /** Need a plane to display. */
  planepointsurface(plane & _pln)
    : state(0), pln(_pln), uoffset(-0.5), voffset(-0.5), 
      uscale(20.0), vscale(20.0) {}

  /** Globaly scale the two axeses together. */
  void scaleSet(doublec s)
    { uscale=s; vscale=s; }

  /** Generate a point of the surface with u and v in unit square. */
  void operator()
  (
    bool & accept,
    double & x,
    double & y,
    double & z,
    doublec u,
    doublec v
  );

};

#endif



