void Mesh::objFileStructure2(const char* mtlfilename){ cout<<mtlfilename<<endl; ifstream mtl(mtlfilename,ios::in); if(!mtl){ cerr<<"File could not be found."<<endl; exit(1); } string materialLine=""; string materialToken=""; while(!mtl.eof()){ if(materialToken!="newmtl"){ getline(mtl, materialLine); std::stringstream os1(materialLine); os1>>materialToken; } if(materialToken =="newmtl"){ std::stringstream os2(materialLine); os2>>materialToken;//new mtl os2>>materialToken;//material string thematerial = materialToken; float red = 0.0776f; float green = 0.2571f; float blue = 0.2041f; do{ if(mtl.eof()){ break; } if(!mtl.eof()){ getline(mtl, materialLine); // cout<<"lines before newmtl ..."<<materialLine<<endl; std::stringstream os3(materialLine); os3>>materialToken; if(materialToken=="Kd"){ os3>>materialToken; //cout<<"red "<<materialToken<<endl; red = atof(materialToken.c_str()); os3>>materialToken; //cout<<"green "<<materialToken<<endl; green = atof(materialToken.c_str()); os3>>materialToken; // cout<<"blue "<<materialToken<<endl; blue = atof(materialToken.c_str()); } }
void testCopyAndThenDelete() { THREE_TIMERS( os1 ); SmartPointerList<QTimer>* os2 = new SmartPointerList<QTimer>( os1 ); SmartPointerList<QTimer> os3( *os2 ); delete os2; QCOMPARE( os1.count(), 3 ); QCOMPARE( os3.count(), 3 ); delete os1[1]; QCOMPARE( os1.count(), 2 ); QCOMPARE( os3.count(), 2 ); }
QuadcopterPlanner::QuadcopterPlanner(): ph_("~"){ pose_pub_ = nh_.advertise<geometry_msgs::PoseStamped>("/app/quadcmdpose",1); status_pub_ = nh_.advertise<actionlib_msgs::GoalStatus>("/app/plannersts",1); bool prmAvail = false; std::string param; if(ph_.getParam("wayPtThreshold",param)){ std::stringstream os1(param.c_str()); os1 >> wayPtThreshold_.x>> wayPtThreshold_.y>> wayPtThreshold_.z; if(ph_.getParam("minThreshold",param)){ std::stringstream os2(param.c_str()); os2 >> min_threshold.x>> min_threshold.y>> min_threshold.z; if(ph_.getParam("step",param)){ std::stringstream os3(param.c_str()); os3 >> step_.x>> step_.y>> step_.z; if(ph_.getParam("proximityThreshold",proxityData_.threshold)){ if(ph_.getParam("avoidStep",collisionData_.avoidStep)){ std::cout << "Parameter read from launch file!" << std::endl; prmAvail=true; } } }
int main(int argc, char *argv[]) { ParamProgram *par = new ParamProgram(); char fileName[300]; if(argc != 2){ cout << "ERRORR !! " << endl; cout << "buildDL_LZ's usage requires the Properties File as parameter !! " << endl; cout << "Example for the file 'config.txt' in the same directory: ./buildDL_LZ config.txt" << endl; exit(1); } par->configFile = string(argv[1]); cout << "Congif file: " << par->configFile << endl; ConfigFile cf(par->configFile); TRACE = cf.Value("GLOBALS","TRACE"); TEST = cf.Value("GLOBALS","TEST"); N_REP = cf.Value("GLOBALS","N_REP"); strcpy(par->inputFile, ((string)(cf.Value("DL","inputFile"))).c_str()); par->filesInList = cf.Value("DL","filesInList"); par->boundSymbol = cf.Value("DL","boundSymbol"); par->cutDoc = cf.Value("DL","cutDoc"); par->lowercase = cf.Value("DL","lowercase"); par->levRMQ_range = cf.Value("DL","levRMQ"); strcpy(par->dirStore, ((string)(cf.Value("DL","dirStore"))).c_str()); cout << "buildDL_LZ config parameters..." << endl; cout << "Input File : " << par->inputFile << endl; cout << "File in list : " << par->filesInList << endl; cout << "Boundary Symbol(code) : " << (int)par->boundSymbol << endl; cout << "Cut Doc. Symbol(code) : " << (int)par->cutDoc << endl; cout << "Lowercase : " << par->lowercase << endl; cout << "Range levels with RMQ : " << par->levRMQ_range << endl; cout << "Store Folder : " << par->dirStore << endl; LZDocList64::TRACE = TRACE; LZDocList64::TEST = TEST; par->index = new LZDocList64(par->levRMQ_range, par->inputFile, par->filesInList, par->cutDoc, par->lowercase, par->dirStore, par->boundSymbol, false); par->n = par->index->n; par->EndDocs = par->index->EndDocs; cout << "____________________________________________________" << endl; cout << "*** Index size " << par->index->sizeDS << " bytes = " << (float)par->index->sizeDS*8.0/(float)par->n << " bpc" << endl; cout << "*** SizeUpRange = " << par->index->sizeUpRange << " bytes = " << (float)par->index->sizeUpRange*8.0/(float)par->n << " bpc" << endl; cout << "====================================================" << endl; par->index->saveDS(true); { // create the FMI to execute test... cout << "____________________________________________________" << endl; cout << " Make the FMI ..." << endl; strcpy(fileName, ""); strcpy(fileName, par->inputFile); cout << " Reading... " << fileName << endl; strcat(fileName, "_copy.txt"); construct(par->index->fmi, fileName, 1); // generate index cout << " ** FMI size " << size_in_bytes(par->index->fmi) << " bytes = " << (float)size_in_bytes(par->index->fmi)/(float)par->n << "|T|" << endl; cout << " ** FMI length " << par->index->fmi.size() << endl; if (par->index->fmi.size() != par->n){ cout << "ERROR. FMI length != n = " << par->n << endl; exit(1); } strcpy(fileName, ""); strcpy(fileName, par->dirStore); strcat(fileName, "fmi.test"); store_to_file(par->index->fmi, fileName); } if (TEST){ strcpy(fileName, ""); strcpy(fileName, par->dirStore); strcat(fileName, "EndDocs.test"); ofstream os2 (fileName, ios::binary); os2.write((const char*)par->EndDocs, par->index->nDocs*sizeof(ulong)); // save LbRev[] if(TRACE) cout << " .- EndDocs[] " << par->index->nDocs*sizeof(ulong) << " Bytes" << endl; os2.close(); par->index->sep_rrr = rrr_vector<127>(par->index->sepPhrase_b); par->index->sep_rank = rrr_vector<127>::rank_1_type(&par->index->sep_rrr); std::cout << " sep_rrr uses " << size_in_bytes(par->index->sep_rrr) << " Bytes" << endl; strcpy(fileName, ""); strcpy(fileName, par->dirStore); strcat(fileName, "sep_rrr.test"); store_to_file(par->index->sep_rrr, fileName); strcpy(fileName, ""); strcpy(fileName, par->dirStore); strcat(fileName, "sep_rank.test"); store_to_file(par->index->sep_rank, fileName); strcpy(fileName, ""); strcpy(fileName, par->dirStore); strcat(fileName, "EndDocs.test"); ofstream os3 (fileName, ios::binary); os3.write((const char*)par->EndDocs, par->index->nDocs*sizeof(ulong)); // save LbRev[] if(TRACE) cout << " .- EndDocs[] " << par->index->nDocs*sizeof(ulong) << " Bytes" << endl; os3.close(); // load Sequence... strcpy(fileName, ""); strcpy(fileName, par->dirStore); strcat(fileName, "sequence.test"); ifstream is(fileName, ios::binary); par->seq = new uchar[par->n]; is.read((char*)par->seq, par->n*sizeof(uchar)); is.close(); cout << "Running test searchPattern.." << endl; testSearchPatt_DL_CSA_LZ(par); cout << "Test searchPattern OK !!" << endl; } par->index->~LZDocList64(); cout << "$$$$$$$$$$$$$$$$$$$$$" << endl; return 0; }