X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fcpm%2FIO%2FWaveFrontOBJReader.hxx;fp=lib%2Fcpm%2FIO%2FWaveFrontOBJReader.hxx;h=0000000000000000000000000000000000000000;hb=6d6bf5d5e3b9318a507216f2f231c32299d1a941;hp=88f9e979f40ff245b53123435a5bfdf0ced845fd;hpb=de28025e5f1835fba69cb0a6666d02f0b7daec0d;p=cpMesh.git diff --git a/lib/cpm/IO/WaveFrontOBJReader.hxx b/lib/cpm/IO/WaveFrontOBJReader.hxx deleted file mode 100644 index 88f9e97..0000000 --- a/lib/cpm/IO/WaveFrontOBJReader.hxx +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef __CPM__IO__WAVEFRONTOBJREADER__HXX__ -#define __CPM__IO__WAVEFRONTOBJREADER__HXX__ - -#include -#include -#include - -// ------------------------------------------------------------------------- -template< typename M > -cpm::IO::WaveFrontOBJReader< M >:: -WaveFrontOBJReader( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -template< typename M > -cpm::IO::WaveFrontOBJReader< M >:: -~WaveFrontOBJReader( ) -{ -} - -// ------------------------------------------------------------------------- -template< typename M > -void cpm::IO::WaveFrontOBJReader< M >:: -GenerateData( ) -{ - typedef typename PointType::ValueType TScalar; - typename M::Pointer out = this->GetOutput( ); - - out->SetCellsAllocationMethod( M::CellsAllocatedDynamicallyCellByCell ); - if( this->m_FileName == "" ) - { - itkExceptionMacro( << "No input FileName" ); - - } // fi - - std::ifstream in( this->m_FileName.c_str( ) ); - if( !in.is_open( ) ) - { - itkExceptionMacro( - << "Unable to open file" << std::endl - << "\"" << m_FileName << "\"" - ); - - } // fi - - in.imbue( std::locale::classic( ) ); - std::string buffer; - - while( !in.eof( ) ) - { - std::getline( in, buffer, '\n' ); - - // Tokenize - std::stringstream ss( buffer ); - std::istream_iterator< std::string > it( ss ); - std::istream_iterator< std::string > end; - std::vector< std::string > line( it, end ); - if( line.size( ) == 0 ) - continue; - - // Now, we are talking... - if( line[ 0 ] == "v" || line[ 0 ] == "V" ) - { - // Add points - PointType pnt; - pnt.Fill( TScalar( 0 ) ); - - if( line.size( ) > 1 && M::PointDimension >= 1 ) - pnt[ 0 ] = TScalar( std::atof( line[ 1 ].c_str( ) ) ); - if( line.size( ) > 2 && M::PointDimension >= 2 ) - pnt[ 1 ] = TScalar( std::atof( line[ 2 ].c_str( ) ) ); - if( line.size( ) > 3 && M::PointDimension >= 3 ) - pnt[ 2 ] = TScalar( std::atof( line[ 3 ].c_str( ) ) ); - if( M::PointDimension >= 4 ) - { - if( line.size( ) > 4 ) - pnt[ 3 ] = TScalar( std::atof( line[ 4 ].c_str( ) ) ); - else - pnt[ 4 ] = TScalar( 1 ); - - } // fi - out->SetPoint( out->GetNumberOfPoints( ), pnt ); - } - else if( line[ 0 ] == "f" || line[ 0 ] == "F" ) - { - if( line.size( ) > 3 ) - { - // Add a face - CellAutoPointer cell; - TPolygonCell* face = new TPolygonCell( ); - - for( unsigned int k = 1; k < line.size( ); ++k ) - { - PointIdentifier pId = - PointIdentifier( - std::atoi( - line[ k ]. - substr( 0, line[ k ].find_first_of( "/" ) ).c_str( ) - ) - ); - - // In OBJ files, vertices are numbered from 1 - face->AddPointId( pId - 1 ); - - } // rof - cell.TakeOwnership( face ); - out->SetCell( out->GetNumberOfCells( ), cell ); - - } // fi - - } // fi - - } // elihw - - // Finish the job - in.close( ); -} - -#endif // __CPM__IO__WAVEFRONTOBJREADER__HXX__ - -// eof - $RCSfile$