Esempio n. 1
0
File: Gis.cpp Progetto: digirea/KVS
bool Gis::CheckExtension( const std::string& filename )
{
    if ( filename.find(";") != std::string::npos )
    {
        std::string hdr; // header file
        std::string bil; // data file
        kvs::Tokenizer t( filename, ";" );
        while ( !t.isLast() )
        {
            const kvs::File file( t.token() );
            if ( file.extension() == "hdr" || file.extension() == "HDR" ) { hdr = file.filePath(); }
            if ( file.extension() == "res" || file.extension() == "RES" ) { bil = file.filePath(); }
        }
        if ( !hdr.empty() && !bil.empty() ) return true;
    }
    else
    {
        const kvs::File file( filename );
        if ( file.extension() == "tem" || file.extension() == "TEM" ||
             file.extension() == "sem" || file.extension() == "SEM" ||
             file.extension() == "mem" || file.extension() == "MEM" )
        {
            return true;
        }
    }

    return false;
}
Esempio n. 2
0
void MainWindow::open()
{
  QFileDialog* dialog = new QFileDialog( this, "Open file ...", QDir::homePath() );
  if ( dialog->exec() )
    {
      QStringList filenames = dialog->selectedFiles();
      QString filename_first = filenames.at(0);

  QString fn = QFileDialog::getExistingDirectory(this,"Open Dir", QDir::homePath() );
  if( fn!=NULL){
    kvs::Directory directory( fn.toStdString() );
    const kvs::FileList files = directory.fileList();
    int file_length = files.size();
    std::vector<std::string> filename;
    std::vector<std::string> filename_sei;
    int nsteps = 0;
    int sei_steps = 0;
    int first_step = 0;

    for ( int i = 0; i < file_length; i++ ){
      const kvs::File file = files[i];
      if( file.extension() == "dat" ){
	nsteps++;
	filename.push_back( file.filePath() );
	if(filename_first.toStdString() == filename.at(nsteps-1)){
	  first_step = nsteps-1;
	}
      }
      if( file.extension() == "sei" ){
	sei_steps++;
	filename_sei.push_back( file.filePath() );
      }
    }
    if(nsteps != sei_steps){
      printf("%d files detected and %d SecondInvariant files detected\n",nsteps, sei_steps);//54800
      m_mainwidget->opendir(filename, nsteps, first_step);
    }else{
      printf("%d files detected\n",nsteps);//54800
      m_mainwidget->opendir(filename, filename_sei,  nsteps, first_step);
    }
  }
    }
}
Esempio n. 3
0
void initialize( std::string filename )
{
    time_step = 0;
//    filename = "5/Density";

    msec = 20;
    nsteps = 0;
    kvs::Directory directory( filename );
    const kvs::FileList files = directory.fileList();
    int file_length = files.size();
    std::vector<std::string> file_name;
    for ( int i = 0; i < file_length; i++ )
    {
        const kvs::File file = files[i];
        if( file.extension() == "kvsml" )
        {
            nsteps++;
            file_name.push_back( file.filePath() );
        }
    }
    
    object = new kvs::StructuredVolumeObject*[nsteps];
    std::cout << nsteps << std::endl;
    
    kvs::Timer time;
    time.start();
    for ( int i = 0; i < nsteps; i++ )
    { 
        object[i] = new kvs::StructuredVolumeImporter( file_name[i] );
        object[i]->setName( "object" );
        std::cout << "\r" << i << std::flush;        
    }
    time.stop();
    std::cout << "\r" << "                           " << std::flush;
    std::cout << "\r" << "Finish Reading." << std::endl;
    std::cout <<"Loading time: " <<time.msec()<<"msec"<<std::endl;
    time_step = 0;
}
Esempio n. 4
0
void MainWindow::open_animation()
{
  animation_flag = true;
  QString fn = QFileDialog::getExistingDirectory(this,"Open Dir", QDir::homePath() );

      kvs::Directory directory( fn.toStdString() );
      const kvs::FileList files = directory.fileList();
      int file_length = files.size();

      std::vector<std::string> filename;
      int nsteps = 0;

      for ( int i = 0; i < file_length; i++ ){
	const kvs::File file = files[i];
	if( file.extension() == "kvsml" ){
	  nsteps++;
	  filename.push_back( file.filePath() );
	  printf("%s\n",filename.at(nsteps-1).c_str());
	}
      }
      m_mainwidget->open_animation(filename, nsteps);
  is_animation = true;
  animation_flag = false;
}