#include "GridSpace.hh" namespace RVL { template<> ostream & writeMeta(Grid const & g, ostream & e) { g.write(e); } template<> size_t getDataSize(Grid const & g) { if (g.isInit()) { size_t nnn = 1; for (size_t i=0; i size_t getMetaSize(Grid const & g) { if (g.isInit()) { size_t nnn = g.getDimension()*(Axis::getAxisSize()); return nnn; } else { RVLException e; e<<"Error: Grid::getMetaSize()\n"; e<<" object not initialized - lacking " < char * serialize(Axis const & a, size_t & len) { len = Axis::getAxisSize(); size_t loc=0; size_t n = a.getLength(); float d = a.getStep(); float o = a.getOrigin(); int id = a.getID(); char * cbuf = new char[len]; memcpy((&(cbuf[loc])),(char *)(&n),sizeof(size_t)); loc += sizeof(size_t); memcpy((&(cbuf[loc])),(char *)(&d),sizeof(float)); loc += sizeof(float); memcpy((&(cbuf[loc])),(char *)(&o),sizeof(float)); loc += sizeof(float); memcpy((&(cbuf[loc])),(char *)(&id),sizeof(int)); loc += sizeof(int); return cbuf; } template<> Axis * deserialize(char * cbuf, size_t len) { if (len != Axis::getAxisSize()) { RVLException e; e<<"Error: deserialize\n"; e<<" 2nd param must = axis size = "< char * serialize(Grid const & g, size_t & len) { len = getMetaSize(g); char * c = new char[len]; size_t loc=0; size_t tmp; for (size_t i=0; i< g.getDimension(); i++) { memcpy(&(c[loc]),serialize(g.getAxis(i),tmp),Axis::getAxisSize()); if (tmp != Axis::getAxisSize()) { RVLException e; e<<"Error: serialize\n"; e<<" wrong number of bytes read on axis "< Grid * deserialize(char * cbuf, size_t len) { // first check that the length is divisible by axis length, and compute // number of axes } }