cellShapeIO.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "cellShape.H"
00031 #include "token.H"
00032 #include "cellModeller.H"
00033
00034
00035
00036 namespace Foam
00037 {
00038
00039
00040
00041 Istream& operator>>(Istream& is, cellShape& s)
00042 {
00043 bool readEndBracket = false;
00044
00045
00046 token t(is);
00047
00048 if (t.isPunctuation())
00049 {
00050 if (t.pToken() == token::BEGIN_LIST)
00051 {
00052 readEndBracket = true;
00053
00054 is >> t;
00055 }
00056 else
00057 {
00058 FatalIOErrorIn("operator>>(Istream&, cellShape& s)", is)
00059 << "incorrect first token, expected '(', found "
00060 << t.info()
00061 << exit(FatalIOError);
00062 }
00063 }
00064
00065
00066 if (t.isLabel())
00067 {
00068 s.m = cellModeller::lookup(int(t.labelToken()));
00069 }
00070 else if (t.isWord())
00071 {
00072 s.m = cellModeller::lookup(t.wordToken());
00073 }
00074 else
00075 {
00076 FatalIOErrorIn("operator>>(Istream& is, cellShape& s)", is)
00077 << "Bad type of token for cellShape symbol " << t.info()
00078 << exit(FatalIOError);
00079 return is;
00080 }
00081
00082
00083 if (!s.m)
00084 {
00085 FatalIOErrorIn("operator>>(Istream& is, cellShape& s)", is)
00086 << "CellShape has unknown model " << t.info()
00087 << exit(FatalIOError);
00088 return is;
00089 }
00090
00091
00092 is >> static_cast<labelList&>(s);
00093
00094 if (readEndBracket)
00095 {
00096
00097 is.readEnd("cellShape");
00098 }
00099
00100 return is;
00101 }
00102
00103
00104 Ostream& operator<<(Ostream& os, const cellShape & s)
00105 {
00106
00107 os << token::BEGIN_LIST;
00108
00109
00110 os << (s.m)->index() << token::SPACE;
00111
00112
00113
00114
00115
00116 os << static_cast<const labelList&>(s);
00117
00118
00119 os << token::END_LIST;
00120
00121 return os;
00122 }
00123
00124
00125 #if defined (__GNUC__)
00126 template<>
00127 #endif
00128 Ostream& operator<<(Ostream& os, const InfoProxy<cellShape>& ip)
00129 {
00130 const cellShape& cs = ip.t_;
00131
00132 if (!(&cs.model()))
00133 {
00134 os << " cellShape has no model!\n";
00135 }
00136 else
00137 {
00138 os << cs.model().info() << endl;
00139 }
00140
00141 os << "\tGeom:\tpoint\tlabel\txyz\n";
00142
00143 forAll(cs, i)
00144 {
00145 os << "\t\t" << i << "\t" << cs[i] << endl;
00146 }
00147
00148 return os;
00149 }
00150
00151
00152
00153
00154 }
00155
00156
Copyright © 2000-2009 OpenCFD Ltd