00001
00002 #ifndef _IOMESH_H
00003 #define _IOMESH_H
00004
00005 #include "IOManager.h"
00006
00007 #include "Mesh.h"
00008 #include "MeshOBJ.h"
00009
00010 namespace gk {
00011
00012
00013 class MeshIO : public IOManager<Mesh>
00014 {
00015
00016 MeshIO( const MeshIO& );
00017 MeshIO& operator=( const MeshIO& );
00018
00019
00020 MeshIO( )
00021 :
00022 IOManager<Mesh>()
00023 {}
00024
00025 ~MeshIO( ) {}
00026
00027 public:
00028
00029 static
00030 Mesh *read( const std::string& filename, const std::string& name= "" )
00031 {
00032
00033 Mesh *mesh= manager().find(filename, name);
00034 if(mesh != NULL)
00035 return mesh;
00036
00037
00038 mesh= new Mesh;
00039 if(MeshLoadFromOBJ(filename, mesh) < 0)
00040 {
00041 printf("'%s' failed.\n", filename.c_str());
00042 delete mesh;
00043 return NULL;
00044 }
00045
00046
00047 return manager().insert(mesh, filename, name);
00048 }
00049
00050 static
00051 MeshIO& manager( )
00052 {
00053 static MeshIO manager;
00054 return manager;
00055 }
00056 };
00057
00058 }
00059
00060 #endif