00001 /* 00002 * Copyright (c) 2004 CSIRO ICT Centre 00003 * 00004 * $Id: Neighbours.h 587 2004-12-03 15:06:33Z nch $ 00005 */ 00006 00007 /* 00008 * Implements the Matcher interface for determining nearest neighbours 00009 * within a single catalogue. 00010 * 00011 * Implements the generic matcher methods required for various filter 00012 * algorithms. Also provides an efficient plane sweep filter. 00013 * 00014 * one object producer is required, plus an object consumer to report 00015 * those objects that don't match and a pair consumer for those that do. 00016 * 00017 * The active list is required to maintain an efficient set of active 00018 * objects for testing against the test obejcts. 00019 * 00020 * The producer and active list are owned by this class and are deleted 00021 * by the destructor. 00022 */ 00023 00024 #ifndef NEIGHBOURS_DEFINED 00025 #define NEIGHBOURS_DEFINED 00026 00027 #include "String.h" 00028 00029 #include "ActiveList.h" 00030 #include "Matcher.h" 00031 00032 class Object; 00033 class ObjectConsumer; 00034 class ObjectPairConsumer; 00035 class ObjectProducer; 00036 00037 00038 class Neighbours : public Matcher 00039 { 00040 public: 00041 Neighbours(ObjectProducer * prod, 00042 ActiveList * activeList, 00043 ObjectPairConsumer * pairCons, 00044 ObjectConsumer * uCons, 00045 double maxD); 00046 virtual ~Neighbours(); 00047 00048 virtual String const & getName() const { return name(); }; 00049 static String const & name() { return s_name; }; 00050 00051 virtual void getReady(); 00052 virtual void finished(); 00053 virtual void doFilter(); 00054 00055 virtual Object const * nextActiveObject(); 00056 virtual Object const * nextTestObject(); 00057 00058 virtual double getLowerBound(Object const * testObject); 00059 virtual double getUpperBound(Object const * testObject); 00060 00061 virtual void addActiveObject(Object const * activeObject); 00062 00063 virtual void reportActiveNoMatch(Object const * activeObject); 00064 virtual void reportTestNoMatch(Object const * testObject); 00065 00066 virtual bool test(Object const * activeObject, 00067 Object const * testObject); 00068 virtual void test(Object const * testObject); 00069 00070 virtual void flushActiveObjects(double lowerBound); 00071 virtual void flushActiveObjects(Object const * activeObject); 00072 00073 private: 00074 static String const s_name; 00075 00076 ObjectProducer * producer; 00077 ObjectConsumer * uConsumer; 00078 ActiveList * activeList; 00079 ActiveObject * testActive; 00080 Object const * testObj; 00081 bool testMatchedPreviously; 00082 Object const * currentObj; 00083 double maxDistance; 00084 int cnt; 00085 00086 Neighbours(); 00087 Neighbours(Neighbours const &); 00088 Neighbours & operator=(Neighbours const &); 00089 }; 00090 00091 00092 #endif // ifndef NEIGHBOURS_DEFINED