Commit 687c4e76 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'feature/filemanager-improvements' into 'master'

FileManager improvements

See merge request !37
parents ad214e55 c7ff1cac
Pipeline #7506 failed with stage
in 3 minutes and 39 seconds
......@@ -126,7 +126,9 @@ bool FileManager::getCleanLine(std::istream& _ifs, std::string& _string, bool _s
}
if(_ifs.eof()) {
std::cerr << "End of file reached while searching for input!" << std::endl;
if (verbosity_level_ >= 2) {
std::cerr << "End of file reached while searching for input!" << std::endl;
}
return false;
}
}
......@@ -141,7 +143,9 @@ bool FileManager::isHexahedralMesh(const std::string& _filename) const {
std::ifstream iff(_filename.c_str(), std::ios::in);
if(!iff.good()) {
std::cerr << "Could not open file " << _filename << " for reading!" << std::endl;
if (verbosity_level_ >= 1) {
std::cerr << "Could not open file " << _filename << " for reading!" << std::endl;
}
iff.close();
return false;
}
......@@ -185,7 +189,9 @@ bool FileManager::isTetrahedralMesh(const std::string& _filename) const {
std::ifstream iff(_filename.c_str(), std::ios::in);
if(!iff.good()) {
std::cerr << "Could not open file " << _filename << " for reading!" << std::endl;
if (verbosity_level_ >= 1) {
std::cerr << "Could not open file " << _filename << " for reading!" << std::endl;
}
iff.close();
return false;
}
......
......@@ -45,6 +45,8 @@
#include <string>
#include <fstream>
#include <istream>
#include <ostream>
namespace OpenVolumeMesh {
......@@ -66,6 +68,34 @@ public:
/// Default destructor
~FileManager();
/**
* \brief set minimum level for errors that are printed to std::cerr
* @param _level 0: no output; 1: only errors; 2: warnings/info
*/
void setVerbosityLevel(int _level) { verbosity_level_ = _level;}
/**
* \brief Read a mesh from an std::istream
*
* Returns true if the file was successfully read. The mesh
* is stored in parameter _mesh. If something goes wrong,
* this function returns false.
*
* @param _istream The stream to read the mesh from
* @param _mesh A reference to an OpenVolumeMesh instance
* @param _topologyCheck Pass true if you want to perform a topology check
* each time an entity is added (slower performance)
* @param _computeBottomUpIncidences Pass true if you want the file manager
* to directly compute the bottom-up incidences
* for the mesh. (Note: These are needed for
* some iterators to work, see documentation)
*/
template <class MeshT>
bool readStream(std::istream &_istream, MeshT& _mesh,
bool _topologyCheck = true,
bool _computeBottomUpIncidences = true) const;
/**
* \brief Read a mesh from a file
*
......@@ -87,6 +117,16 @@ public:
bool _topologyCheck = true,
bool _computeBottomUpIncidences = true) const;
/**
* \brief Write a mesh to an std::ostream
*
* @param _ostream The stream to write the mesh to
* @param _mesh A const reference to an OpenVolumeMesh instance
*/
template <class MeshT>
void writeStream(std::ostream &_ostream, const MeshT& _mesh) const;
/**
* \brief Write a mesh to a file
*
......@@ -134,6 +174,9 @@ private:
// Get a whole line from file
bool getCleanLine(std::istream& ifs, std::string& _string, bool _skipEmptyLines = true) const;
int verbosity_level_ = 3;
};
} // Namespace IO
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment