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
00037
00038 #ifndef topoSetSource_H
00039 #define topoSetSource_H
00040
00041 #include "pointField.H"
00042 #include "word.H"
00043 #include "labelList.H"
00044 #include "faceList.H"
00045 #include "typeInfo.H"
00046 #include "runTimeSelectionTables.H"
00047 #include "autoPtr.H"
00048 #include "NamedEnum.H"
00049 #include "HashTable.H"
00050
00051
00052
00053 namespace Foam
00054 {
00055
00056
00057 class polyMesh;
00058 class topoSet;
00059
00060
00061
00062
00063
00064 class topoSetSource
00065 {
00066 public:
00067
00068
00069
00070
00071 enum setAction
00072 {
00073 CLEAR,
00074 NEW,
00075 INVERT,
00076 ADD,
00077 DELETE,
00078 SUBSET,
00079 LIST
00080 };
00081
00082 protected:
00083
00084
00085 static HashTable<string>* usageTablePtr_;
00086
00087 class addToUsageTable
00088 {
00089 public:
00090
00091 addToUsageTable(const word& name, const string& msg)
00092 {
00093 if (!usageTablePtr_)
00094 {
00095 usageTablePtr_ = new HashTable<string>();
00096 }
00097 usageTablePtr_->insert(name, msg);
00098 }
00099
00100 ~addToUsageTable()
00101 {
00102 if (usageTablePtr_)
00103 {
00104 delete usageTablePtr_;
00105 usageTablePtr_ = NULL;
00106 }
00107 }
00108 };
00109
00110
00111
00112
00113 const polyMesh& mesh_;
00114
00115
00116 void addOrDelete(topoSet& set, const label cellI, const bool) const;
00117
00118
00119 private:
00120
00121 static const NamedEnum<setAction, 7> actionNames_;
00122
00123 static const string illegalSource_;
00124
00125
00126
00127
00128
00129 topoSetSource(const topoSetSource&);
00130
00131
00132 void operator=(const topoSetSource&);
00133
00134
00135 public:
00136
00137
00138 TypeName("topoSetSource");
00139
00140
00141
00142
00143
00144 static setAction toAction(const word& actionName)
00145 {
00146 return actionNames_[actionName];
00147 }
00148
00149
00150 static Istream& checkIs(Istream& is);
00151
00152
00153
00154
00155 declareRunTimeSelectionTable
00156 (
00157 autoPtr,
00158 topoSetSource,
00159 word,
00160 (
00161 const polyMesh& mesh,
00162 const dictionary& dict
00163 ),
00164 (mesh, dict)
00165 );
00166
00167
00168 declareRunTimeSelectionTable
00169 (
00170 autoPtr,
00171 topoSetSource,
00172 istream,
00173 (
00174 const polyMesh& mesh,
00175 Istream& is
00176 ),
00177 (mesh, is)
00178 );
00179
00180
00181
00182
00183 class iNew
00184 {
00185 const polyMesh& mesh_;
00186
00187 public:
00188
00189 iNew(const polyMesh& mesh)
00190 :
00191 mesh_(mesh)
00192 {}
00193
00194 autoPtr<topoSetSource> operator()(Istream& is) const
00195 {
00196 word topoSetSourceType(is);
00197 dictionary dict(is);
00198 return topoSetSource::New(topoSetSourceType, mesh_, dict);
00199 }
00200 };
00201
00202
00203 static const string& usage(const word& name)
00204 {
00205 if (!usageTablePtr_)
00206 {
00207 usageTablePtr_ = new HashTable<string>();
00208 }
00209
00210 const HashTable<string>& usageTable = *usageTablePtr_;
00211
00212 if (usageTable.found(name))
00213 {
00214 return usageTable[name];
00215 }
00216 else
00217 {
00218 return illegalSource_;
00219 }
00220 }
00221
00222
00223
00224
00225
00226 topoSetSource(const polyMesh& mesh);
00227
00228
00229 autoPtr<topoSetSource> clone() const
00230 {
00231 notImplemented("autoPtr<topoSetSource> clone() const");
00232 return autoPtr<topoSetSource>(NULL);
00233 }
00234
00235
00236
00237
00238
00239 static autoPtr<topoSetSource> New
00240 (
00241 const word& topoSetSourceType,
00242 const polyMesh& mesh,
00243 const dictionary& dict
00244 );
00245
00246
00247 static autoPtr<topoSetSource> New
00248 (
00249 const word& topoSetSourceType,
00250 const polyMesh& mesh,
00251 Istream& is
00252 );
00253
00254
00255
00256
00257 virtual ~topoSetSource();
00258
00259
00260
00261
00262 const polyMesh& mesh() const
00263 {
00264 return mesh_;
00265 }
00266
00267
00268
00269
00270 virtual void applyToSet(const setAction action, topoSet&) const = 0;
00271
00272 };
00273
00274
00275
00276
00277 }
00278
00279
00280
00281 #endif
00282
00283
Copyright © 2000-2007 OpenCFD Ltd