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
00101
00102
00103
00104 const polyMesh& mesh_;
00105
00106
00107 void addOrDelete(topoSet& set, const label cellI, const bool) const;
00108
00109
00110 private:
00111
00112 static const NamedEnum<setAction, 7> actionNames_;
00113
00114 static const string illegalSource_;
00115
00116
00117
00118
00119
00120 topoSetSource(const topoSetSource&);
00121
00122
00123 void operator=(const topoSetSource&);
00124
00125
00126 public:
00127
00128
00129 TypeName("topoSetSource");
00130
00131
00132
00133
00134
00135 static setAction toAction(const word& actionName)
00136 {
00137 return actionNames_[actionName];
00138 }
00139
00140
00141 static Istream& checkIs(Istream& is);
00142
00143
00144
00145
00146 declareRunTimeSelectionTable
00147 (
00148 autoPtr,
00149 topoSetSource,
00150 word,
00151 (
00152 const polyMesh& mesh,
00153 const dictionary& dict
00154 ),
00155 (mesh, dict)
00156 );
00157
00158
00159 declareRunTimeSelectionTable
00160 (
00161 autoPtr,
00162 topoSetSource,
00163 istream,
00164 (
00165 const polyMesh& mesh,
00166 Istream& is
00167 ),
00168 (mesh, is)
00169 );
00170
00171
00172
00173
00174 class iNew
00175 {
00176 const polyMesh& mesh_;
00177
00178 public:
00179
00180 iNew(const polyMesh& mesh)
00181 :
00182 mesh_(mesh)
00183 {}
00184
00185 autoPtr<topoSetSource> operator()(Istream& is) const
00186 {
00187 word topoSetSourceType(is);
00188 dictionary dict(is);
00189 return topoSetSource::New(topoSetSourceType, mesh_, dict);
00190 }
00191 };
00192
00193
00194 static const string& usage(const word& name)
00195 {
00196 if (!usageTablePtr_)
00197 {
00198 usageTablePtr_ = new HashTable<string>();
00199 }
00200
00201 const HashTable<string>& usageTable = *usageTablePtr_;
00202
00203 if (usageTable.found(name))
00204 {
00205 return usageTable[name];
00206 }
00207 else
00208 {
00209 return illegalSource_;
00210 }
00211 }
00212
00213
00214
00215
00216
00217 topoSetSource(const polyMesh& mesh);
00218
00219
00220 autoPtr<topoSetSource> clone() const
00221 {
00222 notImplemented("autoPtr<topoSetSource> clone() const");
00223 return autoPtr<topoSetSource>(NULL);
00224 }
00225
00226
00227
00228
00229
00230 static autoPtr<topoSetSource> New
00231 (
00232 const word& topoSetSourceType,
00233 const polyMesh& mesh,
00234 const dictionary& dict
00235 );
00236
00237
00238 static autoPtr<topoSetSource> New
00239 (
00240 const word& topoSetSourceType,
00241 const polyMesh& mesh,
00242 Istream& is
00243 );
00244
00245
00246
00247
00248 virtual ~topoSetSource();
00249
00250
00251
00252
00253 const polyMesh& mesh() const
00254 {
00255 return mesh_;
00256 }
00257
00258
00259
00260
00261 virtual void applyToSet(const setAction action, topoSet&) const = 0;
00262
00263 };
00264
00265
00266
00267
00268 }
00269
00270
00271
00272 #endif
00273
00274