MC_io_obj.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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