Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009, 2010 EPITA Research and Development 00002 // Laboratory (LRDE) 00003 // 00004 // This file is part of Olena. 00005 // 00006 // Olena is free software: you can redistribute it and/or modify it under 00007 // the terms of the GNU General Public License as published by the Free 00008 // Software Foundation, version 2 of the License. 00009 // 00010 // Olena is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 // As a special exception, you may use this file as part of a free 00019 // software project without restriction. Specifically, if other files 00020 // instantiate templates or use macros or inline functions from this 00021 // file, or you compile this file and link it with other files to produce 00022 // an executable, this file does not by itself cause the resulting 00023 // executable to be covered by the GNU General Public License. This 00024 // exception does not however invalidate any other reasons why the 00025 // executable file might be covered by the GNU General Public License. 00026 00027 #ifndef MLN_IO_FLD_WRITE_HEADER_HH 00028 # define MLN_IO_FLD_WRITE_HEADER_HH 00029 00032 00033 # include <cstdlib> 00034 00035 # include <iostream> 00036 00037 # include <mln/io/fld/header.hh> 00038 00039 namespace mln 00040 { 00041 00042 namespace io 00043 { 00044 00045 namespace fld 00046 { 00052 void write_header(std::ostream& file, const fld_header& h); 00053 00054 # ifndef MLN_INCLUDE_ONLY 00055 00056 inline 00057 void 00058 write_header(std::ostream& file, const fld_header& h) 00059 { 00060 file << "# AVS field file" << std::endl; 00061 file << "# Generated by Milena 1.0 http://olena.lrde.epita.fr" << std::endl; 00062 file << "# EPITA Research and Development Laboratory (LRDE)" << std::endl; 00063 00064 file << "ndim=" << h.ndim << std::endl; 00065 for (int i = 0; i < h.ndim; i++) 00066 file << "dim" << (i + 1) << "=" << h.dim[i] << std::endl; 00067 file << "nspace=" << h.nspace << std::endl 00068 << "veclen=" << h.veclen << std::endl; 00069 00070 switch (h.data) 00071 { 00072 case data_type::BYTE : 00073 file << "data=byte" << std::endl; 00074 break; 00075 case data_type::SHORT : 00076 file << "data=short" << std::endl; 00077 break; 00078 case data_type::INTEGER : 00079 file << "data=integer" << std::endl; 00080 break; 00081 case data_type::FLOAT : 00082 file << "data=float" << std::endl; 00083 break; 00084 case data_type::DOUBLE : 00085 file << "data=double" << std::endl; 00086 break; 00087 default: 00088 std::cerr << "Data type not supported: abort()."; 00089 std::abort(); 00090 } 00091 00092 switch (h.field) 00093 { 00094 case field_type::UNIFORM : 00095 file << "field=uniform" << std::endl; 00096 break; 00097 case field_type::IRREGULAR : 00098 file << "field=irregular" << std::endl; 00099 break; 00100 case field_type::RECTILINEAR : 00101 file << "field=rectilinear" << std::endl; 00102 break; 00103 default: 00104 std::cerr << "Field type not suported: abort()."; 00105 std::abort(); 00106 } 00107 00108 file << "min_ext="; 00109 for (int i = 0; i < h.nspace; i++) 00110 file << h.min_ext[i] << " "; 00111 file << std::endl; 00112 00113 file << "max_ext="; 00114 for (int i = 0; i < h.nspace; i++) 00115 file << h.max_ext[i] << " "; 00116 file << std::endl; 00117 00118 file << "\f\f"; 00119 } 00120 00121 #endif // !MLN_INCLUDE_ONLY 00122 00123 } // end of namespace mln::io::fld 00124 00125 } // end of namespace mln::io 00126 00127 } // end of namespace mln 00128 00129 #endif // !MLN_IO_FLD_WRITE_HEADER_HH