From 4aa67d78e9238a65eb94a762328465e2541fd4c4 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Fri, 6 Nov 2015 13:45:57 +0100 Subject: Combine and sort results This change introduces (experimental and not very clean) combining of results. It might be worth writing a disjoint angle range class to get cleaner code here, as the while loops at the end are quite far from being beautiful. In addition the output ranges are sorted by their lower border. I'm using Lambda expressions for this, so C+11 is required. Also, this is currently completely untested. --- main.cpp | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 1620ff4..51e9506 100644 --- a/main.cpp +++ b/main.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include "anglerange.h" using namespace std; @@ -352,7 +353,7 @@ int main(int argc, char* argv[]) } } } - +/* cout << "Possible coincident lattice matches with px, qx:" << std::endl; for(i=0;i ranges; + ranges.reserve(xoverlaps.size()+yoverlaps.size()+1); + ranges.insert(ranges.end(),xoverlaps.begin(),xoverlaps.end()); + ranges.insert(ranges.end(),yoverlaps.begin(),yoverlaps.end()); + if(ranges.size()>1) //combining elements only makes sense, if there are at least 2 elements to combine... + { + bool stop; + do + { + i=0; + stop=false; + do + { + j=i+1; + do + { + anglerange tmp = ranges.at(i).combine(ranges.at(j)); + if(!(tmp.isempty())) + { + stop=true; + ranges.push_back(tmp); + ranges.erase(ranges.begin()+j); + ranges.erase(ranges.begin()+i); + } + j++; + } + while(!stop && j1) + { + bool stop; + do + { + i=0; + stop=false; + do + { + j=i+1; + do + { + anglerange tmp = commensurate.at(i).combine(commensurate.at(j)); + if(!(tmp.isempty())) + { + stop=true; + commensurate.push_back(tmp); + commensurate.erase(commensurate.begin()+j); + commensurate.erase(commensurate.begin()+i); + } + j++; + } + while(!stop && j