Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

template<class ArrayT>
void Impala::Core::Array::Pattern::PxWriteRaw ( ArrayT *  src,
std::string  fileName,
bool  binary 
) [inline]

Definition at line 116 of file PxReadWriteRaw.h.

References ArrayCH(), ArrayCPB(), ArrayCW(), PxArrayForceNonDistributed(), PxMyCPU(), and PxRootCPU().

00117 {
00118     PxArrayForceNonDistributed(src);
00119 
00120     if (PxMyCPU() == PxRootCPU()) {
00121         typedef typename ArrayT::StorType StorT;
00122 
00123         std::string typeStr = Element::TypeString<StorT>(0);
00124         std::string formatStr = std::string("version: 1, binary: %d, type: ")
00125             + typeStr + std::string(", elemSize: %d, width: %d, height: %d, nr: %d");
00126         int width = ArrayCW(src);
00127         int height = ArrayCH(src);
00128         int elemSize = ArrayT::ElemSize();
00129         int nrA = 1;
00130         char buf[200];
00131         sprintf(buf, formatStr.c_str(), binary, elemSize, width, height, nrA);
00132 
00133         FILE* fp;
00134         if (binary) {   // write to binary file
00135             fp = fopen(fileName.c_str(), "wb");
00136             fwrite(buf, sizeof(char), 200, fp);
00137             for (int y=0 ; y<height ; y++) {
00138                 StorT* srcPtr = ArrayCPB(src, 0, y);
00139                 fwrite(srcPtr, sizeof(StorT), width*elemSize, fp);
00140             }
00141         } else {        // write to text file
00142             fp = fopen(fileName.c_str(), "w") ;
00143             fprintf(fp, "%s\n", buf);
00144             std::string fs = NativeTypeFormat<StorT>(0) + std::string(" ");
00145             for (int n=0 ; n<nrA ; n++) {
00146                 for(int i=0 ; i<height ; i++) {
00147                     StorT* srcPtr = ArrayCPB(src, 0, i);
00148                     for(int j=0 ; j<width ; j++) {
00149                         for (int k=0 ; k<elemSize ; k++) {
00150                             fprintf(fp, fs.c_str(), *srcPtr++);
00151                         }
00152                     }
00153                     fprintf(fp, "\n");
00154                 }
00155             }
00156         }
00157         fclose(fp);
00158     }
00159 }

Here is the call graph for this function:


Generated on Fri Mar 19 11:03:03 2010 for ImpalaSrc by  doxygen 1.5.1