00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _DATAFILEIF_H_
00012 #define _DATAFILEIF_H_
00013
00014 #include <iostream>
00015 #include <fstream>
00016 using std::istream;
00017 using std::ifstream;
00018
00019 #include "MayDay.H"
00020 #include "RealVect.H"
00021 #include "IntVectSet.H"
00022 #include "FArrayBox.H"
00023 #include "RefCountedPtr.H"
00024
00025 #include "BaseIF.H"
00026
00027 #include "NamespaceHeader.H"
00028
00030
00055 class DataFileIF: public BaseIF
00056 {
00057 public:
00059
00062 enum DataType {Invalid=-1, ASCII=0, Binary, NUMDATATYPES};
00063
00065
00072 DataFileIF(const DataFileIF::DataType& a_dataType,
00073 const Real& a_value,
00074 const bool& a_inside);
00075
00077
00084 DataFileIF(const char* const a_filename,
00085 const DataFileIF::DataType& a_dataType,
00086 const Real& a_value,
00087 const bool& a_inside);
00088
00090
00098 DataFileIF(const DataFileIF::DataType& a_dataType,
00099 const RealVect& a_spacing,
00100 const RealVect& a_origin,
00101 const Real& a_value,
00102 const bool& a_inside);
00103
00105
00113 DataFileIF(const char* const a_filename,
00114 const DataFileIF::DataType& a_dataType,
00115 const RealVect& a_spacing,
00116 const RealVect& a_origin,
00117 const Real& a_value,
00118 const bool& a_inside);
00119
00121
00129 DataFileIF(const DataFileIF::DataType& a_dataType,
00130 const IntVect& a_num,
00131 const RealVect& a_spacing,
00132 const RealVect& a_origin,
00133 const Real& a_value,
00134 const bool& a_inside);
00135
00137
00145 DataFileIF(const char* const a_filename,
00146 const DataFileIF::DataType& a_dataType,
00147 const IntVect& a_num,
00148 const RealVect& a_spacing,
00149 const RealVect& a_origin,
00150 const Real& a_value,
00151 const bool& a_inside);
00152
00154 DataFileIF(const DataFileIF& a_inputIF);
00155
00157
00167 DataFileIF(const RefCountedPtr<FArrayBox> a_data,
00168 const Real& a_noDataValue,
00169 const IntVect& a_num,
00170 const RealVect& a_spacing,
00171 const RealVect& a_origin,
00172 const Real& a_value,
00173 const bool& a_inside);
00174
00176 virtual ~DataFileIF();
00177
00179
00182 virtual void GetHeader(IntVect& a_num,
00183 RealVect& a_spacing,
00184 RealVect& a_origin) const;
00185
00187
00190 virtual void GetParams(Real& a_value,
00191 bool& a_inside) const;
00192
00194
00197 virtual void SetParams(const Real& a_value,
00198 const bool& a_inside);
00199
00201
00204 virtual void SetNoDataValue(const Real& a_value);
00205
00207
00212 virtual Real value(const RealVect& a_point) const;
00213
00214 virtual BaseIF* newImplicitFunction() const;
00215
00216 protected:
00217 void OpenFile(ifstream& a_file,
00218 const char* const a_filename);
00219
00220 void CloseFile(ifstream& a_file);
00221
00222 void ReadMinHeader(IntVect& a_num,
00223 istream& a_file);
00224
00225 void ReadFullHeader(IntVect& a_num,
00226 RealVect& a_spacing,
00227 RealVect& a_origin,
00228 istream& a_file);
00229
00230 RefCountedPtr<FArrayBox> ReadData(Real& a_maxValue,
00231 istream& a_file,
00232 const DataFileIF::DataType& a_dataType,
00233 const IntVect& a_num);
00234
00235 void MakeCorners(void);
00236
00237 IntVect m_num;
00238 RealVect m_spacing;
00239 RealVect m_origin;
00240
00241 Real m_value;
00242
00243 bool m_inside;
00244
00245 RefCountedPtr<FArrayBox> m_data;
00246 Real m_noDataValue;
00247
00248 IntVectSet m_corners;
00249
00250 private:
00251 DataFileIF()
00252 {
00253 MayDay::Error("DataFileIF uses strong construction");
00254 }
00255
00256 void operator=(const DataFileIF& a_inputIF)
00257 {
00258 MayDay::Error("DataFileIF doesn't allow assignment");
00259 }
00260 };
00261
00262 #include "NamespaceFooter.H"
00263 #endif