| 46 | // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // |
| 47 | |
| 48 | void Foam::patchSeedSet::calcSamples |
| 49 | ( |
| 50 | DynamicList<point>& samplingPts, |
| 51 | DynamicList<label>& samplingCells, |
| 52 | DynamicList<label>& samplingFaces, |
| 53 | DynamicList<label>& samplingSegments, |
| 54 | DynamicList<scalar>& samplingCurveDist |
| 55 | ) |
| 56 | { |
| 57 | if (debug) |
| 58 | { |
| 59 | Info<< "patchSeedSet : sampling on patches :" << endl; |
| 60 | } |
| 61 | |
| 62 | // Construct search tree for all patch faces. |
| 63 | label sz = 0; |
| 64 | forAllConstIter(labelHashSet, patchSet_, iter) |
| 65 | { |
| 66 | const polyPatch& pp = mesh().boundaryMesh()[iter.key()]; |
| 67 | |
| 68 | sz += pp.size(); |
| 69 | |
| 70 | if (debug) |
| 71 | { |
| 72 | Info<< " " << pp.name() << " size " << pp.size() << endl; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | labelList patchFaces(sz); |
| 77 | sz = 0; |
| 78 | forAllConstIter(labelHashSet, patchSet_, iter) |
| 79 | { |
| 80 | const polyPatch& pp = mesh().boundaryMesh()[iter.key()]; |
| 81 | forAll(pp, i) |
| 82 | { |
| 83 | patchFaces[sz++] = pp.start()+i; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | |
| 88 | label totalSize = returnReduce(sz, sumOp<label>()); |
| 89 | |
| 90 | |
| 91 | // Shuffle and truncate if in random mode |
| 92 | if (maxPoints_ < totalSize) |
| 93 | { |
| 94 | // Check what fraction of maxPoints_ I need to generate locally. |
| 95 | label myMaxPoints = label(scalar(sz)/totalSize*maxPoints_); |
| 96 | |
| 97 | rndGenPtr_.reset(new Random(123456)); |
| 98 | Random& rndGen = rndGenPtr_(); |
| 99 | |
| 100 | labelList subset = identity(sz); |
| 101 | for (label iter = 0; iter < 4; iter++) |
| 102 | { |
| 103 | forAll(subset, i) |
| 104 | { |
| 105 | label j = rndGen.integer(0, subset.size()-1); |
no test coverage detected