cm_file.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <iostream>
00038 #include "String.h"
00039
00040 #include "ActiveList.h"
00041 #include "AngularSeparationRefine.h"
00042 #include "BoundingBoxRefine.h"
00043 #include "CrossMatch.h"
00044 #include "DecPlaneSweepFilter.h"
00045 #include "FileProducerFactory.h"
00046 #include "FileWriter.h"
00047 #include "FilePairWriter.h"
00048 #include "Filter.h"
00049 #include "IndexedActiveList.h"
00050 #include "Matcher.h"
00051 #include "NestedLoopFilter.h"
00052 #include "Object.h"
00053 #include "ObjectConsumer.h"
00054 #include "ObjectPairConsumer.h"
00055 #include "ObjectPairRefineConsumer.h"
00056 #include "ObjectProducer.h"
00057 #include "Refine.h"
00058 #include "SimpleActiveList.h"
00059 #include "TextFileDatumWriter.h"
00060 #include "Timer.h"
00061
00062 static void usage(char const * const prog_name)
00063 {
00064 std::cerr << prog_name
00065 << " <a_dir|0> <a_file> <binary|ascii> [merge] <a_maxSD>"
00066 << " <b_dir|0> <b_file> <binary|ascii> [merge] <b_maxSD>"
00067 << " <z_alpha> <index|list> <bb|as> <filter|nested|sweep>" << std::endl;
00068 }
00069
00070 int main(int argc, char * argv[])
00071 {
00072 #ifdef PLOT_TIMES
00073 Timer::globalTimer()->cont();
00074 #endif
00075
00076 int status = 0;
00077
00078 if (argc < 13 || argc > 15)
00079 {
00080 usage(argv[0]);
00081 status = 1;
00082 }
00083 else
00084 {
00085 int param = 1;
00086 char * aDir = argv[param++];
00087 char * aName = argv[param++];
00088 bool aBinary = (strcmp(argv[param++], "binary") == 0);
00089 bool aMerge = false;
00090 if (strcmp(argv[param], "merge") == 0)
00091 {
00092 aMerge = true;
00093 param++;
00094 }
00095 double aMaxSD = atof(argv[param++]);
00096
00097 char * bDir = argv[param++];
00098 char * bName = argv[param++];
00099 bool bBinary = (strcmp(argv[param++], "binary") == 0);
00100 bool bMerge = false;
00101 if (strcmp(argv[param], "merge") == 0)
00102 {
00103 bMerge = true;
00104 param++;
00105 }
00106 double bMaxSD = atof(argv[param++]);
00107
00108 double z_alpha = atof(argv[param++]);
00109 Object::zAlpha = z_alpha;
00110
00111 bool useIndex = (strcmp(argv[param++], "index") == 0);
00112 bool useBB = (strcmp(argv[param++], "bb") == 0);
00113 bool useFilter = (strcmp(argv[param], "filter") == 0);
00114 bool useNestedLoop = (!useFilter && strcmp(argv[param++], "nested") == 0);
00115
00116 if (useFilter)
00117 std::cout << "Using CM filter : true" << std::endl;
00118 else if (useNestedLoop)
00119 std::cout << "Using generic nested loop : true" << std::endl;
00120 else
00121 std::cout << "Using generic plane sweep : true" << std::endl;
00122 std::cout << "Using index active list : " << ((useIndex) ? "true" : "false") << std::endl;
00123 std::cout << "Using full BB refine : " << ((useBB) ? "true" : "false") << std::endl;
00124
00125
00126
00127
00128
00129
00130 ObjectPairConsumer accAngSepPairCons(AngularSeparationRefine::name() + " accept");
00131 ObjectPairConsumer rejAngSepPairCons(AngularSeparationRefine::name() + " reject");
00132
00133 AngularSeparationRefine angSepRefine(&accAngSepPairCons,
00134 &rejAngSepPairCons);
00135
00136 ObjectPairRefineConsumer angSepConsumer(BoundingBoxRefine::name(),
00137 &angSepRefine);
00138
00139 ObjectPairConsumer rejBBPairCons(BoundingBoxRefine::name() + " reject");
00140
00141 BoundingBoxRefine bbRefine(&angSepConsumer, &rejBBPairCons);
00142
00143
00144 ObjectPairRefineConsumer pairCons(((useNestedLoop) ? NestedLoopFilter::name()
00145 : DecPlaneSweepFilter::name()),
00146 ((useBB) ? (Refine*) &bbRefine
00147 : (Refine*) &angSepRefine));
00148
00149
00150
00151
00152
00153
00154
00155
00156 ObjectConsumer uaCons("A points reject");
00157 ObjectConsumer ubCons("B points reject");
00158
00159 ObjectProducer * aProd = FileProducerFactory::instance()->createProducer(
00160 aDir, aName, aBinary, aMerge, false, aMaxSD);
00161 ObjectProducer * bProd = FileProducerFactory::instance()->createProducer(
00162 bDir, bName, bBinary, bMerge, false, bMaxSD);
00163
00164
00165 ActiveList * aList = (useIndex) ? (ActiveList *) new IndexedActiveList()
00166 : (ActiveList *) new SimpleActiveList();
00167 Matcher * matcher = new CrossMatch(aProd, bProd, aList , &pairCons, &uaCons, &ubCons);
00168 Filter * filter = 0;
00169
00170 if (useFilter)
00171 filter = new Filter(matcher);
00172 else if (useNestedLoop)
00173 filter = new NestedLoopFilter(matcher);
00174 else
00175 filter = new DecPlaneSweepFilter(matcher);
00176
00177 filter->filter();
00178
00179 delete filter;
00180 }
00181
00182 return status;
00183 }