source: projectionDesigner/trunk/projdesigner/include/gmtl/Comparitors.h @ 195

Last change on this file since 195 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 2.2 KB
Line 
1/************************************************************** ggt-head beg
2 *
3 * GGT: Generic Graphics Toolkit
4 *
5 * Original Authors:
6 *   Allen Bierbaum
7 *
8 * -----------------------------------------------------------------
9 * File:          Comparitors.h,v
10 * Date modified: 2002/01/26 23:47:53
11 * Version:       1.2
12 * -----------------------------------------------------------------
13 *
14 *********************************************************** ggt-head end */
15/*************************************************************** ggt-cpr beg
16*
17* GGT: The Generic Graphics Toolkit
18* Copyright (C) 2001,2002 Allen Bierbaum
19*
20* This library is free software; you can redistribute it and/or
21* modify it under the terms of the GNU Lesser General Public
22* License as published by the Free Software Foundation; either
23* version 2.1 of the License, or (at your option) any later version.
24*
25* This library is distributed in the hope that it will be useful,
26* but WITHOUT ANY WARRANTY; without even the implied warranty of
27* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28* Lesser General Public License for more details.
29*
30* You should have received a copy of the GNU Lesser General Public
31* License along with this library; if not, write to the Free Software
32* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33*
34 ************************************************************ ggt-cpr end */
35#ifndef _GMTL_COMPARITORS_H_
36#define _GMTL_COMPARITORS_H_
37
38// This file contains helper comparitors
39//
40// They can be used as comparison functors for STL container
41// operations (or for anything else you may want to use them for...)
42//
43
44#include <gmtl/Vec3.h>
45#include <gmtl/Point3.h>
46
47namespace gmtl
48{
49   // Allows for the comparison of projected point distances
50   // onto a given vector
51   struct CompareIndexPointProjections
52   {
53   public:
54      CompareIndexPointProjections() : points(NULL)
55      {;}
56
57      bool operator()(const unsigned x, const unsigned y)
58      {
59         float xVal = sortDir.dot((*points)[x]);
60         float yVal = sortDir.dot((*points)[y]);
61
62         return (xVal < yVal);
63      }
64
65      const std::vector<Point3>* points;
66      gmtl::Vec3                 sortDir;       // Direction to sort by
67   };
68};
69
70#endif
71
Note: See TracBrowser for help on using the repository browser.