Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_CONTAINERS_GRID_IO_GRID_RAW_WRITE_H
00002 #define OPENTISSUE_CORE_CONTAINERS_GRID_IO_GRID_RAW_WRITE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <iostream>
00013 #include <cstdio>
00014 #include <string>
00015
00016 namespace OpenTissue
00017 {
00018 namespace grid
00019 {
00020
00029 template <typename grid_type>
00030 inline bool raw_write(std::string const & filename, grid_type & grid)
00031 {
00032 typedef typename grid_type::value_type value_type;
00033 FILE *stream;
00034 if( (stream = fopen( filename.c_str(), "wb" )) == NULL ){
00035 std::cerr << "raw_write(): Unable to open file" << filename << std::endl;
00036 return false;
00037 }
00038 fwrite( grid.data(), sizeof( value_type ), grid.size(), stream );
00039 fclose( stream );
00040 std::cout << "raw_write(): Completed writing grid file " << filename << std::endl;
00041 return true;
00042 }
00043
00044 }
00045 }
00046
00047
00048 #endif