void InternalMergeBlocks( BLOCKTYPE * a_DstTypes, const BLOCKTYPE * a_SrcTypes, NIBBLETYPE * a_DstMetas, const NIBBLETYPE * a_SrcMetas, int a_SizeX, int a_SizeY, int a_SizeZ, int a_SrcOffX, int a_SrcOffY, int a_SrcOffZ, int a_DstOffX, int a_DstOffY, int a_DstOffZ, int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ, int a_DstSizeX, int a_DstSizeY, int a_DstSizeZ ) { UNUSED(a_SrcSizeY); UNUSED(a_DstSizeY); for (int y = 0; y < a_SizeY; y++) { int SrcBaseY = (y + a_SrcOffY) * a_SrcSizeX * a_SrcSizeZ; int DstBaseY = (y + a_DstOffY) * a_DstSizeX * a_DstSizeZ; for (int z = 0; z < a_SizeZ; z++) { int SrcBaseZ = SrcBaseY + (z + a_SrcOffZ) * a_SrcSizeX; int DstBaseZ = DstBaseY + (z + a_DstOffZ) * a_DstSizeX; int SrcIdx = SrcBaseZ + a_SrcOffX; int DstIdx = DstBaseZ + a_DstOffX; for (int x = 0; x < a_SizeX; x++) { if (MetasValid) { Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], a_DstMetas[DstIdx], a_SrcMetas[SrcIdx]); } else { BLOCKTYPE FakeDestMeta = 0; Combinator(a_DstTypes[DstIdx], a_SrcTypes[SrcIdx], FakeDestMeta, (NIBBLETYPE)0); } ++DstIdx; ++SrcIdx; } // for x } // for z } // for y }
int main(int argc, char **argv) { std::string dictionnary; std::string letterset; std::string wl; bool anagram = false; bool sortByLength = false; int i=1; while(i<argc) { if(strcmp(argv[i],"--d")==0) { if(i+1<argc) { dictionnary = argv[i+1]; i++; } else usage(); } else if(strcmp(argv[i],"--ls")==0) { if(i+1<argc) { letterset = argv[i+1]; i++; } else usage(); } else if(strcmp(argv[i],"--w")==0) { if(i+1<argc) { wl = argv[i+1]; i++; } else usage(); } else if(strcmp(argv[i],"-a")==0) { anagram = true; } else if(strcmp(argv[i],"-sl")==0) { sortByLength = true; } else { usage(); } i++; } if(dictionnary.empty() || (!wl.empty() && (!letterset.empty() || sortByLength || anagram ) ) || (wl.empty() && letterset.empty()) ) usage(); Dictionnary d = Dictionnary(dictionnary); Combinator c = Combinator(); c.setDictionnary(d); if(!wl.empty()) { std::vector<std::string> words = split(wl,','); std::cout << "-------------------------------------------------------------------------------" << std::endl; std::cout << "Test des mots suivants " << wl << std::endl; for(std::vector<std::string>::iterator it = words.begin(); it != words.end();++it) { if(d.isValid(*it)) std::cout << *it << " : OK " << std::endl; else std::cout << *it << " : KO " << std::endl; } std::cout << "-------------------------------------------------------------------------------" << std::endl; } else { c.setLetterSet(letterset); c.setAnagramMode(anagram); std::vector<std::string> res = c.giveMeWords(); std::cout << "-------------------------------------------------------------------------------" << std::endl; std::cout << "Avec le dictionnaire sélectionné, et les lettres " << c.getLetterSet() << std::endl; std::cout << "Il est possible de former les mots suivants :" << std::endl; if(sortByLength) std::sort(res.begin(), res.end(),sortFunction); else std::sort(res.begin(), res.end()); for(std::vector<std::string>::iterator it = res.begin(); it != res.end();++it) { std::cout << *it << std::endl; } std::cout << "-------------------------------------------------------------------------------" << std::endl; } return 0; }