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