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
00031
00032
00033
00034
00035
00036 #ifndef graph_H
00037 #define graph_H
00038
00039 #include "string.H"
00040 #include "point.H"
00041 #include "HashPtrTable.H"
00042 #include "curve.H"
00043
00044
00045
00046 namespace Foam
00047 {
00048
00049
00050
00051
00052
00053 class graph
00054 :
00055 public HashPtrTable<curve>
00056 {
00057
00058
00059 string title_;
00060 string xName_;
00061 string yName_;
00062
00063 scalarField x_;
00064
00065
00066 struct xy
00067 {
00068 scalar x_, y_;
00069
00070 xy()
00071 {}
00072
00073
00074
00075 friend bool operator==(const xy& a, const xy& b)
00076 {
00077 return equal(a.x_, b.x_) && equal(a.y_, b.y_);
00078 }
00079
00080 friend bool operator!=(const xy& a, const xy& b)
00081 {
00082 return !(a == b);
00083 }
00084
00085 friend Istream& operator>>(Istream& is, xy& xyd)
00086 {
00087 is >> xyd.x_ >> xyd.y_;
00088 return is;
00089 }
00090
00091 friend Ostream& operator<<(Ostream& os, const xy& xyd)
00092 {
00093 os << xyd.x_ << ' ' << xyd.y_;
00094 return os;
00095 }
00096 };
00097
00098
00099
00100
00101 void readCurves(Istream&);
00102
00103
00104 public:
00105
00106
00107
00108
00109 graph
00110 (
00111 const string& title,
00112 const string& xName,
00113 const string& yName,
00114 const scalarField& x
00115 );
00116
00117
00118 graph
00119 (
00120 const string& title,
00121 const string& xName,
00122 const string& yName,
00123 const scalarField& x,
00124 const scalarField& y
00125 );
00126
00127
00128 graph
00129 (
00130 const string& title,
00131 const string& xName,
00132 const string& yName,
00133 Istream& is
00134 );
00135
00136
00137 graph(Istream& is);
00138
00139
00140
00141
00142
00143
00144 const string& title() const
00145 {
00146 return title_;
00147 }
00148
00149 const string& xName() const
00150 {
00151 return xName_;
00152 }
00153
00154 const string& yName() const
00155 {
00156 return yName_;
00157 }
00158
00159
00160 const scalarField& x() const
00161 {
00162 return x_;
00163 }
00164
00165 scalarField& x()
00166 {
00167 return x_;
00168 }
00169
00170
00171 const scalarField& y() const;
00172
00173 scalarField& y();
00174
00175
00176
00177
00178 class writer
00179 {
00180
00181 protected:
00182
00183 void writeXY
00184 (
00185 const scalarField& x,
00186 const scalarField& y,
00187 Ostream&
00188 ) const;
00189
00190 public:
00191
00192
00193 TypeName("writer");
00194
00195
00196 declareRunTimeSelectionTable
00197 (
00198 autoPtr,
00199 writer,
00200 word,
00201 (),
00202 ()
00203 );
00204
00205
00206
00207
00208
00209 static autoPtr<writer> New
00210 (
00211 const word& writeFormat
00212 );
00213
00214
00215
00216
00217
00218 writer()
00219 {}
00220
00221
00222
00223
00224 virtual ~writer()
00225 {}
00226
00227
00228
00229
00230
00231
00232
00233
00234 virtual const word& ext() const = 0;
00235
00236
00237
00238
00239
00240 virtual void write(const graph&, Ostream&) const = 0;
00241 };
00242
00243
00244 void writeTable(Ostream&) const;
00245
00246
00247 void write(Ostream&, const word& format) const;
00248
00249
00250 void write(const fileName& fName, const word& format) const;
00251
00252
00253
00254
00255
00256 friend Ostream& operator<<(Ostream&, const graph&);
00257 };
00258
00259
00260
00261
00262 }
00263
00264
00265
00266 #endif
00267
00268