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 triSurfaceTools_H
00036 #define triSurfaceTools_H
00037
00038 #include "label.H"
00039 #include "labelList.H"
00040 #include "boolList.H"
00041 #include "point.H"
00042 #include "pointField.H"
00043 #include "HashTable.H"
00044 #include "DynamicList.H"
00045 #include "labelHashSet.H"
00046 #include "FixedList.H"
00047
00048
00049
00050 namespace Foam
00051 {
00052
00053
00054 class triSurface;
00055 class edge;
00056 class labelledTri;
00057 class polyBoundaryMesh;
00058
00059
00060
00061
00062
00063 namespace triSurfaceTools
00064 {
00065
00066 void writeOBJ
00067 (
00068 const fileName& fName,
00069 const pointField& pts
00070 );
00071
00072
00073 void writeOBJ
00074 (
00075 const triSurface& surf,
00076 const fileName& fName,
00077 const boolList& markedVerts
00078 );
00079
00080
00081 void getVertexTriangles
00082 (
00083 const triSurface& surf,
00084 const label edgeI,
00085 labelList& edgeTris
00086 );
00087
00088
00089 labelList getVertexVertices
00090 (
00091 const triSurface& surf,
00092 const edge& e
00093 );
00094
00095
00096
00097 FixedList<label, 3> sortedFaceEdges
00098 (
00099 const triSurface& surf,
00100 const label faceI
00101 );
00102
00103
00104 void orderVertices
00105 (
00106 const labelledTri& f,
00107 const label v1,
00108 const label v2,
00109 label& vA,
00110 label& vB
00111 );
00112
00113
00114 label otherFace
00115 (
00116 const triSurface& surf,
00117 const label faceI,
00118 const label edgeI
00119 );
00120
00121
00122 void otherEdges
00123 (
00124 const triSurface& surf,
00125 const label faceI,
00126 const label edgeI,
00127 label& e1,
00128 label& e2
00129 );
00130
00131
00132 void otherVertices
00133 (
00134 const triSurface& surf,
00135 const label faceI,
00136 const label vertI,
00137 label& vert1I,
00138 label& vert2I
00139 );
00140
00141
00142 label oppositeEdge
00143 (
00144 const triSurface& surf,
00145 const label faceI,
00146 const label vertI
00147 );
00148
00149
00150 label oppositeVertex
00151 (
00152 const triSurface& surf,
00153 const label faceI,
00154 const label edgeI
00155 );
00156
00157
00158 label getEdge
00159 (
00160 const triSurface& surf,
00161 const label vert1I,
00162 const label vert2I
00163 );
00164
00165
00166 label getTriangle
00167 (
00168 const triSurface& surf,
00169 const label e0I,
00170 const label e1I,
00171 const label e2I
00172 );
00173
00174
00175 label minEdge
00176 (
00177 const triSurface& surf,
00178 const labelList& edgeIndices
00179 );
00180
00181
00182 label maxEdge
00183 (
00184 const triSurface& surf,
00185 const labelList& edgeIndices
00186 );
00187
00188 scalar faceCosAngle
00189 (
00190 const point& pStart,
00191 const point& pEnd,
00192 const point& pLeft,
00193 const point& pRight
00194 );
00195
00196
00197
00198
00199
00200 scalar pseudoAngle
00201 (
00202 const vector& e0,
00203 const vector& e1,
00204 const vector& vec
00205 );
00206
00207
00208
00209 labelHashSet getCollapsedFaces
00210 (
00211 const triSurface& surf,
00212 label edgeI
00213 );
00214
00215
00216
00217 label vertexUsesFace
00218 (
00219 const triSurface& surf,
00220 const labelHashSet& faceUsed,
00221 const label vertI
00222 );
00223
00224
00225
00226
00227
00228
00229
00230
00231 void getMergedEdges
00232 (
00233 const triSurface& surf,
00234 const label edgeI,
00235 const labelHashSet& collapsedFaces,
00236 HashTable<label, label, Hash<label> >& edgeToEdge,
00237 HashTable<label, label, Hash<label> >& edgeToFace
00238 );
00239
00240
00241
00242 scalar edgeCosAngle
00243 (
00244 const triSurface& surf,
00245 const label v1,
00246 const point& pt,
00247 const labelHashSet& collapsedFaces,
00248 const HashTable<label, label, Hash<label> >& edgeToEdge,
00249 const HashTable<label, label, Hash<label> >& edgeToFace,
00250 const label faceI,
00251 const label edgeI
00252 );
00253
00254
00255
00256
00257 scalar collapseMinCosAngle
00258 (
00259 const triSurface& surf,
00260 const label v1,
00261 const point& pt,
00262 const labelHashSet& collapsedFaces,
00263 const HashTable<label, label, Hash<label> >& edgeToEdge,
00264 const HashTable<label, label, Hash<label> >& edgeToFace
00265 );
00266
00267
00268 bool collapseCreatesFold
00269 (
00270 const triSurface& surf,
00271 const label v1,
00272 const point& pt,
00273 const labelHashSet& collapsedFaces,
00274 const HashTable<label, label, Hash<label> >& edgeToEdge,
00275 const HashTable<label, label, Hash<label> >& edgeToFace,
00276 const scalar minCos
00277 );
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 static const label ANYEDGE = -1;
00293 static const label NOEDGE = -2;
00294 static const label COLLAPSED = -3;
00295
00296 void protectNeighbours
00297 (
00298 const triSurface& surf,
00299 const label vertI,
00300 labelList& faceStatus
00301 );
00302
00303
00304 triSurface collapseEdges
00305 (
00306 const triSurface& surf,
00307 const labelList& collapsableEdges
00308 );
00309
00310
00311
00312
00313
00314 triSurface collapseEdges
00315 (
00316 const triSurface& surf,
00317 const labelList& collapsableEdges,
00318 const pointField& edgeMids,
00319 labelList& faceStatus
00320 );
00321
00322 enum refineType
00323 {
00324 NONE,
00325 RED,
00326 GREEN
00327 };
00328
00329 void calcRefineStatus
00330 (
00331 const triSurface& surf,
00332 const label faceI,
00333 labelList& refine
00334 );
00335
00336 void greenRefine
00337 (
00338 const triSurface& surf,
00339 const label faceI,
00340 const label edgeI,
00341 const label newPointI,
00342 DynamicList<labelledTri>& newFaces
00343 );
00344
00345
00346 triSurface greenRefine
00347 (
00348 const triSurface& surf,
00349 const labelList& refineEdges
00350 );
00351
00352 triSurface doRefine
00353 (
00354 const triSurface& surf,
00355 const labelList& refineStatus
00356 );
00357
00358
00359 triSurface redGreenRefine
00360 (
00361 const triSurface& surf,
00362 const labelList& refineFaces
00363 );
00364
00365
00366 triSurface mergePoints
00367 (
00368 const triSurface& surf,
00369 const scalar mergeTol
00370 );
00371
00372
00373
00374
00375 vector surfaceNormal
00376 (
00377 const triSurface& surf,
00378 const label nearestFaceI,
00379 const point& nearestPt
00380 );
00381
00382
00383
00384
00385 triSurface triangulate
00386 (
00387 const polyBoundaryMesh& mBesh,
00388 const labelHashSet& includePatches,
00389 const bool verbose = false
00390 );
00391
00392
00393
00394
00395 triSurface triangulateFaceCentre
00396 (
00397 const polyBoundaryMesh& mBesh,
00398 const labelHashSet& includePatches,
00399 const bool verbose = false
00400 );
00401 }
00402
00403
00404
00405
00406 }
00407
00408
00409
00410 #endif
00411
00412