diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h index e0963c20cf6c69b8f53a3f96f598942347ba475c..f84a3834ebb28767374455d8d48035ffac275dbf 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h @@ -79,6 +79,8 @@ protected: std::string m_FileName; + std::string m_PreviousFileName; + private: InputVectorDataParameter(const Parameter &); //purposely not implemented void operator =(const Parameter&); //purposely not implemented diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataParameter.cxx index e358a38b319d15b07dd232381d9dcb5b47aee9c4..f60cf29078bf0c487c35b90ed0c94f9fcee1800d 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataParameter.cxx @@ -43,28 +43,11 @@ InputVectorDataParameter::SetFromFileName(const std::string& filename) // First clear previous file chosen this->ClearValue(); - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) - if (!filename.empty() - && itksys::SystemTools::FileExists(filename.c_str())) - { - VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New(); - try - { - reader->SetFileName(filename); - reader->UpdateOutputInformation(); - } - catch(itk::ExceptionObject & /*err*/) - { - return false; - } + // No file existence is done here : + m_FileName = filename; + SetActive( true ); - // the specified filename is valid => store the value - m_FileName = filename; - SetActive(true); - return true; - } - return false; + return true; } @@ -80,23 +63,17 @@ InputVectorDataParameter::GetVectorData() { // 2 cases : the user sets a filename vs. the user sets a vector data //////////////////////// Filename case: - if (!m_FileName.empty()) + if (!m_FileName.empty() && m_PreviousFileName!=m_FileName) { - //typedef otb::ImageFileReader<TOutputImage> ReaderType; - //typename ReaderType::Pointer reader = ReaderType::New(); - m_Reader = VectorDataFileReaderType::New(); - m_Reader->SetFileName(m_FileName); - try - { - // Update the viewer here to load the file => no streaming for VectorData - m_Reader->Update(); - } - catch (itk::ExceptionObject &) - { - this->ClearValue(); - } + VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New(); + reader->SetFileName(m_FileName); + // Update the viewer here to load the file => no streaming for VectorData + reader->Update(); + + m_VectorData = reader->GetOutput(); + m_Reader = reader; - m_VectorData = m_Reader->GetOutput(); + m_PreviousFileName = m_FileName; } //////////////////////// VectorData case: else @@ -104,7 +81,7 @@ InputVectorDataParameter::GetVectorData() if (m_VectorData.IsNull()) { // Else : error - itkExceptionMacro("No input vector data or filename detected..."); + itkExceptionMacro("No input vector data detected..."); } }