MC_io_obj.hpp

Go to the documentation of this file.
00001 
00002 /*
00003 **    Mesh Converter
00004 **    Copyright (C) 2009  Damien Rohmer
00005 **
00006 **    This program is free software: you can redistribute it and/or modify
00007 **    it under the terms of the GNU General Public License as published by
00008 **    the Free Software Foundation, either version 3 of the License, or
00009 **    (at your option) any later version.
00010 **
00011 **   This program is distributed in the hope that it will be useful,
00012 **    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 **    GNU General Public License for more details.
00015 **
00016 **    You should have received a copy of the GNU General Public License
00017 **    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 #ifndef _MC_IO_OBJ_HPP_
00022 #define _MC_IO_OBJ_HPP_
00023 
00024 
00025 #include <MC_v3d_vector.hpp>
00026 #include <MC_connectivity_index.hpp>
00027 
00028 #include <iostream>
00029 #include <fstream>
00030 
00031 
00032 namespace mesh_conv
00033 {
00034     class MC_mesh_index_vector;
00035     class MC_mesh_index_vector_draw;
00036 
00038     class MC_io_obj
00039     {
00040         public:
00041 
00044         static std::pair <MC_v3d_vector,MC_connectivity_index> read_obj(std::istream& stream);
00045 
00048         static std::pair <MC_v3d_vector,MC_connectivity_index> read_obj_texture(std::istream& stream);
00051         static std::pair <MC_v3d_vector,MC_connectivity_index> read_obj_texture_file(const std::string& file);
00052 
00055         static std::pair <MC_v3d_vector,MC_connectivity_index> read_obj_normal(std::istream& stream);
00056 
00059         static std::pair <MC_v3d_vector,MC_connectivity_index> read_obj_file(const std::string& filename);
00060 
00061 
00063         static std::ostream& write_obj(std::ostream& stream,const MC_mesh_index_vector& to_write);
00065         static std::ostream& write_obj(std::ostream& stream,const MC_mesh_index_vector_draw& to_write);
00066 
00068         template <typename T>
00069                 static const MC_mesh_index_vector& write_obj_file(const std::string& string_file,const T& to_write)
00070         {
00071             std::ofstream ofile(string_file.c_str());
00072             if(ofile.good()!=true)
00073             {std::cout<<"Error in MC_io_obj::write_obj_file("<<string_file<<",MC_mesh_index_vector), cannot open the file"<<std::endl;exit(-1);}
00074 
00075             MC_io_obj::write_obj(ofile,to_write);
00076             ofile.close();
00077             return to_write;
00078         }
00079 
00080 
00081         private:
00082     };
00083 }
00084 
00085 #endif

Generated on Sun Apr 18 20:24:47 2010 by  doxygen 1.6.1