From fa9f777177a01ccc03cb98381609b48d5d46ce7e Mon Sep 17 00:00:00 2001 From: Daniel Girardeau-Montaut Date: Sun, 9 Aug 2026 20:40:00 +0200 Subject: [PATCH] Option to set the number of threads used with the SOR & Noise filters --- include/CloudSamplingTools.h | 8 ++++++-- src/CloudSamplingTools.cpp | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/CloudSamplingTools.h b/include/CloudSamplingTools.h index dd48d4e..e286956 100644 --- a/include/CloudSamplingTools.h +++ b/include/CloudSamplingTools.h @@ -151,13 +151,15 @@ namespace CCCoreLib \param nSigma number of sigmas under which the points should be kept \param octree associated octree if available \param progressCb the client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback) + \param maxThreadCount maximum number of threads to use (0 = max available) \return a reference cloud corresponding to the filtered cloud **/ static ReferenceCloud* sorFilter( GenericIndexedCloudPersist* cloud, int knn = 6, double nSigma = 1.0, DgmOctree* octree = nullptr, - GenericProgressCallback* progressCb = nullptr); + GenericProgressCallback* progressCb = nullptr, + int maxThreadCount = 0); //! Noise filter based on the distance to the approximate local surface /** This filter removes points based on their distance relatively to the best fit plane computed on their neighbors. @@ -171,6 +173,7 @@ namespace CCCoreLib \param absoluteError absolute error (if useAbsoluteError is true) \param octree associated octree if available \param progressCb the client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback) + \param maxThreadCount maximum number of threads to use (0 = max available) \return a reference cloud corresponding to the filtered cloud **/ static ReferenceCloud* noiseFilter( GenericIndexedCloudPersist* cloud, @@ -182,7 +185,8 @@ namespace CCCoreLib bool useAbsoluteError = true, double absoluteError = 0.0, DgmOctree* octree = nullptr, - GenericProgressCallback* progressCb = nullptr); + GenericProgressCallback* progressCb = nullptr, + int maxThreadCount = 0); protected: diff --git a/src/CloudSamplingTools.cpp b/src/CloudSamplingTools.cpp index 4d0518d..797a9b5 100644 --- a/src/CloudSamplingTools.cpp +++ b/src/CloudSamplingTools.cpp @@ -461,7 +461,8 @@ ReferenceCloud* CloudSamplingTools::sorFilter( GenericIndexedCloudPersist* input int knn/*=6*/, double nSigma/*=1.0*/, DgmOctree* inputOctree/*=nullptr*/, - GenericProgressCallback* progressCb/*=nullptr*/) + GenericProgressCallback* progressCb/*=nullptr*/, + int maxThreadCount/*=0*/) { if (!inputCloud || knn <= 0 || inputCloud->size() <= static_cast(knn)) { @@ -517,7 +518,8 @@ ReferenceCloud* CloudSamplingTools::sorFilter( GenericIndexedCloudPersist* input additionalParameters, true, progressCb, - "SOR filter") == 0) + "SOR filter", + maxThreadCount ) == 0) { //something went wrong break; @@ -579,7 +581,8 @@ ReferenceCloud* CloudSamplingTools::noiseFilter(GenericIndexedCloudPersist* inpu bool useAbsoluteError/*=true*/, double absoluteError/*=0.0*/, DgmOctree* inputOctree/*=nullptr*/, - GenericProgressCallback* progressCb/*=nullptr*/) + GenericProgressCallback* progressCb/*=nullptr*/, + int maxThreadCount/*=0*/) { if (!inputCloud || inputCloud->size() < 2 || (useKnn && knn <= 0) || (!useKnn && kernelRadius <= 0)) { @@ -612,7 +615,7 @@ ReferenceCloud* CloudSamplingTools::noiseFilter(GenericIndexedCloudPersist* inpu } //additional parameters - void* additionalParameters[] = {reinterpret_cast(filteredCloud), + void* additionalParameters[] { reinterpret_cast(filteredCloud), reinterpret_cast(&kernelRadius), reinterpret_cast(&nSigma), reinterpret_cast(&removeIsolatedPoints), @@ -633,7 +636,8 @@ ReferenceCloud* CloudSamplingTools::noiseFilter(GenericIndexedCloudPersist* inpu additionalParameters, true, progressCb, - "Noise filter" ) == 0) + "Noise filter", + maxThreadCount ) == 0) { //something went wrong delete filteredCloud;