Skip to content

Commit cac3533

Browse files
authored
Update DgmOctree syntax (#100)
* Improve the syntax of ScalarFieldTools::computeCellGaussianFilter * Syntax fix * Restore the definition of DgmOctree::MultiThreadingWrapper in the header to avoid issues when linking CCCoreLib statically on Windows
1 parent a8ce427 commit cac3533

4 files changed

Lines changed: 282 additions & 301 deletions

File tree

‎include/DgmOctree.h‎

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace CCCoreLib
2424
class GenericIndexedCloudPersist;
2525
class GenericProgressCallback;
2626
class NormalizedProgress;
27-
struct MultiThreadingWrapper;
2827

2928
//! The octree structure used throughout the library
3029
/** Implements the GenericOctree interface.
@@ -349,7 +348,7 @@ namespace CCCoreLib
349348
- (NormalizedProgress*) optional (normalized) progress callback
350349
- return success
351350
**/
352-
using octreeCellFunc = bool (*)(const octreeCell &, void **, NormalizedProgress *);
351+
using octreeCellFunc = bool (*)(const octreeCell&, void**, NormalizedProgress*);
353352

354353
/******************************/
355354
/** METHODS **/
@@ -361,7 +360,7 @@ namespace CCCoreLib
361360
explicit DgmOctree(GenericIndexedCloudPersist* cloud);
362361

363362
//! DgmOctree destructor
364-
~DgmOctree() override;
363+
~DgmOctree() override = default;
365364

366365
//! Clears the octree
367366
virtual void clear();
@@ -1114,7 +1113,7 @@ namespace CCCoreLib
11141113

11151114
//! Computes statistics about cells for a given level of subdivision
11161115
/** This method requires some computation, therefore it shouldn't be
1117-
called too often.
1116+
called too often.
11181117
\param level the level of subdivision
11191118
**/
11201119
void computeCellsStatistics(unsigned char level);
@@ -1128,19 +1127,19 @@ namespace CCCoreLib
11281127
\param level the level of subdivision
11291128
**/
11301129
void getNeighborCellsAround(const Tuple3i& cellPos,
1131-
cellIndexesContainer &neighborCellsIndexes,
1132-
int neighbourhoodLength,
1133-
unsigned char level) const;
1130+
cellIndexesContainer &neighborCellsIndexes,
1131+
int neighbourhoodLength,
1132+
unsigned char level) const;
11341133

11351134
//! Gets point in the neighbourhing cells of a specific cell
11361135
/** \warning May throw a std::bad_alloc exception if memory is insufficient.
11371136
\param nNSS NN search parameters (from which are used: cellPos, pointsInNeighbourCells and level)
11381137
\param neighbourhoodLength the new distance (in terms of cells) at which to look for neighbour cells
11391138
\param getOnlyPointsWithValidScalar whether to ignore points having an invalid associated scalar value
11401139
**/
1141-
void getPointsInNeighbourCellsAround(NearestNeighboursSearchStruct &nNSS,
1142-
int neighbourhoodLength,
1143-
bool getOnlyPointsWithValidScalar = false) const;
1140+
void getPointsInNeighbourCellsAround( NearestNeighboursSearchStruct &nNSS,
1141+
int neighbourhoodLength,
1142+
bool getOnlyPointsWithValidScalar = false) const;
11441143

11451144
//! Returns the index of a given cell represented by its code
11461145
/** Same algorithm as the other "getCellIndex" method, but in an optimized form.
@@ -1215,8 +1214,39 @@ namespace CCCoreLib
12151214
//! Std. dev. of cell population per level of subdivision
12161215
double m_stdDevCellPopulation[MAX_OCTREE_LEVEL + 1];
12171216

1218-
//! Multithreading wrapper
1219-
MultiThreadingWrapper* m_MT_wrapper;
1217+
//! Octree cell description helper struct
1218+
struct octreeCellDesc
1219+
{
1220+
DgmOctree::CellCode truncatedCode;
1221+
unsigned i1, i2;
1222+
unsigned char level;
1223+
};
1224+
1225+
//! Structure containing objects needed to run octree operations in parallel
1226+
struct MultiThreadingWrapper
1227+
{
1228+
octreeCellFunc cellFunc = nullptr;
1229+
bool cellFuncSuccess = true;
1230+
DgmOctree* octree = nullptr;
1231+
GenericProgressCallback* progressCb = nullptr;
1232+
NormalizedProgress* normProgressCb = nullptr;
1233+
void** userParams = nullptr;
1234+
1235+
void reset()
1236+
{
1237+
cellFunc = nullptr;
1238+
cellFuncSuccess = true;
1239+
octree = nullptr;
1240+
normProgressCb = nullptr;
1241+
progressCb = nullptr;
1242+
userParams = nullptr;
1243+
}
1244+
1245+
void launchOctreeCellFunc(const octreeCellDesc& desc);
1246+
};
1247+
1248+
//! Multi-threading wrapper structure
1249+
MultiThreadingWrapper m_MT_wrapper;
12201250

12211251
//! Whether the octree build is in progress
12221252
std::atomic<bool> m_buildInProgress;

‎include/ScalarFieldTools.h‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,15 @@ namespace CCCoreLib
7171
DgmOctree* theOctree = nullptr);
7272

7373
//! Computes a spatial gaussian filter on a scalar field associated to a point cloud
74-
/** The "amplitutde" of the gaussian filter must be precised (sigma).
75-
As 99% of the gaussian distribution is between -3*sigma and +3*sigma
76-
around the mean value, this filter will only look for neighbouring
77-
points (around each point) in a sphere of radius 3*sigma.
78-
It also permits to use the filter as a bilateral filter. Where the wights are computed also considering the
79-
distance of the neighbor's scalar value from the current point scalar value. (weighted with gaussian as distances are)
80-
Warning: this method assumes the input scalar field is different from output.
74+
/** The "amplitutde" of the Gaussian filter must be specified (sigma).
75+
As 99% of the Gaussian distribution is between -3*sigma and +3*sigma around the mean value,
76+
this filter will only look for neighbors within a sphere of radius 3*sigma.
77+
One can also use the filter as a Bilateral filter. In this case the weights are computed considering the
78+
difference of the neighbors SF values with the current point SF value (also following a Gaussian distribution).
79+
Warning: this method assumes the input scalar field is different from the output one.
8180
\param sigma filter variance
8281
\param theCloud a point cloud (associated to scalar values)
83-
\param sigmaSF the sigma for the bilateral filter. when different than -1 turns the gaussian filter into a bilateral filter
82+
\param sigmaSF if strictly positive, the variance for the Bilateral filter
8483
\param progressCb the client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
8584
\param theOctree the octree, if it has already been computed
8685
\return success

0 commit comments

Comments
 (0)