void AdvancedOutput<OversampleOutput>::outputStep(const ExecFlagType & type) { // Output is not allowed if (!_allow_output && type != EXEC_FORCED) return; // If recovering disable output of initial condition, it was already output if (type == EXEC_INITIAL && _app.isRecovering()) return; // Do nothing if the filename is not correct for output if (!checkFilename()) return; // Return if the current output is not on the desired interval if (type != EXEC_FINAL && !onInterval()) return; // Perform oversample solution projection updateOversample(); // Call output methods for various types output(type); }
//-------------------------------------------------------------------------------- int main(int argc, char** argv) { if(argc < 2) { PCL_ERROR("Syntax is: %s <source.ply>", argv[0]); return EXIT_FAILURE; } // load pointcloud from file std::string fname = std::string(argv[1]); if (!checkFilename(fname)) { PCL_ERROR("Given file is not a valid .ply file: ", argv[1]); return EXIT_FAILURE; } std::cout << "loading " << fname << std::endl; pcl::PointCloud<PointNormalT>::Ptr cloud_in(new pcl::PointCloud<PointNormalT>); pcl::io::loadPLYFile(fname, *cloud_in); // statistical outlier removal pcl::PointCloud<PointNormalT>::Ptr cloud_sor = filterSOR(cloud_in); // save output if (!cloud_sor->empty()) { pcl::io::savePLYFileBinary("cloud_sor.ply", *cloud_sor); } else { PCL_ERROR("SOR filtered pointcloud is empty."); return EXIT_FAILURE; } return EXIT_SUCCESS; }
FileOutput::FileOutput(const std::string & name, InputParameters & parameters) : Output(name, parameters), _file_base(getParam<std::string>("file_base")), _file_num(declareRecoverableData<unsigned int>("file_num", 0)), _padding(getParam<unsigned int>("padding")), _output_file(true) { // If restarting reset the file number if (_problem_ptr->isRestarting()) _file_num = 0; // Set the file base, if it has not been set already if (!isParamValid("file_base")) { if (getParam<bool>("_short_cut")) _file_base = getOutputFileBase(_app); else _file_base = getOutputFileBase(_app, "_" + name); } // Check the file directory of file_base std::string base = "./" + _file_base; base = base.substr(0, base.find_last_of('/')); if (access(base.c_str(), W_OK) == -1) mooseError("Can not write to directory: " + base + " for file base: " + _file_base); // Append the 'displaced' name, if desired and displaced mesh is being used if (isParamValid("use_displaced") && getParam<bool>("use_displaced") && isParamValid("append_displaced") && getParam<bool>("append_displaced")) _file_base = _file_base + "_displaced"; // Update the file_base check _output_file = checkFilename(); }
bool Transfercontrol::start(int source, int dest, int id, char* filename, Net &net, Client &client) // initiate file transfer from source to dest // the caller should give this transaction an id that is unique to this source { if (std::strlen(filename) < MAX_FILENAME_SIZE) { *out << VERBOSE_LOUD << "Starting transfer...\n"; bool found = false; for (int i = 0; i < (int) transferrecv.size(); i++) { if (transferrecv[i].getSource() == source && transferrecv[i].getId() == id) { // needs a source, id pair to be unique found = true; break; } } if (!found) { if (checkFilename(filename)) { transferrecv.push_back(Transferrecv(source, dest, id, writePath.c_str(), filename)); if (!transferrecv.back().getActive()) return false; // already got file }else *out << VERBOSE_LOUD << "Error with filename, failed the check, transaction ignored\n"; }else{ *out << VERBOSE_LOUD << "Error, transfer already being processed\n"; } *out << VERBOSE_LOUD << "Started transfer\n"; }else{ *out << VERBOSE_LOUD << "Error with transfer start, filename too long\n"; } return true; // started - only return false if file is already there, indicating need to loadRemote }
//-------------------------------------------------------------------------------- int main(int argc, char** argv) { if(argc < 2) { PCL_ERROR("Syntax is: %s <source.ply>", argv[0]); return EXIT_FAILURE; } // load pointcloud from file std::string fname = std::string(argv[1]); if (!checkFilename(fname)) { PCL_ERROR("Given file is not a valid .ply file: ", argv[1]); return EXIT_FAILURE; } std::cout << "loading " << fname << std::endl; pcl::PointCloud<PointT>::Ptr cloud_in(new pcl::PointCloud<PointT>); pcl::io::loadPLYFile(fname, *cloud_in); // moving least squares pcl::PointCloud<PointT>::Ptr cloud_mls = runMLS(cloud_in); // save output if (!cloud_mls->empty()) { pcl::io::savePLYFileBinary("cloud_xyzrgb_mls.ply", *cloud_mls); } else { PCL_ERROR("MLS result pointcloud is empty."); return EXIT_FAILURE; } return EXIT_SUCCESS; }
bool FileOutput::shouldOutput(const ExecFlagType & type) { if (!checkFilename()) return false; return Output::shouldOutput(type); }
/*! * \fn G_MODULE_EXPORT void validAssistantNewCsuOne(GtkWidget *widget, gpointer data) * Valid the first page of the assistant for a new csu file * \param[in] widget the widget which send the signal * \param[in] data the globalData */ G_MODULE_EXPORT void validAssistantNewCsuOne(GtkWidget *widget, gpointer data) { globalData *user_data = (globalData*) data; gchar name[SIZE_MAX_FILE_NAME]; gint index; gchar *folder; bool folder_ok; bool filename_ok; GtkWidget *grid_1 = getWidgetFromBuilder(user_data->ptr_builder,"grid_new_csu_file_assistant_1"); /* Get the filename, the index of the game configuration and the folder */ g_utf8_strncpy(name,gtk_entry_get_text(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid_1),1,0))),SIZE_MAX_FILE_NAME/8); index = gtk_combo_box_get_active(GTK_COMBO_BOX(gtk_grid_get_child_at(GTK_GRID(grid_1),1,3))); folder = g_locale_from_utf8(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(gtk_grid_get_child_at(GTK_GRID(grid_1),1,1))),-1,NULL,NULL,NULL); #ifndef PORTABLE folder_ok = changeSystemPath(folder); #else folder_ok = checkPath(folder); #endif // PORTABLE filename_ok = checkFilename(name,folder); /* Test the filename */ if (strcmp(name,"") == 0 || filename_ok == false) setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid_1),0,0)),0,TRUE,100,0,0,FALSE,0,0,0); else setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid_1),0,0)),0,FALSE,100,0,0,FALSE,0,0,0); /* Test if a game configuration is selected */ if (index < 0 ) setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid_1),0,3)),0,TRUE,100,0,0,FALSE,0,0,0); else setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid_1),0,3)),0,FALSE,100,0,0,FALSE,0,0,0); /* Test the folder */ if (folder_ok == false) setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid_1),0,1)),0,TRUE,100,0,0,FALSE,0,0,0); else setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid_1),0,1)),0,FALSE,100,0,0,FALSE,0,0,0); /* Test if the page one is valid or not */ if (strcmp(name,"") != 0 && index >=0 && folder_ok != false && filename_ok == true) { gtk_assistant_set_page_complete(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1,TRUE); if (user_data->ptr_csu_struct_tmp != NULL) closeCsuStruct(user_data->ptr_csu_struct_tmp); user_data->ptr_csu_struct_tmp = newCsuStruct(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(gtk_grid_get_child_at(GTK_GRID(grid_1),1,2))),user_data->config); } else gtk_assistant_set_page_complete(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1,FALSE); g_free(folder); }
void checkTable(struct sqlConnection *conn, char *table, struct hash *mdbHash, struct hash *allBbiNames) // check to see if table is represented in the metaDb.ra // Also check gbdb referencing tables to see if files exist and have // the correct name { verbose(2, "checking table %s\n", table); if (hashLookup(mdbHash, table) == NULL) warn("table %s is not in metaDb", table); int result = sqlFieldIndex(conn, table, "fileName"); if (result >= 0) checkFilename(conn, table, allBbiNames); }
ImageExporterOutputWidget::ImageExporterOutputWidget(gloperate::ResourceManager & resourceManager, gloperate::Painter * painter, gloperate_qt::QtOpenGLWindow * context, QWidget *parent) : QWidget(parent) , m_context(context) , m_supportedTags( { { "width", "<width>" }, { "height", "<height>" }, { "enum_num", "<enum#" }, { "year", "<year>" }, { "month", "<month>" }, { "day", "<day>" }, { "hour", "<hour>" }, { "minute", "<minute>" }, { "second", "<second>" }, { "millisec", "<millisecond>" } }) , m_ui(new Ui_ImageExporterOutputWidget) , m_resolution(new QSize(1,1)) { m_ui->setupUi(this); m_ui->fileNameTextEdit->setMaximumHeight(m_ui->directoryLineEdit->height() * 2); initializeFileNameTextEdit(); connect(m_ui->saveButton, &QPushButton::clicked, this, &ImageExporterOutputWidget::handleSave); connect(m_ui->openDirectoryButton, &QPushButton::clicked, this, &ImageExporterOutputWidget::browseDirectory); connect(m_ui->fileNameTextEdit, &FileNameTextEdit::textChanged, this, &ImageExporterOutputWidget::checkFilename); connect(m_ui->fileNameTextEdit, &FileNameTextEdit::textChanged, this, &ImageExporterOutputWidget::saveFilename); connect(this, &ImageExporterOutputWidget::filenameChanged, this, &ImageExporterOutputWidget::updateFilenamePreview); m_imageExporter = new gloperate::ImageExporter(painter, resourceManager); context->makeCurrent(); m_imageExporter->initialize(); context->doneCurrent(); if (!gloperate::ImageExporter::isApplicableTo(painter)) m_ui->saveButton->setDisabled(true); restoreSettings(); updateDirectory(); checkFilename(); }
int MainWindow::RadiosondeEquipmentConverter( const QString &s_FilenameIn, QStringList &sl_FilenameOut, structMethod *Method_ptr, structStation *Station_ptr, const int i_NumOfFiles ) { int i_Year = 2000; int i_Month = 1; int i_Day = 1; int i_StationNumber = 0; int i_MethodID = 0; QString InputStr = ""; QString s_RadiosondeIdentification = ""; QString SearchString1 = "*C0005"; QString SearchString2 = "*U0005"; QString s_StationName = ""; QString s_EventLabel = ""; unsigned int ui_length = 1; unsigned int ui_filesize = 1; bool b_Stop = false; // *********************************************************************************************************************** QFileInfo fi( s_FilenameIn ); if ( ( fi.exists() == false ) || ( fi.suffix().toLower() == "zip" ) || ( fi.suffix().toLower() == "gz" ) ) return( _FILENOEXISTS_ ); // *********************************************************************************************************************** QFile fin( s_FilenameIn ); if ( fin.open( QIODevice::ReadOnly | QIODevice::Text ) == false ) return( -10 ); ui_filesize = fin.size(); // *********************************************************************************************************************** QTextStream tin( &fin ); // *********************************************************************************************************************** initProgress( i_NumOfFiles, s_FilenameIn, tr( "Radiosonde equipment converter working ..." ), 100 ); // *********************************************************************************************************************** InputStr = tin.readLine(); ui_length = incProgress( i_NumOfFiles, ui_filesize, ui_length, InputStr ); if ( ( InputStr.startsWith( "*C0001" ) == false ) && ( InputStr.startsWith( "*U0001" ) == false ) ) { resetProgress( i_NumOfFiles ); fin.close(); return( -40 ); } // *********************************************************************************************************************** InputStr = tin.readLine(); ui_length = incProgress( i_NumOfFiles, ui_filesize, ui_length, InputStr ); i_StationNumber = InputStr.left( 3 ).toInt(); s_StationName = findStationName( i_StationNumber, Station_ptr ); s_EventLabel = findEventLabel( i_StationNumber, Station_ptr ); // *********************************************************************************************************************** i_Day = 1; i_Month = InputStr.mid( 4, 2 ).toInt(); i_Year = InputStr.mid( 7, 4 ).toInt(); QDateTime dt = QDateTime().toUTC(); dt.setDate( QDate( i_Year, i_Month, i_Day ) ); dt.setTime( QTime( 0, 0, 0 ) ); // *********************************************************************************************************************** if ( checkFilename( fi.fileName(), s_EventLabel, InputStr.mid( 4, 2 ), InputStr.mid( 9, 2 ) ) == false ) { resetProgress( i_NumOfFiles ); fin.close(); return( -41 ); } // *********************************************************************************************************************** QFile fout( fi.absolutePath() + "/" + s_EventLabel + "_" + dt.toString( "yyyy-MM" ) + "_0005.txt" ); if ( fout.open( QIODevice::WriteOnly | QIODevice::Text ) == false ) { resetProgress( i_NumOfFiles ); fin.close(); return( -20 ); } QTextStream tout( &fout ); appendItem( sl_FilenameOut, fout.fileName() ); // *********************************************************************************************************************** // LR0005 tout << "File name\tStation ID\tEvent label\tStation\tYYYY-MM\t"; tout << "Manufacturer\tLocation\tDistance from radiation site [km]\t"; tout << "Time of 1st launch [hh]\tTime of 2nd launch [hh]\tTime of 3rd launch [hh]\t"; tout << "Time of 4th launch [hh]\tIdentification of radiosonde\tRemarks\t"; tout << "PANGAEA method\tPANGAEA method ID" << endl; while ( ( tin.atEnd() == false ) && ( ui_length != (unsigned int) _APPBREAK_ ) && ( b_Stop == false ) ) { InputStr = tin.readLine(); ui_length = incProgress( i_NumOfFiles, ui_filesize, ui_length, InputStr ); if ( ( InputStr.startsWith( SearchString1 ) == true ) || ( InputStr.startsWith( SearchString2 ) == true ) ) { tout << s_EventLabel.toLower() << dt.toString( "MMyy" ) << ".dat" << "\t"; tout << i_StationNumber << "\t" << s_EventLabel << "\t" << s_StationName << "\t" << dt.toString( "yyyy-MM" ) << "\t"; InputStr = tin.readLine(); ui_length = incProgress( i_NumOfFiles, ui_filesize, ui_length, InputStr ); if ( InputStr.simplified().right( 1 ) == "Y" ) { InputStr = tin.readLine(); ui_length = incProgress( i_NumOfFiles, ui_filesize, ui_length, InputStr ); tout << InputStr.left( 30 ).simplified() << "\t"; tout << InputStr.mid( 30, 25 ).simplified() << "\t"; tout << InputStr.mid( 57, 3 ) << "\t"; tout << InputStr.mid( 61, 2 ) << "\t"; tout << InputStr.mid( 64, 2 ) << "\t"; tout << InputStr.mid( 67, 2 ) << "\t"; tout << InputStr.mid( 70, 2 ) << "\t"; tout << InputStr.mid( 73, 5 ).simplified() << "\t"; s_RadiosondeIdentification = InputStr.left( 30 ).simplified(); if ( InputStr.mid( 73, 5 ).simplified().isEmpty() == false ) s_RadiosondeIdentification += ", " + InputStr.mid( 73, 5 ).simplified(); i_MethodID = findMethodID( s_RadiosondeIdentification, Method_ptr ); InputStr = tin.readLine(); ui_length = incProgress( i_NumOfFiles, ui_filesize, ui_length, InputStr ); tout << InputStr.simplified() << "\t" << "Radiosonde, " << s_RadiosondeIdentification << "\t"; tout << i_MethodID << endl; } b_Stop = true; } // Abort if first data record reached if ( ( InputStr.startsWith( "*C0100" ) == true ) || ( InputStr.startsWith( "*U0100" ) == true ) ) b_Stop = true; } //--------------------------------------------------------------------------------------------------- resetProgress( i_NumOfFiles ); fin.close(); fout.close(); if ( ui_length == (unsigned int) _APPBREAK_ ) return( _APPBREAK_ ); return( _NOERROR_ ); }