Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

4Darray.h

Go to the documentation of this file.
00001 //**************************************************************************
00002 #ifndef _4DARRAY_H
00003 #define _4DARRAY_H
00004 //**************************************************************************
00005 #include "myendian.h"
00006 #include "remotesocket.h"
00007 //**************************************************************************
00008 template <class Etype>
00009 inline int RemoteSocket::SendArray4D(Etype ****a, int n1, int n2, int n3, int n4)
00010 {
00011 static int elemsize = sizeof(Etype);
00012 int rowsize = elemsize*n4;
00013 int totsize = rowsize*n1*n2*n3;
00014 unsigned char *data;
00015 ALLOC1D(&data, totsize);
00016 int ptr = 0;
00017 
00018 for (int i = 0; i < n1; i++)
00019 for (int j = 0; j < n2; j++)
00020 for (int k = 0; k < n3; k++)
00021         {
00022          memcpy(&data[ptr], &a[i][j][k][0], rowsize);
00023          ptr += rowsize;
00024         }
00025 
00026 setByteOrder(data, totsize, elemsize);
00027 SendBytes(totsize, data);
00028 FREE1D(&data, totsize);
00029 
00030 return 0;
00031 }
00032 //**************************************************************************
00033 template <class Etype>
00034 inline int RemoteSocket::RecvArray4D(Etype ****a, int n1, int n2, int n3, int n4)
00035 {
00036 static int elemsize = sizeof(Etype);
00037 int rowsize = elemsize*n4;
00038 int totsize = rowsize*n1*n2*n3;
00039 unsigned char *data;
00040 ALLOC1D(&data, totsize);
00041 int ptr = 0;
00042 
00043 RecvBytes(totsize, data);
00044 setByteOrder(data, totsize, elemsize);
00045 
00046 for (int i = 0; i < n1; i++)
00047 for (int j = 0; j < n2; j++)
00048 for (int k = 0; k < n3; k++)
00049         {
00050          memcpy(&a[i][j][k][0], &data[ptr], rowsize);
00051          ptr += rowsize;
00052         }
00053 
00054 FREE1D(&data, totsize);
00055 
00056 return 0;
00057 }
00058 //**************************************************************************
00059 #endif // _4DARRAY_H
00060 //**************************************************************************

Generated on Sun Jun 16 17:36:48 2002 for POSSE: Portable Object-oriented Scientific Steering Environment by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001