Skip to content

Commit

Permalink
Add NormalX/Y/Z and Curvature dimensions.
Browse files Browse the repository at this point in the history
Close #1590
  • Loading branch information
abellgithub committed May 30, 2017
1 parent 9e283a8 commit 46e3462
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
18 changes: 9 additions & 9 deletions filters/NormalFilter.cpp
Expand Up @@ -67,11 +67,10 @@ void NormalFilter::addArgs(ProgramArgs& args)

void NormalFilter::addDimensions(PointLayoutPtr layout)
{
m_nx = layout->registerOrAssignDim("NormalX", Dimension::Type::Double);
m_ny = layout->registerOrAssignDim("NormalY", Dimension::Type::Double);
m_nz = layout->registerOrAssignDim("NormalZ", Dimension::Type::Double);
m_curvature = layout->registerOrAssignDim("Curvature",
Dimension::Type::Double);
using namespace Dimension;

layout->registerDims({Id::NormalX, Id::NormalY, Id::NormalZ,
Id::Curvature});
}

void NormalFilter::filter(PointView& view)
Expand All @@ -96,12 +95,13 @@ void NormalFilter::filter(PointView& view)
auto eval = solver.eigenvalues();
auto evec = solver.eigenvectors().col(0);

view.setField(m_nx, i, evec[0]);
view.setField(m_ny, i, evec[1]);
view.setField(m_nz, i, evec[2]);
view.setField(Dimension::Id::NormalX, i, evec[0]);
view.setField(Dimension::Id::NormalY, i, evec[1]);
view.setField(Dimension::Id::NormalZ, i, evec[2]);

double sum = eval[0] + eval[1] + eval[2];
view.setField(m_curvature, i, sum ? std::fabs(eval[0] / sum) : 0);
view.setField(Dimension::Id::Curvature, i,
sum ? std::fabs(eval[0] / sum) : 0);
}
}

Expand Down
1 change: 0 additions & 1 deletion filters/NormalFilter.hpp
Expand Up @@ -65,7 +65,6 @@ class PDAL_DLL NormalFilter : public Filter

private:
int m_knn;
Dimension::Id m_nx, m_ny, m_nz, m_curvature;

virtual void addDimensions(PointLayoutPtr layout);
virtual void addArgs(ProgramArgs& args);
Expand Down
20 changes: 20 additions & 0 deletions pdal/Dimension.json
Expand Up @@ -337,5 +337,25 @@
"name": "OriginId",
"type": "uint32",
"description": "A file source ID from which the point originated. This ID is global to a derivative dataset which may be aggregated from multiple files."
},
{
"name": "NormalX",
"type": "double",
"description": "X component of a vector normal to surface at this point"
},
{
"name": "NormalY",
"type": "double",
"description": "Y component of a vector normal to surface at this point"
},
{
"name": "NormalZ",
"type": "double",
"description": "Z component of a vector normal to surface at this point"
},
{
"name": "Curvature",
"type": "double",
"description": "Curvature of surface at this point"
}
] }

0 comments on commit 46e3462

Please sign in to comment.