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