9#include <kernel/adjacency/adjactor.hpp> 
   11#include <kernel/util/string.hpp> 
   53      template<
typename Adjactor_>
 
   54      static void write(
const String& filename, 
const Adjactor_& adj)
 
   57        std::ofstream ofs(filename, std::ios_base::binary|std::ios_base::out);
 
   58        if(!(ofs.is_open() && ofs.good()))
 
   77      template<
typename Adjactor_>
 
   78      static void write(std::ostream& os, 
const Adjactor_& adj)
 
   80        typedef std::uint8_t u8;
 
   84        for(
int i(0); i < 18; ++i)
 
   88        const Index w = adj.get_num_nodes_image();
 
   89        const Index h = adj.get_num_nodes_domain();
 
   92        XASSERTM((w <= 
Index(32767)) && (h <= 
Index(32767)), 
"TGA dimensions are limited to 32767");
 
   95        header[12] = u8( w       & 0xFF);
 
   96        header[13] = u8((w >> 8) & 0x7F);
 
   97        header[14] = u8( h       & 0xFF);
 
   98        header[15] = u8((h >> 8) & 0x7F);
 
  106        os.write(
reinterpret_cast<char*
>(header), 18);
 
  109        std::vector<char> scan(std::size_t(w), -1);
 
  112        for(
Index i(0); i < h; ++i)
 
  115          auto jt = adj.image_end(i);
 
  118          for(
auto it = adj.image_begin(i); it != jt; ++it)
 
  125          os.write(scan.data(), std::streamsize(scan.size()));
 
  128          for(
auto it = adj.image_begin(i); it != jt; ++it)
 
  135        const char* footer = 
"\0\0\0\0\0\0\0\0TRUEVISION-XFILE.\0";
 
  136        os.write(footer, 26);
 
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
static void write(std::ostream &os, const Adjactor_ &adj)
Writes out an adjactor to a TGA image file.
static void write(const String &filename, const Adjactor_ &adj)
Writes out an adjactor to a TGA image file.
Base class for file related errors.
String class implementation.
std::uint64_t Index
Index data type.