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

Method filter

filters/ZsmoothFilter.cpp:93–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91
92
93void ZsmoothFilter::filter(PointView& view)
94{
95 const KD2Index& kdi = view.build2dIndex();
96
97 for (PointId idx = 0; idx < view.size(); ++idx)
98 {
99 double d = view.getFieldAs<double>(Dimension::Id::Z, idx);
100
101 std::vector<double> valList;
102 PointIdList nears = kdi.radius(idx, m_p->radius);
103 for (PointId n = 1; n < nears.size(); ++n)
104 {
105 double z = view.getFieldAs<double>(Dimension::Id::Z, nears[n]);
106 valList.push_back(z);
107 }
108 std::sort(valList.begin(), valList.end());
109
110 double val;
111 if (valList.empty())
112 val = view.getFieldAs<double>(Dimension::Id::Z, idx);
113 else if (valList.size() == 1)
114 val = valList[0];
115 else if (m_p->pos == 0.0)
116 val = valList[0];
117 else if (m_p->pos == 1.0)
118 val = valList[valList.size() - 1];
119 else
120 {
121 double pos = m_p->pos * (valList.size() - 1);
122 size_t low = (size_t)std::floor(pos);
123 size_t high = low + 1;
124 double highfrac = pos - low;
125 double lowfrac = 1 - highfrac;
126 val = valList[low] * lowfrac + valList[high] * highfrac;
127
128 }
129 view.setField(m_p->statDim, idx, val);
130 }
131}
132
133} // namespace pdal

Callers

nothing calls this directly

Calls 6

sizeMethod · 0.45
radiusMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
setFieldMethod · 0.45

Tested by

no test coverage detected