]> Creatis software - cpMesh.git/blob - lib/cpm/IO/WaveFrontOBJReader.h
First commit
[cpMesh.git] / lib / cpm / IO / WaveFrontOBJReader.h
1 #ifndef __CPM__IO__WAVEFRONTOBJREADER__H__
2 #define __CPM__IO__WAVEFRONTOBJREADER__H__
3
4 #include <string>
5 #include <itkIntTypes.h>
6 #include <itkMesh.h>
7 #include <itkMeshSource.h>
8 #include <itkPolygonCell.h>
9
10 namespace cpm
11 {
12   namespace IO
13   {
14     /**
15      * \class WaveFrontOBJReader
16      * \brief
17      * Reads a wavefront OBJ file and create an itkMesh.
18      *
19      * Caveat1: itkWaveFrontOBJReader will read only vertices and faces.
20      *          Normal, parameters and textures vectors are ignored.
21      *
22      */
23     template< typename M >
24     class WaveFrontOBJReader
25       : public itk::MeshSource< M >
26     {
27     public:
28       typedef WaveFrontOBJReader              Self;
29       typedef itk::MeshSource< M >            Superclass;
30       typedef itk::SmartPointer< Self >       Pointer;
31       typedef itk::SmartPointer< const Self > ConstPointer;
32
33       typedef M                                    MeshType;
34       typedef typename M::MeshTraits               MeshTraits;
35       typedef typename M::PointType                PointType;
36       typedef typename MeshTraits::PixelType       PixelType;
37       typedef typename M::Pointer                  MeshPointer;
38       typedef typename M::CellTraits               CellTraits;
39       typedef typename M::CellIdentifier           CellIdentifier;
40       typedef typename M::CellType                 CellType;
41       typedef typename M::CellAutoPointer          CellAutoPointer;
42       typedef typename M::PointIdentifier          PointIdentifier;
43       typedef typename CellTraits::PointIdIterator PointIdIterator;
44       typedef typename M::PointsContainerPointer   PointsContainerPointer;
45       typedef typename M::PointsContainer          PointsContainer;
46
47       typedef itk::PolygonCell< CellType > TPolygonCell;
48
49     public:
50       itkNewMacro( Self );
51       itkTypeMacro( WaveFrontOBJReader, itkMeshSource );
52
53       itkSetStringMacro( FileName );
54       itkGetStringMacro( FileName );
55
56     protected:
57       WaveFrontOBJReader( );
58       virtual ~WaveFrontOBJReader( );
59
60       virtual void GenerateData( );
61
62     private:
63       // Purposely not implemented
64       WaveFrontOBJReader( const Self& );
65       Self& operator=( const Self & );
66
67     protected:
68       std::string m_FileName;
69     };
70
71   } // ecapseman
72
73 } // ecapseman
74
75 #include <cpm/IO/WaveFrontOBJReader.hxx>
76
77 #endif // __CPM__IO__WAVEFRONTOBJREADER__H__
78
79 // eof - $RCSfile$