frcm_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
00038
00039
00040 #include <iostream>
00041 #include "String.h"
00042
00043 #include "ActiveList.h"
00044 #include "BinaryFileObjectWriter.h"
00045 #include "BoundingBoxRefine.h"
00046 #include "DecPlaneSweepFilter.h"
00047 #include "FileProducerFactory.h"
00048 #include "FileWriter.h"
00049 #include "FilePairWriter.h"
00050 #include "Filter.h"
00051 #include "FixedRadiusCrossMatch.h"
00052 #include "IndexedActiveList.h"
00053 #include "Matcher.h"
00054 #include "NestedLoopFilter.h"
00055 #include "Object.h"
00056 #include "ObjectConsumer.h"
00057 #include "ObjectPairConsumer.h"
00058 #include "ObjectPairRefineConsumer.h"
00059 #include "ObjectProducer.h"
00060 #include "ObjectPairRefine.h"
00061 #include "SimpleActiveList.h"
00062 #include "TextFileObjectWriter.h"
00063 #include "Timer.h"
00064 #include "WithinDistanceRefine.h"
00065
00066
00067 static void usage(char const * const prog_name)
00068 {
00069 std::cerr << prog_name
00070 << " <a_dir|0> <a_file> <binary|ascii> [merge]"
00071 << " <b_dir|0> <b_file> <binary|ascii> [merge]"
00072 << " <maxDistInArcSecs> <index|list> <bb|as> <filter|nested|sweep>"
00073 << " <outfile_name>" << std::endl;
00074 }
00075
00076 int main(int argc, char * argv[])
00077 {
00078 #ifdef PLOT_TIMES
00079 Timer::globalTimer()->cont();
00080 #endif
00081
00082 int status = 0;
00083
00084 if (argc < 12 || argc > 14)
00085 {
00086 usage(argv[0]);
00087 status = 1;
00088 }
00089 else
00090 {
00091 int param = 1;
00092 char * aDir = argv[param++];
00093 char * aName = argv[param++];
00094 bool aBinary = true;
00095 if (strcmp(argv[param++], "ascii") == 0)
00096 aBinary = false;
00097 bool aMerge = false;
00098 if (strcmp(argv[param], "merge") == 0)
00099 {
00100 aMerge = true;
00101 param++;
00102 }
00103
00104 char * bDir = argv[param++];
00105 char * bName = argv[param++];
00106 bool bBinary = true;
00107 if (strcmp(argv[param++], "ascii") == 0)
00108 bBinary = false;
00109 bool bMerge = false;
00110 if (strcmp(argv[param], "merge") == 0)
00111 {
00112 bMerge = true;
00113 param++;
00114 }
00115
00116 double maxDist = atof(argv[param++])/3600.0;
00117
00118 bool useIndex = (strcmp(argv[param++], "index") == 0);
00119 bool useBB = (strcmp(argv[param++], "bb") == 0);
00120 bool useFilter = (strcmp(argv[param], "filter") == 0);
00121 bool useNestedLoop = (!useFilter && strcmp(argv[param], "nested") == 0);
00122
00123 char * outFile = argv[++param];
00124
00125 if (useFilter)
00126 std::cout << "Using FRCM filter : true" << std::endl;
00127 else if (useNestedLoop)
00128 std::cout << "Using generic nested loop : true" << std::endl;
00129 else
00130 std::cout << "Using generic plane sweep : true" << std::endl;
00131 std::cout << "Using index active list : " << ((useIndex) ? "true" : "false") << std::endl;
00132 std::cout << "Using full BB refine : " << ((useBB) ? "true" : "false") << std::endl;
00133 std::cout << "Max distance (Dec Degs) : " << maxDist << std::endl;
00134
00135
00136 ObjectPairConsumer accWithinDistPairCons(WithinDistanceRefine::name() + " accept",
00137 new FilePairWriter(new TextFileObjectWriter(), outFile, true));
00138
00139 ObjectPairConsumer rejWithinDistPairCons(WithinDistanceRefine::name() + " reject");
00140
00141 WithinDistanceRefine distanceRefine(maxDist, &accWithinDistPairCons,
00142 &rejWithinDistPairCons);
00143
00144 ObjectPairRefineConsumer bbCons(BoundingBoxRefine::name(), &distanceRefine);
00145
00146 ObjectPairConsumer rejBBPairCons(BoundingBoxRefine::name() + " reject");
00147
00148 BoundingBoxRefine bbRefine(&bbCons, &rejBBPairCons);
00149
00150
00151 ObjectPairRefineConsumer pairCons(useNestedLoop ? NestedLoopFilter::name()
00152 : DecPlaneSweepFilter::name(),
00153 useBB ? (ObjectPairRefine*) &bbRefine
00154 : (ObjectPairRefine*) &distanceRefine);
00155
00156
00157 ObjectConsumer uaCons("A points reject");
00158 ObjectConsumer ubCons("B points reject");
00159
00160 ObjectProducer * aProd = FileProducerFactory::instance()->createProducer(
00161 aDir, aName, aBinary, aMerge, true, false);
00162 ObjectProducer * bProd = FileProducerFactory::instance()->createProducer(
00163 bDir, bName, bBinary, bMerge, true, false);
00164
00165 ActiveList * aList = (useIndex) ? (ActiveList *) new IndexedActiveList()
00166 : (ActiveList *) new SimpleActiveList();
00167 Matcher * matcher = new FixedRadiusCrossMatch(aProd, bProd, aList , &pairCons, &uaCons, &ubCons, maxDist);
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 }