BOOST_AUTO_TEST_CASE_TEMPLATE ( test_mapping_range, Tp, every_quad ) { Tp fix(20, randomize(-100, 100)); { // non-const mapping_iterator_pair<typename Tp::container_type> pair(mapping_range(fix.container, 2u)); BOOST_CHECK(pair.first == mapping_begin(fix.container, 2u)); BOOST_CHECK(pair.second == mapping_end(fix.container, 2u)); mapping_iterator_pair<typename Tp::container_type> pair2; pair2 = mapping_range(fix.container, 3u); BOOST_CHECK(pair2.first == mapping_begin(fix.container, 3u)); BOOST_CHECK(pair2.second == mapping_end(fix.container, 3u)); } { // const mapping_iterator_pair<const typename Tp::container_type> pair0(mapping_range(fix.container, 1u)); // cast constructor BOOST_CHECK(pair0.first == mapping_begin(fix.container, 1u)); BOOST_CHECK(pair0.second == mapping_end(fix.container, 1u)); mapping_iterator_pair<const typename Tp::container_type> pair1(mapping_crange(fix.container, 2u)); // copy constructor BOOST_CHECK(pair1.first == mapping_begin(fix.container, 2u)); BOOST_CHECK(pair1.second == mapping_end(fix.container, 2u)); mapping_iterator_pair<const typename Tp::container_type> pair2; pair2 = mapping_crange(fix.container, 3u); // assignment operator BOOST_CHECK(pair2.first == mapping_cbegin(fix.container, 3u)); BOOST_CHECK(pair2.second == mapping_cend(fix.container, 3u)); } }
int main() { upperPair pair1(123, namePair("aaaaa", "xxxxxxx")); upperPair pair2(345, namePair("bbb", "yyy")); cout << "no\tfirst name\tlast name\n"; printUpperPair(pair1); printUpperPair(pair2); }
Table* read_from_chefmozhours4() { ifstream myfile ("chefmozhours4.csv"); if (myfile.is_open()) { Table::ColumnList columns; String placeID; getline( myfile, placeID, ',' ); columns.push_back(make_pair(placeID, Table::varchar)); String hours; getline( myfile, hours, ',' ); columns.push_back(make_pair(hours, Table::varchar)); String days; getline( myfile, days, '\n' ); columns.push_back(make_pair(days, Table::varchar)); Table* geo = new Table(columns); // Create geo using the defined columns while ( myfile.good() ) { vector<pair<string, string> > entries; // Entries for the record to be placed in the table string placeID; getline( myfile, placeID, ',' ); pair <string,string> pair0 ("placeID",placeID); // value init entries.push_back(pair0); string hours; getline( myfile, hours, ',' ); pair <string,string> pair1 ("hours",hours); // value init entries.push_back(pair1); string days; getline( myfile, days, '\n' ); pair <string,string> pair2 ("days",days); // value init entries.push_back(pair2); Record add(entries); // Create record to add to table geo->insert(add); // Insert add record into geo } myfile.close(); return geo; } }
void Id2DataPairTest::testSet ( void ) { Id2DataPair pair0(0); CPPUNIT_ASSERT_THROW(pair0.set(*m_map), WrongState); Id2DataPair pair1(0, m_dataContainer); CPPUNIT_ASSERT_NO_THROW(pair1.set(*m_map)); CPPUNIT_ASSERT_EQUAL(m_dataContainer, m_map->get(0)); CPPUNIT_ASSERT(pair1.data().empty()); CPPUNIT_ASSERT_THROW(pair1.set(*m_map), WrongState); Id2DataPair pair3(10, m_dataContainer); CPPUNIT_ASSERT_THROW(pair3.set(*m_map), WrongId); }
Table* read_from_usercuisine() { ifstream myfile ("usercuisine.csv"); if (myfile.is_open()) { Table::ColumnList columns; String userID; getline( myfile, userID, ',' ); columns.push_back(make_pair(userID, Table::varchar)); String Rcuisine; getline( myfile, Rcuisine, '\n' ); columns.push_back(make_pair(Rcuisine, Table::varchar)); Table* geo = new Table(columns); // Create geo using the defined columns while ( myfile.good() ) { vector<pair<string, string> > entries; // Entries for the record to be placed in the table string userID; getline( myfile, userID, ',' ); pair <string,string> pair0 ("userID",userID); // value init entries.push_back(pair0); string Rcuisine; getline( myfile, Rcuisine, '\n' ); pair <string,string> pair1 ("Rcuisine",Rcuisine); // value init entries.push_back(pair1); Record add(entries); // Create record to add to table geo->insert(add); // Insert add record into geo } myfile.close(); return geo; } }
void TestCube::setPairs(vector<shared_ptr<ImagePair>> &pairs) { shared_ptr<Image> image1(new Image()); shared_ptr<Image> image2(new Image()); shared_ptr<Image> image3(new Image()); shared_ptr<ImagePair> pair1(new ImagePair()); shared_ptr<ImagePair> pair2(new ImagePair()); pair1->image1 = image1; pair1->image2 = image2; pair2->image1 = image2; pair2->image2 = image3; TestCube::setKeypointsImg1(image1->keypoints_); TestCube::setKeypointsImg2(image2->keypoints_); TestCube::setKeypointsImg3(image3->keypoints_); TestCube::setMatches(8, pair1->matches); TestCube::setMatches(9, pair2->matches); pairs.push_back(pair1); pairs.push_back(pair2); }
// This method sends the error report over the Internet BOOL CErrorReportSender::SendReport() { int status = 1; if(!g_CrashInfo.m_bSendErrorReport) { m_Assync.SetProgress(_T("Error report sending disabled."), 0); // Move report files to Recycle Bin Utility::RecycleFile(g_CrashInfo.m_sErrorReportDirName, true); m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return FALSE; } m_Assync.SetProgress(_T("[sending_report]"), 0); std::multimap<int, int> order; std::pair<int, int> pair3(g_CrashInfo.m_uPriorities[CR_SMAPI], CR_SMAPI); order.insert(pair3); std::pair<int, int> pair2(g_CrashInfo.m_uPriorities[CR_SMTP], CR_SMTP); order.insert(pair2); std::pair<int, int> pair1(g_CrashInfo.m_uPriorities[CR_HTTP], CR_HTTP); order.insert(pair1); std::multimap<int, int>::reverse_iterator rit; for(rit=order.rbegin(); rit!=order.rend(); rit++) { m_Assync.SetProgress(_T("[sending_attempt]"), 0); m_SendAttempt++; if(m_Assync.IsCancelled()){ break; } int id = rit->second; BOOL bResult = FALSE; if(id==CR_HTTP) bResult = SendOverHTTP(); else if(id==CR_SMTP) bResult = SendOverSMTP(); else if(id==CR_SMAPI) bResult = SendOverSMAPI(); if(bResult==FALSE) continue; if(id==CR_SMAPI && bResult==TRUE) { status = 0; break; } if(0==m_Assync.WaitForCompletion()) { status = 0; break; } } if(status==0) { m_Assync.SetProgress(_T("[status_success]"), 0); if(g_CrashInfo.m_bSendErrorReport) { // Move report files to Recycle Bin Utility::RecycleFile(g_CrashInfo.m_sErrorReportDirName, false); } } else { CString str; str.Format(_T("The error report is saved to '%s'"), m_sZipName); m_Assync.SetProgress(str, 0); m_Assync.SetProgress(_T("[status_failed]"), 0); } m_Assync.SetCompleted(status); return 0; }
void ofApp::update(){ float frame = ofGetFrameNum(); ofVec3f attractor( 10, 10, 50 ); attractor.rotate( ofGetFrameNum()/4, ofVec3f(0.5, 0.3, 0.1) ); ofVec3f diff; for( int i=0; i<shapes.size(); i++ ){ ofVec3f pos = shapes[i]->getPosition(); diff = attractor - pos; float dist2 = diff.lengthSquared(); float power = (1.0/dist2) * 50000.0; ofVec3f force( 0,0,0 ); if( 1 ){ float noise = 0; float amp = 0.5; for( int j=0; j<4; j++ ){ noise += ofNoise( pos.x, pos.y, pos.z, frame*0.001) * amp; amp *= 0.5; } force += diff.normalized() * power; } #pragma mark ADD_PERLIN_NOISE if( 0 ){ ofVec3f noise; noise.zero(); float amp = 0.5; for( int j=0; j<4; j++ ){ noise.x += ofSignedNoise( pos.x, frame*0.001 ) * amp; noise.y += ofSignedNoise( pos.y, frame*0.001 ) * amp; noise.z += ofSignedNoise( pos.z, frame*0.001 ) * amp; amp *= 0.5; } force += noise*5.0; } shapes[i]->applyCentralForce( force ); points.setVertex( i, pos ); } lines.clear(); int num_line = 3; // per point for( int i=0; i<shapes.size(); i++ ){ // if(ofRandom(1.0)>0.1) // continue; ofVec3f pos1 = shapes[i]->getPosition(); multimap<float, ofVec3f> near_p; pair<float, ofVec3f> pair1( 999999999999, ofVec3f(0,0,0) ); for( int line=0; line<num_line; line++ ){ near_p.insert( pair1 ); } for( int j=i+1; j<shapes.size(); j++ ){ ofVec3f pos2 = shapes[j]->getPosition(); float dist = pos1.distance( pos2 ); multimap<float, ofVec3f>::iterator itr = near_p.end(); itr--; if( dist < itr->first ){ std::pair<float, ofVec3f> pair2( dist, pos2 ); near_p.insert( pair2 ); multimap<float, ofVec3f>::iterator end = near_p.end(); near_p.erase( --end ); } } multimap<float, ofVec3f>::iterator itr = near_p.begin(); for(; itr!=near_p.end(); itr++ ){ ofVec3f &pos2 = itr->second; lines.addVertex( pos1 ); lines.addVertex( pos2 ); lines.addColor( ofFloatColor( ofRandom(0.2,0.4), ofRandom(0.2, 0.4)) ); lines.addColor( ofFloatColor( ofRandom(0.2,0.4), ofRandom(0.2, 0.4)) ); } } world.update(); }
void ad_grav_wall::update_lines(){ lines.clear(); prep_lines.clear(); polys.clear(); const vector<ofFloatColor> & pcol = points.getColors(); btCollisionObjectArray& objs = world.world->getCollisionObjectArray(); #pragma mark GLOBAL_PIVOT_LINE if(0){ //float limit = 730; // ABC // float limit = 1050; // DEF float limit = 6050; //FGH int n = 1 + ofNoise(ofGetFrameNum()*1.2) * 800; for( int i=0; i<n; i++ ){ int id1 = ofNoise(i, ofGetFrameNum()*2.0) * (objs.size()-1); if( ofRandomuf()<0.02 ) id1 = ofRandom(0, 20); ofPoint &gpv = ofApp::app->global_pivot; btTransform &trans1 = objs[id1]->getWorldTransform(); btVector3 &bpos1 = trans1.getOrigin(); ofVec3f pos1( bpos1.x(), bpos1.y(), bpos1.z() ); float d = pos1.distance( gpv ); if( d<30 || limit<d ) continue; ofFloatColor c = ofFloatColor(0.8, 0.8) - pcol[id1]; c.a = 0.3; lines.addVertex( pos1 ); lines.addVertex( gpv ); lines.addColor( c ); lines.addColor( c ); for( int k=0; k<3; k++ ){ float rate = 1+k*0.5; ofVec3f d1 = pos1; ofVec3f d2 = gpv; d1.x += ofRandomf() * rate; d1.y += ofRandomf() * rate; lines.addVertex( d1 ); lines.addVertex( d2 ); lines.addColor( c ); lines.addColor( c ); } } } #pragma mark RANDOM_LINE for( int i=0; i<1000; i++ ){ int id1 = ofRandom(0, objs.size()-1); int id2 = ofRandom(0, objs.size()-1); if( objs[id1]->isKinematicObject() || objs[id2]->isKinematicObject() ) continue; btTransform &trans1 = objs[id1]->getWorldTransform(); btVector3 &bpos1 = trans1.getOrigin(); ofVec3f pos1( bpos1.x(), bpos1.y(), bpos1.z() ); btTransform &trans2 = objs[id2]->getWorldTransform(); btVector3 &bpos2 = trans2.getOrigin(); ofVec3f pos2( bpos2.x(), bpos2.y(), bpos2.z() ); float d = pos1.distance(pos2); float limit = 200; if( d<30 || limit<d ) continue; ofFloatColor c = ofFloatColor(0.8, 0.8) - pcol[id1]; c.b = 0.8; c.a = 0.1; lines.addVertex( pos1 ); lines.addVertex( pos2 ); lines.addColor( c ); lines.addColor( c ); for( int k=0; k<3; k++ ){ float rate = 1.0 + k; ofVec3f d1 = pos1; ofVec3f d2 = pos2; d1.x += ofRandomf() * rate; d1.y += ofRandomf() * rate; d2.x += ofRandomf() * rate; d2.y += ofRandomf() * rate; lines.addVertex( d1 ); lines.addVertex( d2 ); lines.addColor( c ); lines.addColor( c ); } } #pragma mark NEAR_LINE for( int i=0; i<objs.size(); i++ ){ float nR = ofApp::app->getNoise(i,0); float nG = ofApp::app->getNoise(i,1); float nB = ofApp::app->getNoise(i,2); btTransform &trans = objs[i]->getWorldTransform(); btVector3 &bpos = trans.getOrigin(); ofVec3f pos1( bpos.x(), bpos.y(), bpos.z() ); pos1.z = 0; { int num_line = ofNoise(i*0.1, ofGetFrameNum()*0.5)*5 + ofGetFrameNum()*0.003; num_line = MIN(num_line, 10); bool bStatic1 = objs[i]->isStaticObject(); if( bStatic1 ) continue; if( num_line <= 0 ) continue; multimap<float, ofVec3f> near_p; pair<float, ofVec3f> pair1( 999999999999, ofVec3f(-12345,0,0) ); for( int line=0; line<num_line; line++ ){ near_p.insert( pair1 ); } for( int j=0; j<objs.size(); j++ ){ if( i==j ) continue; bool bStatic2 = objs[j]->isStaticObject(); if( bStatic2 ) continue; btTransform &trans = objs[j]->getWorldTransform(); btVector3 &bpos = trans.getOrigin(); ofVec3f pos2( bpos.x(), bpos.y(), bpos.z() ); pos2.z = 0; float dist = pos1.distance( pos2 ); multimap<float, ofVec3f>::iterator itr = near_p.end(); itr--; if( dist < itr->first ){ std::pair<float, ofVec3f> pair2( dist, pos2 ); near_p.insert( pair2 ); multimap<float, ofVec3f>::iterator end = near_p.end(); near_p.erase( --end ); } } multimap<float, ofVec3f>::iterator itr = near_p.begin(); for(; itr!=near_p.end(); itr++ ){ ofVec3f &pos2 = itr->second; if(pos2.x == -12345) continue; float d = pos1.distance(pos2); float limit = 600; if( d<10 || limit<d ) continue; ofFloatColor c = ofFloatColor(0.8, 0.8) - pcol[i]; c.a = 0.2; lines.addVertex( pos1 ); lines.addVertex( pos2 ); lines.addColor( c ); lines.addColor( c ); c.r += nR*0.1 + ofRandomf()*0.01; c.g += nG*0.1 + ofRandomf()*0.01; c.b += nB*0.1 + ofRandomf()*0.01; c.a = 0.05; int n = ofNoise( i, ofGetFrameNum() ) * 10.0; for( int k=0; k<n; k++ ){ float rate = 1.0 + k; ofVec3f d1 = pos1; ofVec3f d2 = pos2; d1.x += ofRandomf() * rate; d1.y += ofRandomf() * rate; d2.x += ofRandomf() * rate; d2.y += ofRandomf() * rate; lines.addVertex( d1 ); lines.addVertex( d2 ); lines.addColor( c ); lines.addColor( c ); } } } } #pragma mark PREP_LINE { int limit = 110; for( int i=0; i<objs.size(); i++ ){ btTransform &trans = objs[i]->getWorldTransform(); btVector3 &bpos = trans.getOrigin(); ofVec3f pos1( bpos.x(), bpos.y(), bpos.z() ); pos1.z = 0; gvWall * gl = static_cast<gvWall*>(objs[i]->getUserPointer()); if( gl != NULL){ ofVec3f toline = ad_geom_util::vec_pl(pos1, gl->p1, gl->p2); ofVec3f onLine = pos1 + toline; float len = toline.length(); bool isOnline = ad_geom_util::isOnline(onLine, gl->p1, gl->p2); if( ofApp::app->getNoise(i,2) + ofNoise(i*0.002) > 1.45 ){ if( len < limit && isOnline ){ prep_lines.addVertex(pos1); prep_lines.addVertex(onLine); ofFloatColor c = pcol[i]; c.b *= 1; c.a = 0.1; prep_lines.addColor( c ); prep_lines.addColor( c ); int n = 1 + ofNoise( i, ofGetFrameNum() ) * 20.0; for( int k=0; k<n; k++ ){ float rate = 1.0 + k*0.1; ofVec3f d1 = pos1; ofVec3f d2 = onLine; d1.x += ofRandomf() * rate; d1.y += ofRandomf() * rate;w d2.x += ofRandomf() * rate; d2.y += ofRandomf() * rate; lines.addVertex( d1 ); lines.addVertex( d2 ); lines.addColor( c ); lines.addColor( c ); } } } } } } #pragma mark POLY_LINE if(0){ for( int i=0; i<20; i++ ){ for( int j=0; j<3; j++ ){ int id = ofApp::app->getNoise(i + j*511) * (objs.size()-1); if(ofRandomuf()>0.65) id = ofRandom(0, objs.size()-1); btTransform &trans = objs[id]->getWorldTransform(); btVector3 &bpos = trans.getOrigin(); ofVec3f pos1( bpos.x(), bpos.y(), 0); gvWall * gl = static_cast<gvWall*>(objs[id]->getUserPointer()); if( gl == NULL) continue; ofVec3f toline = ad_geom_util::vec_pl(pos1, gl->p1, gl->p2); ofVec3f onLine = pos1 + toline; float len = toline.length(); int minl = ofNoise(id*0.01, ofGetFrameNum()*0.12) * 200 + 100; int maxl = ofNoise(id*0.012, ofGetFrameNum()*0.113)*200 + minl; if ( minl<len && len<maxl ) { ofVec3f dir = gl->p2-gl->p1; ofVec3f dirn = dir.getNormalized(); ofVec3f toLinen = toline.getNormalized(); float lenToEnd = (gl->p2 - onLine).length(); dirn *= ofNoise( i*0.03 )<0.0 ? -1 : 1; int n = ofNoise( ofGetFrameNum()*0.1 ) *3 +1; for (int k=0; k<n; k++) { float width = lenToEnd; //300 + ofRandomf()*10; int step = width/2; ofVec3f current = pos1 + ofVec3f(ofRandomf()*5, 5, 0); ofVec3f toline = ad_geom_util::vec_pl(current, gl->p1, gl->p2); float height = toline.length(); ofPolyline poly; poly.addVertex( pos1 ); current -= dirn*10; poly.addVertex( current ); ofxTransitions tr; for( int l=0; l<step; l++ ){ float plotx = log10(l)/log10(step); float x = width * plotx; float y = tr.easeInOutCubic(l, 0, height, step); ofVec3f v = dirn*x + toLinen*y; poly.addVertex( current + v); } polys.push_back( poly ); } } } } } }
void ofApp::update(){ float frame = ofGetFrameNum(); for( int i=0; i<attrs.getNumVertices(); i++ ){ ofVec3f ap = attrs.getVertex(i); ofVec3f n; n.x = ofSignedNoise(i, ap.x, frame*0.0001)*6.0; n.y = ofSignedNoise(i, ap.y, frame*0.0001)*6.0; n.z = ofSignedNoise(i, ap.z, frame*0.0001)*6.0; float dist = ap.distance(ofVec3f(ap.x, 0,0) ); ap.rotate( 100.0/dist, ofVec3f(1,0,0) ); attrs.setVertex(i, ap+n); } for( int i=0; i<shapes.size(); i++ ){ ofVec3f pos = shapes[i]->getPosition(); ofVec3f force( 0,0,0 ); for( int j=0; j<attrs.getNumVertices(); j++ ){ ofVec3f diff = attrs.getVertex(j) - pos; float dist2 = diff.lengthSquared(); if(dist2>100){ float power = (1.0/dist2) * 100000.0; force += diff.normalized() * power; } } shapes[i]->applyCentralForce( force ); pos.x = ((float)i/shapes.size()-0.5) * ofGetWidth()/2;; pos.z *= 0.1; points.setVertex( i, pos ); } lines.clear(); for( int i=0; i<shapes.size(); i++ ){ float noise = ofNoise(i*0.01); int num_line = 1 + noise*10.0; // per point // if(ofRandom(1.0)>0.1) // continue; ofVec3f pos1 = shapes[i]->getPosition(); multimap<float, ofVec3f> near_p; pair<float, ofVec3f> pair1( 999999999999, ofVec3f(-12345,0,0) ); for( int line=0; line<num_line; line++ ){ near_p.insert( pair1 ); } for( int j=i+1; j<shapes.size(); j++ ){ ofVec3f pos2 = shapes[j]->getPosition(); float dist = pos1.distance( pos2 ); multimap<float, ofVec3f>::iterator itr = near_p.end(); itr--; if( dist < itr->first ){ std::pair<float, ofVec3f> pair2( dist, pos2 ); near_p.insert( pair2 ); multimap<float, ofVec3f>::iterator end = near_p.end(); near_p.erase( --end ); } } multimap<float, ofVec3f>::iterator itr = near_p.begin(); for(; itr!=near_p.end(); itr++ ){ ofVec3f &pos2 = itr->second; if(pos2.x == -12345) continue; float d = pos1.distance(pos2); if( d<3 || 12+noise*60.0<d ) continue; lines.addVertex( pos1 ); lines.addVertex( pos2 ); ofFloatColor c; c.setHsb( ofNoise(i*0.01)*0.6+0.7, ofRandom(0.1,0.8), ofNoise(i*0.01)*0.8+0.1); c.a = ofNoise(c.r*0.001)*0.7+ 0.1; lines.addColor( c ); lines.addColor( c ); } } p2p.clear(); for( int i=0; i<points.getNumVertices(); i++ ){ ofVec3f p1 = points.getVertex(i); if( ofRandomf()<0.3) continue; p1.z = 0; p1.y = 1; p2p.addVertex(p1); p1.y = 0; p2p.addVertex(p1); ofFloatColor c( 0.1, 0.2, 1, 0.6); p2p.addColor( c ); p2p.addColor( c ); } world.update(); }
Table* read_from_geoplaces2() { ifstream myfile ("geoplaces2.csv"); if (myfile.is_open()) { Table::ColumnList columns; String placeID; getline( myfile, placeID, ',' ); columns.push_back(make_pair(placeID, Table::integer)); String latitude; getline( myfile, latitude, ',' ); columns.push_back(make_pair(latitude, Table::floating)); String longitude; getline( myfile, longitude, ',' ); columns.push_back(make_pair(longitude, Table::floating)); String the_geom_meter; getline( myfile, the_geom_meter, ',' ); columns.push_back(make_pair(the_geom_meter, Table::varchar)); String name; getline( myfile, name, ',' ); columns.push_back(make_pair(name, Table::varchar)); String address; getline( myfile, address, ',' ); columns.push_back(make_pair(address, Table::varchar)); String city; getline( myfile, city, ',' ); columns.push_back(make_pair(city, Table::varchar)); String state; getline( myfile, state, ',' ); columns.push_back(make_pair(state, Table::varchar)); String country; getline( myfile, country, ',' ); columns.push_back(make_pair(country, Table::varchar)); String fax; getline( myfile, fax, ',' ); columns.push_back(make_pair(fax, Table::varchar)); String zip; getline( myfile, zip, ',' ); columns.push_back(make_pair(zip, Table::varchar)); String alcohol; getline( myfile, alcohol, ',' ); columns.push_back(make_pair(alcohol, Table::varchar)); String smoking_area; getline( myfile, smoking_area, ',' ); columns.push_back(make_pair(smoking_area, Table::varchar)); String dress_code; getline( myfile, dress_code, ',' ); columns.push_back(make_pair(dress_code, Table::varchar)); String accessibility; getline( myfile, accessibility, ',' ); columns.push_back(make_pair(accessibility, Table::varchar)); String price; getline( myfile, price, ',' ); columns.push_back(make_pair(price, Table::varchar)); String url; getline( myfile, url, ',' ); columns.push_back(make_pair(url, Table::varchar)); String Rambience; getline( myfile, Rambience, ',' ); columns.push_back(make_pair(Rambience, Table::varchar)); String franchise; getline( myfile, franchise, ',' ); columns.push_back(make_pair(franchise, Table::varchar)); String area; getline( myfile, area, ',' ); columns.push_back(make_pair(area, Table::varchar)); String other_services; getline( myfile, other_services, '\n' ); columns.push_back(make_pair(other_services, Table::varchar)); Table* geo = new Table(columns); // Create geo using the defined columns while ( myfile.good() ) { vector<pair<string, string> > entries; // Entries for the record to be placed in the table string placeID; getline( myfile, placeID, ',' ); pair <string,string> pair0 ("placeID",placeID); // value init entries.push_back(pair0); string latitude; getline( myfile, latitude, ',' ); pair <string,string> pair1 ("latitude",latitude); // value init entries.push_back(pair1); string longitude; getline( myfile, longitude, ',' ); pair <string,string> pair2 ("longitude",longitude); // value init entries.push_back(pair2); string the_geom_meter; getline( myfile, the_geom_meter, ',' ); pair <string,string> pair3 ("the_geom_meter",the_geom_meter); // value init entries.push_back(pair3); string name; getline( myfile, name, ',' ); pair <string,string> pair4 ("name",name); // value init entries.push_back(pair4); string address; getline( myfile, address, ',' ); pair <string,string> pair5 ("address",address); // value init entries.push_back(pair5); string city; getline( myfile, city, ',' ); pair <string,string> pair6 ("city",city); // value init entries.push_back(pair6); string state; getline( myfile, state, ',' ); pair <string,string> pair7 ("state",state); // value init entries.push_back(pair7); string country; getline( myfile, country, ',' ); pair <string,string> pair8 ("country",country); // value init entries.push_back(pair8); string fax; getline( myfile, fax, ',' ); pair <string,string> pair9 ("fax",fax); // value init entries.push_back(pair9); string zip; getline( myfile, zip, ',' ); pair <string,string> pair10 ("zip",zip); // value init entries.push_back(pair10); string alcohol; getline( myfile, alcohol, ',' ); pair <string,string> pair11 ("alcohol",alcohol); // value init entries.push_back(pair11); string smoking_area; getline( myfile, smoking_area, ',' ); pair <string,string> pair12 ("smoking_area",smoking_area); // value init entries.push_back(pair12); string dress_code; getline( myfile, dress_code, ',' ); pair <string,string> pair13 ("dress_code",dress_code); // value init entries.push_back(pair13); string accessibility; getline( myfile, accessibility, ',' ); pair <string,string> pair14 ("accessibility",accessibility); // value init entries.push_back(pair14); string price; getline( myfile, price, ',' ); pair <string,string> pair15 ("price",price); // value init entries.push_back(pair15); string url; getline( myfile, url, ',' ); pair <string,string> pair16 ("url",url); // value init entries.push_back(pair16); string Rambience; getline( myfile, Rambience, ',' ); pair <string,string> pair17 ("Rambience",Rambience); // value init entries.push_back(pair17); string franchise; getline( myfile, franchise, ',' ); pair <string,string> pair18 ("franchise",franchise); // value init entries.push_back(pair18); string area; getline( myfile, area, ',' ); pair <string,string> pair19 ("area",area); // value init entries.push_back(pair19); string other_services; getline( myfile, other_services, '\n' ); pair <string,string> pair20 ("other_services",other_services); // value init entries.push_back(pair20); Record add(entries); // Create record to add to table geo->insert(add); // Insert add record into geo } myfile.close(); return geo; } }
Table* read_from_userprofile() { ifstream myfile ("userprofile.csv"); if (myfile.is_open()) { Table::ColumnList columns; String userID; getline( myfile, userID, ',' ); columns.push_back(make_pair(userID, Table::varchar)); String latitude; getline( myfile, latitude, ',' ); columns.push_back(make_pair(latitude, Table::floating)); String longitude; getline( myfile, longitude, ',' ); columns.push_back(make_pair(longitude, Table::integer)); String smoker; getline( myfile, smoker, ','); columns.push_back(make_pair(smoker, Table::varchar)); String drink_level; getline( myfile, drink_level, ','); columns.push_back(make_pair(drink_level, Table::varchar)); String dress_preference; getline( myfile, dress_preference, ',' ); columns.push_back(make_pair(dress_preference, Table::varchar)); String ambience; getline( myfile, ambience, ',' ); columns.push_back(make_pair(ambience, Table::varchar)); String transport; getline( myfile, transport, ',' ); columns.push_back(make_pair(transport, Table::varchar)); String marital_status; getline( myfile, marital_status, ',' ); columns.push_back(make_pair(marital_status, Table::varchar)); String hijos; getline( myfile, hijos, ','); columns.push_back(make_pair(hijos, Table::varchar)); String birth_year; getline( myfile, birth_year, ',' ); columns.push_back(make_pair(birth_year, Table::integer)); String interest; getline( myfile, interest, ',' ); columns.push_back(make_pair(interest, Table::varchar)); String personality; getline( myfile, personality, ',' ); columns.push_back(make_pair(personality, Table::varchar)); String religion; getline( myfile, religion, ',' ); columns.push_back(make_pair(religion, Table::varchar)); String activity; getline( myfile, activity, ',' ); columns.push_back(make_pair(activity, Table::varchar)); String color; getline( myfile, color, ',' ); columns.push_back(make_pair(color, Table::varchar)); String weight; getline( myfile, weight, ',' ); columns.push_back(make_pair(weight, Table::integer)); String budget; getline( myfile, budget, ',' ); columns.push_back(make_pair(budget, Table::varchar)); String height; getline( myfile, height, '\n' ); columns.push_back(make_pair(height, Table::floating)); Table* geo = new Table(columns); // Create geo using the defined columns while ( myfile.good() ) { vector<pair<string, string> > entries; // Entries for the record to be placed in the table string userID; getline( myfile, userID, ',' ); pair <string,string> pair0 ("userID",userID); // value init entries.push_back(pair0); string latitude; getline( myfile, latitude, ',' ); pair <string,string> pair1 ("latitude",latitude); // value init entries.push_back(pair1); string longitude; getline( myfile, longitude, ',' ); pair <string,string> pair2 ("longitude",longitude); // value init entries.push_back(pair2); string smoker; getline( myfile, smoker, ',' ); pair <string,string> pair3 ("smoker",smoker); // value init entries.push_back(pair3); string drink_level; getline( myfile, drink_level, ',' ); pair <string,string> pair4 ("drink_level",drink_level); // value init entries.push_back(pair4); string dress_preference; getline( myfile, dress_preference, ',' ); pair <string,string> pair5 ("dress_preference",dress_preference); // value init entries.push_back(pair5); string ambience; getline( myfile, ambience, ',' ); pair <string,string> pair6 ("ambience",ambience); // value init entries.push_back(pair6); string transport; getline( myfile, transport, ',' ); pair <string,string> pair7 ("transport",transport); // value init entries.push_back(pair7); string marital_status; getline( myfile, marital_status, ',' ); pair <string,string> pair8 ("marital_status",marital_status); // value init entries.push_back(pair8); string hijos; getline( myfile, hijos, ',' ); pair <string,string> pair9 ("hijos",hijos); // value init entries.push_back(pair9); string birth_year; getline( myfile, birth_year, ',' ); pair <string,string> pair10 ("birth_year",birth_year); // value init entries.push_back(pair10); string interest; getline( myfile, interest, ',' ); pair <string,string> pair11 ("interest",interest); // value init entries.push_back(pair11); string personality; getline( myfile, personality, ',' ); pair <string,string> pair12 ("personality",personality); // value init entries.push_back(pair12); string religion; getline( myfile, religion, ',' ); pair <string,string> pair13 ("religion",religion); // value init entries.push_back(pair13); string activity; getline( myfile, activity, ',' ); pair <string,string> pair14 ("activity",activity); // value init entries.push_back(pair14); string color; getline( myfile, color, ',' ); pair <string,string> pair15 ("color",color); // value init entries.push_back(pair15); string weight; getline( myfile, weight, ',' ); pair <string,string> pair16 ("weight",weight); // value init entries.push_back(pair16); string budget; getline( myfile, budget, ',' ); pair <string,string> pair17 ("budget",budget); // value init entries.push_back(pair17); string height; getline( myfile, height, '\n' ); pair <string,string> pair18 ("height",height); // value init entries.push_back(pair18); Record add(entries); // Create record to add to table geo->insert(add); // Insert add record into geo } myfile.close(); return geo; } }
Table* read_from_rating_final() { ifstream myfile ("rating_final.csv"); if (myfile.is_open()) { Table::ColumnList columns; String placeID; getline( myfile, placeID, ',' ); columns.push_back(make_pair(placeID, Table::varchar)); String latitude; getline( myfile, latitude, ',' ); columns.push_back(make_pair(latitude, Table::integer)); String longitude; getline( myfile, longitude, ',' ); columns.push_back(make_pair(longitude, Table::integer)); String the_geom_meter; getline( myfile, the_geom_meter, ',' ); columns.push_back(make_pair(the_geom_meter, Table::integer)); String name; getline( myfile, name, '\n' ); columns.push_back(make_pair(name, Table::integer)); Table* geo = new Table(columns); // Create geo using the defined columns while ( myfile.good() ) { vector<pair<string, string> > entries; // Entries for the record to be placed in the table string placeID; getline( myfile, placeID, ',' ); pair <string,string> pair0 ("userID",placeID); // value init entries.push_back(pair0); string latitude; getline( myfile, latitude, ',' ); pair <string,string> pair1 ("placeID",latitude); // value init entries.push_back(pair1); string longitude; getline( myfile, longitude, ',' ); pair <string,string> pair2 ("rating",longitude); // value init entries.push_back(pair2); string the_geom_meter; getline( myfile, the_geom_meter, ',' ); pair <string,string> pair3 ("food_rating",the_geom_meter); // value init entries.push_back(pair3); string name; getline( myfile, name, '\n' ); pair <string,string> pair4 ("service_rating",name); // value init entries.push_back(pair4); Record add(entries); // Create record to add to table geo->insert(add); // Insert add record into geo } myfile.close(); return geo; } }
void loop_scheme(){ int newfacesnum = 4 * numfaces; //Every face will be split in 4 vector<Face> newFaces; Face newface; int index = 0; // index for new array of faces NewVertexMap newvertexmap; NewIndexMap newindexmap; for(int i = 0; i < newfacesnum; i++) newFaces.push_back(newface); for(int i = 0; i < numfaces; i++){ Vertex *newvertix = new Vertex[3]; size_t newpositions[3] = {0}; for(int j = 0; j < 3; j++){ newvertix[j].coord = (faxes[i].ver[j].coord + faxes[i].ver[(j+1)%3].coord)/2; Pair pair1(faxes[i].ver[j].id, faxes[i].ver[(j+1)%3].id); Pair pair2(faxes[i].ver[(j+1)%3].id, faxes[i].ver[j].id); if(faxes[i].ver[(j+1)%3].id > faxes[i].ver[j].id){ newvertexmap.insert(NewVertexMap::value_type(pair1, newvertix[j].coord)); } else { newvertexmap.insert(NewVertexMap::value_type(pair2, newvertix[j].coord)); } newpositions[j] = vertixes.size(); vertixes.push_back(newvertix[j]); } newFaces[4 * i].ver = new Vertex[3]; newFaces[4 * i].numedges = 3; newFaces[4 * i + 1].ver = new Vertex[3]; newFaces[4 * i + 1].numedges = 3; newFaces[4 * i + 2].ver = new Vertex[3]; newFaces[4 * i + 2].numedges = 3; newFaces[4 * i + 3].ver = new Vertex[3]; newFaces[4 * i + 3].numedges = 3; // Assign vertices newFaces[4 * i].ver[0] = faxes[i].ver[0]; newFaces[4 * i].ver[1] = newvertix[0]; newFaces[4 * i].ver[2] = newvertix[2]; newFaces[4 * i + 1].ver[0] = newvertix[0]; newFaces[4 * i + 1].ver[1] = faxes[i].ver[1]; newFaces[4 * i + 1].ver[2] = newvertix[1]; newFaces[4 * i + 2].ver[0] = newvertix[1]; newFaces[4 * i + 2].ver[1] = faxes[i].ver[2]; newFaces[4 * i + 2].ver[2] = newvertix[2]; newFaces[4 * i + 3].ver[0] = newvertix[0]; newFaces[4 * i + 3].ver[1] = newvertix[1]; newFaces[4 * i + 3].ver[2] = newvertix[2]; } // for(int i = 0 ; i< numfaces; i++){ // Vec3f *newvertix = new Vec3f[3]; // for(int j = 0; j < 3; j++){ // newvertix[j] = (faces[i].ver[j].coord + faces[i].ver[(j+1)%3].coord)/2; // Pair pair1(faces[i].ver[j].id, faces[i].ver[(j+1)%3].id); // Pair pair2(faces[i].ver[(j+1)%3].id, faces[i].ver[j].id); // if(faces[i].ver[(j+1)%3].id > faces[i].ver[j].id){ // newvertexmap.insert(NewVertexMap::value_type(pair1, newvertix[j])); // } else { // newvertexmap.insert(NewVertexMap::value_type(pair2, newvertix[j])); // } // } // } // // Lets assign the new vertices and values // NewVertexMap::const_iterator iter; // for(iter = newvertexmap.begin(); iter != newvertexmap.end(); iter++){ // newindexmap.insert(NewIndexMap::value_type(iter->first, (int)vertixes.size())); // contains the position // vertixes.push_back(newvertexmap.find(iter->first)); // } // for(int i = 0; i < numfaces; i++){ // } //Fix at the end numfaces = newfacesnum; faxes = newFaces; selectedFace = -1; }