コード例 #1
0
ファイル: main.cpp プロジェクト: wontheone1/cpp_2015
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);
}
コード例 #2
0
ファイル: main.cpp プロジェクト: kpatt1011/315database
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;
  }
}
コード例 #3
0
ファイル: testcube.cpp プロジェクト: nordewal/sfm
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);
}
コード例 #4
0
ファイル: MovementHandler.cpp プロジェクト: Keader/Sunwell
void WorldSession::HandleMoveWorldportAckOpcode()
{
    // ignore unexpected far teleports
    if (!GetPlayer()->IsBeingTeleportedFar())
        return;

    GetPlayer()->SetSemaphoreTeleportFar(0);

    // get the teleport destination
    WorldLocation const& loc = GetPlayer()->GetTeleportDest();

    // possible errors in the coordinate validity check
    if (!MapManager::IsValidMapCoord(loc))
    {
        KickPlayer();
        return;
    }

    // get the destination map entry, not the current one, this will fix homebind and reset greeting
    MapEntry const* mEntry = sMapStore.LookupEntry(loc.GetMapId());
    InstanceTemplate const* mInstance = sObjectMgr->GetInstanceTemplate(loc.GetMapId());

    Map* oldMap = GetPlayer()->GetMap();
    if (GetPlayer()->IsInWorld())
    {
        sLog->outError("Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName().c_str(), oldMap->GetId(), loc.GetMapId());
        oldMap->RemovePlayerFromMap(GetPlayer(), false);
    }

    // reset instance validity, except if going to an instance inside an instance
    if (GetPlayer()->m_InstanceValid == false && !mInstance)
    {
        GetPlayer()->m_InstanceValid = true;
        // pussywizard: m_InstanceValid can be false only by leaving a group in an instance => so remove temp binds that could not be removed because player was still on the map!
        if (!sInstanceSaveMgr->PlayerIsPermBoundToInstance(GetPlayer()->GetGUIDLow(), oldMap->GetId(), oldMap->GetDifficulty()))
            sInstanceSaveMgr->PlayerUnbindInstance(GetPlayer()->GetGUIDLow(), oldMap->GetId(), oldMap->GetDifficulty(), true);
    }

    // relocate the player to the teleport destination
    Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), GetPlayer());
    // the CanEnter checks are done in TeleporTo but conditions may change
    // while the player is in transit, for example the map may get full
    if (!newMap || !newMap->CanEnter(GetPlayer()))
    {
        sLog->outError("Map %d could not be created for player %d, porting player to homebind", loc.GetMapId(), GetPlayer()->GetGUIDLow());
        GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
        return;
    }

    GetPlayer()->Relocate(loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation());

    GetPlayer()->ResetMap();
    GetPlayer()->SetMap(newMap);

    GetPlayer()->SendInitialPacketsBeforeAddToMap();
    if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer()))
    {
        sLog->outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow(), loc.GetMapId());
        GetPlayer()->ResetMap();
        GetPlayer()->SetMap(oldMap);
        GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
        return;
    }

    oldMap->AfterPlayerUnlinkFromMap();

    // pussywizard: transport teleport couldn't teleport us to the same map (some other teleport pending, reqs not met, etc.), but we still have transport set until player moves! clear it if map differs (crashfix)
    if (Transport* t = _player->GetTransport())
        if (!t->IsInMap(_player))
        {
            t->RemovePassenger(_player);
            _player->m_transport = NULL;
            _player->m_movementInfo.transport.Reset();
            _player->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
        }

    if (!_player->getHostileRefManager().isEmpty())
        _player->getHostileRefManager().deleteReferences(); // pussywizard: multithreading crashfix

    CellCoord pair(Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()));
    Cell cell(pair);
    if (!GridCoord(cell.GridX(), cell.GridY()).IsCoordValid())
    {
        KickPlayer();
        return;
    }
    newMap->LoadGrid(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());

    // pussywizard: player supposed to enter bg map
    if (_player->InBattleground())
    {
        // but landed on another map, cleanup data
        if (!mEntry->IsBattlegroundOrArena())
            _player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE, PLAYER_MAX_BATTLEGROUND_QUEUES, false, false, TEAM_NEUTRAL);
        // everything ok
        else if (Battleground* bg = _player->GetBattleground())
        {
            if (_player->IsInvitedForBattlegroundInstance()) // GMs are not invited, so they are not added to participants
                bg->AddPlayer(_player);
        }
    }

    // pussywizard: arena spectator stuff
    {
        if (newMap->IsBattleArena() && ((BattlegroundMap*)newMap)->GetBG() && _player->HasPendingSpectatorForBG(((BattlegroundMap*)newMap)->GetInstanceId()))
        {
            _player->ClearReceivedSpectatorResetFor();
            _player->SetIsSpectator(true);
            ArenaSpectator::SendCommand(_player, "%sENABLE", SPECTATOR_ADDON_PREFIX);
            ((BattlegroundMap*)newMap)->GetBG()->AddSpectator(_player);
            ArenaSpectator::HandleResetCommand(_player);
        }
        else
            _player->SetIsSpectator(false);

        GetPlayer()->SetPendingSpectatorForBG(0);
        timeWhoCommandAllowed = time(NULL) + sWorld->GetNextWhoListUpdateDelaySecs() + 1; // after exiting arena Subscribe will scan for a player and cached data says he is still in arena, so disallow until next update

        if (uint32 inviteInstanceId = _player->GetPendingSpectatorInviteInstanceId())
        {
            if (Battleground* tbg = sBattlegroundMgr->GetBattleground(inviteInstanceId))
                tbg->RemoveToBeTeleported(_player->GetGUID());
            _player->SetPendingSpectatorInviteInstanceId(0);
        }
    }

    // xinef: do this again, player can be teleported inside bg->AddPlayer(_player)!!!!
    CellCoord pair2(Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()));
    Cell cell2(pair2);
    if (!GridCoord(cell2.GridX(), cell2.GridY()).IsCoordValid())
    {
        KickPlayer();
        return;
    }
    newMap->LoadGrid(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());

    GetPlayer()->SendInitialPacketsAfterAddToMap();

    // resurrect character at enter into instance where his corpse exist after add to map
    Corpse* corpse = GetPlayer()->GetCorpse();
    if (corpse && corpse->GetType() != CORPSE_BONES && corpse->GetMapId() == GetPlayer()->GetMapId())
    {
        if (mEntry->IsDungeon())
        {
            GetPlayer()->ResurrectPlayer(0.5f, false);
            GetPlayer()->SpawnCorpseBones();
        }
    }

    bool allowMount = !mEntry->IsDungeon() || mEntry->IsBattlegroundOrArena();
    if (mInstance)
    {
        Difficulty diff = GetPlayer()->GetDifficulty(mEntry->IsRaid());
        if (MapDifficulty const* mapDiff = GetMapDifficultyData(mEntry->MapID, diff))
            if (mapDiff->resetTime)
                if (time_t timeReset = sInstanceSaveMgr->GetResetTimeFor(mEntry->MapID, diff))
                {
                    uint32 timeleft = uint32(timeReset - time(NULL));
                    GetPlayer()->SendInstanceResetWarning(mEntry->MapID, diff, timeleft, true);
                }
        allowMount = mInstance->AllowMount;
    }

    // mount allow check
    if (!allowMount)
        _player->RemoveAurasByType(SPELL_AURA_MOUNTED);

    // update zone immediately, otherwise leave channel will cause crash in mtmap
    uint32 newzone, newarea;
    GetPlayer()->GetZoneAndAreaId(newzone, newarea, true);
    GetPlayer()->UpdateZone(newzone, newarea);

    // honorless target
    if (GetPlayer()->pvpInfo.IsHostile)
        GetPlayer()->CastSpell(GetPlayer(), 2479, true);

    // in friendly area
    else if (GetPlayer()->IsPvP() && !GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
        GetPlayer()->UpdatePvP(false, false);

    // resummon pet
    GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();

    //lets process all delayed operations on successful teleport
    GetPlayer()->ProcessDelayedOperations();
}
コード例 #5
0
ファイル: ErrorReportSender.cpp プロジェクト: doo/CrashRpt
// 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;
}
コード例 #6
0
ファイル: ofApp.cpp プロジェクト: stdmtb/3s1e
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();
}
コード例 #7
0
ファイル: ad_grav_wall.cpp プロジェクト: stdmtb/3s1e
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 );
                }
            }
        }
    }
    }
}
コード例 #8
0
ファイル: ofApp.cpp プロジェクト: stdmtb/3s1e
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();
}
コード例 #9
0
void GNURadioGui::displaySettings()
{
	int oldIndex = 0;

	oldIndex = ui->cboDevices->currentIndex();
	ui->cboDevices->clear();

	QString oldArgs = ui->txtDeviceArgs->text();

	osmosdr::devices_t devices = osmosdr::device::find();

	for ( uint i = 0; i < devices.size(); i++ )
	{
		osmosdr::device_t dev = devices[i];

		QString label;

		if ( dev.count( "label" ) )
		{
			label = QString(dev[ "label" ].c_str());
			dev.erase("label");
		}

		QPair< QString, QString > pair(label, dev.to_string().c_str());
		m_devs.append(pair);

		ui->cboDevices->addItem(label);
	}

	if ( ui->cboDevices->count() && oldIndex >= 0 )
	{
		if ( oldIndex > ui->cboDevices->count() - 1 )
			oldIndex = 0;

		ui->cboDevices->setCurrentIndex(oldIndex);

		if ( oldArgs.length() == 0 )
			ui->txtDeviceArgs->setText( m_devs[oldIndex].second );
	}

	if ( oldArgs.length() )
		ui->txtDeviceArgs->setText( oldArgs );

	ui->centerFrequency->setValueRange(7,
					   unsigned(m_freqMin / 1000.0),
					   unsigned(m_freqMax / 1000.0));

	ui->centerFrequency->setValue(m_generalSettings.m_centerFrequency / 1000);

	ui->sldFreqCorr->setRange(-100, +100);
	ui->sldFreqCorr->setValue( m_freqCorr );
	ui->lblFreqCorr->setText(tr("%1").arg(ui->sldFreqCorr->value()));

	m_gainControls.clear();
	QVBoxLayout *layoutGains = ui->verticalLayoutGains;
	QLayoutItem *layoutItem;

	while ( ( layoutItem = layoutGains->takeAt( 0 ) ) != NULL )
	{
		QLayout *layout = layoutItem->layout();

		if ( !layout )
			continue;

		while ( ( layoutItem = layout->takeAt( 0 ) ) != NULL )
		{
			delete layoutItem->widget();
			delete layoutItem;
		}

		delete layout;
	}

	for ( uint i = 0; i < m_namedGains.size(); i++ )
	{
		std::pair< QString, std::vector<double> > pair = m_namedGains[i];

		QHBoxLayout *layout = new QHBoxLayout();
		QLabel *gainName = new QLabel( pair.first + " Gain" );
		QSlider *gainSlider = new QSlider(Qt::Horizontal);
		QLabel *gainLabel = new QLabel("0");
		gainLabel->setMinimumWidth(30);
		gainLabel->setAlignment(Qt::AlignHCenter | Qt::AlignHCenter);

		QPair< QSlider*, QLabel* > pair2( gainSlider, gainLabel );
		m_gainControls.push_back( pair2 );

		connect(gainSlider, SIGNAL(valueChanged(int)),
			this, SLOT(on_sldGain_valueChanged(int)));

		layout->addWidget(gainName);
		layout->addWidget(gainSlider);
		layout->addWidget(gainLabel);

		layoutGains->addLayout(layout);

		std::vector<double> gain_values = pair.second;

		if ( gain_values.size() ) {
			gainSlider->setRange(0, gain_values.size() - 1);
			gainSlider->setValue(gain_values.size() / 4);
			gainSlider->setEnabled(true);
		} else {
			gainSlider->setEnabled(false);
		}
	}

	oldIndex = ui->cboSampleRate->currentIndex();
	ui->cboSampleRate->clear();

	for ( uint i = 0; i < m_sampRates.size(); i++ )
		ui->cboSampleRate->addItem( QString::number(m_sampRates[i] / 1e6) );

	if ( oldIndex > ui->cboSampleRate->count() - 1 )
		oldIndex = 0;

	if ( ui->cboSampleRate->count() && oldIndex >= 0 )
		ui->cboSampleRate->setCurrentIndex(oldIndex);

	if ( ui->cboSampleRate->count() ) {
		ui->cboSampleRate->setEnabled(true);
	} else {
		ui->cboSampleRate->setEnabled(false);
	}

	oldIndex = ui->cboAntennas->currentIndex();
	ui->cboAntennas->clear();

	if ( m_antennas.size() ) {
		for ( uint i = 0; i < m_antennas.size(); i++ )
			ui->cboAntennas->addItem( m_antennas[i] );

		if ( oldIndex > ui->cboAntennas->count() - 1 )
			oldIndex = 0;

		if ( ui->cboAntennas->count() && oldIndex >= 0 )
			ui->cboAntennas->setCurrentIndex(oldIndex);

		ui->cboAntennas->setEnabled(true);
	} else {
		ui->cboAntennas->setEnabled(false);
	}

	oldIndex = ui->cboDCOffset->currentIndex();
	ui->cboDCOffset->clear();

	if ( m_dcoffs.size() ) {
		for ( uint i = 0; i < m_dcoffs.size(); i++ )
			ui->cboDCOffset->addItem( m_dcoffs[i] );

		if ( ui->cboDCOffset->count() && oldIndex >= 0 )
			ui->cboDCOffset->setCurrentIndex(oldIndex);

		ui->cboDCOffset->setEnabled(true);
	} else {
		ui->cboDCOffset->setEnabled(false);
	}

	oldIndex = ui->cboIQBalance->currentIndex();
	ui->cboIQBalance->clear();

	if ( m_iqbals.size() ) {
		for ( uint i = 0; i < m_iqbals.size(); i++ )
			ui->cboIQBalance->addItem( m_iqbals[i] );

		if ( ui->cboIQBalance->count() && oldIndex >= 0 )
			ui->cboIQBalance->setCurrentIndex(oldIndex);

		ui->cboIQBalance->setEnabled(true);
	} else {
		ui->cboIQBalance->setEnabled(false);
	}

	oldIndex = ui->cboBandwidth->currentIndex();
	ui->cboBandwidth->clear();

	for ( uint i = 0; i < m_bandwidths.size(); i++ )
		if ( 0.0 == m_bandwidths[i] )
			ui->cboBandwidth->addItem( "Auto" );
		else
			ui->cboBandwidth->addItem( QString::number(m_bandwidths[i] / 1e6) );

	if ( oldIndex > ui->cboBandwidth->count() - 1 )
		oldIndex = 0;

	if ( ui->cboBandwidth->count() && oldIndex >= 0 )
		ui->cboBandwidth->setCurrentIndex(oldIndex);

	if ( ui->cboBandwidth->count() ) {
		ui->cboBandwidth->setEnabled(true);
	} else {
		ui->cboBandwidth->setEnabled(false);
	}
}
コード例 #10
0
ファイル: main.cpp プロジェクト: kpatt1011/315database
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;

  }

}
コード例 #11
0
ファイル: main.cpp プロジェクト: kpatt1011/315database
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;
  }
}
コード例 #12
0
ファイル: main.cpp プロジェクト: kpatt1011/315database
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;
  }
}
コード例 #13
0
ファイル: loop.cpp プロジェクト: wilmerhenao/Loop-Scheme
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;
}