proj home

Files   Classes   Functions   Hierarchy  

pointsurface< T, G > Class Template Reference

Surface visualization with points. More...

#include <pointsurface.h>

Inheritance diagram for pointsurface< T, G >:
Collaboration diagram for pointsurface< T, G >:

List of all members.

Public Member Functions

 pointsurface (uintc N_)
 Pass the number of points, preserves OpenGL attributes and turns off lighting.
template<typename FN >
void addsurface2D (FN &fn)
 Construct a surface from 2D input.
template<typename FN >
void addsurface3D (FN &fn)
 Construct a surface from 3D input.

Public Attributes

uint N
 The number of points to draw.
random11< T, Grnd
 The random number generator.


Detailed Description

template<typename T = double, typename G = randomgenerator>
class pointsurface< T, G >

Surface visualization with points.

This function randomly generates points and passes them to a client supplied function which either rejects the point or accepts it. If the point is accepted the function interprets the point in 3D by writing another point and passing it back to this class.

This is all done through the functional object interface. Both 2D and 3D versions exist because there are also surfaces that are better described with 3D coordinates.

In this sense it is like a MonteCarlo method. For example a circle could be drawn with a rejection test of all points in the unit square outside the circle. So the rejection serves as a mask.

Unit intervals are used to make this object generic. It is the client who interprets the interval. The random sampling of points on this interval is uniform.

Definition at line 35 of file pointsurface.h.


Constructor & Destructor Documentation

template<typename T = double, typename G = randomgenerator>
pointsurface< T, G >::pointsurface ( uintc  N_  )  [inline]

Pass the number of points, preserves OpenGL attributes and turns off lighting.

Definition at line 50 of file pointsurface.h.

References gobjContainerPrePost::post, gobjContainerPrePost::pre, and gobjContainer::push().

00051     : N(N_)
00052   {
00053     pre.push( new gobjglPushAttrib(GL_LIGHTING) );
00054     pre.push( new gobjglPushAttrib(GL_CURRENT_BIT) );
00055     pre.push( new gobjglDisable(GL_LIGHTING) );
00056 
00057     post.push( new gobjglPopAttrib() );
00058     post.push( new gobjglPopAttrib() );
00059   }


Member Function Documentation

template<typename T = double, typename G = randomgenerator>
template<typename FN >
void pointsurface< T, G >::addsurface2D ( FN &  fn  )  [inline]

Construct a surface from 2D input.

Definition at line 63 of file pointsurface.h.

References pointsurface< T, G >::N, gobjContainer::nuke(), gobjContainer::push(), pointsurface< T, G >::rnd, point3< T >::x, point3< T >::y, and point3< T >::z.

Referenced by planeinttest::test01(), diskinttest::test01(), pointsurfacetest::test01(), and pointsurfacetest::test03().

00064   {
00065     point3<double> p;
00066     bool valid(false);
00067 
00068     nuke();
00069 
00070     push( new gobjglBegin(GL_POINTS) );
00071 
00072     for (uint i=0; i<N; )
00073     {
00074       point3<double> p;
00075       fn(valid,p.x,p.y,p.z,rnd(),rnd());
00076       if (valid)
00077       {
00078         push( new gobjglVertex3d(p) );
00079         ++i;
00080       }
00081     }
00082 
00083     push( new gobjglEnd() );
00084   }

template<typename T = double, typename G = randomgenerator>
template<typename FN >
void pointsurface< T, G >::addsurface3D ( FN &  fn  )  [inline]

Construct a surface from 3D input.

Definition at line 88 of file pointsurface.h.

References pointsurface< T, G >::N, gobjContainer::nuke(), gobjContainer::push(), pointsurface< T, G >::rnd, point3< T >::x, point3< T >::y, and point3< T >::z.

Referenced by pointsurfacetest::test02().

00089   {
00090     point3<double> p;
00091     bool valid(false);
00092 
00093     nuke();
00094 
00095     push( new gobjglBegin(GL_POINTS) );
00096 
00097     for (uint i=0; i<N; )
00098     {
00099       point3<double> p;
00100       fn(valid,p.x,p.y,p.z,rnd(),rnd(),rnd());
00101       if (valid)
00102       {
00103         push( new gobjglVertex3d(p) );
00104         ++i;
00105       }
00106     }
00107 
00108     push( new gobjglEnd() );
00109   }


Member Data Documentation

template<typename T = double, typename G = randomgenerator>
uint pointsurface< T, G >::N

The number of points to draw.

Definition at line 42 of file pointsurface.h.

Referenced by pointsurface< T, G >::addsurface2D(), and pointsurface< T, G >::addsurface3D().

template<typename T = double, typename G = randomgenerator>
random11<T,G> pointsurface< T, G >::rnd

The random number generator.

Generates a random number on the interval [0.0,1.0].

Definition at line 46 of file pointsurface.h.

Referenced by pointsurface< T, G >::addsurface2D(), and pointsurface< T, G >::addsurface3D().


The documentation for this class was generated from the following file:

Generated on Fri Mar 4 00:50:10 2011 for Chelton Evans Source by  doxygen 1.5.8