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