Go to the documentation of this file.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 #ifndef triSurface_H
00036 #define triSurface_H
00037
00038 #include <OpenFOAM/PrimitivePatch_.H>
00039 #include <OpenFOAM/pointField.H>
00040 #include <triSurface/labelledTri.H>
00041 #include <OpenFOAM/boolList.H>
00042 #include <triSurface/geometricSurfacePatchList.H>
00043 #include <triSurface/surfacePatchList.H>
00044 #include <OpenFOAM/triFaceList.H>
00045
00046
00047
00048 namespace Foam
00049 {
00050
00051 class Time;
00052 class IFstream;
00053
00054
00055
00056
00057
00058 class triSurface
00059 :
00060 public PrimitivePatch<labelledTri, ::Foam::List, pointField, point>
00061 {
00062
00063
00064
00065 typedef labelledTri Face;
00066 typedef PrimitivePatch
00067 <
00068 labelledTri,
00069 ::Foam::List,
00070 pointField,
00071 point
00072 >
00073 ParentType;
00074
00075
00076
00077
00078
00079 static const int STLheaderSize = 80;
00080
00081
00082
00083 geometricSurfacePatchList patches_;
00084
00085
00086
00087
00088
00089 mutable labelListList* sortedEdgeFacesPtr_;
00090
00091
00092
00093 mutable labelList* edgeOwnerPtr_;
00094
00095
00096
00097
00098
00099 void calcSortedEdgeFaces() const;
00100
00101
00102 void calcEdgeOwner() const;
00103
00104
00105
00106 surfacePatchList calcPatches(labelList& faceMap) const;
00107
00108
00109 void setDefaultPatches();
00110
00111
00112
00113 bool stitchTriangles
00114 (
00115 const pointField& rawPoints,
00116 const scalar tol = SMALL,
00117 const bool verbose = false
00118 );
00119
00120
00121 bool read(Istream&);
00122
00123
00124 bool read(const fileName&, const word& ext, const bool check = true);
00125
00126 bool readSTL(const fileName&);
00127 bool readSTLASCII(const fileName&);
00128 bool readSTLBINARY(const fileName&);
00129 bool readGTS(const fileName&);
00130 bool readOBJ(const fileName&);
00131 bool readOFF(const fileName&);
00132 bool readTRI(const fileName&);
00133 bool readAC(const fileName&);
00134 bool readNAS(const fileName&);
00135
00136
00137 void write(const fileName&, const word& ext, const bool sort) const;
00138
00139
00140
00141 void writeSTLASCII(Ostream&) const;
00142
00143
00144 void writeSTLBINARY(std::ostream&) const;
00145
00146
00147
00148 void writeGTS(const bool writeSorted, Ostream&) const;
00149
00150
00151
00152
00153 void writeOBJ(const bool writeSorted, Ostream&) const;
00154
00155
00156
00157
00158 void writeOFF(const bool writeSorted, Ostream&) const;
00159
00160
00161 void writeVTK(const bool writeSorted, Ostream&) const;
00162
00163
00164
00165 void writeTRI(const bool writeSorted, Ostream&) const;
00166
00167
00168 void writeSMESH(const bool writeSorted, Ostream&) const;
00169
00170
00171 void writeAC(Ostream&) const;
00172
00173
00174 void writeDX(const bool, Ostream&) const;
00175 void writeDXGeometry(const bool, Ostream&) const;
00176 void writeDXTrailer(Ostream&) const;
00177
00178
00179
00180
00181 static List<labelledTri> convertToTri
00182 (
00183 const faceList&,
00184 const label defaultRegion = 0
00185 );
00186
00187
00188 static List<labelledTri> convertToTri
00189 (
00190 const triFaceList&,
00191 const label defaultRegion = 0
00192 );
00193
00194
00195 static void printTriangle
00196 (
00197 Ostream&,
00198 const Foam::string& pre,
00199 const labelledTri&,
00200 const pointField&
00201 );
00202
00203
00204 static string getLineNoComment(IFstream&);
00205
00206 protected:
00207
00208
00209
00210
00211 pointField& storedPoints()
00212 {
00213 return const_cast<pointField&>(ParentType::points());
00214 }
00215
00216
00217 List<Face>& storedFaces()
00218 {
00219 return static_cast<List<Face>&>(*this);
00220 }
00221
00222 public:
00223
00224
00225
00226
00227 typedef bool BoundaryMesh;
00228
00229
00230
00231 ClassName("triSurface");
00232
00233
00234
00235
00236
00237 static fileName triSurfInstance(const Time&);
00238
00239
00240
00241
00242
00243 triSurface();
00244
00245
00246 triSurface
00247 (
00248 const List<labelledTri>&,
00249 const geometricSurfacePatchList&,
00250 const pointField&
00251 );
00252
00253
00254 triSurface
00255 (
00256 List<labelledTri>&,
00257 const geometricSurfacePatchList&,
00258 pointField&,
00259 const bool reUse
00260 );
00261
00262
00263 triSurface(const List<labelledTri>&, const pointField&);
00264
00265
00266
00267 triSurface(const triFaceList&, const pointField&);
00268
00269
00270 triSurface(const fileName&);
00271
00272
00273 triSurface(Istream&);
00274
00275
00276 triSurface(const Time& d);
00277
00278
00279 triSurface(const triSurface&);
00280
00281
00282
00283
00284
00285 ~triSurface();
00286
00287 void clearOut();
00288
00289 void clearTopology();
00290
00291 void clearPatchMeshAddr();
00292
00293
00294
00295
00296
00297
00298 const geometricSurfacePatchList& patches() const
00299 {
00300 return patches_;
00301 }
00302
00303 geometricSurfacePatchList& patches()
00304 {
00305 return patches_;
00306 }
00307
00308
00309
00310
00311
00312 const labelListList& sortedEdgeFaces() const;
00313
00314
00315
00316
00317
00318 const labelList& edgeOwner() const;
00319
00320
00321
00322
00323 virtual void movePoints(const pointField&);
00324
00325
00326 virtual void scalePoints(const scalar&);
00327
00328
00329 void checkTriangles(const bool verbose);
00330
00331
00332 void checkEdges(const bool verbose);
00333
00334
00335 void cleanup(const bool verbose);
00336
00337
00338
00339
00340 void markZone
00341 (
00342 const boolList& borderEdge,
00343 const label faceI,
00344 const label currentZone,
00345 labelList& faceZone
00346 ) const;
00347
00348
00349
00350
00351 label markZones
00352 (
00353 const boolList& borderEdge,
00354 labelList& faceZone
00355 ) const;
00356
00357
00358
00359
00360
00361 void subsetMeshMap
00362 (
00363 const boolList& include,
00364 labelList& pointMap,
00365 labelList& faceMap
00366 ) const;
00367
00368
00369
00370 triSurface subsetMesh
00371 (
00372 const boolList& include,
00373 labelList& pointMap,
00374 labelList& faceMap
00375 ) const;
00376
00377
00378
00379
00380 void write(Ostream&) const;
00381
00382
00383 void write(const fileName&, const bool sortByRegion = false) const;
00384
00385
00386 void write(const Time&) const;
00387
00388
00389 void writeDX(const scalarField&, Ostream&) const;
00390 void writeDX(const vectorField&, Ostream&) const;
00391
00392
00393 void writeStats(Ostream&) const;
00394
00395
00396
00397
00398 void operator=(const triSurface&);
00399
00400
00401
00402
00403 friend Ostream& operator<<(Ostream&, const triSurface&);
00404 };
00405
00406
00407
00408
00409 }
00410
00411
00412
00413 #endif
00414
00415