From 7321fa6b7ecdda4bf8872b562ffe1c4183df40e6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 24 Aug 2017 13:05:21 +0200 Subject: [PATCH] don't filter point cloud when estimating normals to avoid mismatch of number of points and normals --- .../App/AppReverseEngineering.cpp | 17 ++++++++++++++++- src/Mod/ReverseEngineering/App/Segmentation.cpp | 5 ++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp b/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp index b5db47f1ee..4fdfe0939c 100644 --- a/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp +++ b/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp @@ -114,7 +114,22 @@ public: "filterVoxelGrid(dim)." ); add_keyword_method("normalEstimation",&Module::normalEstimation, - "normalEstimation(Points)." + "normalEstimation(Points,[KSearch=0, SearchRadius=0]) -> Normals\n" + "KSearch is an int and used to search the k-nearest neighbours in\n" + "the k-d tree. Alternatively, SearchRadius (a float) can be used\n" + "as spatial distance to determine the neighbours of a point\n" + "Example:\n" + "\n" + "import ReverseEngineering as Reen\n" + "pts=App.ActiveDocument.ActiveObject.Points\n" + "nor=Reen.normalEstimation(pts,KSearch=5)\n" + "\n" + "f=App.ActiveDocument.addObject('Points::FeaturePython','Normals')\n" + "f.addProperty('Points::PropertyNormalList','Normal')\n" + "f.Points=pts\n" + "f.Normal=nor\n" + "f.ViewObject.Proxy=0\n" + "f.ViewObject.DisplayMode=1\n" ); #endif #if defined(HAVE_PCL_SEGMENTATION) diff --git a/src/Mod/ReverseEngineering/App/Segmentation.cpp b/src/Mod/ReverseEngineering/App/Segmentation.cpp index 9340f73e05..eb2f7c5bcb 100644 --- a/src/Mod/ReverseEngineering/App/Segmentation.cpp +++ b/src/Mod/ReverseEngineering/App/Segmentation.cpp @@ -179,6 +179,7 @@ void NormalEstimation::perform(std::vector& normals) cloud->width = int (cloud->points.size ()); cloud->height = 1; +#if 0 // Build a passthrough filter to remove spurious NaNs pcl::PointCloud::Ptr cloud_filtered (new pcl::PointCloud); pcl::PassThrough pass; @@ -186,13 +187,15 @@ void NormalEstimation::perform(std::vector& normals) pass.setFilterFieldName ("z"); pass.setFilterLimits (0, 1.5); pass.filter (*cloud_filtered); +#endif // Estimate point normals pcl::PointCloud::Ptr cloud_normals (new pcl::PointCloud); pcl::search::KdTree::Ptr tree (new pcl::search::KdTree ()); pcl::NormalEstimation ne; ne.setSearchMethod (tree); - ne.setInputCloud (cloud_filtered); + //ne.setInputCloud (cloud_filtered); + ne.setInputCloud (cloud); if (kSearch > 0) ne.setKSearch (kSearch); if (searchRadius > 0)