Commit 8d9b1027 authored by Mike Rye's avatar Mike Rye
Browse files

Add KdTree option to normal filter.

parent 30256b1b
......@@ -3,8 +3,8 @@
## General
* Create [vtkMultiBlockDataSetAlgorithm](https://vtk.org/doc/nightly/html/classvtkMultiBlockDataSetAlgorithm.html) base classes for filters that return multiple inputs (e.g. the pending Euclidean cluster extraction filter).
* Consider how to optimize the directory hierarchy.
* Update the CMake `add_module` macro to allow for more flexibility (e.g. remove the assumption of a particular base class through file inspection).
* Consider how to improve the directory hierarchy.
* Add KdTree options to filters that support them (use PCLNormalEstimationFilter as template).
## OpenNi Source
......
......@@ -114,7 +114,7 @@ macro(add_module name)
# Add the ServerManager xml file.
list(APPEND ServerManagerXML "xml/${name}.xml")
# The final part of the name determines the subdirectory in which the related
# The final part of the name determines the subdirectory in which the C++
# files are located. For example, all modules ending in "Filter" are expected
# to be in the "filter" directory.
string(REGEX MATCH "[A-Z][a-z]+[0-9]*$" filter_type "${name}")
......
......@@ -21,6 +21,7 @@
// #define PCL_NO_PRECOMPILE
#include <pcl/features/normal_3d_omp.h>
#include <pcl/search/kdtree.h>
vtkStandardNewMacro(vtkPCLNormalEstimationFilter);
......@@ -39,6 +40,8 @@ void vtkPCLNormalEstimationFilter::PrintSelf(ostream & os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "Radius: " << this->Radius << "\n";
os << indent << "UseKdtree: " << this->UseKdTree << "\n";
os << indent << "Epsilon: " << this->Epsilon << "\n";
}
//------------------------------------------------------------------------------
......@@ -87,6 +90,8 @@ int vtkPCLNormalEstimationFilter::EstimateNormals(
)
{
typedef pcl::PointCloud<NormalPointType> NormalCloudT;
typedef pcl::search::KdTree<PointType> KdTreeT;
typename NormalCloudT::Ptr outputCloud(new NormalCloudT);
// Copy the xyz data. The normal data will be inserted by the estimator below.
......@@ -95,6 +100,13 @@ int vtkPCLNormalEstimationFilter::EstimateNormals(
pcl::NormalEstimationOMP<PointType, NormalPointType> ne;
ne.setRadiusSearch(this->Radius);
ne.setInputCloud(inputCloud);
if (this->UseKdTree)
{
typename KdTreeT::Ptr kdtree(new KdTreeT());
std::cout << "Epsilon: " << kdtree->getEpsilon() << '\n';
kdtree->setEpsilon(this->Epsilon);
ne.setSearchMethod(kdtree);
}
ne.compute((* outputCloud));
vtkPCLConversions::PolyDataFromPointCloud(outputCloud, output);
......
......@@ -42,11 +42,21 @@ private:
// Filter parameters.
private:
double Radius {0.05};
// KdTree attributes
bool UseKdTree {false};
float Epsilon {0}; // default value of pcl::search::Kdtree
public:
vtkSetMacro(Radius, double);
vtkGetMacro(Radius, double);
vtkSetMacro(UseKdTree, bool);
vtkGetMacro(UseKdTree, bool);
vtkSetMacro(Epsilon, float);
vtkGetMacro(Epsilon, float);
//------------------------------------------------------------------------------
private:
int ApplyPCLFilter(
......
......@@ -31,6 +31,36 @@
<Documentation>The radius within which neighboring points will be considered.</Documentation>
</DoubleVectorProperty>
<IntVectorProperty
name="UseKdTree"
label="Use KdTree"
command="SetUseKdTree"
number_of_elements="1"
default_values="0"
panel_visibility="advanced"
>
<BooleanDomain name="bool" />
<Documentation>Configure the filter to explicitly use a K-d tree.</Documentation>
</IntVectorProperty>
<DoubleVectorProperty
name="Epsilon"
command="SetEpsilon"
number_of_elements="1"
default_values="0"
panel_visibility="advanced"
>
<Documentation>Search epsilon precision (error bound) for nearest neighbor searches.</Documentation>
</DoubleVectorProperty>
<PropertyGroup
label="K-d Tree Properties"
panel_visibility="advanced"
>
<Property name="UseKdTree" />
<Property name="Epsilon" />
</PropertyGroup>
<Hints>
<ShowInMenu category="PCL" />
</Hints>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment