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 triSurfaceTools_H
00037 #define triSurfaceTools_H
00038
00039 #include "boolList.H"
00040 #include "pointField.H"
00041 #include "DynamicList.H"
00042 #include "HashSet.H"
00043 #include "FixedList.H"
00044 #include "vector2D.H"
00045 #include "triPointRef.H"
00046 #include "surfaceLocation.H"
00047
00048
00049
00050 namespace Foam
00051 {
00052
00053
00054 class triSurface;
00055 class edge;
00056 class labelledTri;
00057 class polyBoundaryMesh;
00058 class plane;
00059
00060
00061
00062
00063
00064 class triSurfaceTools
00065 {
00066
00067
00068
00069
00070 enum refineType
00071 {
00072 NONE,
00073 RED,
00074 GREEN
00075 };
00076 static void calcRefineStatus
00077 (
00078 const triSurface& surf,
00079 const label faceI,
00080 List<refineType>& refine
00081 );
00082 static void greenRefine
00083 (
00084 const triSurface& surf,
00085 const label faceI,
00086 const label edgeI,
00087 const label newPointI,
00088 DynamicList<labelledTri>& newFaces
00089 );
00090 static triSurface doRefine
00091 (
00092 const triSurface& surf,
00093 const List<refineType>& refineStatus
00094 );
00095
00096
00097
00098
00099 static scalar faceCosAngle
00100 (
00101 const point& pStart,
00102 const point& pEnd,
00103 const point& pLeft,
00104 const point& pRight
00105 );
00106
00107 static void protectNeighbours
00108 (
00109 const triSurface& surf,
00110 const label vertI,
00111 labelList& faceStatus
00112 );
00113
00114
00115 static labelHashSet getCollapsedFaces
00116 (
00117 const triSurface& surf,
00118 label edgeI
00119 );
00120
00121
00122
00123 static label vertexUsesFace
00124 (
00125 const triSurface& surf,
00126 const labelHashSet& faceUsed,
00127 const label vertI
00128 );
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 static void getMergedEdges
00139 (
00140 const triSurface& surf,
00141 const label edgeI,
00142 const labelHashSet& collapsedFaces,
00143 HashTable<label, label, Hash<label> >& edgeToEdge,
00144 HashTable<label, label, Hash<label> >& edgeToFace
00145 );
00146
00147
00148
00149
00150 static scalar edgeCosAngle
00151 (
00152 const triSurface& surf,
00153 const label v1,
00154 const point& pt,
00155 const labelHashSet& collapsedFaces,
00156 const HashTable<label, label, Hash<label> >& edgeToEdge,
00157 const HashTable<label, label, Hash<label> >& edgeToFace,
00158 const label faceI,
00159 const label edgeI
00160 );
00161
00162
00164
00165
00166 static scalar collapseMinCosAngle
00167 (
00168 const triSurface& surf,
00169 const label v1,
00170 const point& pt,
00171 const labelHashSet& collapsedFaces,
00172 const HashTable<label, label, Hash<label> >& edgeToEdge,
00173 const HashTable<label, label, Hash<label> >& edgeToFace
00174 );
00175
00176
00177 bool collapseCreatesFold
00178 (
00179 const triSurface& surf,
00180 const label v1,
00181 const point& pt,
00182 const labelHashSet& collapsedFaces,
00183 const HashTable<label, label, Hash<label> >& edgeToEdge,
00184 const HashTable<label, label, Hash<label> >& edgeToFace,
00185 const scalar minCos
00186 );
00187
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 static surfaceLocation cutEdge
00205 (
00206 const triSurface& s,
00207 const label triI,
00208 const label excludeEdgeI,
00209 const label excludePointI,
00210 const point& triPoint,
00211 const plane& cutPlane,
00212 const point& toPoint
00213 );
00214
00215
00216
00217 static void snapToEnd
00218 (
00219 const triSurface& s,
00220 const surfaceLocation& endInfo,
00221 surfaceLocation& current
00222 );
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 static surfaceLocation visitFaces
00233 (
00234 const triSurface& s,
00235 const labelList& eFaces,
00236 const surfaceLocation& start,
00237 const label excludeEdgeI,
00238 const label excludePointI,
00239 const surfaceLocation& end,
00240 const plane& cutPlane
00241 );
00242
00243
00244 public:
00245
00246
00247
00248
00249 static void writeOBJ
00250 (
00251 const fileName& fName,
00252 const pointField& pts
00253 );
00254
00255
00256 static void writeOBJ
00257 (
00258 const triSurface& surf,
00259 const fileName& fName,
00260 const boolList& markedVerts
00261 );
00262
00263
00264
00265
00266
00267 static void getVertexTriangles
00268 (
00269 const triSurface& surf,
00270 const label edgeI,
00271 labelList& edgeTris
00272 );
00273
00274
00275 static labelList getVertexVertices
00276 (
00277 const triSurface& surf,
00278 const edge& e
00279 );
00280
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 static label otherFace
00293 (
00294 const triSurface& surf,
00295 const label faceI,
00296 const label edgeI
00297 );
00298
00299
00300 static void otherEdges
00301 (
00302 const triSurface& surf,
00303 const label faceI,
00304 const label edgeI,
00305 label& e1,
00306 label& e2
00307 );
00308
00309
00310
00311 static void otherVertices
00312 (
00313 const triSurface& surf,
00314 const label faceI,
00315 const label vertI,
00316 label& vert1I,
00317 label& vert2I
00318 );
00319
00320
00321 static label oppositeEdge
00322 (
00323 const triSurface& surf,
00324 const label faceI,
00325 const label vertI
00326 );
00327
00328
00329 static label oppositeVertex
00330 (
00331 const triSurface& surf,
00332 const label faceI,
00333 const label edgeI
00334 );
00335
00336
00337 static label getEdge
00338 (
00339 const triSurface& surf,
00340 const label vert1I,
00341 const label vert2I
00342 );
00343
00344
00345 static label getTriangle
00346 (
00347 const triSurface& surf,
00348 const label e0I,
00349 const label e1I,
00350 const label e2I
00351 );
00352
00353
00354
00355
00356 static triSurface collapseEdges
00357 (
00358 const triSurface& surf,
00359 const labelList& collapsableEdges
00360 );
00361
00362
00363
00364
00365
00366
00367
00368 static const label ANYEDGE;
00369 static const label NOEDGE;
00370 static const label COLLAPSED;
00371
00372
00373
00374
00375
00376
00377 static triSurface collapseEdges
00378 (
00379 const triSurface& surf,
00380 const labelList& collapsableEdges,
00381 const pointField& edgeMids,
00382 labelList& faceStatus
00383 );
00384
00385
00386
00387
00388
00389 static triSurface greenRefine
00390 (
00391 const triSurface& surf,
00392 const labelList& refineEdges
00393 );
00394
00395
00396
00397 static triSurface redGreenRefine
00398 (
00399 const triSurface& surf,
00400 const labelList& refineFaces
00401 );
00402
00403
00404
00405
00406
00407 static label minEdge
00408 (
00409 const triSurface& surf,
00410 const labelList& edgeIndices
00411 );
00412
00413
00414 static label maxEdge
00415 (
00416 const triSurface& surf,
00417 const labelList& edgeIndices
00418 );
00419
00420
00421 static triSurface mergePoints
00422 (
00423 const triSurface& surf,
00424 const scalar mergeTol
00425 );
00426
00427
00428
00429
00430 static vector surfaceNormal
00431 (
00432 const triSurface& surf,
00433 const label nearestFaceI,
00434 const point& nearestPt
00435 );
00436
00437
00438 enum sideType
00439 {
00440 UNKNOWN,
00441 INSIDE,
00442 OUTSIDE
00443 };
00444
00445
00446
00447 static sideType edgeSide
00448 (
00449 const triSurface& surf,
00450 const point& sample,
00451 const point& nearestPoint,
00452 const label edgeI
00453 );
00454
00455
00456
00457
00458 static sideType surfaceSide
00459 (
00460 const triSurface& surf,
00461 const point& sample,
00462 const label nearestFaceI,
00463 const point& nearestPt,
00464 const scalar tol
00465 );
00466
00467
00468
00469
00470
00471
00472 static triSurface triangulate
00473 (
00474 const polyBoundaryMesh& mBesh,
00475 const labelHashSet& includePatches,
00476 const bool verbose = false
00477 );
00478
00479
00480
00481
00482
00483 triSurface triangulateFaceCentre
00484 (
00485 const polyBoundaryMesh& mBesh,
00486 const labelHashSet& includePatches,
00487 const bool verbose = false
00488 );
00489
00490
00491
00492
00493
00494
00495 static void calcInterpolationWeights
00496 (
00497 const triPointRef&,
00498 const point&,
00499 FixedList<scalar, 3>& weights
00500 );
00501
00502
00503
00504
00505
00506
00507
00508
00509 static void calcInterpolationWeights
00510 (
00511 const triSurface& s,
00512 const pointField& samplePts,
00513 List<FixedList<label, 3> >& verts,
00514 List<FixedList<scalar, 3> >& weights
00515 );
00516
00517
00518
00519 static triSurface delaunay2D(const List<vector2D>&);
00520
00521
00522
00523
00524
00525
00526 static surfaceLocation classify
00527 (
00528 const triSurface&,
00529 const label triI,
00530 const point& trianglePoint
00531 );
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549 static surfaceLocation trackToEdge
00550 (
00551 const triSurface&,
00552 const surfaceLocation& start,
00553 const surfaceLocation& end,
00554 const plane& cutPlane
00555 );
00556
00557
00558
00559
00560
00561
00562 static void track
00563 (
00564 const triSurface&,
00565 const surfaceLocation& endInfo,
00566 const plane& cutPlane,
00567 surfaceLocation& hitInfo
00568 );
00569 };
00570
00571
00572
00573
00574 }
00575
00576
00577
00578 #endif
00579
00580