MCPcopy Create free account
hub / github.com/PDAL/PDAL / sample

Method sample

io/private/copcwriter/Processor.cpp:104–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102
103
104void 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
154bool Processor::acceptable(GridKey key)

Callers

nothing calls this directly

Calls 11

childMethod · 0.80
gridKeyMethod · 0.80
appendPointMethod · 0.80
gridMethod · 0.80
PointRefClass · 0.50
beginMethod · 0.45
endMethod · 0.45
resetMethod · 0.45
numPointsMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected