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
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 #ifndef cellCuts_H
00084 #define cellCuts_H
00085
00086 #include <dynamicMesh/edgeVertex.H>
00087 #include <OpenFOAM/labelList.H>
00088 #include <OpenFOAM/boolList.H>
00089 #include <OpenFOAM/scalarField.H>
00090 #include <OpenFOAM/pointField.H>
00091 #include <OpenFOAM/DynamicList.H>
00092 #include <OpenFOAM/typeInfo.H>
00093
00094
00095
00096 namespace Foam
00097 {
00098
00099
00100 class polyMesh;
00101 class cellLooper;
00102 class refineCell;
00103 class plane;
00104
00105
00106
00107
00108
00109 class cellCuts
00110 :
00111 public edgeVertex
00112 {
00113
00114
00115
00116
00117
00118 boolList pointIsCut_;
00119
00120
00121 boolList edgeIsCut_;
00122
00123
00124 scalarField edgeWeight_;
00125
00126
00127
00128
00129
00130
00131 mutable labelListList* faceCutsPtr_;
00132
00133
00134
00135 Map<edge> faceSplitCut_;
00136
00137
00138
00139
00140
00141 labelListList cellLoops_;
00142
00143
00144 label nLoops_;
00145
00146
00147 labelListList cellAnchorPoints_;
00148
00149
00150
00151
00152
00153 static label findPartIndex
00154 (
00155 const labelList&,
00156 const label n,
00157 const label val
00158 );
00159
00160
00161
00162 static boolList expand(const label size, const labelList& labels);
00163
00164
00165
00166 static scalarField expand
00167 (
00168 const label,
00169 const labelList&,
00170 const scalarField&
00171 );
00172
00173
00174
00175 static label firstUnique
00176 (
00177 const labelList& lst,
00178 const Map<label>&
00179 );
00180
00181
00182
00183
00184
00185 void writeUncutOBJ(const fileName&, const label cellI) const;
00186
00187
00188 void writeOBJ
00189 (
00190 const fileName& dir,
00191 const label cellI,
00192 const pointField& loopPoints,
00193 const labelList& anchors
00194 ) const;
00195
00196
00197 label edgeEdgeToFace
00198 (
00199 const label cellI,
00200 const label edgeA,
00201 const label edgeB
00202 ) const;
00203
00204
00205
00206 label edgeVertexToFace
00207 (
00208 const label cellI,
00209 const label edgeI,
00210 const label vertI
00211 ) const;
00212
00213
00214 label vertexVertexToFace
00215 (
00216 const label cellI,
00217 const label vertA,
00218 const label vertB
00219 ) const;
00220
00221
00222
00223
00224
00225 void calcFaceCuts() const;
00226
00227
00228
00229
00230
00231 label findEdge
00232 (
00233 const label faceI,
00234 const label v0,
00235 const label v1
00236 ) const;
00237
00238
00239 label loopFace(const label cellI, const labelList& loop) const;
00240
00241
00242 bool walkPoint
00243 (
00244 const label cellI,
00245 const label startCut,
00246
00247 const label exclude0,
00248 const label exclude1,
00249
00250 const label otherCut,
00251
00252 label& nVisited,
00253 labelList& visited
00254 ) const;
00255
00256
00257 bool crossEdge
00258 (
00259 const label cellI,
00260 const label startCut,
00261 const label faceI,
00262 const label otherCut,
00263
00264 label& nVisited,
00265 labelList& visited
00266 ) const;
00267
00268
00269
00270 bool addCut
00271 (
00272 const label cellI,
00273 const label cut,
00274 label& nVisited,
00275 labelList& visited
00276 ) const;
00277
00278
00279
00280 bool walkFace
00281 (
00282 const label cellI,
00283 const label startCut,
00284 const label faceI,
00285 const label cut,
00286
00287 label& lastCut,
00288 label& beforeLastCut,
00289 label& nVisited,
00290 labelList& visited
00291 ) const;
00292
00293
00294
00295
00296 bool walkCell
00297 (
00298 const label cellI,
00299 const label startCut,
00300 const label faceI,
00301 const label prevCut,
00302 label& nVisited,
00303 labelList& visited
00304 ) const;
00305
00306
00307 void calcCellLoops(const labelList& cutCells);
00308
00309
00310
00311
00312
00313 bool checkFaces
00314 (
00315 const label cellI,
00316 const labelList& anchorPoints
00317 ) const;
00318
00319
00320
00321 void walkEdges
00322 (
00323 const label cellI,
00324 const label pointI,
00325 const label status,
00326
00327 Map<label>& edgeStatus,
00328 Map<label>& pointStatus
00329 ) const;
00330
00331
00332 bool loopAnchorConsistent
00333 (
00334 const label cellI,
00335 const pointField& loopPts,
00336 const labelList& anchorPoints
00337 ) const;
00338
00339
00340
00341
00342 bool calcAnchors
00343 (
00344 const label cellI,
00345 const labelList& loop,
00346 const pointField& loopPts,
00347
00348 labelList& anchorPoints
00349 ) const;
00350
00351
00352
00353 pointField loopPoints
00354 (
00355 const labelList& loop,
00356 const scalarField& loopWeights
00357 ) const;
00358
00359
00360 scalarField loopWeights(const labelList& loop) const;
00361
00362
00363
00364 bool validEdgeLoop
00365 (
00366 const labelList& loop,
00367 const scalarField& loopWeights
00368 ) const;
00369
00370
00371 label countFaceCuts
00372 (
00373 const label faceI,
00374 const labelList& loop
00375 ) const;
00376
00377
00378
00379 bool conservativeValidLoop
00380 (
00381 const label cellI,
00382 const labelList& loop
00383 ) const;
00384
00385
00386
00387
00388
00389 bool validLoop
00390 (
00391 const label cellI,
00392 const labelList& loop,
00393 const scalarField& loopWeights,
00394 Map<edge>& newFaceSplitCut,
00395 labelList& anchorPoints
00396 ) const;
00397
00398
00399
00400 void setFromCellLoops();
00401
00402
00403 bool setFromCellLoop
00404 (
00405 const label cellI,
00406 const labelList& loop,
00407 const scalarField& loopWeights
00408 );
00409
00410
00411
00412 void setFromCellLoops
00413 (
00414 const labelList& cellLabels,
00415 const labelListList& cellLoops,
00416 const List<scalarField>& cellLoopWeights
00417 );
00418
00419
00420
00421 void setFromCellCutter
00422 (
00423 const cellLooper&,
00424 const List<refineCell>& refCells
00425 );
00426
00427
00428 void setFromCellCutter
00429 (
00430 const cellLooper&,
00431 const labelList& cellLabels,
00432 const List<plane>&
00433 );
00434
00435
00436 void orientPlanesAndLoops();
00437
00438
00439 void calcLoopsAndAddressing(const labelList& cutCells);
00440
00441
00442 void check() const;
00443
00444
00445
00446 cellCuts(const cellCuts&);
00447
00448
00449 void operator=(const cellCuts&);
00450
00451
00452 public:
00453
00454
00455 ClassName("cellCuts");
00456
00457
00458
00459
00460
00461 cellCuts
00462 (
00463 const polyMesh& mesh,
00464 const labelList& cutCells,
00465 const labelList& meshVerts,
00466 const labelList& meshEdges,
00467 const scalarField& meshEdgeWeights
00468 );
00469
00470
00471 cellCuts
00472 (
00473 const polyMesh& mesh,
00474 const labelList& meshVerts,
00475 const labelList& meshEdges,
00476 const scalarField& meshEdgeWeights
00477 );
00478
00479
00480
00481
00482 cellCuts
00483 (
00484 const polyMesh& mesh,
00485 const labelList& cellLabels,
00486 const labelListList& cellLoops,
00487 const List<scalarField>& cellEdgeWeights
00488 );
00489
00490
00491
00492 cellCuts
00493 (
00494 const polyMesh& mesh,
00495 const cellLooper& cellCutter,
00496 const List<refineCell>& refCells
00497 );
00498
00499
00500
00501 cellCuts
00502 (
00503 const polyMesh& mesh,
00504 const cellLooper& cellCutter,
00505 const labelList& cellLabels,
00506 const List<plane>& cutPlanes
00507 );
00508
00509
00510 cellCuts
00511 (
00512 const polyMesh& mesh,
00513 const boolList& pointIsCut,
00514 const boolList& edgeIsCut,
00515 const scalarField& edgeWeight,
00516 const Map<edge>& faceSplitCut,
00517 const labelListList& cellLoops,
00518 const label nLoops,
00519 const labelListList& cellAnchorPoints
00520 );
00521
00522
00523
00524
00525 ~cellCuts();
00526
00527
00528 void clearOut();
00529
00530
00531
00532
00533
00534
00535
00536 const boolList& pointIsCut() const
00537 {
00538 return pointIsCut_;
00539 }
00540
00541
00542 const boolList& edgeIsCut() const
00543 {
00544 return edgeIsCut_;
00545 }
00546
00547
00548 const scalarField& edgeWeight() const
00549 {
00550 return edgeWeight_;
00551 }
00552
00553
00554
00555 const labelListList& faceCuts() const
00556 {
00557 if (!faceCutsPtr_)
00558 {
00559 calcFaceCuts();
00560 }
00561 return *faceCutsPtr_;
00562 }
00563
00564
00565 const Map<edge>& faceSplitCut() const
00566 {
00567 return faceSplitCut_;
00568 }
00569
00570
00571 const labelListList& cellLoops() const
00572 {
00573 return cellLoops_;
00574 }
00575
00576
00577 label nLoops() const
00578 {
00579 return nLoops_;
00580 }
00581
00582
00583 const labelListList& cellAnchorPoints() const
00584 {
00585 return cellAnchorPoints_;
00586 }
00587
00588
00589
00590
00591
00592
00593 pointField loopPoints(const label cellI) const;
00594
00595
00596 labelList nonAnchorPoints
00597 (
00598 const labelList& cellPoints,
00599 const labelList& anchorPoints,
00600 const labelList& loop
00601 ) const;
00602
00603
00604 void flip(const label cellI);
00605
00606
00607
00608 void flipLoopOnly(const label cellI);
00609
00610
00611
00612
00613
00614 void writeOBJ
00615 (
00616 Ostream& os,
00617 const pointField& loopPoints,
00618 label& vertI
00619 ) const;
00620
00621
00622 void writeOBJ(Ostream& os) const;
00623
00624
00625 void writeCellOBJ(const fileName& dir, const label cellI) const;
00626
00627 };
00628
00629
00630
00631
00632 }
00633
00634
00635
00636 #endif
00637
00638