00001 /* 00002 * Copyright (c) 2004 CSIRO ICT Centre 00003 * 00004 * $Id: DecPlaneSweepFilter.cpp 587 2004-12-03 15:06:33Z nch $ 00005 */ 00006 00007 /* 00008 * A note on terminology: The filter passes the objects from one of the 00009 * ObjectProducers through the active list, while objects from the other 00010 * ObjectProducer are used to test against the active list. Therefore 00011 * we distinguish between the object sets by referring to 00012 * activeObjectProducer, nextActiveObject, etc, on the one hand, and 00013 * testObjectProducer, nextTestObject, etc, on the other. 00014 * 00015 * Note the matcher owns the objects producers and active list. 00016 */ 00017 00018 #include "String.h" 00019 00020 #include "ActiveList.h" 00021 #include "DecPlaneSweepFilter.h" 00022 #include "Matcher.h" 00023 #include "Object.h" 00024 #include "Profiler.h" 00025 00026 00027 String DecPlaneSweepFilter::s_name("DecPlaneSweepFilter"); 00028 00029 00030 DecPlaneSweepFilter::DecPlaneSweepFilter(Matcher * matcher) 00031 : Filter(matcher) 00032 { 00033 } 00034 00035 DecPlaneSweepFilter::~DecPlaneSweepFilter() 00036 { 00037 } 00038 00039 /* the basic plane sweep filter algorithm */ 00040 00041 void DecPlaneSweepFilter::filter() 00042 { 00043 preFilter(); 00044 00045 Object const * testObject = matcher->nextTestObject(); 00046 Object const * activeObject = matcher->nextActiveObject(); 00047 00048 /* Loop: for as long are there are more test objects */ 00049 while (testObject != 0) 00050 { 00051 double lowerBound = matcher->getLowerBound(testObject); 00052 double upperBound = matcher->getUpperBound(testObject); 00053 00054 // remove from the active list those objects that are below the lower bound 00055 matcher->flushActiveObjects(lowerBound); 00056 00057 // populate the active list with candidates 00058 while (activeObject != 0 && activeObject->getDec() <= upperBound) 00059 { 00060 if (activeObject->getDec() < lowerBound) 00061 { 00062 // no need to put it in - it cannot match 00063 matcher->reportActiveNoMatch(activeObject); 00064 delete activeObject; 00065 } 00066 else 00067 { 00068 matcher->addActiveObject(activeObject); 00069 } 00070 activeObject = matcher->nextActiveObject(); 00071 } 00072 00073 matcher->test(testObject); 00074 testObject = matcher->nextTestObject(); 00075 } 00076 00077 // no more test objects, but there may still be some in the active list 00078 matcher->flushActiveObjects(activeObject); 00079 00080 postFilter(); 00081 } 00082