void MainWindow::on_actionOpen_triggered()
{
    on_actionReal_Time_toggled(false);
    QFileDialog * dialog = new QFileDialog(this);
    dialog->setNameFilter(tr("data files (*.txt)"));
    dialog->setDirectory(QDir::currentPath());
    dialog->exec();
    QStringList filename_list = dialog->selectedFiles();
    QString datafilename = filename_list.first();

    QFile datafile(datafilename);
    if (!datafile.open(QIODevice::ReadOnly))
        return;

    QTextStream in_stream(&datafile);

    QVector<QPoint> in_points;

    while (!in_stream.atEnd())
    {
        float x, y;
        in_stream >> x >> y;
        in_points << QPoint(x, y);
        //qDebug() << x << ", " << y;
    }

    if (in_points.last().x() == 0 && in_points.last().y() == 0)
    {
        in_points.pop_back();
    }

    points = in_points;
    update();
    //on_actionPerform_triggered();
}
Beispiel #2
0
// Loads an encapsulated block into a temporary list
INXObjList* BlockOperations::LoadBlock(INXString Info) {
	ifstream datafile(Info);
	INXObjList* encapsulated = new INXObjList;
	char type[256];
	long int id;

	// store the id value
	id = ConData::uniqueidgenerator;


	if(datafile.is_open())
	{
		int i = 0;
		while ((!datafile.eof()) && (!datafile.bad())) {
			i++;
			datafile >> type;
		//	TRACE(type);
			if (strcmp(type,"END_OF_BLOCKS")==0) break;
			else
			if (strcmp(type,"BEGIN_BLOCK")==0) {
				ConData *blob = new ConData;
				blob->Load(&datafile);
				encapsulated->AddTail((CObject*) blob);
			}
			if(i>500)
			{
			//	TRACE("hang\n");

			}

		}
	}
//Loads a vector of JPG images into a bottle based on our 'database' file
void ANTData::loadDatabase()
{

    string file;
    string databaseFolder;
    if (databaseContext == "")
        databaseFolder = databaseName;
    else
        databaseFolder = databaseContext + "/" + databaseName;

    cout << "ANTData::loadDatabase: trying to read from " << (databaseFolder + "/" + databaseName).c_str() << endl;

    ifstream datafile((databaseFolder + "/" + databaseName).c_str());
    if (datafile.is_open()) {
        while (!datafile.eof()) {  //open the file and read in each line
            getline(datafile,file);
            if (file.size() <= 3) break;
            file = databaseFolder + "/" + file;
            IplImage *thisImg = cvLoadImage(file.c_str());  //load image
            ImageOf <PixelRgb> yarpImg;
            yarpImg.wrapIplImage(thisImg);  
            imgs.push_back(yarpImg);
        }
    }
	else {
		cout << "ANTData::loadDatabase: unable to open " << (databaseFolder + "/" + databaseName).c_str() << endl;
	}
}
Beispiel #4
0
int main()
{
  QString path = getenv("HOME");
  path += "/maskingdata";

  QFile datafile(path);
  datafile.open(IO_ReadOnly);

  QDataStream datastream(&datafile);

  //currently the QStrings at the beginning of the file
  //are just being read, not written to stdout
  QString str;
  for(int i = 0; i < 3; i++)
    datastream >> str;


  float val;
  int counter = 0;

  while( ! datastream.atEnd() )
    {
      counter++;
      datastream >> val;
      printf("%d:  %f \n", counter, val);
    }

  return 0;
}
Beispiel #5
0
int main(int argC, char* argv[]) {
  if(argc < 1) {
    cerr << "need training data" << endl;
    exit(1);
  }

  corpus trainingData;
  {
    ifstream datafile(argv[1]);
    char line[255];
    while(datafile.getline(line,255)) {
      sentence s;
      string word;
      istrstream iline(line,strlen(line));
      while(iline >> word) {
	s.push_back(word);
      }
      if(s.size() > 0)
	trainingData.push_back(s);
    } 
  }

  cerr << "reading cnf grammar..." << endl;
  PCFG aPCFG;
  cin >> aPCFG;
  aPCFG.train(trainingData);
  cout << aPCFG;
}
Beispiel #6
0
    void ParmMap::inputParms(string fileName){
        std::ifstream datafile(fileName);
        if (!datafile) {
            std::cerr << "Couldn't open parmFile: " <<fileName << std::endl;
            exit (-1);
        }

        string parmName, inputStr,sep;
        double parmValue;
        vector<double> parmValueVector;
        ParmMap::iterator mapit;
        
        while (getline(datafile,inputStr)) {
            
            vector<string> tokens;
            boost::split(tokens, inputStr, boost::is_any_of(" "));

            unsigned numArg = tokens.size();
            
            parmName = tokens[0];
            
            for (unsigned i=1;i<numArg;i++){
                parmValue = getDouble(tokens[i]);
                parmValueVector.push_back(parmValue);
            }
            
            vector<double> parmV;
            parmV = parmValueVector;
            (*this)[parmName] = parmV;
            parmValueVector.clear();
        }
        
        datafile.clear();
        datafile.close();
    }
Beispiel #7
0
bool readCSV(std::string filename, std::vector< std::vector<cv::Point> >& content) {
	std::ifstream datafile(filename.c_str());
	if (datafile) {
		int counter = 0;
		int sizeof_point = 2;
		std::string line;
		while(std::getline(datafile,line)) {
			std::stringstream  lineStream(line);
			std::string        cell;
			std::vector<cv::Point> row_content;
			std::vector<int> set_content;
			counter = 0;
			cv::Point tmp;
			while(std::getline(lineStream,cell,',')) {
				set_content.push_back(atoi(cell.c_str()));
				counter += 1;
				if (counter == sizeof_point && set_content.size() != 0) {
					tmp.x = set_content[0];
					tmp.y = set_content[1];
					row_content.push_back(tmp);
					set_content.clear();
					counter = 0;
				}
			}
			content.push_back(row_content);
			row_content.clear();
		}
		datafile.close();
		return true;
	}
	else {
		datafile.close();
		return false;
	}
}
Beispiel #8
0
bool readCSV(std::string filename, int x_ref, int y_ref) {
	std::ifstream datafile(filename.c_str());
	int x = 0;
	int y = 0;
	if (datafile) {
		std::string line;
		while(std::getline(datafile,line)) {
			std::stringstream  lineStream(line);
			std::string        cell;
			std::vector<int> row_content;
			x = 0;
			while(std::getline(lineStream,cell,',')) {
				x += 1;
			}
			y += 1;
		}
		datafile.close();
		if (x == x_ref && y == y_ref)
			return true;
		else
			return false;
	}
	else {
		datafile.close();
		return false;
	}
}
Beispiel #9
0
void AOSSessionMapHolder::setSessionData(const AString& sessionId, const AString& data)
{
  ALock lock(mp_SyncObject);
  
  //a_Create a new session
  AOSSessionData *pData = new AOSSessionData(sessionId, *this);
  AFile_AString datafile(data);
  pData->fromAFile(datafile);
  m_SessionMap.insert(CONTAINER::value_type(sessionId, pData));
}
/*!
	Read data from the file
*/
void Preferences::readData()
{
    // open file
    QFile datafile(d->file_);
    if (!datafile.open(IO_ReadOnly))
	{
        // error opening file
        qWarning("Error: cannot open preferences file " + d->file_);
        datafile.close();
        d->filestate_ = false;
        return;
    }
    d->filestate_ = true;

    // open dom document
    QDomDocument doc("preferences");
    if (!doc.setContent(&datafile))
	{
        qWarning("Error: " + d->file_ + " is not a proper preferences file");
        datafile.close();
        d->formatstate_ = false;
        return;
    }
    datafile.close();

    // check the doc type and stuff
    if (doc.doctype().name() != "preferences")
	{
        // wrong file type
        qWarning("Error: " + d->file_ + " is not a valid preferences file");
        d->formatstate_ = false;
        return;
    }
    QDomElement root = doc.documentElement();
    if (root.attribute("application") != d->format_)
	{
        // right file type, wrong application
        qWarning("Error: " + d->file_ + " is not a preferences file for " + d->format_);
        d->formatstate_ = false;
        return;
    }
    // We don't care about application version...

    // get list of groups
    QDomNodeList nodes = root.elementsByTagName("group");

    // iterate through the groups
    QDomNodeList options;
    for ( uint n = 0; n < nodes.count(); ++n ) {
        if ( nodes.item(n).isElement() && !nodes.item(n).isComment() ) {
            processGroup( nodes.item(n).toElement() );
        }
    }
    d->formatstate_ = true;
}
Beispiel #11
0
bool checkCSV(std::string filename) {
	std::ifstream datafile(filename.c_str());
	if (datafile) {
		datafile.close();
		return true;
	}
	else {
		datafile.close();
		return false;
	}
}
Beispiel #12
0
/*!
  \param filename the full path of a file
  \param n_line number of lines of a file
  \param n_col number of columns of a file
*/
Matrix ImageB::loadData(string filename, int& n_line, int& n_col)
{
   Matrix mat(2048,2048);
   string line;
   ifstream datafile ( filename.c_str() );
   int min_col; //pega a linha com menor quantidade de colunas para evitar erros de indexação da matrix

   n_line = n_col = 0;
   min_col = 2048;

  if (datafile.is_open())
  {
    while (! datafile.eof() )
    {
      getline (datafile,line);
      vector<double> vec;
      //verifica para os separadores válidos:  , ; \t
      vec = procDataLine(line,';');
      if (vec.size() == 0)
      {
         vec = procDataLine(line,'\t');
         if (vec.size() == 0)
               vec = procDataLine(line,',');
      }
    
      /*verifica se a linha não está em branco. Isso evita erros de arquivos 
       defeituosos ou com uma linha em branco o final*/
      if (vec.size() != 0 && line != "")//tamanho em colunas diferente de zero
      {   
        n_col = vec.size();
        
        if (n_col <= min_col)//encontra a menor coluna
            min_col = n_col;
        
        ++n_line;
        
        for( uint i=1; i <= vec.size(); i++)
          {
            mat(n_line,i) = vec[i-1];
        }
      }
    
    }
    datafile.close();
  }
  else cout << "Unable to open file"; 
   
  n_col = min_col;//seta a linha com menos colunas
  if (n_col <= 0 || n_line <= 0)
        n_col = n_line = 1;

  return mat;
}
TInt Cdmatest::FetchLeafL( CStifItemParser& aItem )	
	{

    TInt ret( KErrNone );
    // Print to UI
    TestModuleIf().Printf( 0, _L("Camtest"), _L("FetchLeafL") );

	iResultsFunction = NULL;
	
    TInt i( 0 );
    TPtrC8 nodename ( GetNextStringLC( aItem, _L( "nodename" ) )->Des() ) ;
    
    //TPtrC datafile;
    TPtrC datafile( KNullDesC );
    i = aItem.GetNextString ( datafile ) ;
    if ( i != KErrNone ) 
	    {
	    iLog->Log(_L("FetchLeafL: ERROR Reading outfile argument: 0x%X"), i );
	    //return i;
	    }
	else
		{
		iSaveFileName = datafile;
		iLog->Log( _L( " Save file nameis '%S'" ), &iSaveFileName );
		iResultsFunction = SaveDataL;
		}
    
	SetURIL(nodename) ;
		
		/*
			void FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
								   const TDesC8& aType, TInt aResultsRef,
								   TInt aStatusRef );
		*/
    TPtrC8 parentURI(RemoveLastSeg(nodename));
    HBufC8 *luid = GetLuidAllocLC( parentURI );

	Adapter()->FetchLeafObjectL( *iURI, *luid, KEmptyType, 7, 8 ) ;
	if ( iStatus == MSmlDmAdapter::EOk )
		{
		iLog->Log( _L("FetchLeafL: FetchLeafObjectL Successful! %d" ), iStatus );	
		}
	else
		{
		iLog->Log( _L("FetchLeafL: FetchLeafObjectL Error ! %d" ), iStatus );	
		ret = KErrGeneral ;
		}
	CleanupStack::PopAndDestroy( luid );
	CleanupStack::PopAndDestroy(  ); // nodename
	iLog->Log( _L("FetchLeafL Test Complete with status %d" ), ret );	
    return ret;
	}	
int main( int argc, char * argv[] ){

	std::ifstream datafile(argv[1]);

	std::string line;

	while( std::getline( datafile, line ) ){

		process_data( line );
	}

	return 0;
}
Beispiel #15
0
bool
TWelcomeDialog::CanClose()
{
	char password2[MAX_ENTRY_SIZE];

	passwordEdit1->GetText(password,sizeof(password));
	passwordEdit2->GetText(password2,sizeof(password2));

	if (strlen(password) == 0 && strlen(password2)==0) {return false;}

	if (strlen(password2) == 0) {
		MessageBox("You must enter your password twice for confirmation");
		passwordEdit2->SetFocus();
		return false;
	}

	if (strcmp(password,password2) != 0) {
		MessageBox("The passwords do not match. Please re-enter them.");
		passwordEdit1->Clear();
		passwordEdit2->Clear();
		passwordEdit1->SetFocus();
		return false;
	}

	// pad out password if it is less than the crypt key size
	if (strlen(password) < CRYPT_KEY_SIZE-1) {
		int sum = 0;
		for (int i=0; i< strlen(password);i++) {
			sum += (int)password[i];
		}
		for (i=strlen(password);i<CRYPT_KEY_SIZE;i++) {
			password[i] = sum % 31 + 1;
		}
		password[CRYPT_KEY_SIZE]=0;
	}

	BYTE buffer[MAX_CRYPT_SIZE+IV_SIZE];
	memset(buffer,0,sizeof(buffer));
	memcpy(buffer,password,sizeof(password));

	TCrypt *crypt = new TCrypt();
	crypt->encrypt(buffer,sizeof(buffer),(BYTE *)password);
	delete crypt;

	ofstream datafile("pass.dat",ios::binary);
	datafile.write((char *)&buffer,sizeof(buffer));
	datafile.close();

	return TRUE;
}
Beispiel #16
0
int main(int argc, char** argv){
	if(argc != 3){
		cout << "USAGE :: ./Parse <image_path> <datafile_path>";
		exit(-1);
	}
	string imagefile(argv[1]);
	string datafile(argv[2]);
	bool DEBUG = false;
	Mat Image = imread(imagefile, 1);

	if(DEBUG){
		// show image
		namedWindow("image", CV_WINDOW_AUTOSIZE);
		imshow("image", Image);
	}

	// get image info in a struct
	AnnotatedDatasetInfo info = getImageData(Image, datafile);

	if(DEBUG){
		// printing data
		int rows = 240;
		int cols = 320;
		cout << "Mat\n";
		for(int i = 0; i < rows; i++)
		{
			for(int j = 0; j < cols; j++)
				cout << info.Labels.at<int>(i, j) << " ";
			cout << endl;
		}
		cout << "\nDepth\n";
		for(int i = 0; i < rows; i++)
		{
			for(int j = 0; j < cols; j++)
				cout << info.Depths.at<Vec3f>(i, j)[0] << ", " << info.Depths.at<Vec3f>(i, j)[1] << ", " << info.Depths.at<Vec3f>(i, j)[2] << " :: ";
			cout << endl;
		}	
		cout << "\nPoints\n";
		for(int i = 0; i <= 1; i++)
		{
			for(int j = 0; j < info.Points[i].size(); j++)
				cout << "(" << info.Points[i][j].x << ", " << info.Points[i][j].y << "), ";
			cout << endl;
		}	

		waitKey(0);
	}
}
Beispiel #17
0
void SODL::Copy2Flattened() {	
	ConData* blob;
	long int id = 0;
	INXPOSITION pos;
		char * type =new char[256];
		int blankcount=0;

	// Copy the condata list to the flattened list
	// save the condata list and then load it back in to flattened
	// Alternatively could use a copy constructor
	pos = flattened->GetHeadPosition();
	while(pos) {
		blob = (ConData *) (flattened->GetNext(pos));
		delete blob;
	}
	flattened->RemoveAll();
	// need to do save in view class
	//SaveProg(workDir + TEMPDIR + "temp");
	ifstream datafile(workDir + TEMPDIR + "temp");


	while ((!datafile.eof()) && (!datafile.bad()) && (blankcount<1000000)) {
		datafile >> type;
		if (strcmp(type,"END_OF_BLOCKS")==0)
			break;
		else
			if (strcmp(type,"BEGIN_BLOCK")==0) {
				blob = new ConData;
				blob->Load(&datafile);
				flattened->AddTail((INXObject*) blob);
				id = blob->identnum;
			} else {
				blankcount++;
			}
	}
	
	// set the uniqueidgenerator to the identnum of the last icon
	// This is necessary as it is possible that this value may be greater than
	// the number of icons loaded, due to icons being deleted previously. This
	// prevents icon IDs being duplicated
	// Need to add 1, since uniqueidgenerator is incremented after a new icon is
	// instantiated.
	id++;
	ConData::uniqueidgenerator = id;
	delete type;
}
Beispiel #18
0
INXObjList* EditList::LoadTemp() {	
	ConData* blob;
	long int id = 0;
	INXObjList* temp = new INXObjList;

	// Copy the condata list to the flattened list
	// save the condata list and then load it back in to flattened
	// Alternatively could use a copy constructor
	temp->RemoveAll();
	//SaveProg(workDir + TEMPDIR + "temp");
	ifstream datafile(workDir + TEMPDIR + "temp");
	char type[256];

	while ((!datafile.eof()) && (!datafile.fail())) {
		datafile >> type;
		if (strcmp(type,"END_OF_BLOCKS")==0) break;
		else
		if (strcmp(type,"BEGIN_BLOCK")==0) 
		{
			blob = new ConData;
			
			if(blob)
			{	blob->Load(&datafile);
				temp->AddTail((CObject*) blob);
				id = blob->identnum;
			}
			else
			{
				//delete blob;
				break;
			}
		}
	}
	
	// set the uniqueidgenerator to the identnum of the last icon
	// This is necessary as it is possible that this value may be greater than
	// the number of icons loaded, due to icons being deleted previously. This
	// prevents icon IDs being duplicated
	// Need to add 1, since uniqueidgenerator is incremented after a new icon is
	// instantiated.
	//id++;
	//ConData::uniqueidgenerator = id;
	return temp;
}
Beispiel #19
0
void MapBuilder::convert() {
    char c;
    int x = 0;
    int y = 0;
    int maxX = 0;
    int maxY = 0;
    string mapName, terrainType;
    
    // Declares an Input filestream
    ifstream datafile(readFile.c_str());
    // Declares an Output filestream.
    ofstream mapfile(saveFile.c_str());
    if (datafile.is_open()) {
        cout << "Output open!" << endl;
    }
    
    if (datafile.is_open())
    {
        while (! datafile.eof() )
        {
            datafile >> c;
            if (c == '/') {
                x = 0;
                y++;
            }
            else {
                mapfile << x << " " << y << " " << getType( c ) << " 0" << "\n";
                x++;
            }
            
            if (x > maxX) {
                maxX = x;
            }
            if (y > maxY) {
                maxY = y;
            }
        }
        cout << "Map Width: " << maxX << endl;
        cout << "Map Height: " << maxY - 1 << endl;
        
        datafile.close();
        datafile.clear();
    }   
    else cout << "Unable to open file"; 
            bool loadTestData() {
                fprintf(stderr, "Data file: %s\n", dataFile.c_str());
                //
                // load data
                //
                std::ifstream datafile (dataFile);
                if (!datafile.is_open()) {
                    std::cerr << "Error in opening file: " << dataFile << std::endl;
                    return false;
                }

                std::string line;
                int lastIndex = -1, index = -1, row = -1;
                while (! datafile.eof() ) {
                    getline(datafile, line);
                    row++;
                    
                    if (!line.empty()) {
                        // remove \r charcter
                        size_t car_ret_index = line.rfind("\r");
                        line.erase(car_ret_index);
                        
                        VS s = splt(line);
                        
                        int subjid = atof(s[0].c_str());
                        if (subjid - 1 != lastIndex) {
                            VS subjLines;
                            dataSamples.push_back(subjLines);
                            lastIndex = subjid - 1;
                            index ++;
                        }
                        // add line
                        dataSamples[index].push_back(line);
                    } else {
                        Printf("Empty line found at the input data at row: %i!\n", row);
                    }
                    
                }
                datafile.close();
                
                fprintf(stderr, "Loaded: %lu subjects\n", dataSamples.size());
                
                return true;
            }
Beispiel #21
0
void GMExperiment6_1::loadData()
{
   ifstream datafile(filename.c_str());
   if(!datafile.is_open())
   {
     output << "Couldn't Open Data File\n";
   }
   else
   {
     rawData.clear();
     Vector2f temp;
     while(datafile >> temp[0] >> temp[1])
     {
     rawData.push_back(temp);
     }
     datafile.close();
   }

}
Beispiel #22
0
bool
TEnterPasswordDialog::CanClose()
{
	BYTE encryptedPassword[MAX_CRYPT_SIZE+IV_SIZE];

	passwordEdit->GetText(password,sizeof(password));

  	// pad out password if it is less than the crypt key size
	if (strlen(password) < CRYPT_KEY_SIZE-1) {
		int sum=0;
		for (int i=0; i< strlen(password);i++) {
			sum += (int)password[i];
		}
		for (i=strlen(password);i<CRYPT_KEY_SIZE;i++) {
			password[i] = sum % 31 + 1; // keep extra chars in the range of control chars
		}
		password[CRYPT_KEY_SIZE]=0;
	}

	ifstream datafile("pass.dat",ios::binary);
	datafile.read(encryptedPassword,sizeof(encryptedPassword));
	datafile.close();

	BYTE buffer[MAX_ENTRY_SIZE+IV_SIZE];
	memset(buffer,0,sizeof(buffer));
	memcpy(buffer,encryptedPassword,sizeof(encryptedPassword));

	TCrypt *crypt = new TCrypt();
	crypt->decrypt(buffer,sizeof(buffer),(BYTE *)password);
	delete crypt;

	if (strcmp((char *)buffer,password) != 0) {
		MessageBox("Sorry, that password is incorrect.","Incorrect Password");
		if (++login_attempts > 2) CmCancel();

		passwordEdit->Clear();
		passwordEdit->SetFocus();

		return false;
	}

	return TRUE;
}
void MainWindow::on_actionSave_Points_triggered()
{
    QFileDialog * dialog = new QFileDialog(this);
    dialog->setNameFilter(tr("data files (*.txt)"));
    dialog->setDirectory(QDir::currentPath());
    dialog->exec();
    QStringList filename_list = dialog->selectedFiles();
    QString datafilename = filename_list.first();

    QFile datafile(datafilename);
    if (!datafile.open(QIODevice::WriteOnly))
        return;

    QTextStream out_stream(&datafile);

    for(auto& p : points)
    {
        out_stream << p.x() << " " << p.y() << endl;
    }
}
Beispiel #24
0
/** Load a dataset from a text file where each line represent a 16bit word from the XMAP buffer
 * The destination pointer dest must be pre-allocated with dest_len number of 16bit words
 * before calling this function.
 */
int load_dataset_txt(const char * filename, unsigned short *dest, unsigned int dest_len)
{
	int retcode = 0;
	string line;
	ifstream datafile (filename);
	unsigned int i=0;
	if (datafile.is_open())
	{
		while ( datafile.good() && (i<dest_len) )
		{
			getline (datafile,line);
			//cout << line << endl;
			dest[i] = strtoul(line.c_str(), NULL, 0);
			i++;
		}
		datafile.close();
		retcode = i;
	}
	return retcode;
}
void MainWindow::on_actionSaveTriangles_triggered()
{
    QFileDialog * dialog = new QFileDialog(this);
    dialog->setNameFilter(tr("data files (*.txt)"));
    dialog->setDirectory(QDir::currentPath());
    dialog->exec();
    QStringList filename_list = dialog->selectedFiles();
    QString datafilename = filename_list.first();

    QFile datafile(datafilename);
    if (!datafile.open(QIODevice::WriteOnly))
        return;

    QTextStream out_stream(&datafile);

    for (int i = 0; i < triangles.size(); i += 3)
    {
        out_stream << triangles[i].x() << " " << triangles[i].y() << " ";
        out_stream << triangles[i + 1].x() << " " << triangles[i + 1].y() << " ";
        out_stream << triangles[i + 2].x() << " " << triangles[i + 2].y() << endl;
    }
}
Beispiel #26
0
bool readCSV(std::string filename, std::vector< std::vector<float> >& content) {
	std::ifstream datafile(filename.c_str());
	if (datafile) {
		std::string line;
		while(std::getline(datafile,line)) {
			std::stringstream  lineStream(line);
			std::string        cell;
			std::vector<float> row_content;
			while(std::getline(lineStream,cell,',')) {
				row_content.push_back(atof(cell.c_str()));
			}
			content.push_back(row_content);
			row_content.clear();
		}
		datafile.close();
		return true;
	}
	else {
		datafile.close();
		return false;
	}
}
Beispiel #27
0
LPpredicter_Markus()
{

  TString datafile("MC_LM3x3.root");
 
  cout << "weiter oben"<<endl;
  DoPredicter(TString("500-750 GeV"),1,TString("Counter_BSMGrid_500_pre_LP"),TString("Counter_BSMGrid_500"),TString("MC_SM3.root"),datafile);
  DoPredicter(TString("500-750 GeV"),2,TString("Counter_BSMGrid_500_pre_LP"),TString("Counter_BSMGrid_500"),TString("MC_SM3.root"),datafile);
  DoPredicter(TString("500-750 GeV"),3,TString("Counter_BSMGrid_500_pre_LP"),TString("Counter_BSMGrid_500"),TString("MC_SM3.root"),datafile);

   cout <<endl;

  DoPredicter(TString("750-1000 GeV"),1,TString("Counter_BSMGrid_750_pre_LP"),TString("Counter_BSMGrid_750"),TString("MC_SM3.root"),datafile);
  DoPredicter(TString("750-1000 GeV"),2,TString("Counter_BSMGrid_750_pre_LP"),TString("Counter_BSMGrid_750"),TString("MC_SM3.root"),datafile);
  DoPredicter(TString("750-100 GeV"),3,TString("Counter_BSMGrid_750_pre_LP"),TString("Counter_BSMGrid_750"),TString("MC_SM3.root"),datafile);
 
  cout <<endl;
  DoPredicter(TString("1000 GeV"),1,TString("Counter_BSMGrid_final_selection_pre_LP"),TString("Counter_BSMGrid_final_selection"),TString("MC_SM3.root"),datafile);
  DoPredicter(TString("1000 GeV"),2,TString("Counter_BSMGrid_final_selection_pre_LP"),TString("Counter_BSMGrid_final_selection"),TString("MC_SM3.root"),datafile);
  DoPredicter(TString("1000 GeV"),3,TString("Counter_BSMGrid_final_selection_pre_LP"),TString("Counter_BSMGrid_final_selection"),TString("MC_SM3.root"),datafile);
   
}
int main(int argc, char *argv[])
{
    int nPar = 6;
    // Starting values for cosmological parameters
    // From Planck 2015 (http://arxiv.org/abs/1502.01589), Table 3, Column 4
    const double h = 0.6727;
    const double omBH2 = 0.02225;
    const double omCH2 = 0.1198;
    const double tau = 0.079;
    const double ns = 0.9645;
    const double as = 3.094; // ln(10^10*as)
    const double pivot = 0.05;
    LambdaCDMParams params(omBH2, omCH2, h, tau, ns, std::exp(as)/1e10, pivot);

    Cosmo cosmo;
    cosmo.preInitialize(5000, false, false, false, 0, 100, 1e-6, 1.0);

    std::string file_name = "/Volumes/Data1/ncanac/cosmopp_neutrinos/completed_runs/standard_LCDM_mn_build/LCDM_planckposterior.txt";
    std::ifstream datafile(file_name);
    std::string line;
    while(getline(datafile, line))
    {
        std::istringstream iss(line);
        std::vector<double> vec;
        double dummy;
        while(iss >> dummy)
            vec.push_back(dummy);
        std::vector<double> v(&vec[0], &vec[nPar]);
        params.setAllParameters(v);
        cosmo.initialize(params, true, false, false, true);
        for(int i = 0; i < vec.size(); ++i)
            output_screen(vec[i] << " ");
        output_screen(cosmo.sigma8() << std::endl);
    }
    datafile.close();

    return 0;
}
Beispiel #29
0
void Level::load(World &world) const
{
    fs::DataFile df(datafile());

    tinyxml2::XMLDocument doc;
    {
        fs::DataStream ds(df, "terrain.xml");
        string xmlstr = string(
            (std::istreambuf_iterator<char>(ds)),
            std::istreambuf_iterator<char>());

        int error = doc.Parse(xmlstr.c_str());
        if(error != tinyxml2::XML_NO_ERROR)
            throw LevelException(doc.GetErrorStr1());
    }

    const XMLElement *root = doc.RootElement();

    setWorldBounds(root, world);

    const XMLElement *el = root->FirstChildElement();
    while(el) {
        if(strcmp(el->Name(), "zones")==0)
            loadZones(el, world);
        else if(strcmp(el->Name(), "static")==0)
            loadStatic(el, world);
        else if(strcmp(el->Name(), "solid")==0)
            loadSolid(el, world);
        else {
#ifndef NDEBUG
            cerr << "Warning: Unknown level file element: " << el->Name() << endl;
#endif
        }

        el = el->NextSiblingElement();
    }
    
}
Beispiel #30
0
// saves the copySelList
void EditList::SaveCopy(INXString Info) {
	ofstream datafile(Info);
	//put an error trap
	ConData *blob;

	datafile << "IconData" << endl;
	INXPOSITION pos;
	pos = copySelList->GetHeadPosition();
	
	if (!datafile.good()) {
		AfxMessageBox("File could not be written");
	}

	while (pos) { 		
		blob=(ConData *) (copySelList->GetNext(pos));
		datafile<<"BEGIN_BLOCK"<<endl;
		blob->Save(&datafile);
	} 

	datafile<<"END_OF_BLOCKS"<<endl;
	datafile.close();

}