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

Method compute

filters/NormalFilter.cpp:140–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140void NormalFilter::compute(PointView& view, KD3Index& kdi)
141{
142 log()->get(LogLevel::Debug) << "Computing normal vectors\n";
143 for (auto&& p : view)
144 {
145 math::NormalResult result;
146
147 // Perform eigen decomposition of covariance matrix computed from
148 // neighborhood composed of k-nearest neighbors, or within radius.
149 if (m_radiusArg->set())
150 result = math::findNormal(view, kdi.radius(p.pointId(), m_args->m_radius));
151 else
152 result = math::findNormal(view, kdi.neighbors(p.pointId(), m_args->m_knn));
153
154 if (result.normal.isZero())
155 {
156 log()->get(LogLevel::Info)
157 << "Skipping point " << p.pointId()
158 << ": " << result.msg << "\n";
159 continue;
160 }
161
162 if (m_viewpointArg->set())
163 {
164 // If a viewpoint has been specified, orient the normals to face the
165 // viewpoint by taking the dot product of the vector connecting the
166 // point with the viewpoint and the normal. Flip the normal, where
167 // the dot product is negative.
168 double dx = m_args->m_viewpoint.x() - p.getFieldAs<double>(Id::X);
169 double dy = m_args->m_viewpoint.y() - p.getFieldAs<double>(Id::Y);
170 double dz = m_args->m_viewpoint.z() - p.getFieldAs<double>(Id::Z);
171 result.normal = math::orientToViewpoint({ dx, dy, dz }, result.normal);
172 }
173 else if (m_args->m_up)
174 result.normal = math::orientUp(result.normal);
175
176 // Set the computed normal and curvature dimensions.
177 p.setField(Id::NormalX, result.normal[0]);
178 p.setField(Id::NormalY, result.normal[1]);
179 p.setField(Id::NormalZ, result.normal[2]);
180 p.setField(Id::Curvature, result.curvature);
181 }
182}
183
184void NormalFilter::update(
185 PointView& view, KD3Index& kdi, std::vector<bool> inMST,

Callers

nothing calls this directly

Calls 12

findNormalFunction · 0.85
orientToViewpointFunction · 0.85
orientUpFunction · 0.85
logFunction · 0.50
getMethod · 0.45
setMethod · 0.45
radiusMethod · 0.45
neighborsMethod · 0.45
xMethod · 0.45
yMethod · 0.45
zMethod · 0.45
setFieldMethod · 0.45

Tested by

no test coverage detected