Changeset 5d57155 for GenericIOPrint.cxx
- Timestamp:
- 09/25/17 16:15:39 (7 years ago)
- Branches:
- master, pympi
- Children:
- b02d091
- Parents:
- fb69232
- git-author:
- Hal Finkel <hfinkel@…> (09/25/17 16:15:39)
- git-committer:
- Hal Finkel <hfinkel@…> (09/25/17 16:15:39)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GenericIOPrint.cxx
r8f0a211 r5d57155 63 63 class Printer : public PrinterBase { 64 64 public: 65 Printer(GenericIO &G, size_t MNE, const string &N)66 : Data(MNE + G.requestedExtraSpace()/sizeof(T)) {67 G.add Variable(N, Data, true);65 Printer(GenericIO &G, size_t MNE, size_t NE, const string &N) 66 : NumElements(NE), Data(MNE*NE + G.requestedExtraSpace()/sizeof(T)) { 67 G.addScalarizedVariable(N, Data, NE, GenericIO::VarHasExtraSpace); 68 68 } 69 69 70 70 virtual void print(ostream &os, size_t i) { 71 os << scientific << setprecision(numeric_limits<T>::digits10) << Data[i]; 71 for (size_t j = 0; j < NumElements; ++j) { 72 os << scientific << setprecision(numeric_limits<T>::digits10) << 73 Data[i*NumElements + j]; 74 75 if (j != NumElements - 1) 76 os << "\t"; 77 } 72 78 } 73 79 74 80 protected: 81 size_t NumElements; 75 82 vector<T> Data; 76 83 }; … … 79 86 PrinterBase *addPrinter(GenericIO::VariableInfo &V, 80 87 GenericIO &GIO, size_t MNE) { 81 if (sizeof(T) != V. Size)88 if (sizeof(T) != V.ElementSize) 82 89 return 0; 83 90 … … 87 94 return 0; 88 95 89 return new Printer<T>(GIO, MNE, V. Name);96 return new Printer<T>(GIO, MNE, V.Size/V.ElementSize, V.Name); 90 97 } 91 98 … … 241 248 cout << "# "; 242 249 for (size_t i = 0; i < VI.size(); ++i) { 243 cout << VI[i].Name; 250 if (VI[i].Size == VI[i].ElementSize) { 251 cout << VI[i].Name; 252 } else { 253 size_t NumElements = VI[i].Size/VI[i].ElementSize; 254 for (size_t j = 0; j < NumElements; ++j) { 255 cout << VI[i].Name; 256 if (j == 0) { 257 cout << ".x"; 258 } else if (j == 1) { 259 cout << ".y"; 260 } else if (j == 2) { 261 cout << ".z"; 262 } else if (j == 3) { 263 cout << ".w"; 264 } else { 265 cout << ".w" << (j - 3); 266 } 267 268 if (j != NumElements - 1) 269 cout << "\t"; 270 } 271 } 272 244 273 if (i != VI.size() - 1) 245 274 cout << "\t";
Note: See TracChangeset
for help on using the changeset viewer.