retCode showMtdLbl(ioPo f, void *data, long depth, long precision, logical alt) { methodPo mtd = (methodPo) data; normalPo pool = codeLits(mtd); termPo lbl = nthArg(pool, 0); return outMsg(f, "%T", lbl); }
retCode mtdDisp(ioPo out, termPo t, integer precision, integer depth, logical alt) { methodPo mtd = C_MTD(t); normalPo pool = codeLits(mtd); if (pool != Null) { labelPo lbl = C_LBL(nthArg(pool, 0)); return showLbl(out, precision, alt, lbl); } else return outMsg(out, "<unknown mtd>"); }
termPo findPcLocation(methodPo mtd, integer pc) { normalPo lines = mtd->lines; integer start = 0; integer limit = termArity(lines)-1; integer lowerPc = -1; integer upperPc = mtdCodeSize(mtd); termPo lowerLoc = Null; termPo upperLoc = Null; while (limit >= start) { integer mid = start + (limit - start) / 2; normalPo midEntry = C_TERM(nthArg(lines, mid)); integer testPc = integerVal(nthArg(midEntry, 1)); termPo testLoc = nthArg(midEntry, 0); if (testPc == pc) return testLoc; else if (testPc < pc) { start = mid+1; if (testPc > lowerPc) { lowerPc = testPc; lowerLoc = testLoc; } } else { limit = mid-1; if (testPc < upperPc) { upperPc = testPc; upperLoc = testLoc; } } } if (lowerLoc != Null) return lowerLoc; else return upperLoc; }
int main (int argc, const char * argv[]) { try { TCLAP::CmdLine cmd("Keep every nth point, keep a specific percentage randomly or simply copy all points. Creates a .bounds file with the bounding box values.", ' ', "none", false); TCLAP::ValueArg<int> percentageArg("e","percentage","Keep percentage of the points randmonly",false,10,"int"); TCLAP::ValueArg<int> nthArg("n","nth","Keep every nth point",false,10,"int"); TCLAP::SwitchArg copyallSwitch("c","copy","Copy all points", false); std::vector<TCLAP::Arg*> copymodes; copymodes.push_back(&percentageArg); copymodes.push_back(&nthArg); copymodes.push_back(©allSwitch); cmd.xorAdd(copymodes); TCLAP::ValueArg<int> precArg("x","precision","Decimal precision in output file",false,2,"int",cmd); TCLAP::SwitchArg projectSwitch("p","project","Project x y values fron WGS84 to auto utm-zone", cmd, false); TCLAP::SwitchArg flipSignOnZSwitch("f","flip","flip the sign of z-values in output", cmd, false); TCLAP::SwitchArg flipXYSwitch("t","flipxy","Use if order in file is y-x-z or lat-long-z", cmd, false); TCLAP::UnlabeledValueArg<std::string> inputArg( "input", "path to .xyz file", true, "", "input file", cmd); TCLAP::UnlabeledValueArg<std::string> outputArg( "ouput", "path to .xyz file", true, "", "output file", cmd); cmd.parse(argc,argv); Filter f(inputArg.getValue().c_str(),outputArg.getValue().c_str(), projectSwitch.getValue(), flipSignOnZSwitch.getValue(), flipXYSwitch.getValue(), precArg.getValue()); if (percentageArg.isSet()) f.copy_percentage(percentageArg.getValue()); else if (nthArg.isSet()) f.copy_nth(nthArg.getValue()); else f.copy_all(); std::cout << "Written " << f.getLineCount() << " lines" << std::endl; } catch (TCLAP::ArgException &e) // catch any exceptions { std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; } return 0; }
static retCode showConstant(ioPo out, methodPo mtd, integer off) { return outMsg(out, " %,*T", displayDepth, nthArg(mtd->pool, off)); }
termPo getMtdLit(methodPo mtd, integer litNo) { return nthArg(codeLits(mtd), litNo); }