- added precision option to MeshIO and IOManager
refs #1157 git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@748 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -4,10 +4,10 @@
|
|||||||
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
|
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
|
||||||
* www.openmesh.org *
|
* www.openmesh.org *
|
||||||
* *
|
* *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
* This file is part of OpenMesh. *
|
* This file is part of OpenMesh. *
|
||||||
* *
|
* *
|
||||||
* OpenMesh is free software: you can redistribute it and/or modify *
|
* OpenMesh is free software: you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
* published by the Free Software Foundation, either version 3 of *
|
* published by the Free Software Foundation, either version 3 of *
|
||||||
* the License, or (at your option) any later version with the *
|
* the License, or (at your option) any later version with the *
|
||||||
@@ -30,10 +30,10 @@
|
|||||||
* License along with OpenMesh. If not, *
|
* License along with OpenMesh. If not, *
|
||||||
* see <http://www.gnu.org/licenses/>. *
|
* see <http://www.gnu.org/licenses/>. *
|
||||||
* *
|
* *
|
||||||
\*===========================================================================*/
|
\*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*\
|
/*===========================================================================*\
|
||||||
* *
|
* *
|
||||||
* $Revision$ *
|
* $Revision$ *
|
||||||
* $Date$ *
|
* $Date$ *
|
||||||
* *
|
* *
|
||||||
@@ -69,7 +69,7 @@ _IOManager_ *__IOManager_instance = 0;
|
|||||||
|
|
||||||
_IOManager_& IOManager()
|
_IOManager_& IOManager()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!__IOManager_instance)
|
if (!__IOManager_instance)
|
||||||
__IOManager_instance = new _IOManager_();
|
__IOManager_instance = new _IOManager_();
|
||||||
|
|
||||||
@@ -80,13 +80,13 @@ _IOManager_& IOManager()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_IOManager_::
|
_IOManager_::
|
||||||
read(const std::string& _filename, BaseImporter& _bi, Options& _opt)
|
read(const std::string& _filename, BaseImporter& _bi, Options& _opt)
|
||||||
{
|
{
|
||||||
std::set<BaseReader*>::const_iterator it = reader_modules_.begin();
|
std::set<BaseReader*>::const_iterator it = reader_modules_.begin();
|
||||||
std::set<BaseReader*>::const_iterator it_end = reader_modules_.end();
|
std::set<BaseReader*>::const_iterator it_end = reader_modules_.end();
|
||||||
|
|
||||||
// Try all registered modules
|
// Try all registered modules
|
||||||
for(; it != it_end; ++it)
|
for(; it != it_end; ++it)
|
||||||
if ((*it)->can_u_read(_filename))
|
if ((*it)->can_u_read(_filename))
|
||||||
@@ -96,32 +96,7 @@ read(const std::string& _filename, BaseImporter& _bi, Options& _opt)
|
|||||||
_bi.finish();
|
_bi.finish();
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All modules failed to read
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
_IOManager_::
|
|
||||||
read(std::istream& _is, const std::string& _ext, BaseImporter& _bi, Options& _opt)
|
|
||||||
{
|
|
||||||
std::set<BaseReader*>::const_iterator it = reader_modules_.begin();
|
|
||||||
std::set<BaseReader*>::const_iterator it_end = reader_modules_.end();
|
|
||||||
|
|
||||||
// Try all registered modules
|
|
||||||
for(; it != it_end; ++it)
|
|
||||||
if ((*it)->BaseReader::can_u_read(_ext)) //Use the extension check only (no file existence)
|
|
||||||
{
|
|
||||||
_bi.prepare();
|
|
||||||
bool ok = (*it)->read(_is, _bi, _opt);
|
|
||||||
_bi.finish();
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
// All modules failed to read
|
// All modules failed to read
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -132,11 +107,36 @@ read(std::istream& _is, const std::string& _ext, BaseImporter& _bi, Options& _op
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
_IOManager_::
|
_IOManager_::
|
||||||
write(const std::string& _filename, BaseExporter& _be, Options _opt)
|
read(std::istream& _is, const std::string& _ext, BaseImporter& _bi, Options& _opt)
|
||||||
|
{
|
||||||
|
std::set<BaseReader*>::const_iterator it = reader_modules_.begin();
|
||||||
|
std::set<BaseReader*>::const_iterator it_end = reader_modules_.end();
|
||||||
|
|
||||||
|
// Try all registered modules
|
||||||
|
for(; it != it_end; ++it)
|
||||||
|
if ((*it)->BaseReader::can_u_read(_ext)) //Use the extension check only (no file existence)
|
||||||
|
{
|
||||||
|
_bi.prepare();
|
||||||
|
bool ok = (*it)->read(_is, _bi, _opt);
|
||||||
|
_bi.finish();
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All modules failed to read
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
_IOManager_::
|
||||||
|
write(const std::string& _filename, BaseExporter& _be, Options _opt, std::streamsize _precision)
|
||||||
{
|
{
|
||||||
std::set<BaseWriter*>::const_iterator it = writer_modules_.begin();
|
std::set<BaseWriter*>::const_iterator it = writer_modules_.begin();
|
||||||
std::set<BaseWriter*>::const_iterator it_end = writer_modules_.end();
|
std::set<BaseWriter*>::const_iterator it_end = writer_modules_.end();
|
||||||
|
|
||||||
if ( it == it_end )
|
if ( it == it_end )
|
||||||
{
|
{
|
||||||
omerr() << "[OpenMesh::IO::_IOManager_] No writing modules available!\n";
|
omerr() << "[OpenMesh::IO::_IOManager_] No writing modules available!\n";
|
||||||
@@ -148,10 +148,10 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt)
|
|||||||
{
|
{
|
||||||
if ((*it)->can_u_write(_filename))
|
if ((*it)->can_u_write(_filename))
|
||||||
{
|
{
|
||||||
return (*it)->write(_filename, _be, _opt);
|
return (*it)->write(_filename, _be, _opt, _precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// All modules failed to save
|
// All modules failed to save
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -161,11 +161,11 @@ write(const std::string& _filename, BaseExporter& _be, Options _opt)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
_IOManager_::
|
_IOManager_::
|
||||||
write(std::ostream& _os,const std::string &_ext, BaseExporter& _be, Options _opt)
|
write(std::ostream& _os,const std::string &_ext, BaseExporter& _be, Options _opt, std::streamsize _precision)
|
||||||
{
|
{
|
||||||
std::set<BaseWriter*>::const_iterator it = writer_modules_.begin();
|
std::set<BaseWriter*>::const_iterator it = writer_modules_.begin();
|
||||||
std::set<BaseWriter*>::const_iterator it_end = writer_modules_.end();
|
std::set<BaseWriter*>::const_iterator it_end = writer_modules_.end();
|
||||||
|
|
||||||
if ( it == it_end )
|
if ( it == it_end )
|
||||||
{
|
{
|
||||||
omerr() << "[OpenMesh::IO::_IOManager_] No writing modules available!\n";
|
omerr() << "[OpenMesh::IO::_IOManager_] No writing modules available!\n";
|
||||||
@@ -177,10 +177,10 @@ write(std::ostream& _os,const std::string &_ext, BaseExporter& _be, Options _opt
|
|||||||
{
|
{
|
||||||
if ((*it)->BaseWriter::can_u_write(_ext)) //Restrict test to the extension check
|
if ((*it)->BaseWriter::can_u_write(_ext)) //Restrict test to the extension check
|
||||||
{
|
{
|
||||||
return (*it)->write(_os, _be, _opt);
|
return (*it)->write(_os, _be, _opt, _precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// All modules failed to save
|
// All modules failed to save
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -188,18 +188,18 @@ write(std::ostream& _os,const std::string &_ext, BaseExporter& _be, Options _opt
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_IOManager_::
|
_IOManager_::
|
||||||
can_read( const std::string& _format ) const
|
can_read( const std::string& _format ) const
|
||||||
{
|
{
|
||||||
std::set<BaseReader*>::const_iterator it = reader_modules_.begin();
|
std::set<BaseReader*>::const_iterator it = reader_modules_.begin();
|
||||||
std::set<BaseReader*>::const_iterator it_end = reader_modules_.end();
|
std::set<BaseReader*>::const_iterator it_end = reader_modules_.end();
|
||||||
std::string filename = "dummy." + _format;
|
std::string filename = "dummy." + _format;
|
||||||
|
|
||||||
for(; it != it_end; ++it)
|
for(; it != it_end; ++it)
|
||||||
if ((*it)->can_u_read(filename))
|
if ((*it)->can_u_read(filename))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,12 +214,12 @@ can_write( const std::string& _format ) const
|
|||||||
std::set<BaseWriter*>::const_iterator it = writer_modules_.begin();
|
std::set<BaseWriter*>::const_iterator it = writer_modules_.begin();
|
||||||
std::set<BaseWriter*>::const_iterator it_end = writer_modules_.end();
|
std::set<BaseWriter*>::const_iterator it_end = writer_modules_.end();
|
||||||
std::string filename = "dummy." + _format;
|
std::string filename = "dummy." + _format;
|
||||||
|
|
||||||
// Try all registered modules
|
// Try all registered modules
|
||||||
for(; it != it_end; ++it)
|
for(; it != it_end; ++it)
|
||||||
if ((*it)->can_u_write(filename))
|
if ((*it)->can_u_write(filename))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ _IOManager_::
|
|||||||
find_writer(const std::string& _format)
|
find_writer(const std::string& _format)
|
||||||
{
|
{
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
string::size_type dot = _format.rfind('.');
|
string::size_type dot = _format.rfind('.');
|
||||||
|
|
||||||
string ext;
|
string ext;
|
||||||
@@ -240,11 +240,11 @@ find_writer(const std::string& _format)
|
|||||||
ext = _format;
|
ext = _format;
|
||||||
else
|
else
|
||||||
ext = _format.substr(dot+1,_format.length()-(dot+1));
|
ext = _format.substr(dot+1,_format.length()-(dot+1));
|
||||||
|
|
||||||
std::set<BaseWriter*>::const_iterator it = writer_modules_.begin();
|
std::set<BaseWriter*>::const_iterator it = writer_modules_.begin();
|
||||||
std::set<BaseWriter*>::const_iterator it_end = writer_modules_.end();
|
std::set<BaseWriter*>::const_iterator it_end = writer_modules_.end();
|
||||||
std::string filename = "dummy." + ext;
|
std::string filename = "dummy." + ext;
|
||||||
|
|
||||||
// Try all registered modules
|
// Try all registered modules
|
||||||
for(; it != it_end; ++it)
|
for(; it != it_end; ++it)
|
||||||
if ((*it)->can_u_write(filename))
|
if ((*it)->can_u_write(filename))
|
||||||
@@ -252,7 +252,7 @@ find_writer(const std::string& _format)
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ update_read_filters()
|
|||||||
it_end = reader_modules_.end();
|
it_end = reader_modules_.end();
|
||||||
std::string all = "";
|
std::string all = "";
|
||||||
std::string filters = "";
|
std::string filters = "";
|
||||||
|
|
||||||
for(; it != it_end; ++it)
|
for(; it != it_end; ++it)
|
||||||
{
|
{
|
||||||
// Initialized with space, as a workaround for debug build with clang on mac
|
// Initialized with space, as a workaround for debug build with clang on mac
|
||||||
@@ -273,19 +273,19 @@ update_read_filters()
|
|||||||
std::string tmp = " ";
|
std::string tmp = " ";
|
||||||
|
|
||||||
filters += (*it)->get_description() + " (";
|
filters += (*it)->get_description() + " (";
|
||||||
|
|
||||||
std::istringstream iss((*it)->get_extensions());
|
std::istringstream iss((*it)->get_extensions());
|
||||||
|
|
||||||
while (iss && !iss.eof() && (iss >> tmp) )
|
while (iss && !iss.eof() && (iss >> tmp) )
|
||||||
{
|
{
|
||||||
tmp = " *." + tmp; filters += tmp; all += tmp;
|
tmp = " *." + tmp; filters += tmp; all += tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
filters += " );;";
|
filters += " );;";
|
||||||
}
|
}
|
||||||
|
|
||||||
all = "All files ( " + all + " );;";
|
all = "All files ( " + all + " );;";
|
||||||
|
|
||||||
read_filters_ = all + filters;
|
read_filters_ = all + filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ update_write_filters()
|
|||||||
it_end = writer_modules_.end();
|
it_end = writer_modules_.end();
|
||||||
std::string all;
|
std::string all;
|
||||||
std::string filters;
|
std::string filters;
|
||||||
|
|
||||||
for(; it != it_end; ++it)
|
for(; it != it_end; ++it)
|
||||||
{
|
{
|
||||||
// Initialized with space, as a workaround for debug build with clang on mac
|
// Initialized with space, as a workaround for debug build with clang on mac
|
||||||
@@ -319,7 +319,7 @@ update_write_filters()
|
|||||||
all = "All files ( " + all + " );;";
|
all = "All files ( " + all + " );;";
|
||||||
|
|
||||||
write_filters_ = all + filters;
|
write_filters_ = all + filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
|
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
|
||||||
* www.openmesh.org *
|
* www.openmesh.org *
|
||||||
* *
|
* *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
* This file is part of OpenMesh. *
|
* This file is part of OpenMesh. *
|
||||||
* *
|
* *
|
||||||
* OpenMesh is free software: you can redistribute it and/or modify *
|
* OpenMesh is free software: you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
* published by the Free Software Foundation, either version 3 of *
|
* published by the Free Software Foundation, either version 3 of *
|
||||||
* the License, or (at your option) any later version with the *
|
* the License, or (at your option) any later version with the *
|
||||||
@@ -30,10 +30,10 @@
|
|||||||
* License along with OpenMesh. If not, *
|
* License along with OpenMesh. If not, *
|
||||||
* see <http://www.gnu.org/licenses/>. *
|
* see <http://www.gnu.org/licenses/>. *
|
||||||
* *
|
* *
|
||||||
\*===========================================================================*/
|
\*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*\
|
/*===========================================================================*\
|
||||||
* *
|
* *
|
||||||
* $Revision$ *
|
* $Revision$ *
|
||||||
* $Date$ *
|
* $Date$ *
|
||||||
* *
|
* *
|
||||||
@@ -78,7 +78,7 @@ namespace IO {
|
|||||||
//=== IMPLEMENTATION ==========================================================
|
//=== IMPLEMENTATION ==========================================================
|
||||||
|
|
||||||
|
|
||||||
/** This is the real IOManager class that is later encapsulated by
|
/** This is the real IOManager class that is later encapsulated by
|
||||||
SingletonT to enforce its uniqueness. _IOManager_ is not meant to be used
|
SingletonT to enforce its uniqueness. _IOManager_ is not meant to be used
|
||||||
directly by the programmer - the IOManager alias exists for this task.
|
directly by the programmer - the IOManager alias exists for this task.
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ namespace IO {
|
|||||||
class OPENMESHDLLEXPORT _IOManager_
|
class OPENMESHDLLEXPORT _IOManager_
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
_IOManager_() {}
|
_IOManager_() {}
|
||||||
friend OPENMESHDLLEXPORT _IOManager_& IOManager();
|
friend OPENMESHDLLEXPORT _IOManager_& IOManager();
|
||||||
|
|
||||||
@@ -111,46 +111,48 @@ public:
|
|||||||
/**
|
/**
|
||||||
Read a mesh from file _filename. The target data structure is specified
|
Read a mesh from file _filename. The target data structure is specified
|
||||||
by the given BaseImporter. The \c read method consecutively queries all
|
by the given BaseImporter. The \c read method consecutively queries all
|
||||||
of its reader modules. True is returned upon success, false if all
|
of its reader modules. True is returned upon success, false if all
|
||||||
reader modules failed to interprete _filename.
|
reader modules failed to interprete _filename.
|
||||||
*/
|
*/
|
||||||
bool read(const std::string& _filename,
|
bool read(const std::string& _filename,
|
||||||
BaseImporter& _bi,
|
BaseImporter& _bi,
|
||||||
Options& _opt);
|
Options& _opt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read a mesh from open std::istream _is. The target data structure is specified
|
Read a mesh from open std::istream _is. The target data structure is specified
|
||||||
by the given BaseImporter. The \c sread method consecutively queries all
|
by the given BaseImporter. The \c sread method consecutively queries all
|
||||||
of its reader modules. True is returned upon success, false if all
|
of its reader modules. True is returned upon success, false if all
|
||||||
reader modules failed to use _is.
|
reader modules failed to use _is.
|
||||||
*/
|
*/
|
||||||
bool read(std::istream& _filename,
|
bool read(std::istream& _filename,
|
||||||
const std::string& _ext,
|
const std::string& _ext,
|
||||||
BaseImporter& _bi,
|
BaseImporter& _bi,
|
||||||
Options& _opt);
|
Options& _opt);
|
||||||
|
|
||||||
|
|
||||||
/** Write a mesh to file _filename. The source data structure is specified
|
/** Write a mesh to file _filename. The source data structure is specified
|
||||||
by the given BaseExporter. The \c save method consecutively queries all
|
by the given BaseExporter. The \c save method consecutively queries all
|
||||||
of its writer modules. True is returned upon success, false if all
|
of its writer modules. True is returned upon success, false if all
|
||||||
writer modules failed to write the requested format.
|
writer modules failed to write the requested format.
|
||||||
Options is determined by _filename's extension.
|
Options is determined by _filename's extension.
|
||||||
*/
|
*/
|
||||||
bool write(const std::string& _filename,
|
bool write(const std::string& _filename,
|
||||||
BaseExporter& _be,
|
BaseExporter& _be,
|
||||||
Options _opt=Options::Default);
|
Options _opt=Options::Default,
|
||||||
|
std::streamsize _precision = 6);
|
||||||
|
|
||||||
/** Write a mesh to open std::ostream _os. The source data structure is specified
|
/** Write a mesh to open std::ostream _os. The source data structure is specified
|
||||||
by the given BaseExporter. The \c save method consecutively queries all
|
by the given BaseExporter. The \c save method consecutively queries all
|
||||||
of its writer modules. True is returned upon success, false if all
|
of its writer modules. True is returned upon success, false if all
|
||||||
writer modules failed to write the requested format.
|
writer modules failed to write the requested format.
|
||||||
Options is determined by _filename's extension.
|
Options is determined by _filename's extension.
|
||||||
*/
|
*/
|
||||||
bool write(std::ostream& _filename,
|
bool write(std::ostream& _filename,
|
||||||
const std::string& _ext,
|
const std::string& _ext,
|
||||||
BaseExporter& _be,
|
BaseExporter& _be,
|
||||||
Options _opt=Options::Default);
|
Options _opt=Options::Default,
|
||||||
|
std::streamsize _precision = 6);
|
||||||
|
|
||||||
|
|
||||||
/// Returns true if the format is supported by one of the reader modules.
|
/// Returns true if the format is supported by one of the reader modules.
|
||||||
bool can_read( const std::string& _format ) const;
|
bool can_read( const std::string& _format ) const;
|
||||||
@@ -158,19 +160,19 @@ public:
|
|||||||
/// Returns true if the format is supported by one of the writer modules.
|
/// Returns true if the format is supported by one of the writer modules.
|
||||||
bool can_write( const std::string& _format ) const;
|
bool can_write( const std::string& _format ) const;
|
||||||
|
|
||||||
|
|
||||||
size_t binary_size(const std::string& _format,
|
size_t binary_size(const std::string& _format,
|
||||||
BaseExporter& _be,
|
BaseExporter& _be,
|
||||||
Options _opt = Options::Default)
|
Options _opt = Options::Default)
|
||||||
{
|
{
|
||||||
const BaseWriter *bw = find_writer(_format);
|
const BaseWriter *bw = find_writer(_format);
|
||||||
return bw ? bw->binary_size(_be,_opt) : 0;
|
return bw ? bw->binary_size(_be,_opt) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public: //-- QT convenience function ------------------------------------------
|
public: //-- QT convenience function ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/** Returns all readable file extension + descriptions in one string.
|
/** Returns all readable file extension + descriptions in one string.
|
||||||
File formats are separated by <c>;;</c>.
|
File formats are separated by <c>;;</c>.
|
||||||
@@ -180,7 +182,7 @@ public: //-- QT convenience function ------------------------------------------
|
|||||||
|
|
||||||
|
|
||||||
/** Returns all writeable file extension + descriptions in one string.
|
/** Returns all writeable file extension + descriptions in one string.
|
||||||
File formats are separated by <c>;;</c>.
|
File formats are separated by <c>;;</c>.
|
||||||
Convenience function for Qt file dialogs.
|
Convenience function for Qt file dialogs.
|
||||||
*/
|
*/
|
||||||
const std::string& qt_write_filters() const { return write_filters_; }
|
const std::string& qt_write_filters() const { return write_filters_; }
|
||||||
@@ -195,14 +197,14 @@ private:
|
|||||||
|
|
||||||
// collect all writeable file extensions
|
// collect all writeable file extensions
|
||||||
void update_write_filters();
|
void update_write_filters();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public: //-- SYSTEM PART------------------------------------------------------
|
public: //-- SYSTEM PART------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/** Registers a new reader module. A call to this function should be
|
/** Registers a new reader module. A call to this function should be
|
||||||
implemented in the constructor of all classes derived from BaseReader.
|
implemented in the constructor of all classes derived from BaseReader.
|
||||||
*/
|
*/
|
||||||
bool register_module(BaseReader* _bl)
|
bool register_module(BaseReader* _bl)
|
||||||
{
|
{
|
||||||
@@ -212,9 +214,9 @@ public: //-- SYSTEM PART------------------------------------------------------
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Registers a new writer module. A call to this function should be
|
/** Registers a new writer module. A call to this function should be
|
||||||
implemented in the constructor of all classed derived from BaseWriter.
|
implemented in the constructor of all classed derived from BaseWriter.
|
||||||
*/
|
*/
|
||||||
bool register_module(BaseWriter* _bw)
|
bool register_module(BaseWriter* _bw)
|
||||||
{
|
{
|
||||||
@@ -223,20 +225,20 @@ public: //-- SYSTEM PART------------------------------------------------------
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const BaseWriter *find_writer(const std::string& _format);
|
const BaseWriter *find_writer(const std::string& _format);
|
||||||
|
|
||||||
// stores registered reader modules
|
// stores registered reader modules
|
||||||
std::set<BaseReader*> reader_modules_;
|
std::set<BaseReader*> reader_modules_;
|
||||||
|
|
||||||
// stores registered writer modules
|
// stores registered writer modules
|
||||||
std::set<BaseWriter*> writer_modules_;
|
std::set<BaseWriter*> writer_modules_;
|
||||||
|
|
||||||
// input filters (e.g. for Qt file dialog)
|
// input filters (e.g. for Qt file dialog)
|
||||||
std::string read_filters_;
|
std::string read_filters_;
|
||||||
|
|
||||||
// output filters (e.g. for Qt file dialog)
|
// output filters (e.g. for Qt file dialog)
|
||||||
std::string write_filters_;
|
std::string write_filters_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
|
* Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
|
||||||
* www.openmesh.org *
|
* www.openmesh.org *
|
||||||
* *
|
* *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
* This file is part of OpenMesh. *
|
* This file is part of OpenMesh. *
|
||||||
* *
|
* *
|
||||||
* OpenMesh is free software: you can redistribute it and/or modify *
|
* OpenMesh is free software: you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
* published by the Free Software Foundation, either version 3 of *
|
* published by the Free Software Foundation, either version 3 of *
|
||||||
* the License, or (at your option) any later version with the *
|
* the License, or (at your option) any later version with the *
|
||||||
@@ -30,10 +30,10 @@
|
|||||||
* License along with OpenMesh. If not, *
|
* License along with OpenMesh. If not, *
|
||||||
* see <http://www.gnu.org/licenses/>. *
|
* see <http://www.gnu.org/licenses/>. *
|
||||||
* *
|
* *
|
||||||
\*===========================================================================*/
|
\*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*\
|
/*===========================================================================*\
|
||||||
* *
|
* *
|
||||||
* $Revision$ *
|
* $Revision$ *
|
||||||
* $Date$ *
|
* $Date$ *
|
||||||
* *
|
* *
|
||||||
@@ -79,12 +79,12 @@ namespace IO {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/** \brief Read a mesh from file _filename.
|
/** \brief Read a mesh from file _filename.
|
||||||
|
|
||||||
The file format is determined by the file extension.
|
The file format is determined by the file extension.
|
||||||
|
|
||||||
\note If you link statically against OpenMesh, you have to add
|
\note If you link statically against OpenMesh, you have to add
|
||||||
the define OM_STATIC_BUILD to your application. This will
|
the define OM_STATIC_BUILD to your application. This will
|
||||||
ensure that readers and writers get initialized correctly.
|
ensure that readers and writers get initialized correctly.
|
||||||
|
|
||||||
@param _mesh The target mesh that will be filled with the read data
|
@param _mesh The target mesh that will be filled with the read data
|
||||||
@@ -95,22 +95,22 @@ namespace IO {
|
|||||||
@return Successful?
|
@return Successful?
|
||||||
*/
|
*/
|
||||||
template <class Mesh>
|
template <class Mesh>
|
||||||
bool
|
bool
|
||||||
read_mesh(Mesh& _mesh,
|
read_mesh(Mesh& _mesh,
|
||||||
const std::string& _filename,
|
const std::string& _filename,
|
||||||
bool _clear = true)
|
bool _clear = true)
|
||||||
{
|
{
|
||||||
Options opt;
|
Options opt;
|
||||||
return read_mesh(_mesh, _filename, opt, _clear);
|
return read_mesh(_mesh, _filename, opt, _clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** \brief Read a mesh from file _filename.
|
/** \brief Read a mesh from file _filename.
|
||||||
|
|
||||||
The file format is determined by the file extension.
|
The file format is determined by the file extension.
|
||||||
|
|
||||||
\note If you link statically against OpenMesh, you have to add
|
\note If you link statically against OpenMesh, you have to add
|
||||||
the define OM_STATIC_BUILD to your application. This will
|
the define OM_STATIC_BUILD to your application. This will
|
||||||
ensure that readers and writers get initialized correctly.
|
ensure that readers and writers get initialized correctly.
|
||||||
|
|
||||||
@param _mesh The target mesh that will be filled with the read data
|
@param _mesh The target mesh that will be filled with the read data
|
||||||
@@ -123,25 +123,25 @@ read_mesh(Mesh& _mesh,
|
|||||||
@return Successful?
|
@return Successful?
|
||||||
*/
|
*/
|
||||||
template <class Mesh>
|
template <class Mesh>
|
||||||
bool
|
bool
|
||||||
read_mesh(Mesh& _mesh,
|
read_mesh(Mesh& _mesh,
|
||||||
const std::string& _filename,
|
const std::string& _filename,
|
||||||
Options& _opt,
|
Options& _opt,
|
||||||
bool _clear = true)
|
bool _clear = true)
|
||||||
{
|
{
|
||||||
if (_clear) _mesh.clear();
|
if (_clear) _mesh.clear();
|
||||||
ImporterT<Mesh> importer(_mesh);
|
ImporterT<Mesh> importer(_mesh);
|
||||||
return IOManager().read(_filename, importer, _opt);
|
return IOManager().read(_filename, importer, _opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** \brief Read a mesh from file open std::istream.
|
/** \brief Read a mesh from file open std::istream.
|
||||||
|
|
||||||
The file format is determined by parameter _ext. _ext has to include
|
The file format is determined by parameter _ext. _ext has to include
|
||||||
".[format]" in order to work properly (e.g. ".OFF")
|
".[format]" in order to work properly (e.g. ".OFF")
|
||||||
|
|
||||||
\note If you link statically against OpenMesh, you have to add
|
\note If you link statically against OpenMesh, you have to add
|
||||||
the define OM_STATIC_BUILD to your application. This will
|
the define OM_STATIC_BUILD to your application. This will
|
||||||
ensure that readers and writers get initialized correctly.
|
ensure that readers and writers get initialized correctly.
|
||||||
|
|
||||||
@param _mesh The target mesh that will be filled with the read data
|
@param _mesh The target mesh that will be filled with the read data
|
||||||
@@ -155,16 +155,16 @@ read_mesh(Mesh& _mesh,
|
|||||||
@return Successful?
|
@return Successful?
|
||||||
*/
|
*/
|
||||||
template <class Mesh>
|
template <class Mesh>
|
||||||
bool
|
bool
|
||||||
read_mesh(Mesh& _mesh,
|
read_mesh(Mesh& _mesh,
|
||||||
std::istream& _is,
|
std::istream& _is,
|
||||||
const std::string& _ext,
|
const std::string& _ext,
|
||||||
Options& _opt,
|
Options& _opt,
|
||||||
bool _clear = true)
|
bool _clear = true)
|
||||||
{
|
{
|
||||||
if (_clear) _mesh.clear();
|
if (_clear) _mesh.clear();
|
||||||
ImporterT<Mesh> importer(_mesh);
|
ImporterT<Mesh> importer(_mesh);
|
||||||
return IOManager().read(_is,_ext, importer, _opt);
|
return IOManager().read(_is,_ext, importer, _opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -172,12 +172,12 @@ read_mesh(Mesh& _mesh,
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/** \brief Write a mesh to the file _filename.
|
/** \brief Write a mesh to the file _filename.
|
||||||
|
|
||||||
The file format is determined by _filename's extension.
|
The file format is determined by _filename's extension.
|
||||||
|
|
||||||
\note If you link statically against OpenMesh, you have to add
|
\note If you link statically against OpenMesh, you have to add
|
||||||
the define OM_STATIC_BUILD to your application. This will
|
the define OM_STATIC_BUILD to your application. This will
|
||||||
ensure that readers and writers get initialized correctly.
|
ensure that readers and writers get initialized correctly.
|
||||||
|
|
||||||
@param _mesh The mesh that will be written to file
|
@param _mesh The mesh that will be written to file
|
||||||
@@ -188,25 +188,26 @@ read_mesh(Mesh& _mesh,
|
|||||||
@return Successful?
|
@return Successful?
|
||||||
*/
|
*/
|
||||||
template <class Mesh>
|
template <class Mesh>
|
||||||
bool write_mesh(const Mesh& _mesh,
|
bool write_mesh(const Mesh& _mesh,
|
||||||
const std::string& _filename,
|
const std::string& _filename,
|
||||||
Options _opt = Options::Default)
|
Options _opt = Options::Default,
|
||||||
{
|
std::streamsize _precision = 6)
|
||||||
|
{
|
||||||
ExporterT<Mesh> exporter(_mesh);
|
ExporterT<Mesh> exporter(_mesh);
|
||||||
return IOManager().write(_filename, exporter, _opt);
|
return IOManager().write(_filename, exporter, _opt, _precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/** Write a mesh to an open std::ostream.
|
/** Write a mesh to an open std::ostream.
|
||||||
|
|
||||||
The file format is determined by parameter _ext. _ext has to include
|
The file format is determined by parameter _ext. _ext has to include
|
||||||
".[format]" in order to work properly (e.g. ".OFF")
|
".[format]" in order to work properly (e.g. ".OFF")
|
||||||
|
|
||||||
\note If you link statically against OpenMesh, you have to add
|
\note If you link statically against OpenMesh, you have to add
|
||||||
the define OM_STATIC_BUILD to your application. This will
|
the define OM_STATIC_BUILD to your application. This will
|
||||||
ensure that readers and writers get initialized correctly.
|
ensure that readers and writers get initialized correctly.
|
||||||
|
|
||||||
@param _mesh The mesh that will be written to file
|
@param _mesh The mesh that will be written to file
|
||||||
@@ -218,13 +219,14 @@ bool write_mesh(const Mesh& _mesh,
|
|||||||
@return Successful?
|
@return Successful?
|
||||||
*/
|
*/
|
||||||
template <class Mesh>
|
template <class Mesh>
|
||||||
bool write_mesh(const Mesh& _mesh,
|
bool write_mesh(const Mesh& _mesh,
|
||||||
std::ostream& _os,
|
std::ostream& _os,
|
||||||
const std::string& _ext,
|
const std::string& _ext,
|
||||||
Options _opt = Options::Default)
|
Options _opt = Options::Default,
|
||||||
{
|
std::streamsize _precision = 6)
|
||||||
|
{
|
||||||
ExporterT<Mesh> exporter(_mesh);
|
ExporterT<Mesh> exporter(_mesh);
|
||||||
return IOManager().write(_os,_ext, exporter, _opt);
|
return IOManager().write(_os,_ext, exporter, _opt, _precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -246,7 +248,7 @@ bool write_mesh(const Mesh& _mesh,
|
|||||||
@return Binary size in bytes used when writing the data
|
@return Binary size in bytes used when writing the data
|
||||||
*/
|
*/
|
||||||
template <class Mesh>
|
template <class Mesh>
|
||||||
size_t binary_size(const Mesh& _mesh,
|
size_t binary_size(const Mesh& _mesh,
|
||||||
const std::string& _ext,
|
const std::string& _ext,
|
||||||
Options _opt = Options::Default)
|
Options _opt = Options::Default)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user