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
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef MeshedSurface_H
00049 #define MeshedSurface_H
00050
00051 #include "PrimitivePatch.H"
00052 #include "PatchTools.H"
00053 #include "pointField.H"
00054 #include "face.H"
00055 #include "triFace.H"
00056
00057 #include "surfZoneList.H"
00058 #include "surfaceFormatsCore.H"
00059 #include "runTimeSelectionTables.H"
00060 #include "memberFunctionSelectionTables.H"
00061 #include "HashSet.H"
00062
00063
00064
00065 namespace Foam
00066 {
00067
00068
00069
00070 class Time;
00071 class surfMesh;
00072 class polyBoundaryMesh;
00073
00074 template<class Face> class MeshedSurface;
00075 template<class Face> class MeshedSurfaceProxy;
00076 template<class Face> class UnsortedMeshedSurface;
00077
00078
00079
00080
00081
00082 template<class Face>
00083 class MeshedSurface
00084 :
00085 public PrimitivePatch<Face, ::Foam::List, pointField, point>,
00086 public fileFormats::surfaceFormatsCore
00087 {
00088
00089 template<class Face2> friend class MeshedSurface;
00090 template<class Face2> friend class UnsortedMeshedSurface;
00091 friend class surfMesh;
00092
00093 private:
00094
00095
00096
00097 typedef PrimitivePatch
00098 <
00099 Face,
00100 ::Foam::List,
00101 pointField,
00102 point
00103 >
00104 ParentType;
00105
00106 typedef UnsortedMeshedSurface<Face> FriendType;
00107 typedef MeshedSurfaceProxy<Face> ProxyType;
00108
00109
00110
00111
00112
00113 List<surfZone> zones_;
00114
00115
00116
00117
00118 protected:
00119
00120
00121
00122
00123 void transcribe(MeshedSurface<face>&);
00124
00125
00126 void checkZones();
00127
00128
00129 pointField& storedPoints()
00130 {
00131 return const_cast<pointField&>(ParentType::points());
00132 }
00133
00134
00135 List<Face>& storedFaces()
00136 {
00137 return static_cast<List<Face> &>(*this);
00138 }
00139
00140
00141 surfZoneList& storedZones()
00142 {
00143 return zones_;
00144 }
00145
00146
00147 void sortFacesAndStore
00148 (
00149 const Xfer< List<Face> >& unsortedFaces,
00150 const Xfer< List<label> >& zoneIds,
00151 const bool sorted
00152 );
00153
00154
00155 virtual void remapFaces(const UList<label>& faceMap);
00156
00157 public:
00158
00159
00160 ClassName("MeshedSurface");
00161
00162
00163
00164
00165 inline static bool isTri();
00166
00167
00168 static bool canRead(const fileName&, const bool verbose=false);
00169
00170
00171 static bool canReadType(const word& ext, const bool verbose=false);
00172
00173
00174 static bool canWriteType(const word& ext, const bool verbose=false);
00175
00176 static wordHashSet readTypes();
00177 static wordHashSet writeTypes();
00178
00179
00180
00181
00182 MeshedSurface();
00183
00184
00185 MeshedSurface
00186 (
00187 const Xfer< pointField >&,
00188 const Xfer< List<Face> >&,
00189 const Xfer< surfZoneList >&
00190 );
00191
00192
00193
00194 MeshedSurface
00195 (
00196 const Xfer< pointField >&,
00197 const Xfer< List<Face> >&,
00198 const UList<label>& zoneSizes = UList<label>(),
00199 const UList<word>& zoneNames = UList<word>()
00200 );
00201
00202
00203 MeshedSurface(const MeshedSurface&);
00204
00205
00206 MeshedSurface(const UnsortedMeshedSurface<Face>&);
00207
00208
00209 MeshedSurface
00210 (
00211 const polyBoundaryMesh&,
00212 const bool globalPoints=false
00213 );
00214
00215
00216 MeshedSurface(const surfMesh&);
00217
00218
00219 MeshedSurface(const Xfer<UnsortedMeshedSurface<Face> >&);
00220
00221
00222 MeshedSurface(const Xfer<MeshedSurface<Face> >&);
00223
00224
00225 MeshedSurface(const fileName&);
00226
00227
00228 MeshedSurface(const fileName&, const word& ext);
00229
00230
00231 MeshedSurface(const Time&, const word& surfName="");
00232
00233
00234
00235 declareRunTimeSelectionTable
00236 (
00237 autoPtr,
00238 MeshedSurface,
00239 fileExtension,
00240 (
00241 const fileName& name
00242 ),
00243 (name)
00244 );
00245
00246
00247
00248
00249 static autoPtr<MeshedSurface> New
00250 (
00251 const fileName&,
00252 const word& ext
00253 );
00254
00255
00256 static autoPtr<MeshedSurface> New(const fileName&);
00257
00258
00259
00260 virtual ~MeshedSurface();
00261
00262
00263
00264
00265 declareMemberFunctionSelectionTable
00266 (
00267 void,
00268 UnsortedMeshedSurface,
00269 write,
00270 fileExtension,
00271 (
00272 const fileName& name,
00273 const MeshedSurface<Face>& surf
00274 ),
00275 (name, surf)
00276 );
00277
00278
00279 static void write(const fileName&, const MeshedSurface<Face>&);
00280
00281
00282
00283
00284
00285
00286
00287 label size() const
00288 {
00289 return ParentType::size();
00290 }
00291
00292
00293 inline const List<Face>& faces() const
00294 {
00295 return static_cast<const List<Face> &>(*this);
00296 }
00297
00298
00299
00300
00301 const List<surfZone>& surfZones() const
00302 {
00303 return zones_;
00304 }
00305
00306
00307 virtual void addZones
00308 (
00309 const UList<surfZone>&,
00310 const bool cullEmpty=false
00311 );
00312
00313
00314 virtual void addZones
00315 (
00316 const UList<label>& sizes,
00317 const UList<word>& names,
00318 const bool cullEmpty=false
00319 );
00320
00321
00322 virtual void addZones
00323 (
00324 const UList<label>& sizes,
00325 const bool cullEmpty=false
00326 );
00327
00328
00329 virtual void removeZones();
00330
00331
00332
00333
00334
00335 virtual void clear();
00336
00337
00338 virtual void movePoints(const pointField&);
00339
00340
00341 virtual void scalePoints(const scalar&);
00342
00343
00344
00345 virtual void reset
00346 (
00347 const Xfer< pointField >& points,
00348 const Xfer< List<Face> >& faces,
00349 const Xfer< surfZoneList >& zones
00350 );
00351
00352
00353
00354 virtual void reset
00355 (
00356 const Xfer< List<point> >& points,
00357 const Xfer< List<Face> >& faces,
00358 const Xfer< surfZoneList >& zones
00359 );
00360
00361
00362 virtual void cleanup(const bool verbose);
00363
00364 virtual bool stitchFaces
00365 (
00366 const scalar tol=SMALL,
00367 const bool verbose=false
00368 );
00369
00370 virtual bool checkFaces
00371 (
00372 const bool verbose=false
00373 );
00374
00375
00376 virtual label triangulate();
00377
00378
00379
00380
00381 virtual label triangulate(List<label>& faceMap);
00382
00383
00384
00385
00386 MeshedSurface subsetMesh
00387 (
00388 const labelHashSet& include,
00389 labelList& pointMap,
00390 labelList& faceMap
00391 ) const;
00392
00393
00394 MeshedSurface subsetMesh
00395 (
00396 const labelHashSet& include
00397 ) const;
00398
00399
00400 void transfer(MeshedSurface<Face>&);
00401
00402
00403 void transfer(UnsortedMeshedSurface<Face>&);
00404
00405
00406 Xfer< MeshedSurface<Face> > xfer();
00407
00408
00409
00410
00411 bool read(const fileName&, const word& ext);
00412
00413
00414 virtual bool read(const fileName&);
00415
00416
00417
00418
00419 void writeStats(Ostream& os) const;
00420
00421
00422 virtual void write(const fileName& name) const
00423 {
00424 write(name, *this);
00425 }
00426
00427
00428 void write(const Time&, const word& surfName="") const;
00429
00430
00431
00432
00433 void operator=(const MeshedSurface<Face>&);
00434
00435
00436 operator MeshedSurfaceProxy<Face>() const;
00437
00438 };
00439
00440
00441
00442
00443
00444 template<>
00445 inline bool MeshedSurface<triFace>::isTri()
00446 {
00447 return true;
00448 }
00449
00450
00451 template<>
00452 inline label MeshedSurface<triFace>::triangulate()
00453 {
00454 return 0;
00455 }
00456
00457
00458 template<>
00459 inline label MeshedSurface<triFace>::triangulate(List<label>& faceMap)
00460 {
00461 if (&faceMap)
00462 {
00463 faceMap.clear();
00464 }
00465
00466 return 0;
00467 }
00468
00469
00470
00471 }
00472
00473
00474
00475 #ifdef NoRepository
00476 # include "MeshedSurface.C"
00477 #endif
00478
00479
00480
00481 #endif
00482
00483