Main Page   Namespace List   Compound List   File List   Compound Members   File Members  

PointAverage.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003 Eric Bohm
00003  *
00004  *This program is free software; you can redistribute it and/or modify
00005  *it under the terms of the GNU General Public License as published by
00006  *the Free Software Foundation version 2 of the License.
00007  * 
00008  *This program is distributed in the hope that it will be useful, but
00009  *WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  *General Public License for more details.
00012  * 
00013  *You should have received a copy of the GNU General Public License along
00014  *with this program; if not, write to the Free Software Foundation, Inc.,
00015  *675 Mass Ave, Cambridge, MA 02139, USA.
00016  *
00017  */
00018 
00019 #ifndef IS_POINTAVG_DEF_SIG
00020 #define IS_POINTAVG_DEF_SIG 1
00021 using namespace std;
00022 #include <functional>
00024 struct PointAverage: public unary_function< Coordinate, void >
00025 {
00026  public:
00028   PointAverage():xSum(0),ySum(0),zSum(0),numPoints(0)
00029     {
00030     }
00031 
00033   void operator()(Coordinate &p)
00034     {
00035       ++numPoints;
00036       xSum+=p.get_x();
00037       ySum+=p.get_y();
00038       zSum+=p.get_z();
00039     }
00040   
00042   Coordinate result()
00043     {
00044       return Coordinate(0,xSum/numPoints,ySum/numPoints,zSum/numPoints,0.0,0.0,0.0);
00045     }
00046   
00047  private:
00048   GLdouble xSum;  
00049   GLdouble ySum;  
00050   GLdouble zSum;  
00051   size_t numPoints; 
00052 
00053 };
00054 
00055 
00056   
00057 #endif

Generated on Wed Oct 29 10:01:52 2003 for Tetraviewer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002