| 102 | |
| 103 | |
| 104 | void Processor::sample() |
| 105 | { |
| 106 | // Accepted points are those that will go in this (the parent) cell. |
| 107 | // Rejected points will remain in the child cell they were in previously. |
| 108 | |
| 109 | std::unique_ptr<std::mt19937> g; |
| 110 | if (b.opts.fixedSeed) |
| 111 | { |
| 112 | std::vector<int32_t> v{1234}; |
| 113 | std::seed_seq seed(v.begin(), v.end()); |
| 114 | g.reset(new std::mt19937(seed)); |
| 115 | } |
| 116 | else |
| 117 | { |
| 118 | std::random_device rd; |
| 119 | g.reset(new std::mt19937(rd())); |
| 120 | } |
| 121 | |
| 122 | OctantInfo& parent = m_vi.octant(); |
| 123 | PointViewPtr accepted = parent.source(); |
| 124 | |
| 125 | for (int i = 0; i < 8; ++i) |
| 126 | { |
| 127 | OctantInfo& child = m_vi.child(i); |
| 128 | if (child.numPoints() == 0) |
| 129 | continue; |
| 130 | |
| 131 | PointViewPtr& v = child.source(); |
| 132 | PointViewPtr rejected = v->makeNew(); |
| 133 | |
| 134 | std::shuffle(v->begin(), v->end(), *g); |
| 135 | for (PointId idx = 0; idx < v->size(); ++idx) |
| 136 | { |
| 137 | GridKey k = m_vi.gridKey(PointRef(*v, idx)); |
| 138 | |
| 139 | // If we're accepting this point into this voxel from it's child, add it |
| 140 | // to the accepted list and also stick it in the grid. |
| 141 | if (acceptable(k)) |
| 142 | { |
| 143 | accepted->appendPoint(*v, idx); |
| 144 | m_vi.grid().insert(k); |
| 145 | } |
| 146 | else |
| 147 | rejected->appendPoint(*v, idx); |
| 148 | } |
| 149 | v = rejected; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | |
| 154 | bool Processor::acceptable(GridKey key) |