1 #include <IO/deprecated/OFFFileManager.hpp>
12 OFFFileManager::OFFFileManager() :
FileManager<Geometry::TriangleMesh>() {}
33 bool OFFFileManager::importData( std::istream& file, Geometry::TriangleMesh& data ) {
37 addLogErrorEntry(
"HEADER IS NOT CORRECT." );
43 file >> v_size >> f_size >> e_size;
45 Geometry::TriangleMesh::PointAttribHandle::Container vertices;
46 Geometry::TriangleMesh::IndexContainerType indices;
47 vertices.resize( v_size );
48 indices.resize( f_size );
51 for ( uint i = 0; i < v_size; ++i ) {
53 file >> v[0] >> v[1] >> v[2];
58 for ( uint i = 0; i < e_size; ++i ) {
63 for ( uint i = 0; i < f_size; ++i ) {
68 file >> f[0] >> f[1] >> f[2];
69 indices.push_back( f );
73 data.setVertices( std::move( vertices ) );
74 data.setIndices( std::move( indices ) );
78 bool OFFFileManager::exportData( std::ostream& file,
const Geometry::TriangleMesh& data ) {
79 std::string content =
"";
80 const uint v_size = data.vertices().size();
81 const uint f_size = data.getIndices().size();
82 const uint e_size = 0;
85 addLogErrorEntry(
"NO VERTICES PRESENT." );
90 content +=
header() +
"\n" + std::to_string( v_size ) +
" " + std::to_string( f_size ) +
" " +
91 std::to_string( e_size ) +
"\n";
94 for (
const auto& v : data.vertices() ) {
95 content += std::to_string( v[0] ) +
" " + std::to_string( v[1] ) +
" " +
96 std::to_string( v[2] ) +
"\n";
100 for (
const auto& f : data.getIndices() ) {
101 content +=
"3 " + std::to_string( f[0] ) +
" " + std::to_string( f[1] ) +
" " +
102 std::to_string( f[2] ) +
"\n";
std::string fileExtension() const override
INTERFACE.
~OFFFileManager() override
DESTRUCTOR.
std::string header() const
HEADER.