/* * Handle [FORMAT] item. * */ dodiform() { extern char bootstop; extern char bootend; int dev, v, i, br; int modesel; /* flag for mode select */ long cnt, hdsiz; char *s, *d, *wgetstr(); char bs[512], sendata[16]; char pnam[128]; char *seldev = "X", *id = "XXXXX"; HINFO hinfo; char devnames[NAMSIZ]; /* device type name buffer */ long nbad; extern long gbslsiz(), nument(), dsmarkbad(); long pattern, temp; long longrandom(); char pr_id[5]; /* partition scheme id */ /* * Throw up generic formatting/partition warning, * then get physical dev they want to clobber. */ yesscan = 0; fwarning[FWARNCN].ob_state = NORMAL; fwarning[FWARNOK].ob_state = NORMAL; if (execform(fwarning) != FWARNOK) return BAILOUT; if ((dev = gphysdev()) < 0) { return BAILOUT; } strcpy(id, "mn"); br = 0; inqfmt: /* Get all available disk types from wincap 'mn' entries */ wallents(devnames, id); /* Shove format name text into buttons */ for (i = 0, s = devnames; i < 15 && *s; ++i) { dsknames[pfmt[i]].ob_type = G_BUTTON; /* button */ dsknames[pfmt[i]].ob_spec = (long)s; dsknames[pfmt[i]].ob_state = NORMAL; dsknames[pfmt[i]].ob_flags = SELECTABLE | RBUTTON; while (*s++) ; } /* rest of buttons are invisible and untouchable */ for (; i < 15; ++i) { dsknames[pfmt[i]].ob_type = G_IBOX; /* invisible box */ dsknames[pfmt[i]].ob_spec = 0; /* no thickness */ dsknames[pfmt[i]].ob_state = DISABLED; /* nobody home */ dsknames[pfmt[i]].ob_flags = NONE; /* disabled */ } /* clean up rest of the form and throw it up */ dsknames[PFOK].ob_state = NORMAL; dsknames[PFCN].ob_state = NORMAL; if (execform(dsknames) != PFOK) return BAILOUT; /* search for format they picked */ for (i = 0; i < 15; ++i) if (dsknames[pfmt[i]].ob_state & SELECTED) break; if (i >= 15) { /* nothing picked */ return BAILOUT; } if (!br) { if (wgetent(dsknames[pfmt[i]].ob_spec, "mn") == ERROR) { nofmt[NOSCHFMT].ob_spec = dsknames[pfmt[i]].ob_spec; nofmt[NOSCHFMT].ob_state = NORMAL; execform(nofmt, 0); return ERROR; } if ((s = wgetstr("br")) != NULL) { strcpy(id, s); br = 1; /* processing the branch */ goto inqfmt; /* start over */ } } modesel = 1; if (gfparm(&modesel, &hinfo, dsknames[pfmt[i]].ob_spec, id) != 0) { return ERROR; } /* get data pattern to test the disk */ if (wgetnum("dp", &pattern) != OK) { pattern = longrandom(); /* can't find pattern from wincap, make one */ } else { temp = pattern; pattern <<= 16; /* shift pattern to hi word */ pattern |= temp; } /* * One last chance to bail out. */ *seldev = dev + '0'; (fmtfnl[FUNIT].ob_spec)->te_ptext = seldev; fmtfnl[FMTYES].ob_state = NORMAL; fmtfnl[FMTNO].ob_state = NORMAL; if (execform(fmtfnl) != FMTYES) return BAILOUT; /* For REAL !! */ dsplymsg(fmtmsg); bsl = 0L; /* Get size of Bad Sector List */ if ((bslsiz = gbslsiz(dev)) > 0L) { /* Allocate memory for existing BSL */ if ((bsl = (BYTE *)mymalloc((int)bslsiz*512)) <= 0) { ret = err(nomemory); goto formend; } /* Read in BSL */ if ((ret = rdbsl(dev)) != OK) { /* Create a new BSL if current one is unusable */ if (creabsl(dev, NEW, 0L) != OK) { ret = ERROR; goto formend; } } else { /* Remove USER BSL */ if (creabsl(dev, EXPAND, nument(VENDOR)) != OK) { ret = ERROR; goto formend; } } } else if (bslsiz == 0L || bslsiz == ERROR) { /* no bsl or read error */ if (creabsl(dev, NEW, 0L) != OK) { ret = ERROR; goto formend; } } else { /* bslsiz == MDMERR; medium changed error */ ret = ERROR; goto formend; } /* * In supervisor mode * set disk format parameters * and format the disk. */ ostack = Super(NULL); v = OK; /* assume everything is OK */ if (modesel) { /* normal mode select ? */ v = ms(dev, &hinfo); /* Yes, do noprmal mode set */ /* Find formatted capacity of drive */ hdsiz = (long)hinfo.hi_cc * (long)hinfo.hi_dhc * (long)hinfo.hi_spt; } else { /* No, do special mode set */ if ((v = md_sense(dev, sendata)) == OK) { hdsiz = get3bytes(sendata+5); v = sqms(dev, sendata); } } disksiz = hdsiz; delay(); /* kludge delay */ if (v == OK) v = doformat(dev, (UWORD)hinfo.hi_in); /* format */ delay(); /* kludge delay */ Super(ostack); if (v != 0) { ret = errcode(dev); if (tsterr(ret) != OK) formaterr(dev); ret = ERROR; goto formend; } ret = OK; rebootp = 1; formend: erasemsg(); /* Erase formatting box */ if (ret < 0) { if (bsl > 0) free(bsl); return ERROR; } /*------------------------------------------* * Markbad the device destructively. * * Bad Sectors found are added to the BSL. * * Write BSL to device. * *------------------------------------------*/ if ((nbad = dsmarkbad(dev, hdsiz, 1, pattern)) < 0) { free(bsl); return ERROR; } if (wrbsl(dev) != OK) { free(bsl); return ERROR; } free(bsl); /* * Install boot-stopper in sector image; * write root sector to device. * 6-13-88 Setting of soft format parameters in root sector sets * the hard disk size only. */ fillbuf(bs, 512L, 0L); /* create new root sector */ sbslparm(bs); /* set BSL parameters */ if (modesel) { sfmtparm(bs, &hinfo); } else { sdisksiz(bs, disksiz); } for (d = bs, s = &bootstop, cnt = (long)(&bootend - &bootstop); --cnt;) *d++ = *s++; Protobt(bs, -1L, -1, 1); /* make root sector executable */ if ((ret = putroot(dev, bs, (SECTOR)0)) != OK) { if (tsterr(ret) != OK) err(rootwrit); return ERROR; } /* * Make a copy of the default partition name. * Figure out the partition scheme id. */ if ((s = wgetstr("pt")) == NULL) s = DEF_PARTNAME; strcpy(pnam, s); figprid(disksiz, pr_id); dodipart(dev, pnam, pr_id); return OK; }
nsresult nsIconChannel::InitWithGIO(nsIMozIconURI *aIconURI) { nsresult rv; GIcon *icon = NULL; nsCOMPtr<nsIURL> fileURI; // Read icon content aIconURI->GetIconURL(getter_AddRefs(fileURI)); // Get icon for file specified by URI if (fileURI) { bool isFile; nsCAutoString spec; fileURI->GetAsciiSpec(spec); if (NS_SUCCEEDED(fileURI->SchemeIs("file", &isFile)) && isFile) { GFile *file = g_file_new_for_uri(spec.get()); GFileInfo *fileInfo = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_ICON, G_FILE_QUERY_INFO_NONE, NULL, NULL); g_object_unref(file); if (fileInfo) { // icon from g_content_type_get_icon doesn't need unref icon = g_file_info_get_icon(fileInfo); if (icon) g_object_ref(icon); g_object_unref(fileInfo); } } } // Try to get icon by using MIME type if (!icon) { nsCAutoString type; aIconURI->GetContentType(type); // Try to get MIME type from file extension by using nsIMIMEService if (type.IsEmpty()) { nsCOMPtr<nsIMIMEService> ms(do_GetService("@mozilla.org/mime;1")); if (ms) { nsCAutoString fileExt; aIconURI->GetFileExtension(fileExt); ms->GetTypeFromExtension(fileExt, type); } } char *ctype = NULL; // character representation of content type if (!type.IsEmpty()) { ctype = g_content_type_from_mime_type(type.get()); } if (ctype) { icon = g_content_type_get_icon(ctype); g_free(ctype); } } // Get default icon theme GtkIconTheme *iconTheme = gtk_icon_theme_get_default(); GtkIconInfo *iconInfo = NULL; // Get icon size PRInt32 iconSize = GetIconSize(aIconURI); if (icon) { NS_SUCCEEDED(rv); // Use icon and theme to get GtkIconInfo iconInfo = gtk_icon_theme_lookup_by_gicon(iconTheme, icon, iconSize, (GtkIconLookupFlags)0); g_object_unref(icon); } if (!iconInfo) { // Mozilla's mimetype lookup failed. Try the "unknown" icon. iconInfo = gtk_icon_theme_lookup_icon(iconTheme, "unknown", iconSize, (GtkIconLookupFlags)0); if (!iconInfo) { return NS_ERROR_NOT_AVAILABLE; } } // Create a GdkPixbuf buffer containing icon and scale it GdkPixbuf* buf = gtk_icon_info_load_icon(iconInfo, NULL); gtk_icon_info_free(iconInfo); if (!buf) { return NS_ERROR_UNEXPECTED; } rv = ScaleIconBuf(&buf, iconSize); NS_ENSURE_SUCCESS(rv, rv); rv = moz_gdk_pixbuf_to_channel(buf, aIconURI, getter_AddRefs(mRealChannel)); g_object_unref(buf); return rv; }
bool pass(std::chrono::time_point<std::chrono::system_clock>& last_, int millisecond_) { std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now(); std::chrono::milliseconds ms(millisecond_); std::chrono::duration<double, std::milli> d = now - last_; return (d>ms); }
FX_BOOL CXFA_Data::SetMeasure(XFA_ATTRIBUTE eAttr, FX_FLOAT fValue) { CXFA_Measurement ms(fValue, XFA_UNIT_Pt); return m_pNode->SetMeasure(eAttr, ms); }
/* main */ int main(int argc, char *argv[]) { std::ios_base::sync_with_stdio(false); // arguments: p1 p2 [y|(* \ {y})] [true|false] size_t p1 = argc > 2 ? fast_atoi(argv[1]) : 1; // default = 1 size_t p2 = argc > 2 ? fast_atoi(argv[2]) : 1; // default = 1 bool has_constraints = false; // if there are constraints if (argc > 3) has_constraints = strcmp(argv[3],"1") || strcmp(argv[3], "y"); /* if default_constraints_mode is true: * constraints in input mean ONLY THESE MATCH * otherwise: * constraints in input mean ALL EXCEPT THESE MATCH */ bool default_constraints_mode = false; // the semantic of the constraints //if (has_constraints) default_constraints_mode = strcmp(argv[4], "t"); /* (1) read strings, extract sigmas and constraints too */ std::string s1, s2; std::string sigma1(""), sigma2(""); read_stdin(s1, s2); extract_sigma(s1, sigma1); extract_sigma(s2, sigma2); size_t sigma1l = sigma1.size(); size_t sigma2l = sigma2.size(); size_t s1l = s1.size(); size_t s2l = s2.size(); std::vector<p_constr> constraints; if (has_constraints) read_constraints(constraints); /* define the mapping from char -> int */ std::map<char, int> map1; std::map<char, int> map2; define_mapping(sigma1, map1); define_mapping(sigma2, map2); /* integer representations of strings and sigmas */ unsigned* s1i = new unsigned[s1l]; unsigned* s2i = new unsigned[s2l]; unsigned* sigma1i = new unsigned[sigma1l]; unsigned* sigma2i = new unsigned[sigma2l]; for (size_t i = 0; i < sigma1l; ++i) sigma1i[i] = i; // sigma1 for (size_t i = 0; i < sigma2l; ++i) sigma2i[i] = i; // sigma2 for (size_t i = 0; i < s1l; ++i) s1i[i] = map1[s1[i]]; // s1 for (size_t i = 0; i < s2l; ++i) s2i[i] = map2[s2[i]]; // s2 if (_DEBUG) { std::cout << "strings: " << s1 << ", " << s2 << endl; std::cout << "sigmas: " << sigma1 << ", " << sigma2 << endl; std::cout << "int rep (s1): "; for (size_t i = 0; i < s1l; ++i) std::cout << s1i[i]; std::cout << endl; std::cout << "int rep (s2): "; for (size_t i = 0; i < s2l; ++i) std::cout << s2i[i]; std::cout << endl; std::cout << "int rep (sigma1): "; for (size_t i = 0; i < sigma1l; ++i) std::cout << sigma1i[i]; std::cout << endl; std::cout << "int rep (sigma2): "; for (size_t i = 0; i < sigma2l; ++i) std::cout << sigma2i[i]; std::cout << endl; } /* identity (classical) matching schema */ matching_schema<bool> ms(sigma1l, sigma2l, p1, p2, true, default_constraints_mode); ms.set_general(sigma1, sigma2, false); if (has_constraints) ms.set_constraints(map1, map2, constraints, !default_constraints_mode); if (_DEBUG) { if (has_constraints) { std::cout << "Constraints: "; for(std::vector<p_constr>::size_type i = 0; i < constraints.size(); ++i) std::cout << constraints[i].first << ", " << constraints[i].second << endl; } ms.print_matching_schema(sigma1, sigma2); } //int d = bruteforce(s1i, s2i, s1l, s2l, sigma1i, sigma2i, sigma1l, sigma2l, ms); int d = hill_climbing(s1i, s2i, s1l, s2l, sigma1i, sigma2i, sigma1l, sigma2l, p1, ms); std::cout << d << endl; //Alignment<int> a = compute_alignment(s1i, s2i, s1l, s2l, ms); //std::cout << distance_from_alignment(a, sigma1, sigma2, ms, false) << endl; return 0; }
void ForestDetector::detect(cv::Mat& image, std::string imageName)//deuxième paramètre peut-être à supprimer { cv::namedWindow("lol"); cv::namedWindow("detection"); cv::namedWindow("hough"); cv::Mat integral; cv::cvtColor(image, integral, CV_RGB2GRAY);//Convert image to grayscale image cv::integral(integral, integral); int height = image.size().height; int width = image.size().width; unsigned int patchWidth = _pForestEnv->getPatchWidth(); unsigned int patchHeight = _pForestEnv->getPatchHeight(); float currentMax=0; double pas=2; //std::vector<Patch*> vecPatch(nbPatch); cv::Mat result = cv::Mat::zeros(image.size().height/pas, image.size().width/pas, CV_32F); cv::Mat angle = cv::Mat::zeros(image.size().height/pas, image.size().width/pas, CV_64F); std::vector<cv::Point_<int> > offsetMeans; std::vector<cv::Point_<double> > offsetVar; std::vector<int> nbPatchs; cv::Mat imRoi, imIntRoi; double roll=0; double meanRoll=0; std::vector<Leaf*> detectionVotes; std::vector<cv::Mat> detectionMeans; for (int x=0 ; x < width-patchWidth ; x+=pas)//cols { for (int y=0 ; y < height-patchHeight ; y+=pas)//rows { cv::Rect_<int> roi(x, y, patchWidth, patchHeight); cv::Rect_<int> roiInt(x, y, patchWidth+1, patchHeight+1); //patch cv::Mat meanSV; std::vector<cv::Mat> patchs; double conf=0; image(roi).copyTo(imRoi); integral(roiInt).copyTo(imIntRoi); //patchs.push_back(image(roi).clone()); //patchs.push_back(integral(roiInt).clone()); patchs.push_back(imRoi); patchs.push_back(imIntRoi); Patch patch(patchs, roi); std::vector<Leaf*> detectedLeaf; pForest->regression(patch, detectedLeaf); double test=0; double denom=0; for (int i=0 ; i<detectedLeaf.size() ; i++) { offsetMeans.push_back(detectedLeaf[i]->getMeanOffsets()); offsetVar.push_back(detectedLeaf[i]->getVarOffsets()); nbPatchs.push_back(detectedLeaf[i]->getNumberPatchs()); meanSV = detectedLeaf[i]->getSVMean().clone(); conf = detectedLeaf[i]->getConf(); //std::cout << offsetMeans.back() << " " << offsetVar.back() << " " << nbPatchs.back() << std::endl; cv::Point_<int> offset(-offsetMeans.back().x+patchWidth/2+x, -offsetMeans.back().y+patchHeight/2+y); if (offset.x >= 0 && offset.x < width && offset.y >= 0 && offset.y < height) { offset.x = offset.x/pas; offset.y = offset.y/pas; //if ((offsetVar.back().x <= 200) && (offsetVar.back().y <= 200)) if ((conf == 1) && (detectedLeaf[i]->getTrace() < 500)) { //result.at<float>(offset) += 1.*float(1./(sqrt(offsetVar.back().x*offsetVar.back().x+offsetVar.back().y*offsetVar.back().y))); detectionVotes.push_back(detectedLeaf[i]); detectionMeans.push_back(detectedLeaf[i]->getSVMean().clone()); detectionMeans.back().at<double>(0) = offset.x; detectionMeans.back().at<double>(1) = offset.y; result.at<float>(offset) += conf; //result.at<float>(offset) += detectedLeaf[i]->getNumberPatchs(); //result.at<float>(offset) += 1.*float(nbPatchs.back()/sqrt(offsetVar.back().x*offsetVar.back().y)); //result.at<float>(offset) += 1.*float(nbPatchs.back()/sqrt(offsetVar.back().x*offsetVar.back().x+offsetVar.back().y*offsetVar.back().y)); //roll += meanSV.at<double>(6)*conf; denom+=conf; test+=conf*meanSV.at<double>(4); //std::cout << "cooooooooonf : " << test*20 << std::endl; angle.at<double>(y/pas, x/pas) = test/denom; //if (test > maxAngle) maxAngle = test; //if (test < minAngle) minAngle = test; //meanRoll += conf; } else { angle.at<double>(y/pas, x/pas) = -100; } if (result.at<float>(offset) > currentMax) currentMax=result.at<float>(offset); } } } } if (detectionMeans.size()==0) std::cout << "no detection" << std::endl; MeanShift ms(detectionMeans); cv::Mat mean; ms.getMaxCluster(detectionMeans, mean); //cv::Mat imageToSave = result/currentMax; //cv::imwrite("../output/"+imageName, result); //std::cout << result.depth() << std::endl; //std::cout << result.size().height << " " << result.size().width << std::endl; result=result/currentMax*255; result.convertTo(result, CV_8U); //std::cout << "angle : " << angle << std::endl; angle=(angle+22)/45*255; angle.convertTo(angle, CV_8U); cv::applyColorMap(angle, angle, cv::COLORMAP_JET); cv::imshow("hough", angle); //cv::Rect rect(result.cols/2-50, result.rows/2-50, 50, 50); /*cv::RotatedRect rotatedRect(cv::Point2f(result.cols/pas-50/pas, result.rows/pas), cv::Size2f(50/pas, 50/pas), 0); for (int i=0 ; i<2 ; i++) { cv::Rect rect = rotatedRect.boundingRect(); rotatedRect = cv::CamShift(result, rect, cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 10, 1)); }*/ cv::RotatedRect rotatedRect(cv::Point2f(mean.at<double>(0), mean.at<double>(1)), cv::Size2f(128/pas, 128/pas), 0); std::cout << mean.at<double>(3) << " " << mean.at<double>(4) << " " << mean.at<double>(5) << std::endl; cv::Mat imageToSave=result.clone(); cv::ellipse(imageToSave, rotatedRect, cv::Scalar_<int>(0,255,0), 2); rotatedRect.center = rotatedRect.center*pas; rotatedRect.size.height = rotatedRect.size.height*pas; rotatedRect.size.width = rotatedRect.size.width*pas; rotatedRect.angle = roll/meanRoll; //cv::rectangle(image, rotatedRect.boundingRect(), cv::Scalar_<int>(125,255,125), 2); cv::ellipse(image, rotatedRect, cv::Scalar_<int>(125,255,125), 2); cv::applyColorMap(imageToSave, imageToSave, cv::COLORMAP_JET); cv::imwrite("../output/"+imageName, angle); cv::imshow("detection", image); cv::imshow("lol", imageToSave); cv::waitKey(5000); }
// // Time.cpp // helloGL // // Created by tomato on 10/9/13. // Copyright (c) 2013 tomato. All rights reserved. // #include "Time.h" tp_hd Time::time; double Time::dT; tp_hd Time::game_epoch; const tp_hd Time::END_OF_TIME = tp_hd() + ms(600000000); const ms Time::UNTIL_END = ms(600000000);
void MemStreamTest::RunTests() { // ------------------------------------------------------- // Test input stream // ------------------------------------------------------- { std::string test("hi there"); IMemStream ms((char*)(test.data()), test.size()); std::stringstream ss(test); for (int i=0; i<5; i++) { std::string s1, s2; ms >> s1; ss >> s2; TESTEQUAL2("in", s2, s1); TESTEQUAL2("in fail", ss.fail(), ms.fail()); TESTEQUAL2("in eof", ss.eof(), ms.eof()); } // Test changing the buffer std::string test2("bye now"); ms.str((char*)(test2.data()), test2.size()); ms.seekg(0); ms.clear(); std::stringstream ss2(test2); for (int i=0; i<5; i++) { std::string s1, s2; ms >> s1; ss2 >> s2; TESTEQUAL2("in2", s2, s1); TESTEQUAL2("in2 fail", ss2.fail(), ms.fail()); TESTEQUAL2("in2 eof", ss2.eof(), ms.eof()); } } // ------------------------------------------------------- // Test setting the buffer on a default input stream // ------------------------------------------------------- { std::string test("third test"); IMemStream ms; ms.str((char*)(test.data()), test.size()); std::stringstream ss(test); for (int i=0; i<5; i++) { std::string s1, s2; ms >> s1; ss >> s2; TESTEQUAL2("in2", s2, s1); TESTEQUAL2("in2 fail", ss.fail(), ms.fail()); TESTEQUAL2("in2 eof", ss.eof(), ms.eof()); } } // ------------------------------------------------------- // Test output stream // ------------------------------------------------------- { OMemStream ms; std::stringstream ss; for (int i=0; i<500; i++) { ms << i << " "; ss << i << " "; } const char* dataP = ms.str(); size_t size = ms.pcount(); std::string msStr(dataP, size); std::string ssStr = ss.str(); TESTEQUAL2("out data", msStr, ssStr); TESTEQUAL2("out eof", ms.eof(), ss.eof()); TESTEQUAL2("out fail", ms.fail(), ss.fail()); } // ------------------------------------------------------- // Test memory limits // ------------------------------------------------------- // Set max at 0x10000000 for day to day testing so that test doesn't take too long. // To determine the actual memory limits, change this max to something very large and // see where we break. size_t max = 0x10000000L; size_t sizeLimit = memLimitsTest(max); TESTEQUAL2("maximum stream size", sizeLimit >= max, true); }
int read_multiplet_data(int lineno, char filename[], opt* opts, vector<string> *listname, vector<metab_template> *Tems, vector<double> *x, char chemshift[], int s, char inputdir[]) // read in metabolite multiplet data, note at present this assumes the file // is ordered in groups corresponding to different metabolites { vector<string> names(lineno);// name characters the first line matrix c1(lineno); matrix c2(lineno); matrix c3(lineno); matrix c4(lineno); matrix c5(lineno); //matrix c6(lineno); matrix c7(lineno); matrixI c8(lineno); // for ph vector<string> names2(lineno); matrix c11(lineno); matrix c12(lineno); int count = 0; double pst, ped; int nl = read_datf(&names,&c1, &c2, &c3, &c4, &c5, &c7, &c8, filename); if (nl < 0) { return nl; } if ((*opts).usechemshift == 1) { int nl2 = read_dat_chemshift(&names2, &c11,&c12, chemshift, s); if (nl2 < 0) { return nl2; } if (nl != nl2) { printf("Different number of multiplets, exiting ...\n"); system("PAUSE"); exit(1); //return -999; } for (unsigned int j = 0; j < nl2; j++) { if (!((c12[j][0]+50)<0.0000001)) { // if(names[j].compare(names2[j]) == 0 && c11[j][0] == c1[j][0]) //{ c1[j][0] = c12[j][0]; //}else{ // printf("something wrong with multi chemshift, exiting ...\n"); // system("PAUSE"); // exit(1); //} } } } char prevname[80]=" "; char name[80] = {'\0'}; char lis[80] = {'\0'}; metab_template templa("",(*x).size()); for (unsigned int i = 0; i < (*listname).size(); i++) { strcpy(lis,(*listname)[i].c_str()); for (int it = 0; it < nl; it++) { strcpy(name,names[it].c_str()); if (!strcmp(lis,name) && c8[it][0]==1) // find a match in the list { if (!strcmp(prevname, " ")&& c8[it][0]==1)//first prevname do not match prevname { metab_template templa1(name,(*x).size()); templa = templa1; } if (strcmp(prevname,name) && strcmp(prevname, " ") && c8[it][0]==1) // make a new template { metab_template templa1(name,(*x).size()); templa = templa1; } strcpy(prevname,name); for (unsigned int n2 = 0; n2<(*opts).st.size(); n2++) { if ((*opts).st[n2]>(*opts).ed[n2]) { pst = (*opts).ed[n2]; ped = (*opts).st[n2]; } else { ped = (*opts).ed[n2]; pst = (*opts).st[n2]; } if ((c5[it][0]+50)<0.0000001) { if (!((c7[it][0]+50)<0.0000001)) { if (c1[it][0]<ped+(15.0*(*opts).log_fwhh_prop_var)+c7[it][0] && c1[it][0]>pst-(15.0*(*opts).log_fwhh_prop_var)-c7[it][0]) { count = 1; } } else { if (c1[it][0]<ped+(15.0*(*opts).log_fwhh_prop_var)+(*opts).rdelta && c1[it][0]>pst-(15.0*(*opts).log_fwhh_prop_var)-(*opts).rdelta) { count = 1; } } } else { if (!((c7[it][0]+50)<0.0000001)) { if (c5[it][0]<ped+(15.0*(*opts).log_fwhh_prop_var)+c7[it][0] && c5[it][0]>pst-(15.0*(*opts).log_fwhh_prop_var)-c7[it][0]) { count = 1; } } else { if (c5[it][0]<ped+(15.0*(*opts).log_fwhh_prop_var)+(*opts).rdelta && c5[it][0]>pst-(15.0*(*opts).log_fwhh_prop_var)-(*opts).rdelta) { count = 1; } } } } if (count == 1) { if((c2[it][0]+1 <0.0000001) && (c2[it][0]+1 > -0.0000001)) { if (c3[it].size()!=c4[it].size()) { cout<<"\nNo. of protons do not match no. of J constant for metabolite "<<names[it]<<", exiting ...\n"; //system("PAUSE"); exit(1); } double prot=0; for(unsigned int locit=0;locit<c4[it].size();locit++) prot+=c4[it][locit]; vector<double> weights(c4[it]); for(unsigned int locit=0;locit<c4[it].size();locit++) weights[locit]/=prot; //multiplet_site ms(prot, c1[it][0]); multiplet_site ms(&c2[it], c1[it][0], &c3[it], prot, x, c5[it][0],-50, c7[it][0], opts); // vector<unsigned int> c2int(c2[it].size(),0); //vecftoi(c2[it], c2int); ms.setup_param_extra(c3[it],weights); templa.add_multiplet(ms); } else if ((c2[it][0]+2 <0.0000001) && (c2[it][0]+2 > -0.0000001)) { //multiplet_site new_mult2(&pos_vec,&nprot_vec, &x); //cout << "c2 "<<c2[it][0] << endl; vector<double> raster(0.0); double vec_el; multiplet_site ms(&c2[it], c1[it][0], &c3[it], c4[it][0], x, c5[it][0], -50, c7[it][0], opts); if (c3[it].size() == 2) { // raster //printf("find input raster\n"); raster.clear(); char fdirR[3000]={'\0'}; strcpy(fdirR,inputdir); strcat(fdirR,name); strcat(fdirR,".txt"); ifstream inA3_str(fdirR); //cout<<"route "<< fdirR<<endl; //cout<<"file is "<< inA3_str<< endl; //if (!inA3_str) //cout<<"empty, no file "<< inA3_str<< endl; //int tst = 1; int tst2 = 0; while(inA3_str.good()) { tst2 = tst2 +1; inA3_str>>vec_el; //cout<<"vec_el ppm "<<vec_el<<",tst2 " <<tst2<<endl; inA3_str.ignore(1); inA3_str.peek(); if (tst2%2 != 0) { //cout<<"tst2 " <<tst2<<endl; if(vec_el<=max(c3[it][1],c3[it][0]) && vec_el>=min(c3[it][1],c3[it][0])) { inA3_str>>vec_el; raster.push_back(vec_el); tst2 = tst2 +1; } } } /*cout<<"tst = " <<tst<<endl; cout<<"raster1 = "<< raster[0]<<"rasterE = "<<raster[raster.size()-1]<<endl; //cout << "c3 "<<c3[it].size()<<endl; //for (int ii = 0; ii <raster.size(); ii++) //cout<<"raster "<< raster[ii] << " "; FILE *outM; outM = fopen("raster.txt","w"); // wirte to file the metabolites in range for anaylsis for (unsigned int cv = 0; cv <raster.size(); cv++) { fprintf(outM, "%f",raster[cv]); if (cv <=(raster.size()-1)) { fprintf(outM, "\n"); } } fclose(outM);*/ ms.raster_setup(abs(c3[it][1]-c3[it][0]), &raster); } else { printf("Wrong ppm ranges for raster (-2) in J_constant, exiting ...\n"); system("PAUSE"); exit(1); } templa.add_multiplet(ms); } else {
void mbhelp_t::dohelp (char *subject) //************************************************************************* // //************************************************************************* { unsigned int i = 0; long seekpos = 0; int helpall = ! stricmp(subject, "ALL"); int found = 0; char idx[20]; char *subsubject = strchr(subject, ' '); char *mlink = NULL; char *sublink = NULL; char linkstr[40]; char sublinkstr[40]; int linkcnt = 0; char oldsubject[60]; strcpy(linkstr, ""); strcpy(sublinkstr, ""); strcpy(oldsubject, ""); strcpy(idx, "INDEX"); helpf = NULL; idxf = NULL; if (! subsubject) subsubject = strchr(subject, '.'); if (subsubject) *subsubject++ = 0; if (! *subject) subject = "HELP"; if (! helpopen(ms(m_helpext))) { if (! helpopen("GB")) { if (! helpopen("DL")) { putf(ms(m_nohelp)); trace(serious, "dohelp", ms(m_nohelp)); return; } } } if (strstr(idx, subject) == idx) { putf(ms(m_helpkeywords)); while (fscanf(idxf, "%s %ld", inbuf, &seekpos) == 2) { subst1(inbuf, '=', 0); if (! subsubject || strstr(inbuf, subsubject) == inbuf) { #ifdef __FLAT__ if (! strcmp(b->uplink, "HTTP")) html_putf("<a href=\"/cmd?cmd=h+%s\">%-19s</a>", inbuf, inbuf); else #endif putf("%-19s", inbuf); i++; if (! (i % 4)) putv(LF); else putv(' '); } } putv(LF); } else { while (fscanf(idxf, "%s %ld\n", inbuf, &seekpos) == 2) { if (strstr(inbuf, subject) == inbuf || helpall) { if (subsubject && ! helpall) { char *dot = strchr(inbuf, '.'); if (dot) { dot++; if (strstr(dot, subsubject) != dot) continue; } else continue; } mlink = strchr(inbuf, '='); if (mlink) { if (helpall) continue; *mlink = 0; mlink++; strcpy(linkstr, mlink); sublink = strchr(linkstr, '.'); sprintf(oldsubject, "%s -> ", inbuf); if (sublink) { *sublink = 0; strcpy(sublinkstr, sublink + 1); subsubject = sublinkstr; } else subsubject = NULL; subject = linkstr; rewind(idxf); fgets(inbuf, LINELEN, idxf); // skip first line containing filetime if (++linkcnt > 10) { trace(serious, "help", "cyclic link %s.%s", subject, subsubject); break; } continue; } found++; subst1(inbuf, '.', ' '); subst1(oldsubject, '.', ' '); putv(LF); charstr(strlen(inbuf) + 6 + strlen(oldsubject), ':'); putf(":: %s%s ::", oldsubject, inbuf); putv(LF); charstr(strlen(inbuf) + 6 + strlen(oldsubject), ':'); fseek(helpf, seekpos, SEEK_SET); while (fgets(inbuf, LINELEN, helpf)) { if (*inbuf == '\\' && inbuf[1] == '\\') break; putf("%s", inbuf); if (b->abbruch) break; } if (! helpall) break; } if (b->abbruch) break; } //testabbruch(); if (! found) putf(ms(m_helpnotfound), subject, subsubject ? subsubject : "*"); } }
void wmain(int argc, WCHAR* argv[]) { ms(ps(argv[1])); }
unsigned long TimeSync::s() { return ms() / 1000; }
// TODO: Static method? boolean TimeSync::synchronize(Socket *socket, socket_addr_t target, msg_hdr_t *msg_hdr) { if (msg_hdr == NULL) { /* This was called to synchronize the times to a remote address */ if (state != STATE_IDLE) { // XXX: What should we do if a sync was already pending? For now // just continue as if it weren't } /* Begin the synchronization process */ DEBUG3_VALUELN("SYNC to:", target); sendSyncMsg(socket, target, TIMESYNC_SYNC); state = STATE_AWAITING_ACK; } else { if (msg_hdr->type != MSG_TYPE_TIMESYNC) { // TODO: What to do here? goto EXIT; } unsigned long now = millis(); msg_time_sync_t *msg_time = (msg_time_sync_t *)(msg_hdr + 1); socket_addr_t source = socket->sourceFromData(msg_hdr); switch (msg_time->sync_phase) { case TIMESYNC_CHECK: { DEBUG3_COMMAND(unsigned long local_now = ms(); DEBUG3_VALUE("CHECK from:", source); DEBUG3_VALUE(" ts:", msg_time->timestamp); DEBUG3_VALUE(" ms:", local_now); DEBUG3_VALUE(" diff:", (long)(msg_time->timestamp + latency - local_now)); ); sendSyncMsg(socket, source, TIMESYNC_ACK, latency); break; } case TIMESYNC_SYNC: { switch (state) { case STATE_IDLE: case STATE_SYNCED: { // Record the timestamp to compute the latency DEBUG3_VALUE("SYNC from:", source); latency = now; // Reply with ack sendSyncMsg(socket, source, TIMESYNC_ACK); state = STATE_AWAITING_SET; break; } } break; } case TIMESYNC_RESYNC: { if (state == STATE_SYNCED) { delta = (msg_time->timestamp + latency) - now; DEBUG3_VALUE("RESYNC from:", source); DEBUG3_VALUE(" delta:", delta); } break; } case TIMESYNC_ACK: { // TODO: Check if this is a response to the message we sent DEBUG3_VALUE("ACK from:", source); if (state == STATE_AWAITING_ACK) { // Send TIMESYNC_SET sendSyncMsg(socket, source, TIMESYNC_SET); state = STATE_IDLE; } else { DEBUG3_COMMAND(unsigned long local_now = ms(); DEBUG3_VALUE(" ts:", msg_time->timestamp); DEBUG3_VALUE(" ms:", local_now); DEBUG3_VALUE(" diff:", (long)(local_now - msg_time->timestamp)); ); } break; } case TIMESYNC_SET: { if (state == STATE_AWAITING_SET) { /* * Set the latecy to 1/2 the time between sending the ack and receiving * this message, and then use that latecy to compute the delta from * the sender's time. */ DEBUG3_VALUE("SET from:", source); DEBUG3_VALUE(" ts:", msg_time->timestamp); latency = (now - latency) / 2; delta = (msg_time->timestamp + latency) - now; state = STATE_SYNCED; DEBUG3_VALUE(" lat:", latency); DEBUG3_VALUE(" delta:", delta); } break; } }
int main() { try { symbol k("k"),q("q"),p("p"),p1("p1"),p2("p2"),p3("p3"),ms("ms"),l("l"),s("s"),m1s("m1s"),m2s("m2s"),m3s("m3s"); symbol l1("l1"),l2("l2"),l3("l3"),l4("l4"),t("t"),p4("p4"),p5("p5"),tp("tp"),v1("v1"),v2("v2"),l5("l5"); symbol k1("k1"),k2("k2"),k3("k3"),k4("k4"),k5("k5"),ms1("ms1"),ms2("ms2"),ms3("ms3"),ms4("ms4"); // oneloop box // UFXmap l45 = UF(lst(k),lst(pow(k,2),pow(k+p1,2),pow(k+p1+p2,2),pow(k+p1+p2+p3,2)),lst(pow(p1,2)==0,pow(p2,2)==0)); // MBintegral root_int(l45,lst(1,1,1,1),1); //two loop box bubble // UFXmap l45 = UF(lst(k,l),lst(pow(k,2),pow(k+p1,2),pow(k+p1+p2,2),pow(l+p1+p2,2),pow(l+p1+p2+p3,2),pow(l,2),pow(k-l,2)),lst(pow(p1,2)==0,pow(p2,2)==0,pow(p3,2)==0)); //MBintegral root_int(l45,lst(1,1,1,1,1,1,1),2); // B0 // UFXmap l45 = UF(lst(k),lst(ms-pow(k,2),ms-pow(-k,2)),lst(ms==1)); // MBintegral root_int(l45,lst(1,1),1); // 2 loop sunrise //UFXmap l45 = UF(lst(k,q),lst(ms-pow(k,2),ms-pow(-q-k,2),ms-pow(q,2)),lst(ms==1)); //MBintegral root_int(l45,lst(1,1,1),2); //RoMB_planar box2loop(lst(k,l),lst(pow(k,2),pow(k+p1,2),pow(k+p1+p2,2),pow(l+p1+p2,2),pow(l+p1+p2+p3,2),pow(l,2),pow(k-l,2)),lst(pow(p1,2)==0,pow(p2,2)==0,pow(p3,2)==0),lst(1,1,1,1,1,1,1),2); // RoMB_planar box1loop(lst(k),lst(pow(k,2),pow(k+p1,2)-ms,pow(k+p1+p2,2),pow(k+p1+p2+p3,2)),lst(pow(p1,2)==0,pow(p2,2)==0,pow(p3,2)==0,p1==0,p2==0,p3==0,ms==1),lst(1,1,1,1),1); // RoMB_planar B0_1loop(lst(k),lst(pow(k,2)-ms,pow(p+k,2)-ms),lst(ms==0,pow(p,2)==1),lst(1,1),1); // RoMB_planar C0_1loop(lst(k),lst(pow(k,2)-ms,pow(p1+k,2)-ms,pow(p1+p2+k,2)),lst(ms==1,pow(p1,2)==0,pow(p2,2)==0,p1*p2==50),lst(1,1,1),1); //cout<<" new point "<<endl<<root_int.new_point()<<endl; // cout<<" saved point "<<endl<<root_int.get_point()<<endl; // MBcontinue(root_int); //cout<<MB_lst(l45,lst(1,1,1,1),1).expand()<<endl; // RoMB_loop_by_loop box2loop(lst(k,l),lst(pow(k,2),pow(k+p1,2),pow(k+p1+p2,2),pow(l+p1+p2,2),pow(l+p1+p2+p3,2),pow(l,2),pow(k-l,2)),lst(pow(p1,2)==0,pow(p2,2)==0,pow(p3,2)==0),lst(1,1,1,1,1,1,1)); // RoMB_loop_by_loop t2(lst(k,l), lst(pow(k,2),pow(p+k,2),pow(p+k+l,2),pow(l,2),pow(k+l,2)),lst(pow(p,2)==1),lst(1,1,1,1,1)); // works!!! // RoMB_loop_by_loop sunset(lst(k,l), lst(pow(k,2)-1,pow(p-k-l,2)-4,pow(l,2)-5),lst(pow(p,2)==s),lst(1,1,1)); // RoMB_loop_by_loop sunset(lst(k,l), lst(pow(k,2)-m1s,pow(-k-l,2)-m2s,pow(l,2)-m3s),lst(pow(p,2)==s),lst(1,1,1)); // sunset.integrate(lst(m1s==1,m2s==1,m3s==1,s==0),0); // bubble sunset 2=loop // RoMB_loop_by_loop sunset_bub(lst(k,l), lst(-pow(k,2)+ms,-pow(-k-l,2)+ms,-pow(l,2)+ms),lst(pow(p,2)==0),lst(1,1,1)); // sunset_bub.integrate(lst(ms==1,m2s==1,m3s==1,s==0),1); // bubble sunset 3=loop // RoMB_loop_by_loop sunset_bub(lst(p,k,l), lst(-pow(p,2)+ms,-pow(k,2)+ms,-pow(l,2)+ms,-pow(-p-k-l,2)+ms),lst(pow(l3,2)==s),lst(1,1,1,1)); // sunset_bub.integrate(lst(ms==1,m2s==1,m3s==1,s==0),0); // RoMB_loop_by_loop sunset_bub_d(lst(l1,l2,l3), lst(-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l3,2)+ms,-pow(l1+l2,2)+ms,-pow(l1+l2+l3,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1)); // sunset_bub_d.integrate(lst(ms==1,m2s==1,m3s==1,s==0),-1); // RoMB_loop_by_loop sunset_bub_e(lst(l1,l2,l3), lst(-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l3,2)+ms,-pow(l1-l2,2)+ms,-pow(l2-l3,2)+ms,-pow(l3-l1,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1,1)); // sunset_bub_e.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),1); //bubble 4-loop // RoMB_loop_by_loop sunset_bub(lst(k,l1,l2,l3), lst(-pow(k,2)+ms,-pow(l2,2)+ms,-pow(l1,2)+ms,-pow(l3,2)+ms,-pow(k+l1+l2+l3,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1)); // sunset_bub.integrate(lst(ms==1,m2s==1,m3s==1,s==0),0); //bubble 5-loop // RoMB_loop_by_loop sunset_bub5(lst(l3,k,l1,l2,l4), lst(-pow(l3,2)+ms,-pow(k,2)+ms,-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l4,2)+ms,-pow(k+l1+l2+l3+l4,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1,1)); // sunset_bub5.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),3); // RoMB_loop_by_loop sunset_bubC2(lst(l1,l2,l3,l4,l5), lst(-pow(l3,2)+ms,-pow(l5,2)+ms,-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l4,2)+ms,-pow(l5+l1+l2,2)+ms,-pow(l5+l3+l4,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1,1,1)); // sunset_bubC2.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),0); // RoMB_loop_by_loop sunset_bubC2(lst(l1,l2,l3,l4,l5), lst(-pow(l3,2)+ms,-pow(l5,2)+ms,-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l4,2)+ms,-pow(l3+l4+l5,2)+ms,-pow(l1+l2+l5+l3+l4,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1,1,1)); // sunset_bubC2.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),0); // RoMB_loop_by_loop sunset_bubC1(lst(l1,l2,l3,l4,l5), lst(-pow(l3,2)+ms,-pow(l5,2)+ms,-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l4,2)+ms,-pow(l2+l3+l4+l5,2)+ms,-pow(l1+l2+l5+l3+l4,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1,1,1)); // sunset_bubC1.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),0); /* MEGA 5-LOOP BUBBLE with 12 propagators */ //RoMB_loop_by_loop l5p12(lst(k5,k2,k1,k4,k3),lst(-pow(k1,2)+ms,-pow(k2,2)+ms,-pow(k3,2)+ms,-pow(k4,2)+ms,-pow(k5,2)+ms, //-pow(k1-k3,2)+ms,-pow(k1-k4,2)+ms,-pow(k3-k2,2)+ms,-pow(k2-k4,2)+ms,-pow(k5+k3-k1,2)+ms,-pow(k5+k3-k2,2)+ms,-pow(k5+k3-k4,2)+ms),lst(pow(p,2)==0),lst(1,1,1,1,1,1,1,1,1,1,1,1)); //l5p12.integrate(lst(ms==0),0); //RoMB_loop_by_loop l5c1(lst(k2,k5,k3,k4,k1),lst(-pow(k3,2)+ms,-pow(k2,2)+ms,-pow(k1,2)+ms,-pow(k4,2)+ms,-pow(k5,2)+ms, //-pow(k1+k3+k4,2)+ms,-pow(k2+k5-k3-k4,2)+ms),lst(pow(p,2)==0),lst(1,1,1,1,1,1,1)); //l5c1.integrate_map(lst(ms==1),0); // RoMB_loop_by_loop t2loop(lst(k,l), lst(-pow(k,2)+ms,-pow(p+k,2)+ms,-pow(p+k+l,2)+ms,-pow(k+l,2)+ms,-pow(l,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1)); // t2loop.integrate(lst(s==1,ms == 0),1); /* RoMB_loop_by_loop bubble_five_loop(lst(k,l1,l2,l3,l4), lst(pow(k,2)-ms,pow(l1,2)-ms,pow(l2,2)-ms,pow(l3,2)-ms,pow(l4,2)-ms,pow(k+l1,2)-ms,pow(k+l1+l2,2)-ms,pow(k+l1+l2+l3,2)-ms,pow(k+l1+l2+l3+l4,2)-ms,pow(k+l1+l2+l3,2)-ms,pow(k+l1+l2,2)-ms,pow(k+l1,2)-ms), lst(ms==1), lst(1,1,1,1,1,1,1,1,1,1,1,1)); */ // works!!! // RoMB_loop_by_loop B0_1loop_lbl(lst(k),lst(pow(k,2)-2-ms,pow(p+k,2)-ms),lst(ms==0,pow(p,2)==1),lst(2,1)); // RoMB_loop_by_loop B0_1loop_lbl(lst(k),lst(pow(k,2)-m1s,pow(p+k,2)-m2s),lst(pow(p,2)==s),lst(1,1)); // B0_1loop_lbl.integrate(lst(s==-1,m1s==1,m2s==1)); //MB works??? // RoMB_loop_by_loop C0_1loop_lbl(lst(k),lst(pow(k,2),pow(k+p1,2)-m1s,pow(k-p2,2)-m2s),lst(ms==1,pow(p1,2)==m1s,pow(p2,2)==m2s,p1*p2==(s-m1s-m2s)/2),lst(1,1,1)); // C0_1loop_lbl.integrate(lst(m1s==1,m2s==1,s==-100)); //MB works??? /* RoMB_loop_by_loop box1loopm0(lst(k),lst(-pow(k,2),-pow(k+p1,2),-pow(k+p1+p2,2),-pow(k+p1+p2+p4,2)), lst(pow(p1,2)==0,pow(p2,2)==0,pow(p4,2)==0, p1*p2==-s/2,// p1*p4==s/2+t/2,// p2*p4==-t/2 // ), lst(1,1,1,1),false); box1loopm0.integrate_map(lst(s==3,t==1)); box1loopm0.integrate(lst(s==5,t==2)); */ //MASIVE BOX LBL RoMB_loop_by_loop box1loopm(lst(k),lst(-pow(k,2)+ms,-pow(k+p1,2)+ms,-pow(k+p1+p2,2)+ms,-pow(k+p1+p2+p4,2)+ms), lst(pow(p1,2)==0,pow(p2,2)==0,pow(p4,2)==0, p1*p2==s/2,// p1*p4==-(s/2+t/2),// p2*p4==t/2 // ), lst(1,1,1,1),false); box1loopm.integrate_map(lst(ms1==1,ms2==1,ms3==1,ms4==1,ms==1,s==-3,t==-1),3); //triple box /* RoMB_loop_by_loop tribox1loopm(lst(k1,k2,k3),lst(-pow(k1,2)+ms,-pow(k1+p1,2),-pow(k1+p1+p2,2)+ms, -pow(k1-k2,2),-pow(k2,2)+ms,-pow(k2+p1+p2,2)+ms, -pow(k2-k3,2),-pow(k3,2)+ms,-pow(k3+p1+p2,2)+ms, -pow(k3-p3,2)), lst(pow(p1,2)==ms,pow(p2,2)==ms,pow(p3,2)==ms,pow(p4,2)==ms, p1*p2==s/2-ms,// p1*p3==t/2-ms,// p2*p3==ms-(s+t)/2 // ), lst(1,1,1,1,1,1,1,1,1,1),true); tribox1loopm.integrate_map(lst(ms1==1,ms2==1,ms3==1,ms4==1,ms==1,s==-1/2,t==-3)); */ //double box /* RoMB_loop_by_loop dobox1loopm(lst(k1,k2),lst(-pow(k1,2),-pow(k1+p1,2),-pow(k1+p1+p2,2), -pow(k1-k2,2),-pow(k2,2),-pow(k2+p1+p2,2), -pow(k2-p3,2)), lst(pow(p1,2)==0,pow(p2,2)==0,pow(p3,2)==0,pow(p4,2)==0, p1*p2==s/2-ms,// p1*p3==t/2-ms,// p2*p3==ms-(s+t)/2 // ), lst(1,1,1,1,1,1,1),false); dobox1loopm.integrate_map(lst(ms1==1,ms2==1,ms3==1,ms4==1,ms==1,s==-1/2,t==-3)); */ /* 4-loop tadpole */ // RoMB_loop_by_loop tad4(lst(l1, l2, l3, l4),lst(pow(l1,2)- ms,pow(l2,2)- ms,pow(l3 ,2)- ms,pow(l4,2),pow(l1+l2+l3+l4,2)),lst(),lst(1,1,1,1,1)); // tad4.integrate(lst(ms == 1),-2); /* Pentagon */ /* RoMB_loop_by_loop pent(lst(k1),lst(-pow(p1 + k1,2)+ ms,-pow(p1 + p5 + k1,2), -pow(p1 + p5 + p4 + k1,2)+ ms,-pow(p1 + p5 + p4 + p3 + k1,2)+ ms, -pow(k1,2)), lst( p1*p1 == ms, p2*p2 == ms, p3*p3 == 0, p4*p4 == ms, p5*p5 == ms, p1*p2 == 1/2* (tp - 2* ms), p1*p3 == 1/2* (t - tp - v1), p1*p4 == ms - 1/2* (s + t - v1), p1*p5 == 1/2* (s - 2* ms), p2* p3 == 1/2* v1, p2* p4 == 1/2* (s - 2* ms - v1 - v2), p2* p5 == ms - 1/2* (s + tp - v2), p3* p4 == 1/2* v2, p3* p5 == 1/2* (tp - t - v2), p4* p5 == 1/2* (t - 2* ms)), lst(1,1,1,1,1)); pent.integrate_map(lst(s==-2,t==-3,v2==-4,tp==-5,v1==-6,ms==1)); */ /* RoMB_loop_by_loop pent(lst(k1),lst(-pow(p1 + k1,2)+ ms,-pow(p1 + p5 + k1,2), -pow(p1 + p5 + p4 + k1,2)+ ms,-pow(p1 + p5 + p4 + p3 + k1,2)+ ms, -pow(k1,2)), lst( p1*p1 == ms, p2*p2 == ms, p3*p3 == 0, p4*p4 == ms, p5*p5 == ms, p1*p2 == 1/2* (tp - 2* ms), wild(1)*p1*p3 == wild(1)*1/2* (t - tp - v1), wild(2)*p1*p4 == wild(2)*(ms - 1/2* (s + t - v1)), wild(3)* p1*p5 == wild(3)*1/2* (s - 2* ms), wild(4)*p2* p3 == wild(4)*1/2* v1, wild(5)*p2* p4 == wild(5)*1/2* (s - 2* ms - v1 - v2), wild(6)*p2* p5 ==wild(6)*( ms - 1/2* (s + tp - v2)), wild(7)*p3* p4 == wild(7)*1/2* v2, wild(8)*p3* p5 == wild(8)*1/2* (tp - t - v2), wild()*p4* p5 == wild()*1/2* (t - 2* ms)), lst(1,1,1,1,1)); pent.integrate_map(lst(s==-2,t==-3,v2==-4,tp==-5,v1==-6,ms==1)); */ } catch(std::exception &p) { std::cerr<<"******************************************************************"<<endl; std::cerr<<" >>>ERROR: "<<p.what()<<endl; std::cerr<<"******************************************************************"<<endl; return 1; } return 0; }
//#define DEBUG_MODE int SingleSLAM::poseUpdate3D(bool largeErr) { propagateFeatureStates(); //get the feature points corresponding to the map points std::vector<Track2DNode*> nodes; int num = getStaticMappedTrackNodes(nodes); if (num < 1) { double* cR = m_camPos.current()->R; double* cT = m_camPos.current()->t; CamPoseItem* camPos = m_camPos.add(currentFrame(), camId,cR, cT); updateCamParamForFeatPts(K, camPos); warn( "[camera id:%d]intra-camera pose update failed! less than five static map points (%d)", camId, num); //leaveBACriticalSection(); //CoSLAM::ptr->pause(); //enterBACriticalSection(); return -1; } //choose the feature points for pose estimation std::vector<FeaturePoint*> featPts; chooseStaticFeatPts(featPts); std::vector<FeaturePoint*> mappedFeatPts; mappedFeatPts.reserve(nRowBlk * nColBlk * 2); for (size_t i = 0; i < featPts.size(); i++) { if (featPts[i]->mpt) mappedFeatPts.push_back(featPts[i]); } //get the 2D-3D corresponding points int n3D2Ds = mappedFeatPts.size(); Mat_d ms(n3D2Ds, 2), Ms(n3D2Ds, 3), covs(n3D2Ds, 9); for (int i = 0; i < n3D2Ds; i++) { FeaturePoint* fp = mappedFeatPts[i]; ms.data[2 * i] = fp->x; ms.data[2 * i + 1] = fp->y; Ms.data[3 * i] = fp->mpt->x; Ms.data[3 * i + 1] = fp->mpt->y; Ms.data[3 * i + 2] = fp->mpt->z; memcpy(covs.data, fp->mpt->cov, sizeof(double) * 9); } Mat_d R(3, 3), t(3, 1); double* cR = m_camPos.current()->R; double* cT = m_camPos.current()->t; IntraCamPoseOption opt; //test Mat_d old_errs(n3D2Ds, 1); //get reprojection error beform pose update for (int i = 0; i < n3D2Ds; i++) { FeaturePoint* fp = mappedFeatPts[i]; double m[2]; project(K.data, cR, cT, fp->mpt->M, m); old_errs[i] = dist2(m, fp->m); } //end of test intraCamEstimate(K.data, cR, cT, Ms.rows, 0, Ms.data, ms.data, Param::maxErr, R.data, t.data, &opt); Mat_d new_errs(n3D2Ds, 1); for (int i = 0; i < n3D2Ds; i++) { FeaturePoint* fp = mappedFeatPts[i]; double m[2]; project(K.data, R, t, fp->mpt->M, m); new_errs[i] = dist2(m, fp->m); } //find outliers int numOut = 0; double errThres = largeErr ? 6.0 : 2.0; double rm[2], var[4], ivar[4]; for (int i = 0; i < num; i++) { double* pM = nodes[i]->pt->mpt->M; double* pCov = nodes[i]->pt->mpt->cov; project(K, R, t, pM, rm); getProjectionCovMat(K, R, t, pM, pCov, var, Const::PIXEL_ERR_VAR); mat22Inv(var, ivar); double err = mahaDist2(rm, nodes[i]->pt->m, ivar); if (err < errThres) { //inlier nodes[i]->pt->reprojErr = err; seqTriangulate(K, R, t, nodes[i]->pt->m, pM, pCov, Const::PIXEL_ERR_VAR); project(K, R, t, pM, rm); getProjectionCovMat(K, R, t, pM, pCov, var, Const::PIXEL_ERR_VAR); mat22Inv(var, ivar); err = mahaDist2(rm, nodes[i]->pt->m, ivar); // if (err >= 1) { // nodes[i]->pt->mpt->setUncertain(); // //test // printf("poseUpdate:1\n"); // } } else { //outliers numOut++; double repErr = dist2(rm, nodes[i]->pt->m); nodes[i]->pt->reprojErr = repErr; nodes[i]->pt->mpt->setUncertain(); } } CamPoseItem* camPos = m_camPos.add(currentFrame(), camId, R.data, t.data); updateCamParamForFeatPts(K, camPos); // if (currentFrame() > 9) // MyApp::bStop = true; #ifdef DEBUG_MODE //if the number of outliers are too much (may due to some distant points) if (currentFrame() >= 76) { //test printf("f:%d,cam:%d : n3d2d:%d, num:%d, numOut:%d\n", currentFrame(), camId, n3D2Ds, num, numOut); char dirPath[1024]; sprintf(dirPath, "/home/tsou/slam_posefailed/%s", MyApp::timeStr); mkdir(dirPath, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); savePGM(m_img, "/home/tsou/slam_posefailed/%s/%d_img_%d.pgm", MyApp::timeStr, currentFrame(), camId); writeMat(Ms, "/home/tsou/slam_posefailed/%s/%d_pts3d_%d.txt", MyApp::timeStr, currentFrame(), camId); writeMat(ms, "/home/tsou/slam_posefailed/%s/%d_pts2d_%d.txt", MyApp::timeStr, currentFrame(), camId); writeMat(covs, "/home/tsou/slam_posefailed/%s/%d_cov3d_%d.txt", MyApp::timeStr, currentFrame(), camId); writeMat(3, 3, K, "/home/tsou/slam_posefailed/%s/%d_K_%d.txt", MyApp::timeStr, currentFrame(), camId); writeMat(old_errs, "/home/tsou/slam_posefailed/%s/%d_old_errs_%d.txt", MyApp::timeStr, currentFrame(), camId); writeMat(new_errs, "/home/tsou/slam_posefailed/%s/%d_new_errs_%d.txt", MyApp::timeStr, currentFrame(), camId); writeMat(3, 3, cR, "/home/tsou/slam_posefailed/%s/%d_oldR_%d.txt", MyApp::timeStr, currentFrame(), camId); writeMat(3, 1, cT, "/home/tsou/slam_posefailed/%s/%d_oldT_%d.txt", MyApp::timeStr, currentFrame(), camId); writeMat(R, "/home/tsou/slam_posefailed/%s/%d_R_%d.txt", MyApp::timeStr, currentFrame(), camId); writeMat(t, "/home/tsou/slam_posefailed/%s/%dT_%d.txt", MyApp::timeStr, currentFrame(), camId); //test logInfo("program paused for debug at camera %d!\n", currentFrame(), camId); leaveBACriticalSection(); CoSLAM::ptr->pause(); enterBACriticalSection(); } #endif return num; }
int sysbef (char *befbuf) //************************************************************************* // //************************************************************************* { static char shutdown_reason[23]; char xbuf[20]; static char *beftab[] = { "CONNECT", "LOGIN", "CALL", "OSHELL", #ifdef __DOS16__ #ifdef _TNC "TNC", #endif "W2", "UWIN", "TWIN", #ifdef _AUTOTRCWIN "TRWIN", #endif #endif "RTEXT", "CAT", "RPRG", "WTEXT", "WPRG", "RBIN", "WBIN", "SLR", "CLOG", "REORG", "LIFETIME", "MKBOARD", "RMBOARD", "MVBOARD", "SHUTDOWN", "NEW", "KILL", "TEST", "IMPORT", "DISABLE", "ENABLE", #ifdef DIEBOX_UIMPORT "UIMPORT", #endif #ifdef OLDMAILIMPORT "OLDMAILIMPORT", #endif "SETUSER", "BEACON", "GREP", "TGREP", "TAIL", "BEGIN", "BATCH", "EXPORT", "PWGEN", "POSTFWD", "MONITOR", "NOTE", "MACRO", "CFGFLEX", "ORM", "OMV", "OCP", "OMD", "APPEND", #ifdef DF3VI_EXTRACT "EXTRACT", #endif "HOLD", "SETPW", #ifdef FEATURE_YAPP "WYAPP", "RYAPP", #endif #ifdef FEATURE_DIDADIT "WDIDADIT", "RDIDADIT", #endif #if defined FEATURE_SERIAL || defined _TELEPHONE "TTYINIT", #endif #ifdef _TELEPHONE // JJ "TTYCMD", "TTYDIAL", "TTYHANGUP", "TTYSTATUS", "TTYWIN", "TTYCOUNTERRESET", #endif #ifdef _AUTOFWD "AFWDLIST", #endif #ifdef FEATURE_MDPW "MD2SUM", "MD5SUM", #endif #ifdef FEATURE_EDITOR "EDIT", "FEDIT", "REDIT", #else #ifdef DF3VI_FWD_EDIT "FEDIT", "FWDEDIT", #endif #ifdef DF3VI_REJ_EDIT "REDIT", "REJECTEDIT", #endif #ifdef DF3VI_CONV_EDIT "CEDIT", "CONVEDIT", #endif #endif #ifdef _FILEFWD "FWDIMPORT", "FWDEXPORT", #endif "YMBTEST", "SCMDLIST", // Dies ist immer das letzte Kommando! NULL }; enum befnum { unsinn, connect_, login, call_, oshell_, #ifdef __DOS16__ #ifdef _TNC tnc, #endif w2, uwin, twin, #ifdef _AUTOTRCWIN trwin, #endif #endif rtext, rtext_, rprg, wtext, wprg, rbin, wbin, slr, clog, reorg, life_, mkb, rmb, mvb, shutdown_, new_, kill_, test, import, disable_, enable_, #ifdef DIEBOX_UIMPORT uimport_, #endif #ifdef OLDMAILIMPORT oldmailimport_, #endif setuser, beacon, grep_, tgrep, tail, begin, batch, export_, pwgen, postfwd_, monitor_, note, macro, cfgflex_, orm, omv, ocp, omd, _append, #ifdef DF3VI_EXTRACT extract_, #endif hold, setpw, #ifdef FEATURE_YAPP wyapp, ryapp, #endif #ifdef FEATURE_DIDADIT wdidadit, rdidadit, #endif #if defined FEATURE_SERIAL || defined _TELEPHONE ttyinit, #endif #ifdef _TELEPHONE // JJ ttycmd, ttydial, ttyhangup, ttystatus, ttywin_, ttycounterreset, #endif #ifdef _AUTOFWD afwdlist_, #endif #ifdef FEATURE_MDPW md2sum, md5sum, #endif #ifdef FEATURE_EDITOR edit, fedit, redit, #else #ifdef DF3VI_FWD_EDIT fedit, fwdedit, #endif #ifdef DF3VI_REJ_EDIT redit, rejectedit, #endif #ifdef DF3VI_CONV_EDIT cedit, convedit_, #endif #endif #ifdef _FILEFWD fwdimport, fwdexport, #endif ymbtest, scmdlist // Dies ist immer das letzte Kommando! } cmd = unsinn; befbuf += blkill(befbuf); cmd = (befnum) readcmd(beftab, &befbuf, 0); switch (cmd) { #ifdef FEATURE_YAPP case ryapp: #endif #ifdef FEATURE_DIDADIT case rdidadit: #endif #if defined(FEATURE_YAPP) || defined(FEATURE_DIDADIT) break; #endif default: if (u->lf != 6) putv(LF); leerzeile(); // Sends the number of CRs stored in "ALTER LF" } switch (cmd) { case unsinn: if ( mbinitbef(befbuf, 0) #ifdef _TELEPHONE // JJ || ttyinitbef(befbuf, 0) #endif ) { strcpy(xbuf, "^"); mbparsave(); #ifdef _TELEPHONE // JJ ttyparsave(); #endif strncpy(xbuf + 1, befbuf, 18); xbuf[19] = 0; subst1(xbuf, ' ', 0); subst1(xbuf, '=', 0); grep(MBINITNAME, xbuf, o_i); #ifdef _TELEPHONE // JJ grep(INITTTYNAME, xbuf, o_i); #endif return OK; } else return NO; case note: trace(replog, "note", "%s", befbuf); break; #ifdef DF3VI_EXTRACT case extract_: mbchange(befbuf, w_extract, 1); break; #endif case hold: mbchange(befbuf, w_hold, 1); break; case omv: { char f1[50], f2[50]; befbuf = nexttoken(befbuf, f1, 49); befbuf = nexttoken(befbuf, f2, 49); if (! *f1 || ! *f2 || xrename(f1, f2)) putf(ms(m_error)); else { putf(ms(m_moving)); putf(ms(m_nach), f1, f2); } break; } case ocp: { char f1[50], f2[50]; befbuf = nexttoken(befbuf, f1, 49); befbuf = nexttoken(befbuf, f2, 49); if (! *f1 || ! *f2 || filecopy(f1, f2)) putf(ms(m_error)); else { putf(ms(m_copying)); putf(ms(m_nach), f1, f2); } break; } case orm: { char f1[50]; befbuf = nexttoken(befbuf, f1, 49); if (! *f1 || xunlink(f1)) putf(ms(m_filecantdeleted), f1); else putf(ms(m_filedeleted), f1); break; } case omd: { char f1[50]; befbuf = nexttoken(befbuf, f1, 49); killbackslash(f1); if (! *f1 || xmkdir(f1)) putf(ms(m_directorycantcreated), f1); else putf(ms(m_directorycreated), f1); break; } case _append: { char textline[LINELEN+1]; befbuf = nexttoken(befbuf, textline, LINELEN); if (! *befbuf) { putf("Syntax: APPEND <textline> <filename>\n"); break; } FILE *f = s_fopen(befbuf, "sat"); if (f) { fprintf(f, "%s\n", textline); s_fclose(f); } else putf(ms(m_filenotfound), befbuf); } break; case macro: { mk_start(befbuf); } break; case setuser: { char call[CALLEN+1]; befbuf = nexttoken(befbuf, call, CALLEN+1); strupr(call); if (mbcallok(call) && *befbuf) { trace(report, "setuser", "%s", befbuf); { if (! mbalter(NULL, befbuf, call)) putf(ms(m_isunknown), call); b->msg_loadnum = 0; //reload msg loaduser(b->logincall, u, 1); } } else putf("Syntax: SETUSER <call> <option> <value>\n"); } break; case setpw: //automatisierte Passwort-Vergabe { char call[CALLEN+1]; char passwd[40]; int i, pwline = 0; FILE *upwf; befbuf = nexttoken(befbuf, call, CALLEN+1); strupr(call); pwline = atoi(befbuf); if (! mbcallok(call) || ! pwline) { putf("Syntax: SETPW <call> <number>\n"); break; } if (! loaduser(call, u, 0)) { putf(ms(m_isunknown), call); break; } upwf = s_fopen("userpw.bcm", "sr"); if (! upwf) { putf(ms(m_filenotfound), "userpw.bcm"); break; } for (i = 0; i < pwline && ! feof(upwf); i++) fgets(passwd, sizeof(passwd) - 1, upwf); s_fclose(upwf); if (i < pwline) { putf(ms(m_userpwlines), i - 1); break; } strcpy(u->password, passwd); saveuser(u); pwline = strlen(u->password); putf(ms(m_loginpw), pwtypestr(u->loginpwtype), pwtypestr(u->sfpwtype)); putf(" "); putf(ms(m_pwdlength), pwline); sprintf(passwd, "pw set to %i char", pwline); pwlog(call, b->logincall, passwd); b->msg_loadnum = 0; //reload msg loaduser(b->logincall, u, 1); } break; #ifdef DIEBOX_UIMPORT case uimport_: { putf(ms(m_dieboximport)); uimport(); } break; #endif #ifdef OLDMAILIMPORT case oldmailimport_: { scanoptions(befbuf); formoptions(); befbuf += blkill(befbuf); if (isdir(befbuf)) { putf(ms(m_omi_started), befbuf); putflush(); oldmailimport(befbuf); } else putf(ms(m_dirunknown), befbuf); } break; #endif case disable_: { putf(ms(m_boxdisabled)); m.disable = 1; mbparsave(); } break; case enable_: { putf(ms(m_boxenabled)); m.disable = 0; mbparsave(); } break; case test: { if (*befbuf == 'W') { while (1); } // for testing watchdog else if (*befbuf == 'S') { trace(fatal, "test", "abort"); } else if (*befbuf == 'V') { *(char *)0 = 1; } else mk_start(befbuf); } break; case batch: { runbatch(befbuf); } break; case rtext: case rtext_: { fileio_text fio; fio.usefile(befbuf); fio.tx(); putf("\032\n"); // CTRL-Z } break; case wtext: { fileio_text fio; fio.usefile(befbuf); fio.rx(); } break; case rbin: case rprg: { fileio_abin fio; fio.usefile(befbuf); fio.tx(); } break; case wbin: case wprg: { fileio_abin fio; fio.usefile(befbuf); fio.rx(); } break; #ifdef FEATURE_YAPP case ryapp: { fileio_yapp fio; fio.usefile(befbuf); fio.tx(); } break; case wyapp: { fileio_yapp fio; fio.usefile(befbuf); fio.rx(); } break; #endif // FEATURE_YAPP #ifdef FEATURE_DIDADIT case rdidadit: { fileio_dida fio; fio.usefile(befbuf); fio.tx(); } break; case wdidadit: { fileio_dida fio; if (! *befbuf) fio.usefile("dummy"); else { if (befbuf[strlen(befbuf) - 1] != '/') strcat(befbuf, "/"); strcat(befbuf, "dummy"); fio.usefile(befbuf); } fio.rx(); } break; #endif // FEATURE_DIDADIT case slr: { scanoptions(befbuf); putlog(TRACEPATH "/" SYSLOGRNAME, befbuf); } break; case clog: { scanoptions(befbuf); putlog(TRACEPATH "/" CMDLOGNAME, befbuf); } break; case tail: { scanoptions(befbuf); befbuf += blkill(befbuf); if (b->optplus&o_f && *befbuf) { int a; FILE *f = s_fopen(befbuf, "lrt"); if (f) { fseek(f, 0, SEEK_END); do { while ((a = fgetc(f)) != EOF) putv(a); wdelay(349); } while (! testabbruch()); s_fclose(f); } } else { fileio_text fio; fio.usefile(befbuf); fio.settail(-2000); fio.tx(); } } break; case begin: { fileio_text fio; fio.usefile(befbuf); fio.settail(2000); fio.tx(); } break; case monitor_: { if (*befbuf) { scanoptions(befbuf); b->continous = 1; monitor(atoi(befbuf), b->optplus); } else putf("Syntax: MONITOR [-iords] <task-id>\n"); } break; case tgrep: { char string[61]; char name[40]; scanoptions(befbuf); if (b->optminus & o_i) b->optplus |= o_i; //wenn nicht explizit "-i-", ist "-i" default b->usermail = 0; if (! *befbuf) { putf("Syntax: TGREP [pattern] <fwd-bbs>\n"); break; } befbuf = nexttoken(befbuf, string, 60); if (*befbuf) { sprintf(name, TRACEPATH "/t_%s.bcm", befbuf); grep(name, string, b->optplus); } else { sprintf(name, TRACEPATH "/t_%s.bcm", string); putlog(name, ""); } } break; case grep_: { char string[61]; scanoptions(befbuf); if (b->optminus & o_i) b->optplus |= o_i; //wenn nicht explizit "-i-", ist "-i" default b->usermail = 0; befbuf = nexttoken(befbuf, string, 60); grep(befbuf, string, b->optplus); } break; #ifdef _AUTOFWD case afwdlist_: { afwdlist(befbuf); } break; #endif case life_: { if (*befbuf) { strupr(befbuf); char *life = skip(befbuf); int board = finddir(befbuf, b->sysop); if (board > 0) { board -= 1; if (life && *life) { tree[board].lifetime_max = atoi(life); tree[board].lifetime_min = 1; if (tree[board].lifetime_max > 999) tree[board].lifetime_max = 999; if (tree[board].lifetime_max < 1) tree[board].lifetime_max = 1; char *life_min = skip(life); if (life_min && *life_min) { tree[board].lifetime_min = atoi(life_min); if (tree[board].lifetime_min > 999) tree[board].lifetime_min = 999; if (tree[board].lifetime_min < 1) tree[board].lifetime_min = 1; } mbtreesave(); } putf(ms(m_lifetimestat), b->boardfullname, tree[board].lifetime_max, tree[board].lifetime_min); } else putf(ms(m_notfound), befbuf); } else putf("Syntax: LIFETIME <board> <days_maximum> [<days_minimum>]\n" " (with 1 <= days_maximum/days_minimum <= 999)\n\n"); } break; #ifdef _TNC case tnc: { control_tnc(befbuf); } break; #endif case connect_: { termqso(befbuf); } break; case login: { if (mbcallok(befbuf)) { mblogin(befbuf, login_standard, b->uplink); cmdlog("login changed"); putf(ms(m_loginchanged)); } else putf("Syntax: LOGIN <new logincall>\n"); } break; case call_: { if (mbcallok(befbuf)) { mblogin(befbuf, login_silent, b->uplink); b->msg_loadnum--; //Sonst wird falsche Sprache benutzt cmdlog("call changed"); } else putf("Syntax: CALL <new logincall>\n"); } break; case oshell_: { if (t->input == io_file || t->output == io_file) oshell(befbuf, sh_noinput); else oshell(befbuf, m.dosinput ? sh_forceinput : sh_ifmultitask); } break; case reorg: { if (sema_test("purgereorg") == 1) putf(ms(m_purgeallstarted)); else { putf(ms(m_reorginvoked)); fork(P_BACK | P_MAIL, 0, mbreorg, befbuf); } } break; case postfwd_: { putf(ms(m_postfwdinvoked)); fork(P_BACK | P_MAIL, 0, postfwd, "Postfwd"); } break; #ifdef FEATURE_EDITOR case edit: { fork(P_WIND | P_KEYB, 0, editfile, befbuf); } break; case fedit: { fork(P_WIND | P_KEYB, 0, editfile, FWDLISTNAME); } break; case redit: { fork(P_WIND | P_KEYB, 0, editfile, REJECTNAME); } break; #else #ifdef DF3VI_FWD_EDIT case fedit: //wenn kein editor vorhanden remote-editor aufrufen case fwdedit: { fwdlistedit(befbuf); } break; #endif #ifdef DF3VI_REJ_EDIT case redit: case rejectedit: { rejectlistedit(befbuf); } break; #endif #ifdef DF3VI_CONV_EDIT case cedit: case convedit_: { convedit(befbuf); } break; #endif #endif case new_: { scanoptions(befbuf); mbinit(); initfwdlist(); #ifdef _AUTOFWD initafwdlist(); #endif if (! (b->optplus & o_q)) // skip statistics on "new -q" { b->optplus = o_s | o_f | o_c; putf(ms(m_hadrstat)); browse_hadr(""); } mbcvtload(); #ifdef RUNUTILS read_runfile(); #endif msg_dealloc(1); mk_read_jobs(); } break; case kill_: { if (atoi(befbuf)) { while (atoi(befbuf)) { if (! killtask(nextdez(&befbuf), 1)) putf(ms(m_cantkilltask)); } } else putf("Syntax: KILL <task-id>\n"); } break; #ifdef __DOS16__ case w2: { fork(P_WIND | P_KEYB|P_MAIL, 0, mbwin2, m.sysopcall); } break; case uwin: { fork(P_WIND | P_KEYB|P_MAIL, 0, userwin, "Users"); } break; case twin: { fork(P_WIND | P_MAIL, 0, taskwin, befbuf); } break; #ifdef _AUTOTRCWIN case trwin: { if (*befbuf) fork(P_WIND | P_MAIL, 0, trcwin, befbuf); else putf("Syntax: TRWIN [-iords] <task-id>\n"); } break; #endif #endif //__DOS16__ case mkb: { char mainboard[30]; char newboard[20]; char *slash; befbuf = nexttoken(befbuf, mainboard, 29); befbuf = nexttoken(befbuf, newboard, 19); slash = strchr(mainboard + 1, '/'); if (slash && (! *newboard)) { *slash = 0; strcpy(newboard, slash + 1); } if (! *newboard && *mainboard == '/') { strcpy(newboard, mainboard + 1); mainboard[1] = 0; } if (*mainboard && *newboard) { switch (mkboard(mainboard, newboard, 0)) { case 0: putf(ms(m_boardcreated)); break; case 1: putf(ms(m_mainboardnotfound)); break; case 2: putf(ms(m_toomanyboards)); break; case 3: putf(ms(m_boardnameexist)); break; case 4: putf(ms(m_invalidboardname)); break; } } else putf("Syntax: MKBOARD <mainboard> <subboard>\n"); } break; case rmb: { if (*befbuf) { subst1(befbuf, ' ', '/'); if (*befbuf == '/' && befbuf[1] == '/') befbuf++; switch (rmboard(befbuf)) { case 0: putf(ms(m_boardremoved)); break; case 1: putf(ms(m_boardnotfound)); break; case 2: putf(ms(m_boardnotempty)); break; } } else putf("Syntax: RMBOARD <mainboard> <subboard>\n"); } break; case mvb: { char oldboard[20]; char subboard[20]; char neuboard[20]; befbuf = nexttoken(befbuf, oldboard, 19); befbuf = nexttoken(befbuf, subboard, 19); befbuf = nexttoken(befbuf, neuboard, 19); if (*oldboard && *subboard && *neuboard) { switch (mvboard(oldboard, subboard, neuboard)) { case 0: putf(ms(m_boardmoved)); break; case 1: putf(ms(m_newboardnotfound)); break; case 2: putf(ms(m_toomanyboards)); break; case 4: putf(ms(m_oldboardnotfound)); break; } } else putf("Syntax: MVBOARD <oldboard> <subboard> <newboard>\n"); } break; case shutdown_: { scanoptions(befbuf); #ifdef __DOS16__ if (b->optplus & o_r) atexit((void(*)()) MK_FP(0xffff, 0x0000)); #endif runterfahren = 1; sprintf(shutdown_reason, "shutdown by %s", b->logincall); stopreason = shutdown_reason; } break; case cfgflex_: { if (*befbuf && file_isreg("cfgflex.bcm")) { putf(ms(m_flexstarted)); fork(P_BACK | P_MAIL, 0, cfgflex, befbuf); } else putf("Syntax: CFGFLEX <flexcall> (cfgflex.bcm must exist)\n"); } break; case import: { sysimport(befbuf); } break; case export_: { if (*befbuf) { if ((t->input != io_file || t->output == io_dummy) && t->output != io_file) { char fname[51]; scanoptions(befbuf); befbuf = nexttoken(befbuf, fname, 50); if (b->optplus & o_a) // neue Option -b fuer binaer { if (b->optplus & o_b) b->outputfile = s_fopen(fname, "sab"); else b->outputfile = s_fopen(fname, "sat"); } else { if (b->optplus & o_b) b->outputfile = s_fopen(fname, "swb"); else b->outputfile = s_fopen(fname, "swt"); } if (b->outputfile) { s_fsetopt(b->outputfile, 1); b->oldinput = t->input; b->oldoutput = t->output; t->input = io_dummy; t->output = io_file; b->continous = 1; if (b->optplus & o_u) b->sysop = 0; if (*befbuf) mailbef(befbuf, 0); b->sysop = 1; } else putf(ms(m_filenotopen), fname); } } else putf("Syntax: EXPORT <filename> <box-command>\n"); } break; case beacon: { if (*befbuf) { FILE *f = s_fopen(BEACONNAME, "srt"); unsigned int i = 0; char s[LINELEN+1]; if (f) { while (fgets(s, LINELEN, f)) { if (*s) { s[strlen(s) - 1] = 0; putbeacon_tnc(s, befbuf); i++; } } s_fclose(f); } putf(ms(m_beaconframes), i); } else { fork(P_BACK | P_MAIL, 0, sendmailbake, "Beacon"); putf(ms(m_beaconstarted)); } } break; case pwgen: { FILE *f; if (*befbuf && (f = s_fopen(befbuf, "swt")) != 0) { unsigned int i; int upw; upw = ! stricmp(befbuf, "userpw.bcm"); // file fuer setpw for (i = 0; i < 1620; i++) { char c = 0; while (! isalnum(c)) c = random_max('z'); fputc(c, f); //pw-file fuer setpw erzeugen (81 Zeilen mit je 20 Zeichen) if (upw && (i % 20) == 19) fputc(LF, f); } trace(report, "pwgen", "%s created", befbuf); s_fclose(f); } else //ohne Parameter immer userpw.bcm erzeugen if (! *befbuf && (f = s_fopen("userpw.bcm", "swt")) != 0) { unsigned int i; for (i = 0; i < 1620; i++) { char c = 0; while (! isalnum(c)) c = random_max('z'); fputc(c, f); //pw-file fuer setpw erzeugen (81 Zeilen mit je 20 Zeichen) if ((i % 20) == 19) fputc(LF, f); } trace(report, "pwgen", "userpw.bcm created"); s_fclose(f); } } break; case scmdlist: // DH3MB { unsigned int i = 0; while (beftab[i]) putf("(%02d) %s\n", ++i, beftab[i]); } break; #ifdef FEATURE_MDPW case md2sum: { if (! *befbuf) { putf("Syntax: MD2SUM <filename>\n"); break; } if (! file_isreg(befbuf)) putf(ms(m_filenotfound), befbuf); else { MD2 md2; md2.readfile(befbuf, 0L); md2.gethexdigest(b->line); putf("%s %s\n", b->line, befbuf); } } break; case md5sum: { if (! *befbuf) { putf("Syntax: MD5SUM <filename>\n"); break; } if (! file_isreg(befbuf)) putf(ms(m_filenotfound), befbuf); else { MD5 md5; md5.readfile(befbuf, 0L); md5.gethexdigest(b->line); putf("%s %s\n", b->line, befbuf); } } break; #endif #if defined FEATURE_SERIAL || defined _TELEPHONE case ttyinit: { if (eingelogt("getty", 0, 0)) putf(ms(m_ttyactive)); else init_tty(); } break; #endif #ifdef _TELEPHONE // JJ case ttycmd: { if (*befbuf) { if (m.ttydevice > 1) putf_tty("%s\r", befbuf); else putf(ms(m_nomodem)); } else putf("Syntax: TTYCMD <command>\n"); } break; case ttydial: { strupr(befbuf); char *nummer; char call[8]; nummer = nexttoken(befbuf, call, 8); if (*befbuf && mbcallok(call)) { if (m.ttydevice && (get_ufwd(call)[0] || isforwardpartner(call) >= 0)) { putf(ms(m_startphonefwd), call, nummer); sprintf(befbuf, "%s TTY %s", call, nummer); fork(P_BACK | P_MAIL, 0, fwdsend, befbuf); } else putf(ms(m_nottyactive)); } else putf("Syntax: TTYDIAL <call> <number>\n"); } break; case ttyhangup: { tty_hangup(); putf(ms(m_hangupmodem)); } break; case ttystatus: { tty_statustext(); putv(LF); } break; case ttywin_: { fork(P_WIND | P_MAIL, 0, tty_win, befbuf); } break; case ttycounterreset: { tty_counterreset(); putv(LF); } break; #endif #ifdef _FILEFWD case fwdimport: { if (*befbuf) fwd_import(befbuf); } break; case fwdexport: { if (*befbuf) fwd_export(befbuf); } break; #endif case ymbtest: { #ifdef _USERCOMP if (u->comp == 1) { /* char output[256] = { 0 }; char output2[256] = { 0 }; int i, il = 0; */ putf("//COMP 1\n\n"); putflush(); /* il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); // printf("il: %d strlen: %d\n",il,strlen(befbuf)); // printf("befbuf:\n-%s-\nOut:\n-%s-\n",befbuf,output); //putflush(); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); output[0] = '\0'; strcpy(befbuf, "dies ist noch ein laengerer text 2"); il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); output[0] = '\0'; strcpy(befbuf, "dies ist ein noch laengerer text 3"); il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); putf("\n"); il = decomp_sp_stat_huff(output, strlen(output), output2); printf("il: %d strlen: %d\n",il,strlen(output)); printf("Out2:\n-%s-\n",output2); */ /* #include "ahuf.h" // TOP-Huffman class AHUF; AHUF *ahuf; ahuf = new AHUF(); il = ahuf->Komprimieren(true, befbuf, output, strlen(befbuf) ); printf("il: %d strlen: %d\n",il,strlen(befbuf)); printf("befbuf:\n-%s-\nOut:\n-%s-\n",befbuf,output); putflush(); putf("%s",output); putflush(); putf("\n"); */ } #endif } break; } return OK;
void ForestDetector::detect(std::vector<std::vector<double> >& vGroundTruth, std::vector<std::string>& vPaths, cv::Size_<int>& templateSize, std::vector<cv::Point_<int> >& vCenters) { std::ostringstream oss; oss << "../output/result_learning_" << _index << ".txt" << std::endl; std::fstream fileRes(oss.str().c_str(), std::fstream::out); for (int imageInd=0 ; imageInd < vPaths.size() ; imageInd++) { cv::Mat image = cv::imread(vPaths.at(imageInd), CV_LOAD_IMAGE_GRAYSCALE); cv::Mat integral; cv::namedWindow("lol"); cv::namedWindow("detection"); cv::namedWindow("hough"); cv::integral(image, integral); int height = image.size().height; int width = image.size().width; unsigned int patchWidth = _pForestEnv->getPatchWidth(); unsigned int patchHeight = _pForestEnv->getPatchHeight(); float currentMax=0; double pas=2; //For display cv::Mat result = cv::Mat::zeros(image.size().height/pas, image.size().width/pas, CV_32F); cv::Mat angle = cv::Mat::zeros(image.size().height/pas, image.size().width/pas, CV_64F); std::vector<cv::Point_<int> > offsetMeans; std::vector<cv::Point_<double> > offsetVar; std::vector<int> nbPatchs; cv::Mat imRoi, imIntRoi; std::vector<Leaf*> detectionVotes; std::vector<cv::Mat> detectionMeans; for (int x=0 ; x < width-patchWidth ; x+=pas)//cols { for (int y=0 ; y < height-patchHeight ; y+=pas)//rows { cv::Rect_<int> roi(x, y, patchWidth, patchHeight); cv::Rect_<int> roiInt(x, y, patchWidth+1, patchHeight+1); //patch cv::Mat meanSV; std::vector<cv::Mat> patchs; double conf=0; image(roi).copyTo(imRoi); integral(roiInt).copyTo(imIntRoi); patchs.push_back(imRoi); patchs.push_back(imIntRoi); Patch patch(patchs, roi); std::vector<Leaf*> detectedLeaf; pForest->regression(patch, detectedLeaf); double test=0; double denom=0; for (int i=0 ; i<detectedLeaf.size() ; i++) { offsetMeans.push_back(detectedLeaf[i]->getMeanOffsets()); offsetVar.push_back(detectedLeaf[i]->getVarOffsets()); nbPatchs.push_back(detectedLeaf[i]->getNumberPatchs()); meanSV = detectedLeaf[i]->getSVMean().clone(); conf = detectedLeaf[i]->getConf(); //std::cout << offsetMeans.back() << " " << offsetVar.back() << " " << nbPatchs.back() << std::endl; cv::Point_<int> offset(-offsetMeans.back().x+patchWidth/2+x, -offsetMeans.back().y+patchHeight/2+y); if (offset.x >= 0 && offset.x < width && offset.y >= 0 && offset.y < height) { offset.x = offset.x/pas; offset.y = offset.y/pas; //if ((offsetVar.back().x <= 200) && (offsetVar.back().y <= 200)) if ((conf == 1) && (detectedLeaf[i]->getTrace() < 500)) { detectionVotes.push_back(detectedLeaf[i]); detectionMeans.push_back(detectedLeaf[i]->getSVMean().clone()); detectionMeans.back().at<double>(0) = offset.x*pas; detectionMeans.back().at<double>(1) = offset.y*pas; //Might be removed => only for display (and maybe detection with particle filtering) result.at<float>(offset) += conf; denom+=conf; test+=conf*meanSV.at<double>(4); angle.at<double>(y/pas, x/pas) = test/denom; } else { //still for display angle.at<double>(y/pas, x/pas) = -100; } //display as well if (result.at<float>(offset) > currentMax) currentMax=result.at<float>(offset); } }//End of leaf loop }//End of rows loop }//End of cols loop if (detectionMeans.size()==0) { std::cout << "no detection" << std::endl; continue; } //Detection with mean shift MeanShift ms(detectionMeans); cv::Mat mean; ms.getMaxCluster(detectionMeans, mean); //For display result=result/currentMax*255; result.convertTo(result, CV_8U); angle=(angle+22)/45*255; angle.convertTo(angle, CV_8U); cv::applyColorMap(angle, angle, cv::COLORMAP_JET); cv::imshow("hough", angle); //Write in result file fileRes << vPaths[imageInd] << " ";//Image fileRes << vGroundTruth[imageInd].at(1) << " "<< vGroundTruth[imageInd].at(2) << " "<< vGroundTruth[imageInd].at(3) << " " << vGroundTruth[imageInd].at(4) << " " << vGroundTruth[imageInd].at(5) << " " << vGroundTruth[imageInd].at(6) << " ";//Ground Truth fileRes << mean.at<double>(0) << " " << mean.at<double>(1) << " " << mean.at<double>(2) << " " << mean.at<double>(3) << " " << mean.at<double>(4) << " " << mean.at<double>(5) << std::endl;//Detection //End of write cv::RotatedRect rotatedRect(cv::Point2f(mean.at<double>(0)-128/(2*pas), mean.at<double>(1)-128/(2*pas)), cv::Size2f(128/(2*pas), 128/(2*pas)), 0); //std::cout << mean.at<double>(3) << " " << mean.at<double>(4) << " " << mean.at<double>(5) << std::endl; cv::Mat imageToSave=result.clone(); cv::ellipse(imageToSave, rotatedRect, cv::Scalar_<int>(0,255,0), 2); rotatedRect.center = rotatedRect.center*pas; rotatedRect.size.height = rotatedRect.size.height*pas; rotatedRect.size.width = rotatedRect.size.width*pas; cv::ellipse(image, rotatedRect, cv::Scalar_<int>(125,255,125), 2); cv::applyColorMap(imageToSave, imageToSave, cv::COLORMAP_JET); cv::imshow("detection", image); cv::imshow("lol", imageToSave); cv::waitKey(50); }//End of images loop }
void run() { Client::WriteContext ctx(&_txn, ns()); Database* db = ctx.ctx().db(); Collection* coll = db->getCollection(&_txn, ns()); if (!coll) { coll = db->createCollection(&_txn, ns()); } fillData(); // The data we're going to later invalidate. set<DiskLoc> locs; getLocs(&locs, coll); // Build the mock scan stage which feeds the data. WorkingSet ws; auto_ptr<MockStage> ms(new MockStage(&ws)); insertVarietyOfObjects(ms.get(), coll); SortStageParams params; params.collection = coll; params.pattern = BSON("foo" << 1); params.limit = limit(); auto_ptr<SortStage> ss(new SortStage(&_txn, params, &ws, ms.get())); const int firstRead = 10; // Have sort read in data from the mock stage. for (int i = 0; i < firstRead; ++i) { WorkingSetID id = WorkingSet::INVALID_ID; PlanStage::StageState status = ss->work(&id); ASSERT_NOT_EQUALS(PlanStage::ADVANCED, status); } // We should have read in the first 'firstRead' locs. Invalidate the first. ss->saveState(); set<DiskLoc>::iterator it = locs.begin(); ss->invalidate(*it++, INVALIDATION_DELETION); ss->restoreState(&_txn); // Read the rest of the data from the mock stage. while (!ms->isEOF()) { WorkingSetID id = WorkingSet::INVALID_ID; ss->work(&id); } // Release to prevent double-deletion. ms.release(); // Let's just invalidate everything now. ss->saveState(); while (it != locs.end()) { ss->invalidate(*it++, INVALIDATION_DELETION); } ss->restoreState(&_txn); // Invalidation of data in the sort stage fetches it but passes it through. int count = 0; while (!ss->isEOF()) { WorkingSetID id = WorkingSet::INVALID_ID; PlanStage::StageState status = ss->work(&id); if (PlanStage::ADVANCED != status) { continue; } WorkingSetMember* member = ws.get(id); ASSERT(member->hasObj()); ASSERT(!member->hasLoc()); ++count; } ctx.commit(); // Returns all docs. ASSERT_EQUALS(limit() ? limit() : numObj(), count); }
int mbtransfer (char *ziel) //************************************************************************* // // TRANSFER-Prozedur // (wird fuer jedes transferierte File einzeln aufgerufen) // //************************************************************************* { char name[20]; strcpy(name, "mbtransfer"); lastfunc(name); char *line = b->line; int findex; FILE *oldf, *newf; char usermail = 0; int retwert = NO; int nocp; //no-copy flag char oldsubject[101]; unsigned long int oldfpos; char oldmsgty; char oldmailfname[10]; time_t oldmsgtime; char old_ziel[DIRLEN+1]; int old_usermail; char oldboardname[10]; char oldmailpath[FNAMELEN+1]; char zielcall[CALLEN+1]; char newcall[CALLEN+1]; int gleichesboard = NO; unsigned long nummer; #ifdef USERLT short int old_lt; #endif #ifdef DEBUG_FWD trace(report, "mbtransfer", "ziel: %s", ziel); #endif strupr(ziel); nexttoken(ziel, zielcall, CALLEN); strcpy(oldmailpath, b->mailpath); if (sema_test("sendlock") || m.disable) { putf(ms(m_sendnotpossible)); return NO; } if (mbcallok(zielcall)) { // Use newcall if (get_newcall(zielcall, newcall)) { strcpy(zielcall, newcall); putf(ms(m_usingnewcall), newcall); } } char *bbuf = (char *) t_malloc(sizeof(tvar_t) - sizeof(task_t), "tran"); char *oldfname; oldfname = (char *) t_malloc(sizeof(char) * (FNAMELEN+1), "tra2"); if (! bbuf || ! oldfname) return NO; memcpy(bbuf, (char *) b + sizeof(task_t), sizeof(tvar_t) - sizeof(task_t)); strlwr(b->mailpath); strcpy(oldfname, b->mailpath); strcpy(oldmailfname, b->mailfname); oldmsgtime = filename2time(b->mailfname); if ((oldf = s_fopen(oldfname, "srt")) != NULL) { fgets(b->line, BUFLEN - 1, oldf); // Befehlszeile einlesen mbsend_parse(line, 0); if (b->mailtype == 'A' || (b->mailtype == 'B' && b->eraseinfo == 'T')) { retwert = NIL; s_fclose(oldf); goto error_exit; } oldmsgty = b->conttype; // save mailflags ...(conttype) fgets(b->line, BUFLEN - 1, oldf); // Forwardzeile vernichten fgets(b->line, BUFLEN - 1, oldf); // Read-Zeile fgets(oldsubject, BETREFFLEN, oldf); // Betreff cut_blank(oldsubject); // Newline entfernen if (mbcallok(zielcall)) *b->at = 0; // Verteiler loeschen -> Neubestimmen strcpy(old_ziel, b->ziel); #ifdef USERLT old_lt = b->lifetime; b->lifetime = 0; #endif old_usermail = b->usermail; mbsend_parse(ziel, 2); if (! stricmp(b->ziel, b->mailpath+strlen(b->mailpath)-strlen(b->ziel)-8)) { retwert = NIL; s_fclose(oldf); goto error_exit; } b->conttype = oldmsgty; // set mailflags again.. (conttype) if (b->mailtype == 'B' && ! old_usermail) strcpy(b->ziel, old_ziel); weiterleiten(1, b->zielboard); waitfor(e_ticsfull); findex = finddir(b->zielboard, b->sysop); if (findex && !(strlen(b->zielboard)==1 && !b->sysop)) { if (xmkdir(b->boardpath)) { trace(serious, name, "mkdir %s error", b->boardpath); s_fclose(oldf); goto error_exit; } nocp = ! strcmp(b->herkunft, b->logincall) || b->sysop; //kein "CP " wenn Sysop! if (nocp || b->mailtype == 'B') strcpy(b->betreff, oldsubject); else sprintf(b->betreff, "CP %s: %.67s", b->logincall, oldsubject); //Bei Nicht-Bulletin BID neu generieren bzw. wenn BID fehlt if (b->mailtype != 'B'|| ! *b->bid) strcpy(b->bid, newbid()); make_mask(b->mailpath, b->boardfullname); strcpy(b->mask, b->mailpath); // Ursprungsboardnamen aus b->mailpath holen und mit ziel vergleichen strcpy(oldboardname, b->boardname); oldmailpath[strlen(oldmailpath)-8] = 0; if (finddir(oldmailpath,0) > 0) { if (! strcmp(ziel, b->boardname)) gleichesboard = YES; } else gleichesboard = NO; strcpy(b->boardname,oldboardname); // b->boardname wieder herstellen // bei Usermail oder gleichem Board zum Sortieren // Filezeit/-namen neu setzen if (mbcallok(zielcall) || gleichesboard) { strcpy(b->mailfname, time2filename(0)); } else strcpy(b->mailfname, oldmailfname); if (! strstr(b->mailpath, "*.*")) trace(fatal, name, "mask %s", b->mailpath); strcpy(strstr(b->mailpath, "*.*"), b->mailfname); strlwr(b->mailpath); if ((newf = s_fopen(b->mailpath, "sw+t")) != NULL) { s_fsetopt(newf, 1); #ifdef USERLT set_boardlife_max(old_lt); b->lifetime = old_lt; #endif writeheader(newf, 1); if (b->mailtype != 'B') { if (fgets(b->line, BUFLEN - 1, oldf)) { do { // fputs(line,f); skip old R-lines waitfor(e_ticsfull); fgets(b->line, BUFLEN - 1, oldf); } while (! feof(oldf) && *line == 'R' && line[1] == ':'); } fprintf(newf, "%s\n", makeheader(1)); fprintf(newf, "X-Transfer: %s by %s @ %s\n", datestr(ad_time(), 12), b->logincall, m.boxadress); fprintf(newf, "X-Original-Date: %s\n", datestr(oldmsgtime, 10)); do { if(( ! strncasecmp(line, "from", 4) || ! strncmp(line, "de: ", 4) || ! strncmp(line, "de ", 3) || ! strncmp(line, "fm ", 3)) && ! nocp) fprintf(newf, "X-Originally %s", line); else if (( ! strncasecmp(line, "to: ", 4) || ! strncasecmp(line, "to ", 3)) && ! nocp) fprintf(newf, "X-Originally %s", line); else if (! strncmp(line, "X-MID: ", 7)) fprintf(newf, "X-Old-MID: %s", line + 7); else if (! strncmp(line, "X-BID: ", 7)) fprintf(newf, "X-Old-BID: %s", line + 7); else fputs(line, newf); waitfor(e_ticsfull); fgets(b->line, BUFLEN - 1, oldf); } while (! feof(oldf) && *line != LF); fputc(LF, newf); } //Files binaer behandeln oldfpos = ftell(oldf); s_fclose(oldf); s_fclose(newf); writemailflags(); if ((oldf = s_fopen(oldfname, "srb")) != NULL) { if ((newf = s_fopen(b->mailpath, "sab")) != NULL) //append to file { fseek(oldf, oldfpos, SEEK_SET); do { //oe3dzw: Transferroutine transparent int len; len = fread(line, 1, 255, oldf); if (len) fwrite(line, 1, len, newf); waitfor(e_ticsfull); } while (! feof(oldf)); if (b->binstart) //bei binaeren Mails offset neu berechnen { b->binstart += ftell(newf) - ftell(oldf); if (b->binstart < 0) trace(serious, name, "offset %ld in %s", b->binstart, b->mailpath); } s_fclose(newf); if (b->binstart) writelines(); //Neuen Binstart speichern if (b->bytes) { if (old_usermail || gleichesboard) nummer = appenddirlist(1); else nummer = appenddirlist(0); //change old CHECKLINE if (b->usermail) { add_fwdfile("", get_fdelay(b->herkunft), 0); sprintf(b->line, "%s %lu", b->herkunft, nummer); mbtalk("\001", b->zielboard, b->line); trigger_ufwd(b->zielboard); } else { handle fh; char found; if (old_usermail) add_fwdfile("", get_fdelay(b->herkunft), 0); else add_fwdfile("", get_fdelay(b->herkunft), 1); if (findex > 0) tree[findex - 1].newestmail = oldmsgtime; if ((fh = s_open(CHECKNAME, "sr+b")) != EOF) { seek_fname(fh, b->mailfname, &found, 1); long pos = ltell(fh); if (found) { _read(fh, b->line, BLEN); sprintf(b->line + 15, "%-8s", b->boardname); b->line[23] = '~'; #ifdef USERLT char nlt[4]; sprintf(nlt, "%3.3d", b->boardlife_max); memcpy(b->line + 51, nlt, 3); #endif lseek(fh, -(LBLEN), SEEK_CUR); _write(fh, b->line, BLEN); } s_close(fh); if (found && (fh = s_open(CHECKNUMNAME, "sr+b")) != EOF) { lseek(fh, 2*(pos >> 6), SEEK_SET); //2* da 32bit! _write(fh, &nummer, 4); // 4Byte=32 bit s_close(fh); } } else trace(serious, name, "check"); } inc_mailgot(b->boardname); writemailflags(); retwert = OK;
void ModelRenderer::GenTangents(const CModelDefPtr& mdef, std::vector<float>& newVertices, bool gpuSkinning) { MikkTSpace ms(mdef, newVertices, gpuSkinning); ms.generate(); }
int main() { try { symbol k("k"),q("q"),p("p"),p1("p1"),p2("p2"),p3("p3"),ms("ms"),l("l"),s("s"),m1s("m1s"),m2s("m2s"),m3s("m3s"); symbol l1("l1"),l2("l2"),l3("l3"),l4("l4"),t("t"),p4("p4"),p5("p5"),tp("tp"),v1("v1"),v2("v2"),l5("l5"); symbol k1("k1"),k2("k2"),k3("k3"),k4("k4"),k5("k5"),ms1("ms1"),ms2("ms2"),ms3("ms3"),ms4("ms4"); // oneloop box // UFXmap l45 = UF(lst(k),lst(pow(k,2),pow(k+p1,2),pow(k+p1+p2,2),pow(k+p1+p2+p3,2)),lst(pow(p1,2)==0,pow(p2,2)==0)); // MBintegral root_int(l45,lst(1,1,1,1),1); //two loop box bubble // UFXmap l45 = UF(lst(k,l),lst(pow(k,2),pow(k+p1,2),pow(k+p1+p2,2),pow(l+p1+p2,2),pow(l+p1+p2+p3,2),pow(l,2),pow(k-l,2)),lst(pow(p1,2)==0,pow(p2,2)==0,pow(p3,2)==0)); //MBintegral root_int(l45,lst(1,1,1,1,1,1,1),2); // B0 // UFXmap l45 = UF(lst(k),lst(ms-pow(k,2),ms-pow(-k,2)),lst(ms==1)); // MBintegral root_int(l45,lst(1,1),1); // 2 loop sunrise //UFXmap l45 = UF(lst(k,q),lst(ms-pow(k,2),ms-pow(-q-k,2),ms-pow(q,2)),lst(ms==1)); //MBintegral root_int(l45,lst(1,1,1),2); //RoMB_planar box2loop(lst(k,l),lst(pow(k,2),pow(k+p1,2),pow(k+p1+p2,2),pow(l+p1+p2,2),pow(l+p1+p2+p3,2),pow(l,2),pow(k-l,2)),lst(pow(p1,2)==0,pow(p2,2)==0,pow(p3,2)==0),lst(1,1,1,1,1,1,1),2); // RoMB_planar box1loop(lst(k),lst(pow(k,2),pow(k+p1,2)-ms,pow(k+p1+p2,2),pow(k+p1+p2+p3,2)),lst(pow(p1,2)==0,pow(p2,2)==0,pow(p3,2)==0,p1==0,p2==0,p3==0,ms==1),lst(1,1,1,1),1); // RoMB_planar B0_1loop(lst(k),lst(pow(k,2)-ms,pow(p+k,2)-ms),lst(ms==0,pow(p,2)==1),lst(1,1),1); // RoMB_planar C0_1loop(lst(k),lst(pow(k,2)-ms,pow(p1+k,2)-ms,pow(p1+p2+k,2)),lst(ms==1,pow(p1,2)==0,pow(p2,2)==0,p1*p2==50),lst(1,1,1),1); //cout<<" new point "<<endl<<root_int.new_point()<<endl; // cout<<" saved point "<<endl<<root_int.get_point()<<endl; // MBcontinue(root_int); //cout<<MB_lst(l45,lst(1,1,1,1),1).expand()<<endl; // RoMB_loop_by_loop box2loop(lst(k,l),lst(pow(k,2),pow(k+p1,2),pow(k+p1+p2,2),pow(l+p1+p2,2),pow(l+p1+p2+p3,2),pow(l,2),pow(k-l,2)),lst(pow(p1,2)==0,pow(p2,2)==0,pow(p3,2)==0),lst(1,1,1,1,1,1,1)); // RoMB_loop_by_loop t2(lst(k,l), lst(pow(k,2),pow(p+k,2),pow(p+k+l,2),pow(l,2),pow(k+l,2)),lst(pow(p,2)==1),lst(1,1,1,1,1)); // works!!! // RoMB_loop_by_loop sunset(lst(k,l), lst(pow(k,2)-1,pow(p-k-l,2)-4,pow(l,2)-5),lst(pow(p,2)==s),lst(1,1,1)); // RoMB_loop_by_loop sunset(lst(k,l), lst(pow(k,2)-m1s,pow(-k-l,2)-m2s,pow(l,2)-m3s),lst(pow(p,2)==s),lst(1,1,1)); // sunset.integrate(lst(m1s==1,m2s==1,m3s==1,s==0),0); // bubble sunset 2=loop // RoMB_loop_by_loop sunset_bub(lst(k,l), lst(-pow(k,2)+ms,-pow(-k-l,2)+ms,-pow(l,2)+ms),lst(pow(p,2)==0),lst(1,1,1)); // sunset_bub.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),1); // bubble sunset 3=loop //#define TOPO 1 //#if TOPO==1 /****************************************************************** * FRESULT for parameters: {ms==1,m2s==1,m3s==1,s==0} * * FRESULT anl : = 21.308685443306456902+23/3*eps^(-2)+2*eps^(-3)+35/2*eps^(-1) * FRESULT num: = 21.308685443306456902+(7.6666666666666666665)*eps^(-2)+(2.0)*eps^(-3)+(17.5)*eps^(-1) * eps^-3 term: 2 +/- 0 * eps^-2 term: 23/3 +/- 0 * eps^-1 term: 35/2 +/- 0 * eps^0 term: 21.308685443306456902 +/- 0.01814768000077260732 ***************************************************************/ // RoMB_loop_by_loop sunset_bub(lst(p,k,l), lst(-pow(p,2)+ms,-pow(k,2)+ms,-pow(l,2)+ms,-pow(-p-k-l,2)+ms),lst(pow(l3,2)==s),lst(1,1,1,1)); // sunset_bub.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),1); //#elif TOPO==2 // RoMB_loop_by_loop sunset_bub_d(lst(l1,l2,l3), lst(-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l3,2)+ms,-pow(l1+l2,2)+ms,-pow(l1+l2+l3,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1)); // sunset_bub_d.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),1); //#elif TOPO==3 // RoMB_loop_by_loop sunset_bub_e(lst(l1,l2,l3), lst(-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l3,2)+ms,-pow(l1-l2,2)+ms,-pow(l2-l3,2)+ms,-pow(l3-l1,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1,1)); // sunset_bub_e.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),1); //#endif //bubble 4-loop // RoMB_loop_by_loop sunset_bub(lst(k,l1,l2,l3), lst(-pow(k,2)+ms,-pow(l2,2)+ms,-pow(l1,2)+ms,-pow(l3,2)+ms,-pow(k+l1+l2+l3,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1)); // sunset_bub.integrate(lst(ms==1,m2s==1,m3s==1,s==0),0); #define TOPO 5 #if TOPO==1 //bubble 5-loop /* FRESULT for parameters: {ms==1,m2s==1,m3s==1,s==0} FRESULT anl : = 274.5475357301444122+1247/24*eps^(-3)+6/5*Pi^4+(125.67152533053854918)*eps^(-2)+3*eps^(-5)+33/2*eps^(-4)+(259.98755698571087874)*eps^(-1)-110/3*zeta(3) FRESULT num: = 347.3630251884288798+(51.958333333333333332)*eps^(-3)+(125.67152533053854918)*eps^(-2)+(3.0)*eps^(-5)+(16.5)*eps^(-4)+(259.98755698571087874)*eps^(-1) eps^-5 term: 3 +/- 0 eps^-4 term: 33/2 +/- 0 eps^-3 term: 1247/24 +/- 0 eps^-2 term: 125.67152533053854918 +/- 5.2760713655226570643E-5 eps^-1 term: 259.98755698571087874 +/- 9.888628922902401464E-6 eps^0 term: 274.5475357301444122+6/5*Pi^4-110/3*zeta(3) +/- 0.043609817405085687474 */ RoMB_loop_by_loop sunset_bub5(lst(l3,k,l1,l2,l4), lst(-pow(l3,2)+ms,-pow(k,2)+ms,-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l4,2)+ms,-pow(k+l1+l2+l3+l4,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1,1)); sunset_bub5.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),1); #elif TOPO==2 RoMB_loop_by_loop sunset_bubC2(lst(l1,l2,l3,l4,l5), lst(-pow(l3,2)+ms,-pow(l5,2)+ms,-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l4,2)+ms,-pow(l5+l1+l2,2)+ms,-pow(l5+l3+l4,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1,1,1)); sunset_bubC2.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),0); // RoMB_loop_by_loop sunset_bubC2(lst(l1,l2,l3,l4,l5), lst(-pow(l3,2)+ms,-pow(l5,2)+ms,-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l4,2)+ms,-pow(l3+l4+l5,2)+ms,-pow(l1+l2+l5+l3+l4,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1,1,1)); // sunset_bubC2.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),0); // RoMB_loop_by_loop sunset_bubC1(lst(l1,l2,l3,l4,l5), lst(-pow(l3,2)+ms,-pow(l5,2)+ms,-pow(l1,2)+ms,-pow(l2,2)+ms,-pow(l4,2)+ms,-pow(l2+l3+l4+l5,2)+ms,-pow(l1+l2+l5+l3+l4,2)+ms),lst(pow(p,2)==s),lst(1,1,1,1,1,1,1),true); // sunset_bubC1.integrate_map(lst(ms==1,m2s==1,m3s==1,s==0),0); /* MEGA 5-LOOP BUBBLE with 12 propagators */ //RoMB_loop_by_loop l5p12(lst(k5,k2,k1,k4,k3),lst(-pow(k1,2)+ms,-pow(k2,2)+ms,-pow(k3,2)+ms,-pow(k4,2)+ms,-pow(k5,2)+ms, //-pow(k1-k3,2)+ms,-pow(k1-k4,2)+ms,-pow(k3-k2,2)+ms,-pow(k2-k4,2)+ms,-pow(k5+k3-k1,2)+ms,-pow(k5+k3-k2,2)+ms,-pow(k5+k3-k4,2)+ms),lst(pow(p,2)==0),lst(1,1,1,1,1,1,1,1,1,1,1,1)); //l5p12.integrate(lst(ms==0),0); #elif TOPO==3 /* FRESULT for parameters: {ms==1} FRESULT anl : = 1/5400*eps^(-2)*(-1540485.6006392892897+233937*zeta(3)-1505*Pi^4+6656*Pi^2)-1/10*(233.57451266786976057+Pi^2)*eps^(-4)-1/4*eps^(-6)+1/216000*eps^(-1)*(-7.391571256935002719E7+37697940*zeta(3)-40800*zeta(3)*Pi^2-727494*Pi^4+12801600*zeta(5)-1399535*Pi^2)-(3.7800000113486752996)*eps^(-5)+1/1200*(-100893.525326654920406+5280*zeta(3)-349*Pi^2)*eps^(-3) FRESULT num: = -(465.22101564968708165)*eps^(-1)-(0.25)*eps^(-6)-(24.344411706895911919)*eps^(-4)-(3.7800000113486752996)*eps^(-5)-(81.65929734496037395)*eps^(-3)-(248.18307592543818119)*eps^(-2) eps^-6 term: -1/4 +/- 0 eps^-5 term: -3.7800000113486752996 +/- 3.2541102943124789963E-10 eps^-4 term: -23.357451266786976057-1/10*Pi^2 +/- 2.7206664064692618508E-5 eps^-3 term: -84.07793777221243367+22/5*zeta(3)-349/1200*Pi^2 +/- 1.5019954980075151021E-4 eps^-2 term: -285.2751112294980166+25993/600*zeta(3)-301/1080*Pi^4+832/675*Pi^2 +/- 0.00206337770109377918 eps^-1 term: -342.20237300625012586+69811/400*zeta(3)-17/90*zeta(3)*Pi^2-121249/36000*Pi^4+889/15*zeta(5)-279907/43200*Pi^2 +/- 6.187359464224749039 */ RoMB_loop_by_loop l5c1(lst(k2,k5,k3,k4,k1),lst(-pow(k3,2)+ms,-pow(k2,2)+ms,-pow(k1,2)+ms,-pow(k4,2)+ms,-pow(k5,2)+ms, -pow(k1+k3+k4,2)+ms,-pow(k2+k5-k3-k4,2)+ms),lst(pow(p,2)==0),lst(1,1,1,1,1,1,1)); l5c1.integrate_map(lst(ms==1),0); #elif TOPO==4 // point in 2 RoMB_loop_by_loop l5c1(lst(k2,k5,k3,k4,k1),lst(-pow(k3,2)+ms,-pow(k2,2)+ms,-pow(k1,2)+ms,-pow(k4,2)+ms,-pow(k5,2)+ms, -pow(k1+k3+k4,2)+ms,-pow(k2+k5-k3-k4,2)+ms),lst(pow(p,2)==0),lst(1,2,1,1,1,1,1)); l5c1.integrate_map(lst(ms==1),0); #elif TOPO==5 // point in 1 RoMB_loop_by_loop l5c1(lst(k2,k5,k3,k4,k1),lst(-pow(k3,2)+ms,-pow(k2,2)+ms,-pow(k1,2)+ms,-pow(k4,2)+ms,-pow(k5,2)+ms, -pow(k1+k3+k4,2)+ms,-pow(k2+k5-k3-k4,2)+ms),lst(pow(p,2)==0),lst(2,1,1,1,1,1,1)); l5c1.integrate_map(lst(ms==1),0); #endif // RoMB_loop_by_loop t2loop(lst(l,k), lst(-pow(k,2)+ms,-pow(p+k,2)+ms,-pow(p+k+l,2)+ms,-pow(k+l,2)+ms,-pow(l,2)+ms),lst(pow(p,2)==s,ms==0),lst(1,1,1,1,1)); //t2loop.integrate_map(lst(s==-1,ms == 0),3); /* RoMB_loop_by_loop bubble_five_loop(lst(k,l1,l2,l3,l4), lst(pow(k,2)-ms,pow(l1,2)-ms,pow(l2,2)-ms,pow(l3,2)-ms,pow(l4,2)-ms,pow(k+l1,2)-ms,pow(k+l1+l2,2)-ms,pow(k+l1+l2+l3,2)-ms,pow(k+l1+l2+l3+l4,2)-ms,pow(k+l1+l2+l3,2)-ms,pow(k+l1+l2,2)-ms,pow(k+l1,2)-ms), lst(ms==1), lst(1,1,1,1,1,1,1,1,1,1,1,1)); */ // works!!! // RoMB_loop_by_loop B0_1loop_lbl(lst(k),lst(pow(k,2)-2-ms,pow(p+k,2)-ms),lst(ms==0,pow(p,2)==1),lst(2,1)); // RoMB_loop_by_loop B0_1loop_lbl(lst(k),lst(pow(k,2)-m1s,pow(p+k,2)-m2s),lst(pow(p,2)==s),lst(1,1)); // B0_1loop_lbl.integrate(lst(s==-1,m1s==1,m2s==1)); //MB works??? // RoMB_loop_by_loop C0_1loop_lbl(lst(k),lst(pow(k,2),pow(k+p1,2)-m1s,pow(k-p2,2)-m2s),lst(ms==1,pow(p1,2)==m1s,pow(p2,2)==m2s,p1*p2==(s-m1s-m2s)/2),lst(1,1,1)); // C0_1loop_lbl.integrate(lst(m1s==1,m2s==1,s==-100)); //MB works??? /* RoMB_loop_by_loop box1loopm0(lst(k),lst(-pow(k,2),-pow(k+p1,2),-pow(k+p1+p2,2),-pow(k+p1+p2+p4,2)), lst(pow(p1,2)==0,pow(p2,2)==0,pow(p4,2)==0, p1*p2==-s/2,// p1*p4==s/2+t/2,// p2*p4==-t/2 // ), lst(1,1,1,1),false); box1loopm0.integrate_map(lst(s==3,t==1)); box1loopm0.integrate(lst(s==5,t==2)); */ //MASIVE BOX LBL /* RoMB_loop_by_loop box1loopm(lst(k),lst(-pow(k,2)+ms,-pow(k+p1,2)+ms,-pow(k+p1+p2,2)+ms,-pow(k+p1+p2+p4,2)+ms), lst(pow(p1,2)==0,pow(p2,2)==0,pow(p4,2)==0, p1*p2==-s/2,// p1*p4==(s/2+t/2),// p2*p4==-t/2 // ), lst(1,1,1,1),false); box1loopm.integrate_map(lst(ms1==1,ms2==1,ms3==1,ms4==1,ms==1,s==30,t==5)); */ //triple box /* RoMB_loop_by_loop tribox1loopm(lst(k1,k2,k3),lst(-pow(k1,2)+ms,-pow(k1+p1,2),-pow(k1+p1+p2,2)+ms, -pow(k1-k2,2),-pow(k2,2)+ms,-pow(k2+p1+p2,2)+ms, -pow(k2-k3,2),-pow(k3,2)+ms,-pow(k3+p1+p2,2)+ms, -pow(k3-p3,2)), lst(pow(p1,2)==ms,pow(p2,2)==ms,pow(p3,2)==ms,pow(p4,2)==ms, p1*p2==s/2-ms,// p1*p3==t/2-ms,// p2*p3==ms-(s+t)/2 // ), lst(1,1,1,1,1,1,1,1,1,1),true); tribox1loopm.integrate_map(lst(ms1==1,ms2==1,ms3==1,ms4==1,ms==1,s==-1/2,t==-3)); */ //double box /* RoMB_loop_by_loop dobox1loopm(lst(k1,k2),lst(-pow(k1,2),-pow(k1+p1,2),-pow(k1+p1+p2,2), -pow(k1-k2,2),-pow(k2,2),-pow(k2+p1+p2,2), -pow(k2-p3,2)), lst(pow(p1,2)==0,pow(p2,2)==0,pow(p3,2)==0,pow(p4,2)==0, p1*p2==s/2,// p1*p3==t/2,// p2*p3==-(s+t)/2 // ), lst(1,1,1,1,1,1,1),true); dobox1loopm.integrate_map(lst(ms1==1,ms2==1,ms3==1,ms4==1,ms==1,s==-1/2,t==-3)); */ /* 4-loop tadpole */ /* RoMB_loop_by_loop tad4(lst(l1, l2, l3, l4),lst(-pow(l1,2)+ ms,-pow(l2,2)+ ms,-pow(l3 ,2)+ ms,-pow(l4,2),-pow(l1+l2+l3+l4,2)),lst(),lst(1,1,1,1,1)); tad4.integrate_map(lst(ms == 1),1); */ /* Pentagon */ /* RoMB_loop_by_loop pent(lst(k1),lst(-pow(p1 + k1,2)+ ms,-pow(p1 + p5 + k1,2), -pow(p1 + p5 + p4 + k1,2)+ ms,-pow(p1 + p5 + p4 + p3 + k1,2)+ ms, -pow(k1,2)), lst( p1*p1 == ms, p2*p2 == ms, p3*p3 == 0, p4*p4 == ms, p5*p5 == ms, p1*p2 == 1/2* (tp - 2* ms), p1*p3 == 1/2* (t - tp - v1), p1*p4 == ms - 1/2* (s + t - v1), p1*p5 == 1/2* (s - 2* ms), p2* p3 == 1/2* v1, p2* p4 == 1/2* (s - 2* ms - v1 - v2), p2* p5 == ms - 1/2* (s + tp - v2), p3* p4 == 1/2* v2, p3* p5 == 1/2* (tp - t - v2), p4* p5 == 1/2* (t - 2* ms)), lst(1,1,1,1,1)); pent.integrate_map(lst(s==-2,t==-3,v2==-4,tp==-5,v1==-6,ms==1)); */ /* RoMB_loop_by_loop pent(lst(k1),lst(-pow(p1 + k1,2)+ ms,-pow(p1 + p5 + k1,2), -pow(p1 + p5 + p4 + k1,2)+ ms,-pow(p1 + p5 + p4 + p3 + k1,2)+ ms, -pow(k1,2)), lst( p1*p1 == ms, p2*p2 == ms, p3*p3 == 0, p4*p4 == ms, p5*p5 == ms, p1*p2 == 1/2* (tp - 2* ms), wild(1)*p1*p3 == wild(1)*1/2* (t - tp - v1), wild(2)*p1*p4 == wild(2)*(ms - 1/2* (s + t - v1)), wild(3)* p1*p5 == wild(3)*1/2* (s - 2* ms), wild(4)*p2* p3 == wild(4)*1/2* v1, wild(5)*p2* p4 == wild(5)*1/2* (s - 2* ms - v1 - v2), wild(6)*p2* p5 ==wild(6)*( ms - 1/2* (s + tp - v2)), wild(7)*p3* p4 == wild(7)*1/2* v2, wild(8)*p3* p5 == wild(8)*1/2* (tp - t - v2), wild()*p4* p5 == wild()*1/2* (t - 2* ms)), lst(1,1,1,1,1)); pent.integrate_map(lst(s==-2,t==-3,v2==-4,tp==-5,v1==-6,ms==1)); */ } catch(std::exception &p) { std::cerr<<"******************************************************************"<<endl; std::cerr<<" >>>ERROR: "<<p.what()<<endl; std::cerr<<"******************************************************************"<<endl; return 1; } return 0; }
void run() { Client::WriteContext ctx(&_txn, ns()); Database* db = ctx.ctx().db(); Collection* coll = db->getCollection(&_txn, ns()); if (!coll) { WriteUnitOfWork wuow(&_txn); coll = db->createCollection(&_txn, ns()); wuow.commit(); } WorkingSet ws; // Sort by foo:1 MergeSortStageParams msparams; msparams.pattern = BSON("foo" << 1); auto_ptr<MergeSortStage> ms(new MergeSortStage(msparams, &ws, coll)); IndexScanParams params; params.bounds.isSimpleRange = true; params.bounds.startKey = objWithMinKey(1); params.bounds.endKey = objWithMaxKey(1); params.bounds.endKeyInclusive = true; params.direction = 1; // Index 'a'+i has foo equal to 'i'. int numIndices = 20; for (int i = 0; i < numIndices; ++i) { // 'a', 'b', ... string index(1, 'a' + i); insert(BSON(index << 1 << "foo" << i)); BSONObj indexSpec = BSON(index << 1 << "foo" << 1); addIndex(indexSpec); params.descriptor = getIndex(indexSpec, coll); ms->addChild(new IndexScan(&_txn, params, &ws, NULL)); } set<RecordId> locs; getLocs(&locs, coll); set<RecordId>::iterator it = locs.begin(); // Get 10 results. Should be getting results in order of 'locs'. int count = 0; while (!ms->isEOF() && count < 10) { WorkingSetID id = WorkingSet::INVALID_ID; PlanStage::StageState status = ms->work(&id); if (PlanStage::ADVANCED != status) { continue; } WorkingSetMember* member = ws.get(id); ASSERT_EQUALS(member->loc, *it); BSONElement elt; string index(1, 'a' + count); ASSERT(member->getFieldDotted(index, &elt)); ASSERT_EQUALS(1, elt.numberInt()); ASSERT(member->getFieldDotted("foo", &elt)); ASSERT_EQUALS(count, elt.numberInt()); ++count; ++it; } // Invalidate locs[11]. Should force a fetch. We don't get it back. ms->saveState(); ms->invalidate(&_txn, *it, INVALIDATION_DELETION); ms->restoreState(&_txn); // Make sure locs[11] was fetched for us. { // TODO: If we have "return upon invalidation" ever triggerable, do the following test. /* WorkingSetID id = WorkingSet::INVALID_ID; PlanStage::StageState status; do { status = ms->work(&id); } while (PlanStage::ADVANCED != status); WorkingSetMember* member = ws.get(id); ASSERT(!member->hasLoc()); ASSERT(member->hasObj()); string index(1, 'a' + count); BSONElement elt; ASSERT_TRUE(member->getFieldDotted(index, &elt)); ASSERT_EQUALS(1, elt.numberInt()); ASSERT(member->getFieldDotted("foo", &elt)); ASSERT_EQUALS(count, elt.numberInt()); */ ++it; ++count; } // And get the rest. while (!ms->isEOF()) { WorkingSetID id = WorkingSet::INVALID_ID; PlanStage::StageState status = ms->work(&id); if (PlanStage::ADVANCED != status) { continue; } WorkingSetMember* member = ws.get(id); ASSERT_EQUALS(member->loc, *it); BSONElement elt; string index(1, 'a' + count); ASSERT_TRUE(member->getFieldDotted(index, &elt)); ASSERT_EQUALS(1, elt.numberInt()); ASSERT(member->getFieldDotted("foo", &elt)); ASSERT_EQUALS(count, elt.numberInt()); ++count; ++it; } }
NATRON_NAMESPACE_ENTER // those parameters should be ignored (they are always secret in Natron) #define kOCIOParamInputSpace "ocioInputSpace" #define kOCIOParamOutputSpace "ocioOutputSpace" // those parameters should not have their options in the help file if generating markdown, // because the options are dinamlically constructed at run-time from the OCIO config. #define kOCIOParamInputSpaceChoice "ocioInputSpaceIndex" #define kOCIOParamOutputSpaceChoice "ocioOutputSpaceIndex" #define kOCIODisplayPluginIdentifier "fr.inria.openfx.OCIODisplay" #define kOCIODisplayParamDisplay "display" #define kOCIODisplayParamDisplayChoice "displayIndex" #define kOCIODisplayParamView "view" #define kOCIODisplayParamViewChoice "viewIndex" // not yet implemented (see OCIOCDLTransform.cpp) //#define kOCIOCDLTransformPluginIdentifier "fr.inria.openfx.OCIOCDLTransform" //#define kOCIOCDLTransformParamCCCID "cccId" //#define kOCIOCDLTransformParamCCCIDChoice "cccIdIndex" #define kOCIOFileTransformPluginIdentifier "fr.inria.openfx.OCIOFileTransform" #define kOCIOFileTransformParamCCCID "cccId" #define kOCIOFileTransformParamCCCIDChoice "cccIdIndex" // genHTML: true for live HTML output for the internal web-server, false for markdown output QString Node::makeDocumentation(bool genHTML) const { QString ret; QString markdown; QTextStream ts(&ret); QTextStream ms(&markdown); QString pluginID, pluginLabel, pluginDescription, pluginIcon; int majorVersion = getMajorVersion(); int minorVersion = getMinorVersion(); std::vector<std::string> pluginGroup; bool pluginDescriptionIsMarkdown = false; QVector<QStringList> inputs; QVector<QStringList> items; { PluginPtr plugin = getPlugin(); assert(plugin); pluginID = QString::fromUtf8(plugin->getPluginID().c_str()); pluginLabel = QString::fromUtf8( Plugin::makeLabelWithoutSuffix( plugin->getPluginLabel() ).c_str()); pluginDescription = QString::fromUtf8( plugin->getPropertyUnsafe<std::string>(kNatronPluginPropDescription).c_str() ); pluginIcon = QString::fromUtf8(plugin->getPropertyUnsafe<std::string>(kNatronPluginPropIconFilePath).c_str()); pluginGroup = plugin->getPropertyNUnsafe<std::string>(kNatronPluginPropGrouping); pluginDescriptionIsMarkdown = plugin->getPropertyUnsafe<bool>(kNatronPluginPropDescriptionIsMarkdown); for (int i = 0; i < _imp->effect->getNInputs(); ++i) { QStringList input; input << convertFromPlainTextToMarkdown( QString::fromStdString( getInputLabel(i) ), genHTML, true ); input << convertFromPlainTextToMarkdown( QString::fromStdString( getInputHint(i) ), genHTML, true ); input << ( isInputOptional(i) ? tr("Yes") : tr("No") ); inputs.push_back(input); // Don't show more than doc for 4 inputs otherwise it will just clutter the page if (i == 3) { break; } } } // check for plugin icon QString pluginIconUrl; if ( !pluginIcon.isEmpty() ) { QFile iconFile(pluginIcon); if ( iconFile.exists() ) { if (genHTML) { pluginIconUrl.append( QString::fromUtf8("/LOCAL_FILE/") ); pluginIconUrl.append(pluginIcon); pluginIconUrl.replace( QString::fromUtf8("\\"), QString::fromUtf8("/") ); } else { pluginIconUrl.append(pluginID); pluginIconUrl.append(QString::fromUtf8(".png")); } } } // check for extra markdown file QString extraMarkdown; QString pluginMD = pluginIcon; pluginMD.replace( QString::fromUtf8(".png"), QString::fromUtf8(".md") ); QFile pluginMarkdownFile(pluginMD); if ( pluginMarkdownFile.exists() ) { if ( pluginMarkdownFile.open(QIODevice::ReadOnly | QIODevice::Text) ) { extraMarkdown = QString::fromUtf8( pluginMarkdownFile.readAll() ); pluginMarkdownFile.close(); } } // generate knobs info KnobsVec knobs = getEffectInstance()->getKnobs_mt_safe(); for (KnobsVec::const_iterator it = knobs.begin(); it != knobs.end(); ++it) { #pragma message WARN("TODO: restore getDefaultIsSecret from RB-2.2") //if ( (*it)->getDefaultIsSecret() ) { if ( (*it)->getIsSecret() ) { continue; } if ((*it)->getKnobDeclarationType() != KnobI::eKnobDeclarationTypePlugin) { continue; } // do not escape characters in the scriptName, since it will be put between backquotes QString knobScriptName = /*NATRON_NAMESPACE::convertFromPlainTextToMarkdown(*/ QString::fromUtf8( (*it)->getName().c_str() )/*, genHTML, true)*/; QString knobLabel = NATRON_NAMESPACE::convertFromPlainTextToMarkdown( QString::fromUtf8( (*it)->getLabel().c_str() ), genHTML, true); QString knobHint = NATRON_NAMESPACE::convertFromPlainTextToMarkdown( QString::fromUtf8( (*it)->getHintToolTip().c_str() ), genHTML, true); // totally ignore the documentation for these parameters (which are always secret in Natron) if ( knobScriptName.startsWith( QString::fromUtf8("NatronOfxParam") ) || knobScriptName == QString::fromUtf8("exportAsPyPlug") || knobScriptName == QString::fromUtf8(kOCIOParamInputSpace) || knobScriptName == QString::fromUtf8(kOCIOParamOutputSpace) || ( ( pluginID == QString::fromUtf8(kOCIODisplayPluginIdentifier) ) && ( knobScriptName == QString::fromUtf8(kOCIODisplayParamDisplay) ) ) || ( ( pluginID == QString::fromUtf8(kOCIODisplayPluginIdentifier) ) && ( knobScriptName == QString::fromUtf8(kOCIODisplayParamView) ) ) || //( ( pluginID == QString::fromUtf8(kOCIOCDLTransformPluginIdentifier) ) && // ( knobScriptName == QString::fromUtf8(kOCIOCDLTransformParamCCCID) ) ) || ( ( pluginID == QString::fromUtf8(kOCIOFileTransformPluginIdentifier) ) && ( knobScriptName == QString::fromUtf8(kOCIOFileTransformParamCCCID) ) ) || false) { continue; } QString defValuesStr, knobType; std::vector<std::pair<QString, QString> > dimsDefaultValueStr; KnobIntPtr isInt = toKnobInt(*it); KnobChoicePtr isChoice = toKnobChoice(*it); KnobBoolPtr isBool = toKnobBool(*it); KnobDoublePtr isDbl = toKnobDouble(*it); KnobStringPtr isString = toKnobString(*it); bool isLabel = isString && isString->isLabel(); KnobSeparatorPtr isSep = toKnobSeparator(*it); KnobButtonPtr isBtn = toKnobButton(*it); KnobParametricPtr isParametric = toKnobParametric(*it); KnobGroupPtr isGroup = toKnobGroup(*it); KnobPagePtr isPage = toKnobPage(*it); KnobColorPtr isColor = toKnobColor(*it); if (isInt) { knobType = tr("Integer"); } else if (isChoice) { knobType = tr("Choice"); } else if (isBool) { knobType = tr("Boolean"); } else if (isDbl) { knobType = tr("Double"); } else if (isString) { if (isLabel) { knobType = tr("Label"); } else { knobType = tr("String"); } } else if (isSep) { knobType = tr("Separator"); } else if (isBtn) { knobType = tr("Button"); } else if (isParametric) { knobType = tr("Parametric"); } else if (isGroup) { knobType = tr("Group"); } else if (isPage) { knobType = tr("Page"); } else if (isColor) { knobType = tr("Color"); } else { knobType = tr("N/A"); } if (!isGroup && !isPage) { for (int i = 0; i < (*it)->getNDimensions(); ++i) { QString valueStr; if (!isBtn && !isSep && !isParametric) { // If this is a ChoiceParam and we are not generating live HTML doc, // only add the list of entries and their halp if this node should not be // ignored (eg. OCIO colorspace knobs). if ( isChoice && (genHTML || !( knobScriptName == QString::fromUtf8(kOCIOParamInputSpaceChoice) || knobScriptName == QString::fromUtf8(kOCIOParamOutputSpaceChoice) || ( ( pluginID == QString::fromUtf8(kOCIODisplayPluginIdentifier) ) && ( knobScriptName == QString::fromUtf8(kOCIODisplayParamDisplayChoice) ) ) || ( ( pluginID == QString::fromUtf8(kOCIODisplayPluginIdentifier) ) && ( knobScriptName == QString::fromUtf8(kOCIODisplayParamViewChoice) ) ) || //( ( pluginID == QString::fromUtf8(kOCIOCDLTransformPluginIdentifier) ) && // ( knobScriptName == QString::fromUtf8(kOCIOCDLTransformParamCCCIDChoice) ) ) || ( ( pluginID == QString::fromUtf8(kOCIOFileTransformPluginIdentifier) ) && ( knobScriptName == QString::fromUtf8(kOCIOFileTransformParamCCCIDChoice) ) ) || ( ( pluginID == QString::fromUtf8("net.fxarena.openfx.Text") ) && ( knobScriptName == QString::fromUtf8("name") ) ) || // font family from Text plugin ( ( pluginID == QString::fromUtf8("net.fxarena.openfx.Polaroid") ) && ( knobScriptName == QString::fromUtf8("font") ) ) || // font family from Polaroid plugin ( ( pluginID == QString::fromUtf8(PLUGINID_NATRON_PRECOMP) ) && ( knobScriptName == QString::fromUtf8("writeNode") ) ) || ( ( pluginID == QString::fromUtf8(PLUGINID_NATRON_ONEVIEW) ) && ( knobScriptName == QString::fromUtf8("view") ) ) ) ) ) { // see also KnobChoice::getHintToolTipFull() int index = isChoice->getDefaultValue(DimIdx(i)); std::vector<ChoiceOption> entries = isChoice->getEntries(); if ( (index >= 0) && ( index < (int)entries.size() ) ) { valueStr = QString::fromUtf8( entries[index].id.c_str() ); } bool first = true; for (size_t i = 0; i < entries.size(); i++) { QString entryHelp = QString::fromUtf8( entries[i].tooltip.c_str() ); QString entry; if (entries[i].id != entries[i].label) { entry = QString::fromUtf8( "%1 (%2)" ).arg(QString::fromUtf8( entries[i].label.c_str() )).arg(QString::fromUtf8( entries[i].id.c_str() )); } else { entry = QString::fromUtf8( entries[i].label.c_str() ); } if (!entry.isEmpty()) { if (first) { // empty line before the option descriptions if (genHTML) { if ( !knobHint.isEmpty() ) { knobHint.append( QString::fromUtf8("<br />") ); } knobHint.append( tr("Possible values:") + QString::fromUtf8("<br />") ); } else { // we do a hack for multiline elements, because the markdown->rst conversion by pandoc doesn't use the line block syntax. // what we do here is put a supplementary dot at the beginning of each line, which is then converted to a pipe '|' in the // genStaticDocs.sh script by a simple sed command after converting to RsT if ( !knobHint.isEmpty() ) { if (!knobHint.startsWith( QString::fromUtf8(". ") )) { knobHint.prepend( QString::fromUtf8(". ") ); } knobHint.append( QString::fromUtf8("\\\n") ); } knobHint.append( QString::fromUtf8(". ") + tr("Possible values:") + QString::fromUtf8("\\\n") ); } first = false; } if (genHTML) { knobHint.append( QString::fromUtf8("<br />") ); } else { knobHint.append( QString::fromUtf8("\\\n") ); // we do a hack for multiline elements, because the markdown->rst conversion by pandoc doesn't use the line block syntax. // what we do here is put a supplementary dot at the beginning of each line, which is then converted to a pipe '|' in the // genStaticDocs.sh script by a simple sed command after converting to RsT knobHint.append( QString::fromUtf8(". ") ); } if (entryHelp.isEmpty()) { knobHint.append( QString::fromUtf8("**%1**").arg( convertFromPlainTextToMarkdown(entry, genHTML, true) ) ); } else { knobHint.append( QString::fromUtf8("**%1**: %2").arg( convertFromPlainTextToMarkdown(entry, genHTML, true) ).arg( convertFromPlainTextToMarkdown(entryHelp, genHTML, true) ) ); } } } } else if (isInt) { valueStr = QString::number( isInt->getDefaultValue( DimIdx(i) ) ); } else if (isDbl) { valueStr = QString::number( isDbl->getDefaultValue( DimIdx(i) ) ); } else if (isBool) { valueStr = isBool->getDefaultValue( DimIdx(i) ) ? tr("On") : tr("Off"); } else if (isString) { valueStr = QString::fromUtf8( isString->getDefaultValue( DimIdx(i) ).c_str() ); } else if (isColor) { valueStr = QString::number( isColor->getDefaultValue( DimIdx(i) ) ); } } dimsDefaultValueStr.push_back( std::make_pair(convertFromPlainTextToMarkdown( QString::fromUtf8( (*it)->getDimensionName( DimIdx(i) ).c_str() ), genHTML, true ), convertFromPlainTextToMarkdown(valueStr, genHTML, true)) ); } for (std::size_t i = 0; i < dimsDefaultValueStr.size(); ++i) { if ( !dimsDefaultValueStr[i].second.isEmpty() ) { if (dimsDefaultValueStr.size() > 1) { defValuesStr.append(dimsDefaultValueStr[i].first); defValuesStr.append( QString::fromUtf8(": ") ); } defValuesStr.append(dimsDefaultValueStr[i].second); if (i < dimsDefaultValueStr.size() - 1) { defValuesStr.append( QString::fromUtf8(" ") ); } } } if ( defValuesStr.isEmpty() ) { defValuesStr = tr("N/A"); } } if (!isPage && !isSep && !isGroup && !isLabel) { QStringList row; row << knobLabel << knobScriptName << knobType << defValuesStr << knobHint; items.append(row); } } // for (KnobsVec::const_iterator it = knobs.begin(); it!=knobs.end(); ++it) { // generate plugin info ms << tr("%1 node").arg(pluginLabel) << "\n==========\n\n"; // a hack to avoid repeating the documentation for the various merge plugins if ( pluginID.startsWith( QString::fromUtf8("net.sf.openfx.Merge") ) ) { std::string id = pluginID.toStdString(); std::string op; if (id == PLUGINID_OFX_MERGE) { // do nothing } else if (id == "net.sf.openfx.MergeDifference") { op = "difference (a.k.a. absminus)"; } else if (id == "net.sf.openfx.MergeIn") { op = "in"; } else if (id == "net.sf.openfx.MergeMatte") { op = "matte"; } else if (id == "net.sf.openfx.MergeMax") { op = "max"; } else if (id == "net.sf.openfx.MergeMin") { op = "min"; } else if (id == "net.sf.openfx.MergeMultiply") { op = "multiply"; } else if (id == "net.sf.openfx.MergeOut") { op = "out"; } else if (id == "net.sf.openfx.MergePlus") { op = "plus"; } else if (id == "net.sf.openfx.MergeScreen") { op = "screen"; } if ( !op.empty() ) { // we should use the custom link "[Merge node](|http::/plugins/" PLUGINID_OFX_MERGE ".html||rst::net.sf.openfx.MergePlugin|)" // but pandoc borks it ms << tr("The *%1* node is a convenience node identical to the %2, except that the operator is set to *%3* by default.") .arg(pluginLabel) .arg(genHTML ? QString::fromUtf8("<a href=\"" PLUGINID_OFX_MERGE ".html\">Merge node</a>") : QString::fromUtf8(":ref:`" PLUGINID_OFX_MERGE "`") //QString::fromUtf8("[Merge node](http::/plugins/" PLUGINID_OFX_MERGE ".html)") ) .arg( QString::fromUtf8( op.c_str() ) ); goto OUTPUT; } } if (!pluginIconUrl.isEmpty()) { // add a nonbreaking space so that pandoc doesn't use the alt-text as a caption // http://pandoc.org/MANUAL.html#images ms << "![pluginIcon](" << pluginIconUrl << ")"; if (!genHTML) { // specify image width for pandoc-generated printed doc // (for hoedown-generated HTML, this handled by the CSS using the alt=pluginIcon attribute) // see http://pandoc.org/MANUAL.html#images // note that only % units are understood both by pandox and sphinx ms << "{ width=10% }"; } ms << " \n\n"; // required so that there is no legend when converted to rst by pandoc } ms << tr("*This documentation is for version %2.%3 of %1.*").arg(pluginLabel).arg(majorVersion).arg(minorVersion) << "\n\n"; ms << "\n" << tr("Description") << "\n--------------------------------------------------------------------------------\n\n"; if (!pluginDescriptionIsMarkdown) { if (genHTML) { pluginDescription = NATRON_NAMESPACE::convertFromPlainText(pluginDescription, NATRON_NAMESPACE::WhiteSpaceNormal); // replace URLs with links QRegExp re( QString::fromUtf8("((http|ftp|https)://([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])?)") ); pluginDescription.replace( re, QString::fromUtf8("<a href=\"\\1\">\\1</a>") ); } else { pluginDescription = convertFromPlainTextToMarkdown(pluginDescription, genHTML, false); } } ms << pluginDescription << "\n"; // create markdown table ms << "\n" << tr("Inputs") << "\n--------------------------------------------------------------------------------\n\n"; ms << tr("Input") << " | " << tr("Description") << " | " << tr("Optional") << "\n"; ms << "--- | --- | ---\n"; if (inputs.size() > 0) { Q_FOREACH(const QStringList &input, inputs) { QString inputName = input.at(0); QString inputDesc = input.at(1); QString inputOpt = input.at(2); ms << inputName << " | " << inputDesc << " | " << inputOpt << "\n"; }
bool MainWindow::eventFilter(QObject *o, QEvent *e) { #ifdef WIN32 if (o->inherits("QSizeGrip")){ QSizeGrip *grip = static_cast<QSizeGrip*>(o); QMouseEvent *me; switch (e->type()){ case QEvent::MouseButtonPress: me = static_cast<QMouseEvent*>(e); p = me->globalPos(); s = grip->topLevelWidget()->size(); return true; case QEvent::MouseMove: me = static_cast<QMouseEvent*>(e); if (me->state() != LeftButton) break; QWidget *tlw = grip->topLevelWidget(); QRect rc = tlw->geometry(); if (tlw->testWState(WState_ConfigPending)) break; QPoint np(me->globalPos()); int w = np.x() - p.x() + s.width(); int h = np.y() - p.y() + s.height(); if ( w < 1 ) w = 1; if ( h < 1 ) h = 1; QSize ms(tlw->minimumSizeHint()); ms = ms.expandedTo(minimumSize()); if (w < ms.width()) w = ms.width(); if (h < ms.height()) h = ms.height(); if (!(GetWindowLongA(tlw->winId(), GWL_EXSTYLE) & WS_EX_APPWINDOW)){ int dc = GetSystemMetrics(SM_CYCAPTION); int ds = GetSystemMetrics(SM_CYSMCAPTION); tlw->setGeometry(rc.left(), rc.top() + dc - ds, w, h); }else{ tlw->resize(w, h); } MSG msg; while (PeekMessage(&msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)); return true; } } if (e->type() == QEvent::ChildInserted){ QChildEvent *ce = static_cast<QChildEvent*>(e); if (ce->child()->inherits("QSizeGrip")) ce->child()->installEventFilter(this); } #endif if (e->type() == QEvent::ChildRemoved){ QChildEvent *ce = static_cast<QChildEvent*>(e); list<QWidget*>::iterator it; for (it = statusWidgets.begin(); it != statusWidgets.end(); ++it){ if (*it == ce->child()){ statusWidgets.erase(it); break; } } if (statusWidgets.size() == 0){ statusBar()->hide(); setGrip(); } } return QMainWindow::eventFilter(o, e); }
nsresult nsIconChannel::InitWithGnome(nsIMozIconURI *aIconURI) { nsresult rv; if (NS_FAILED(ensure_libgnomeui()) || NS_FAILED(ensure_libgnome()) || NS_FAILED(ensure_libgnomevfs())) { gTriedToLoadGnomeLibs = true; return NS_ERROR_NOT_AVAILABLE; } gTriedToLoadGnomeLibs = true; if (!_gnome_program_get()) { // Get the brandShortName from the string bundle to pass to GNOME // as the application name. This may be used for things such as // the title of grouped windows in the panel. nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID); NS_ASSERTION(bundleService, "String bundle service must be present!"); nsCOMPtr<nsIStringBundle> bundle; bundleService->CreateBundle("chrome://branding/locale/brand.properties", getter_AddRefs(bundle)); nsAutoString appName; if (bundle) { bundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), getter_Copies(appName)); } else { NS_WARNING("brand.properties not present, using default application name"); appName.Assign(NS_LITERAL_STRING("Gecko")); } char* empty[] = { "" }; _gnome_init(NS_ConvertUTF16toUTF8(appName).get(), "1.0", 1, empty, NULL, 0, NULL); } PRUint32 iconSize = GetIconSize(aIconURI); nsCAutoString type; aIconURI->GetContentType(type); GnomeVFSFileInfo fileInfo = {0}; fileInfo.refcount = 1; // In case some GnomeVFS function addrefs and releases it nsCAutoString spec; nsCOMPtr<nsIURL> url; rv = aIconURI->GetIconURL(getter_AddRefs(url)); if (url) { url->GetAsciiSpec(spec); // Only ask gnome-vfs for a GnomeVFSFileInfo for file: uris, to avoid a // network request bool isFile; if (NS_SUCCEEDED(url->SchemeIs("file", &isFile)) && isFile) { _gnome_vfs_get_file_info(spec.get(), &fileInfo, GNOME_VFS_FILE_INFO_DEFAULT); } else { // The filename we get is UTF-8-compatible, which matches gnome expectations. // See also: http://lists.gnome.org/archives/gnome-vfs-list/2004-March/msg00049.html // "Whenever we can detect the charset used for the URI type we try to // convert it to/from utf8 automatically inside gnome-vfs." // I'll interpret that as "otherwise, this field is random junk". nsCAutoString name; url->GetFileName(name); fileInfo.name = g_strdup(name.get()); if (!type.IsEmpty()) { fileInfo.valid_fields = GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE; fileInfo.mime_type = g_strdup(type.get()); } } } if (type.IsEmpty()) { nsCOMPtr<nsIMIMEService> ms(do_GetService("@mozilla.org/mime;1")); if (ms) { nsCAutoString fileExt; aIconURI->GetFileExtension(fileExt); if (!fileExt.IsEmpty()) { ms->GetTypeFromExtension(fileExt, type); } } } // Get the icon theme if (!gIconTheme) { gIconTheme = _gnome_icon_theme_new(); if (!gIconTheme) { _gnome_vfs_file_info_clear(&fileInfo); return NS_ERROR_NOT_AVAILABLE; } } char* name = _gnome_icon_lookup(gIconTheme, NULL, spec.get(), NULL, &fileInfo, type.get(), GNOME_ICON_LOOKUP_FLAGS_NONE, NULL); _gnome_vfs_file_info_clear(&fileInfo); if (!name) return NS_ERROR_NOT_AVAILABLE; // Get the default theme associated with the screen // Do NOT free. GtkIconTheme *theme = gtk_icon_theme_get_default(); if (!theme) { g_free(name); return NS_ERROR_UNEXPECTED; } GError *err = nullptr; GdkPixbuf* buf = gtk_icon_theme_load_icon(theme, name, iconSize, (GtkIconLookupFlags)0, &err); g_free(name); if (!buf) { if (err) g_error_free(err); return NS_ERROR_UNEXPECTED; } rv = ScaleIconBuf(&buf, iconSize); NS_ENSURE_SUCCESS(rv, rv); rv = moz_gdk_pixbuf_to_channel(buf, aIconURI, getter_AddRefs(mRealChannel)); g_object_unref(buf); return rv; }
void ThumbGenerator::loadFile(QImage& image, const QFileInfo& fi) { static int sequence = 0; if (GalleryUtil::IsMovie(fi.filePath())) { bool thumbnailCreated = false; QDir tmpDir("/tmp/mythgallery"); if (!tmpDir.exists()) { if (!tmpDir.mkdir(tmpDir.absolutePath())) { LOG(VB_GENERAL, LOG_ERR, "Unable to create temp dir for movie thumbnail creation: " + tmpDir.absolutePath()); } } if (tmpDir.exists()) { QString thumbFile = QString("%1.png") .arg(++sequence,8,10,QChar('0')); QString cmd = "mythpreviewgen"; QStringList args; args << logPropagateArgs.split(" ", QString::SkipEmptyParts); args << "--infile" << '"' + fi.absoluteFilePath() + '"'; args << "--outfile" << '"' + tmpDir.filePath(thumbFile) + '"'; MythSystemLegacy ms(cmd, args, kMSRunShell); ms.SetDirectory(tmpDir.absolutePath()); ms.Run(); if (ms.Wait() == GENERIC_EXIT_OK) { QFileInfo thumb(tmpDir.filePath(thumbFile)); if (thumb.exists()) { QImage img(thumb.absoluteFilePath()); image = img; thumbnailCreated = true; } } } if (!thumbnailCreated) { QImage *img = GetMythUI()->LoadScaleImage("gallery-moviethumb.png"); if (img) { image = *img; } } } else { #ifdef EXIF_SUPPORT // Try to get thumbnail from exif data ExifData *ed = exif_data_new_from_file(fi.absoluteFilePath() .toLocal8Bit().constData()); if (ed && ed->data) { image.loadFromData(ed->data, ed->size); } if (ed) exif_data_free(ed); if (image.width() > m_width && image.height() > m_height) return; #endif #ifdef DCRAW_SUPPORT QString extension = fi.suffix(); QSet<QString> dcrawFormats = DcrawFormats::getFormats(); int rotateAngle; if (dcrawFormats.contains(extension) && (rotateAngle = DcrawHandler::loadThumbnail(&image, fi.absoluteFilePath())) != -1 && image.width() > m_width && image.height() > m_height) { if (rotateAngle != 0) { QMatrix matrix; matrix.rotate(rotateAngle); image = image.transformed(matrix); } return; } #endif image.load(fi.absoluteFilePath()); } }
void MyWindow::draw() { int i; if (!valid()) { //Init viewport and projection initGL(); double w = this->w(), h = this->h(); glViewport(0, 0, (int)w, (int)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); double left = -.1; double bottom = -.1; double right = 1.1; double top = 1.1; if(w > 1 && h > 1) { if(w > h) { right = -0.1 + 1.2 * w / h; } if(h > w) { bottom = 1.1 - 1.2 * h / w; } } double scale = 1. / 1000.; left = -w * scale; right = w * scale; bottom = -h * scale; top = h * scale; glFrustum(left, right, bottom, top, 5., 30.); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); //Transform------ Vector3 trans = transform.getTrans(); glTranslated(trans[0], trans[1], -10 + trans[2]); double scale = transform.getScale(); glScaled(scale, scale, scale); Quaternion<> r = transform.getRot(); double ang = r.getAngle(); if(fabs(ang) > 1e-6) { Vector3 ax = r.getAxis(); glRotated(ang * 180. / M_PI, ax[0], ax[1], ax[2]); } //Draw---------- if(floor) drawFloor(); vector<const Mesh *> ms(meshes.size()); for(i = 0; i < (int)meshes.size(); ++i) { ms[i] = &(meshes[i]->getMesh()); } //shadows if(floor) { Vector3 lightRay = transform.getRot().inverse() * Vector3(1, 2, 2); if(lightRay[1] == 0) lightRay[1] = 1e-5; lightRay = -lightRay / lightRay[1]; glDisable(GL_LIGHTING); glColor3f(0.1f, 0.1f, 0.1f); glPushMatrix(); float matr[16] = {1,0,0,0, (float)lightRay[0],0,(float)lightRay[2],0, 0,0,1,0, 0,0.01f,0,1}; glMultMatrixf(matr); glDepthMask(0); for(i = 0; i < (int)ms.size(); ++i) drawMesh(*(ms[i]), flatShading); glDepthMask(1); glEnable(GL_LIGHTING); glPopMatrix(); } static GLfloat colr[4] = {1.f, .9f, .75f, 1.0f }; static GLfloat colrb[4] = {1.f, .9f, .75f, 1.0f }; glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, colr); glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, colrb); //draw meshes for(i = 0; i < (int)meshes.size(); ++i) { drawMesh(*(ms[i]), flatShading); } //draw lines glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); for(i = 0; i < (int)lines.size(); ++i) { glColor3d(lines[i].color[0], lines[i].color[1], lines[i].color[2]); glLineWidth((float)lines[i].thickness); glBegin(GL_LINES); glVertex3d(lines[i].p1[0], lines[i].p1[1], lines[i].p1[2]); glVertex3d(lines[i].p2[0], lines[i].p2[1], lines[i].p2[2]); glEnd(); } if(skeleton) { glLineWidth(5); for(i = 0; i < (int)meshes.size(); ++i) { vector<Vector3> v = meshes[i]->getSkel(); if(v.size() == 0) continue; glColor3d(.5, 0, 0); const vector<int> &prev = human.fPrev(); glBegin(GL_LINES); for(int j = 1; j < (int)prev.size(); ++j) { int k = prev[j]; glVertex3d(v[j][0], v[j][1], v[j][2]); glVertex3d(v[k][0], v[k][1], v[k][2]); } glEnd(); } } }
int SingleSLAM::fastPoseUpdate3D() { propagateFeatureStates(); //get the feature points corresponding to the map points std::vector<Track2DNode*> nodes; int num = getStaticMappedTrackNodes(nodes); if (num < 5) { repErr( "[camera id:%d]intra-camera pose update failed! less than five static map points (%d)", camId, num); return -1; } //choose the feature points for pose estimation std::vector<FeaturePoint*> featPts; int iChoose = chooseStaticFeatPts(featPts); //test logInfo("number of chosen features :%d\n", iChoose); std::vector<FeaturePoint*> mappedFeatPts; std::vector<FeaturePoint*> unmappedFeatPts; mappedFeatPts.reserve(nRowBlk * nColBlk * 2); unmappedFeatPts.reserve(nRowBlk * nColBlk * 2); for (size_t i = 0; i < featPts.size(); i++) { if (featPts[i]->mpt) mappedFeatPts.push_back(featPts[i]); else if (featPts[i]->preFrame) unmappedFeatPts.push_back(featPts[i]); } //get the 2D-3D corresponding points int n3D2Ds = mappedFeatPts.size(); Mat_d ms(n3D2Ds, 2), Ms(n3D2Ds, 3), repErrs(n3D2Ds, 1); for (int i = 0; i < n3D2Ds; i++) { FeaturePoint* fp = mappedFeatPts[i]; ms.data[2 * i] = fp->x; ms.data[2 * i + 1] = fp->y; Ms.data[3 * i] = fp->mpt->x; Ms.data[3 * i + 1] = fp->mpt->y; Ms.data[3 * i + 2] = fp->mpt->z; repErrs.data[i] = fp->reprojErr; } //get the 2D-2D corresponding points int n2D2Ds = unmappedFeatPts.size(); Mat_d ums(n2D2Ds, 2), umspre(n2D2Ds, 2), Rpre(n2D2Ds, 9), tpre(n2D2Ds, 3); for (int i = 0; i < n2D2Ds; i++) { FeaturePoint* fp = unmappedFeatPts[i]; ums.data[2 * i] = fp->x; ums.data[2 * i + 1] = fp->y; //travel back to the frame of the first appearance //while (fp->preFrame) { fp = fp->preFrame; //} assert(fp); umspre.data[2 * i] = fp->x; umspre.data[2 * i + 1] = fp->y; doubleArrCopy(Rpre.data, i, fp->cam->R, 9); doubleArrCopy(tpre.data, i, fp->cam->t, 3); } //estimate the camera pose using both 2D-2D and 3D-2D correspondences double R[9], t[3]; double* cR = m_camPos.current()->R; double* cT = m_camPos.current()->t; // //test // logInfo("==============start of camId:%d=================\n", camId); // logInfo("n3D2D:%d, n2D2D:%d\n", n3D2Ds, n2D2Ds); // // write(K, "/home/tsou/data/K.txt"); // write(cR, 3, 3, "/home/tsou/data/%d_R0.txt", camId); // write(cT, 3, 1, "/home/tsou/data/%d_T0.txt", camId); // write(repErrs, "/home/tsou/data/%d_errs.txt", camId); // write(Ms, "/home/tsou/data/%d_Ms.txt", camId); // write(ms, "/home/tsou/data/%d_ms.txt", camId); // write(Rpre, "/home/tsou/data/%d_Rpre.txt", camId); // write(tpre, "/home/tsou/data/%d_tpre.txt", camId); // write(umspre, "/home/tsou/data/%d_umspre.txt", camId); // write(ums, "/home/tsou/data/%d_ums.txt", camId); // // //test // printMat(3, 3, cR); // printMat(3, 1, cT); IntraCamPoseOption opt; double R_tmp[9], t_tmp[3]; intraCamEstimate(K.data, cR, cT, n3D2Ds, repErrs.data, Ms.data, ms.data, 6, R_tmp, t_tmp, &opt); if (getCameraDistance(R_tmp, t_tmp, Rpre.data, tpre.data) > 1000) { opt.verboseLM = 1; intraCamEstimateEpi(K.data, R_tmp, t_tmp, n3D2Ds, repErrs.data, Ms.data, ms.data, n2D2Ds, 0, Rpre.data, tpre.data, umspre.data, ums.data, 6, R, t, &opt); } else { doubleArrCopy(R, 0, R_tmp, 9); doubleArrCopy(t, 0, t_tmp, 3); } // printMat(3, 3, cR); // printMat(3, 1, cT); // printMat(3, 3, R); // printMat(3, 1, cT); // logInfo("==============end of camId:%d=================\n", camId); // intraCamEstimate(K.data,cR,cT,n3D2Ds, repErrs.data,Ms.data,ms.data,6.0,R,t,&opt); // find outliers int numOut = 0; double rm[2], var[4], ivar[4]; for (int i = 0; i < num; i++) { double* pM = nodes[i]->pt->mpt->M; double* pCov = nodes[i]->pt->mpt->cov; project(K, R, t, pM, rm); getProjectionCovMat(K, R, t, pM, pCov, var, Const::PIXEL_ERR_VAR); mat22Inv(var, ivar); double err = mahaDist2(rm, nodes[i]->pt->m, ivar); if (err < 1) { //inlier nodes[i]->pt->reprojErr = err; seqTriangulate(K, R, t, nodes[i]->pt->m, pM, pCov, Const::PIXEL_ERR_VAR); project(K, R, t, pM, rm); getProjectionCovMat(K, R, t, pM, pCov, var, Const::PIXEL_ERR_VAR); mat22Inv(var, ivar); err = mahaDist2(rm, nodes[i]->pt->m, ivar); if (err >= 1) { nodes[i]->pt->mpt->setFalse(); } } else { //outliers numOut++; double repErr = dist2(rm, nodes[i]->pt->m); nodes[i]->pt->reprojErr = repErr; nodes[i]->pt->mpt->setUncertain(); } } CamPoseItem* camPos = m_camPos.add(currentFrame(), camId, R, t); updateCamParamForFeatPts(K, camPos); return num; }
int confOption::setValueFromFile(QString line) { // Used to set values in confOptions from a file line QString rval = line.section("=",1).trimmed(); qDebug() << "setting " << realName << " to " << rval << " (from file)"; if (type == BOOL) { if (rval == "true" || rval == "on" || rval == "yes") { value = true; return 0; } else if (rval == "false" || rval == "off" || rval == "no") { value = false; return 0; } qDebug() << rval << "is not a valid value for setting" << realName << ". Ignoring..."; return -1; } else if (type == INTEGER) { bool ok; qlonglong rvalToNmbr = rval.toLongLong(&ok); if (ok && rvalToNmbr >= minVal && rvalToNmbr <= maxVal) { value = rvalToNmbr; return 0; } qDebug() << rval << "is not a valid value for setting" << realName << ". Ignoring..."; return -1; } else if (type == STRING) { value = rval; return 0; } else if (type == LIST) { if (realName == "ShowStatus") // ShowStatus needs special treatment { if (rval.toLower() == "true" || rval.toLower() == "on") rval = "yes"; else if (rval.toLower() == "false" || rval.toLower() == "off") rval = "no"; } if (possibleVals.contains(rval)) { value = rval.toLower(); return 0; } qDebug() << rval << "is not a valid value for setting" << realName << ". Ignoring..."; value = defVal; return -1; } else if (type == MULTILIST) { QVariantMap map; QStringList readList = rval.split(" ", QString::SkipEmptyParts); for (int i = 0; i < readList.size(); ++i) { if (!possibleVals.contains(readList.at(i))) { qDebug() << rval << "is not a valid value for setting" << realName << ". Ignoring..."; return -1; } } for (int i = 0; i < possibleVals.size(); ++i) { if (readList.contains(possibleVals.at(i))) map[possibleVals.at(i)] = true; else map[possibleVals.at(i)] = false; } value = map; return 0; } else if (type == TIME) { int pos = 0; QRegExp rxValid; // These regex check whether rval is a valid time interval if (hasNsec) rxValid = QRegExp("^(?:\\d*\\.?\\d *(ns|nsec|us|usec|ms|msec|s|sec|second|seconds|m|min|minute|minutes|h|hr|hour|hours|d|day|days|w|week|weeks|month|months|y|year|years)? *)+$"); else rxValid = QRegExp("^(?:\\d*\\.?\\d *(us|usec|ms|msec|s|sec|second|seconds|m|min|minute|minutes|h|hr|hour|hours|d|day|days|w|week|weeks|month|months|y|year|years)? *)+$"); pos = rxValid.indexIn(rval); if (pos > -1) { pos = 0; seconds secs(0); // This regex parses individual elements of the time interval QRegExp rxTimeParse = QRegExp("(\\d*\\.?\\d+) *([a-z]*)"); while ((pos = rxTimeParse.indexIn(rval, pos)) != -1) { if (rxTimeParse.cap(2) == "ns" || rxTimeParse.cap(2) == "nsec" ) { nanoseconds ns(rxTimeParse.cap(1).trimmed().toDouble()); secs += ns; } else if (rxTimeParse.cap(2) == "us" || rxTimeParse.cap(2) == "usec" ) { microseconds us(rxTimeParse.cap(1).trimmed().toDouble()); secs += us; } else if (rxTimeParse.cap(2) == "ms" || rxTimeParse.cap(2) == "msec" ) { milliseconds ms(rxTimeParse.cap(1).trimmed().toDouble()); secs += ms; } else if (rxTimeParse.cap(2) == "s" || rxTimeParse.cap(2) == "sec" || rxTimeParse.cap(2) == "second" || rxTimeParse.cap(2) == "seconds" ) { seconds s(rxTimeParse.cap(1).trimmed().toDouble()); secs += s; } else if (rxTimeParse.cap(2) == "m" || rxTimeParse.cap(2) == "min" || rxTimeParse.cap(2) == "minute" || rxTimeParse.cap(2) == "minutes" ) { minutes min(rxTimeParse.cap(1).trimmed().toDouble()); secs += min; } else if (rxTimeParse.cap(2) == "h" || rxTimeParse.cap(2) == "hr" || rxTimeParse.cap(2) == "hour" || rxTimeParse.cap(2) == "hours" ) { hours hr(rxTimeParse.cap(1).trimmed().toDouble()); secs += hr; } else if (rxTimeParse.cap(2) == "d" || rxTimeParse.cap(2) == "day" || rxTimeParse.cap(2) == "days") { days dy(rxTimeParse.cap(1).trimmed().toDouble()); secs += dy; } else if (rxTimeParse.cap(2) == "w" || rxTimeParse.cap(2) == "week" || rxTimeParse.cap(2) == "weeks") { weeks w(rxTimeParse.cap(1).trimmed().toDouble()); secs += w; } else if (rxTimeParse.cap(2) == "month" || rxTimeParse.cap(2) == "months") { months m(rxTimeParse.cap(1).trimmed().toDouble()); secs += m; } else if (rxTimeParse.cap(2) == "y" || rxTimeParse.cap(2) == "year" || rxTimeParse.cap(2) == "years") { years y(rxTimeParse.cap(1).trimmed().toDouble()); secs += y; } else if (rxTimeParse.cap(2).isEmpty()) { // unitless number, convert it from defReadUnit to seconds seconds tmpSeconds(convertTimeUnit(rxTimeParse.cap(1).trimmed().toDouble(), defReadUnit, timeUnit::s).toDouble()); secs += tmpSeconds; } pos += rxTimeParse.matchedLength(); } // Convert the read value in seconds to defUnit if (defUnit == ns) value = nanoseconds(secs).count(); else if (defUnit == us) value = microseconds(secs).count(); else if (defUnit == ms) value = milliseconds(secs).count(); else if (defUnit == s) value = secs.count(); else if (defUnit == min) value = minutes(secs).count(); else if (defUnit == h) value = hours(secs).count(); else if (defUnit == d) value = days(secs).count(); else if (defUnit == w) value = weeks(secs).count(); else if (defUnit == month) value = months(secs).count(); else if (defUnit == year) value = years(secs).count(); value = value.toULongLong(); // Convert to ulonglong (we don't support float in ui) return 0; } else { qDebug() << rval << "is not a valid value for setting" << realName << ". Ignoring..."; return -1; } } else if (type == RESLIMIT) { bool ok; int nmbr = rval.toUInt(&ok); if (ok) { value = nmbr; return 0; } else if (rval.toLower().trimmed() == "infinity" || rval.trimmed().isEmpty()) { value = -1; return 0; } qDebug() << rval << "is not a valid value for setting" << realName << ". Ignoring..."; return -1; } else if (type == SIZE) { // RegExp to match a number (possibly with decimals) followed by a size unit (or no unit for byte) QRegExp rxSize = QRegExp("(\\b\\d+\\.?\\d*(K|M|G|T|P|E)?\\b)"); int pos = 0; pos = rxSize.indexIn(rval); if (pos > -1 && rxSize.cap(0) == rval.trimmed()) { // convert the specified size unit to megabytes if (rxSize.cap(0).contains("K")) value = rxSize.cap(0).remove("K").toDouble() / 1024; else if (rxSize.cap(0).contains("M")) value = rxSize.cap(0).remove("M").toDouble(); else if (rxSize.cap(0).contains("G")) value = rxSize.cap(0).remove("G").toDouble() * 1024; else if (rxSize.cap(0).contains("T")) value = rxSize.cap(0).remove("T").toDouble() * 1024 * 1024; else if (rxSize.cap(0).contains("P")) value = rxSize.cap(0).remove("P").toDouble() * 1024 * 1024 * 1024; else if (rxSize.cap(0).contains("E")) value = rxSize.cap(0).remove("E").toDouble() * 1024 * 1024 * 1024 * 1024; else value = rxSize.cap(0).toDouble() / 1024 / 1024; // Convert from double to ulonglong (we don't support float in ui) value = value.toULongLong(); return 0; } else { qDebug() << rval << "is not a valid value for setting" << realName << ". Ignoring..."; return -1; } } return -1; }
snd_pcm_sframes_t Sender::Impl::_get_frames_required() const { Duration ms(std::chrono::duration_cast<Duration>(Clock::now() - m_lastFrameTime)); return ms.count()*m_pPlug->get_rate()/1000; }