00001 /************************************************************** ggt-head beg
00002 *
00003 * GGT: Generic Graphics Toolkit
00004 *
00005 * Original Authors:
00006 * Allen Bierbaum
00007 *
00008 * -----------------------------------------------------------------
00009 * File: $RCSfile: Comparitors.h,v $
00010 * Date modified: $Date: 2002/01/26 23:47:53 $
00011 * Version: $Revision: 1.2 $
00012 * -----------------------------------------------------------------
00013 *
00014 *********************************************************** ggt-head end */
00015 /*************************************************************** ggt-cpr beg
00016 *
00017 * GGT: The Generic Graphics Toolkit
00018 * Copyright (C) 2001,2002 Allen Bierbaum
00019 *
00020 * This library is free software; you can redistribute it and/or
00021 * modify it under the terms of the GNU Lesser General Public
00022 * License as published by the Free Software Foundation; either
00023 * version 2.1 of the License, or (at your option) any later version.
00024 *
00025 * This library is distributed in the hope that it will be useful,
00026 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00028 * Lesser General Public License for more details.
00029 *
00030 * You should have received a copy of the GNU Lesser General Public
00031 * License along with this library; if not, write to the Free Software
00032 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00033 *
00034 ************************************************************ ggt-cpr end */
00035 #ifndef _GMTL_COMPARITORS_H_
00036 #define _GMTL_COMPARITORS_H_
00037
00038 // This file contains helper comparitors
00039 //
00040 // They can be used as comparison functors for STL container
00041 // operations (or for anything else you may want to use them for...)
00042 //
00043
00044 #include <gmtl/Vec3.h>
00045 #include <gmtl/Point3.h>
00046
00047 namespace gmtl
00048 {
00049 // Allows for the comparison of projected point distances
00050 // onto a given vector
00051 struct CompareIndexPointProjections
00052 {
00053 public:
00054 CompareIndexPointProjections() : points(NULL)
00055 {;}
00056
00057 bool operator()(const unsigned x, const unsigned y)
00058 {
00059 float xVal = sortDir.dot((*points)[x]);
00060 float yVal = sortDir.dot((*points)[y]);
00061
00062 return (xVal < yVal);
00063 }
00064
00065 const std::vector<Point3>* points;
00066 gmtl::Vec3 sortDir; // Direction to sort by
00067 };
00068 };
00069
00070 #endif
00071
1.2.14 written by Dimitri van Heesch,
© 1997-2002