00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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