source: trunk/VUT/GtpVisibility/include/DistanceQueue.h @ 316

Revision 316, 1.1 KB checked in by mattausch, 19 years ago (diff)

queries are realized as templates

RevLine 
[59]1#ifndef _DistanceQueue_H__
2#define _DistanceQueue_H__
3
4#include "OcclusionQuery.h"
5
6#include <queue>
7
8namespace GtpVisibility {
9
10/*  We define HierarchyNode as void * because
11        there is no common ancestor for hierarchy nodes in Ogre
12*/
13typedef void HierarchyNode;
14
15class HierarchyInterface;
16/** This class implements the less operator for the priority queue, i.e.,
17        a greater distance has a lower priority in the queue.
18*/
[316]19template <typename T> class GtDistance
[59]20{
21public:
[316]22        GtDistance(HierarchyInterface *hierarchyInterface): mHierarchyInterface(hierarchyInterface)
[59]23        {}
24       
25        bool operator() (T v1, T v2) const
26        {
[87]27                return mHierarchyInterface->GetSquaredDistance(v1) > mHierarchyInterface->GetSquaredDistance(v2);
[59]28        }
29               
30private:
31        HierarchyInterface *mHierarchyInterface;
32};
33
34/** A priority queue where closer hierarchy nodes are given a higher priority.
35*/
[316]36typedef std::priority_queue<HierarchyNode *, std::vector<HierarchyNode *>, GtDistance<std::vector<HierarchyNode *>::value_type> > DistanceQueue;
[59]37
38} // namespace GtpVisibility
39
40#endif // DistanceQueue_H
Note: See TracBrowser for help on using the repository browser.