Pair_aln::Pair_aln(const char *blastfile) throw (std::exception): score(0.0f), len_x(0), aln_len_x(0), len_y(0), aln_len_y(0), len_aln(0), len_equ(0), idents(0), pos_matches(0), neg_zero_matches(0), gaps(0), gaps_x(0), gaps_y(0), x_aln_start(0), x_aln_end(0), y_aln_start(0), y_aln_end(0){ #ifndef CM_NO_BOOST std::ifstream in(blastfile); if(!in) throw MyException("Cannot open '%s'!", blastfile); boost::regex blanc("^\\s*$"); boost::regex query_expr("^Query:\\s+(\\d+)\\s+(\\S+)\\s+.*"); boost::regex subjt_expr("^Sbjct:\\s+(\\d+)\\s+(\\S+)\\s+.*"); const size_t L = 4*1024*1024; char buffer[L]; size_t consecutive_blanc_lines=0; std::string x_seq="", y_seq=""; std::vector<int> xvec, yvec; int xs=-1, ys=-1; bool found_data = false; while( in.good() ){ in.getline(buffer, L); //std::cout << buffer << std::endl; if( boost::regex_match(buffer, blanc) ){ if( ys!=-1 && xs!=-1 ){ //std::cout << x_seq << std::endl; //std::cout << y_seq << std::endl <<std::endl; _eval_seqs(xvec, yvec, xs, ys, x_seq, y_seq); } ++consecutive_blanc_lines; if( consecutive_blanc_lines>2 && found_data ) break; xs=-1; ys=-1; }else{ consecutive_blanc_lines=0; } boost::cmatch matches; if( boost::regex_match(buffer, matches, query_expr) ){ xs = atoi( matches.str(1).c_str() ); x_seq = matches.str(2); found_data = true; }else if( boost::regex_match(buffer, matches, subjt_expr) ){ ys = atoi( matches.str(1).c_str() ); y_seq = matches.str(2); found_data = true; } } len_aln = xvec.size(); x = new int[len_aln]; y = new int[len_aln]; for( size_t i=0; i<len_aln; ++i ){ x[i] = xvec[i]-1; y[i] = yvec[i]-1; } #else throw MyException("Constructor not available - compile with libboost."); #endif }
// main program int main(int argc, char *argv[]) { Spectrum blanc(1.0); FresnelOne myFresnel; IsotropicBeckmann myD(1.0); //Blinn myD(0.5); MSHAC myMSHAC(&myD); Microfacetpp myBRDF(blanc, &myFresnel, &myD, &myMSHAC); Spectrum integral(0.0); float theta_o = M_PI / 2.2f; float phi_o = 0.f; Vector w_o(cosf(phi_o) * sinf(theta_o), sinf(phi_o) * sinf(theta_o), cosf(theta_o)); Vector w_i(0.0,0.0,1.0); Vector w_g(0.0, 0.0, 1.0); //float myG = myMSHAC.G(w_o,w_i,Normalize(w_o + w_i)); //float lambda(myD.Lambda(w_o)); float deltaPhi = 0.01, deltaTheta = 0.01; /*RNG myRNG; const int n(300); const int nSamplers(n*n); float samples[nSamplers*2];*/ /*for (int i(0); i < n; i++) { float u1 = (float)i / (float)n; for (int j(0); j < n; j++) { float u2 = (float)j / (float)n; samples[i * n + j * 2] = u1; samples[i * n + j * 2 + 1] = u2; } }*/ /*for (int i(0); i < nSamplers * 2; i++) { samples[i] = myRNG.RandomFloat(); }*/ for (float phi = 0.0; phi <= 2 * M_PI; phi += deltaPhi) { for (float theta = 0.0; theta <= M_PI / 2.0; theta += deltaTheta) { w_i.x = cos(phi) * sin(theta); w_i.y = sin(phi) * sin(theta); w_i.z = cos(theta); integral += myBRDF.f(w_o, w_i) * AbsDot(w_g,w_i) * deltaPhi * deltaTheta * sin(theta); //integral += myD.D(w_i) * AbsDot(w_g, w_i) * deltaPhi * deltaTheta * sin(theta); } } integral = Spectrum(1.0) - integral; //Spectrum retour = myBRDF.rho(w_o,nSamplers, samples); /*Options options; vector<string> filenames; // Process command-line arguments for (int i = 1; i < argc; ++i) { if (!strcmp(argv[i], "--ncores")) options.nCores = atoi(argv[++i]); else if (!strcmp(argv[i], "--outfile")) options.imageFile = argv[++i]; else if (!strcmp(argv[i], "--quick")) options.quickRender = true; else if (!strcmp(argv[i], "--quiet")) options.quiet = true; else if (!strcmp(argv[i], "--verbose")) options.verbose = true; else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) { printf("usage: pbrt [--ncores n] [--outfile filename] [--quick] [--quiet] " "[--verbose] [--help] <filename.pbrt> ...\n"); return 0; } else filenames.push_back(argv[i]); } // Print welcome banner if (!options.quiet) { printf("pbrt version %s of %s at %s [Detected %d core(s)]\n", PBRT_VERSION, __DATE__, __TIME__, NumSystemCores()); printf("Copyright (c)1998-2014 Matt Pharr and Greg Humphreys.\n"); printf("The source code to pbrt (but *not* the book contents) is covered by the BSD License.\n"); printf("See the file LICENSE.txt for the conditions of the license.\n"); fflush(stdout); } pbrtInit(options); // Process scene description PBRT_STARTED_PARSING(); if (filenames.size() == 0) { // Parse scene from standard input ParseFile("-"); } else { // Parse scene from input files for (u_int i = 0; i < filenames.size(); i++) if (!ParseFile(filenames[i])) Error("Couldn't open scene file \"%s\"", filenames[i].c_str()); } pbrtCleanup();*/ return 0; }