ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ScalarFieldTools.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "CVToolbox.h"
12 #include "DgmOctree.h"
13 
14 namespace cloudViewer {
15 
16 class GenericCloud;
17 class GenericIndexedCloud;
18 class GenericIndexedCloudPersist;
19 class GenericProgressCallback;
20 
22 struct KMeanClass {
24  ScalarType mean;
26  ScalarType minValue;
28  ScalarType maxValue;
29 };
30 
32 
36 public:
38 
43  static ScalarType computeMeanScalarValue(GenericCloud* theCloud);
44 
46 
51  static ScalarType computeMeanSquareScalarValue(GenericCloud* theCloud);
52 
55 
68  static int computeScalarFieldGradient(
70  PointCoordinateType radius,
71  bool euclideanDistances,
72  bool sameInAndOutScalarField = false,
73  GenericProgressCallback* progressCb = nullptr,
74  DgmOctree* theOctree = nullptr);
75 
78 
96  static bool applyScalarFieldGaussianFilter(
97  PointCoordinateType sigma,
99  PointCoordinateType sigmaSF,
100  GenericProgressCallback* progressCb = nullptr,
101  DgmOctree* theOctree = nullptr);
102 
104 
111  static void multiplyScalarFields(
112  GenericIndexedCloud* firstCloud,
113  GenericIndexedCloud* secondCloud,
114  GenericProgressCallback* progressCb = nullptr);
115 
117 
124  static void computeScalarFieldHistogram(const GenericCloud* theCloud,
125  unsigned numberOfClasses,
126  std::vector<int>& histo);
127 
129 
133  static void computeScalarFieldExtremas(const GenericCloud* theCloud,
134  ScalarType& minV,
135  ScalarType& maxV);
136 
138 
140  static unsigned countScalarFieldValidValues(const GenericCloud* theCloud);
141 
144 
154  static bool computeKmeans(const GenericCloud* theCloud,
155  unsigned char K,
156  KMeanClass kmcc[],
157  GenericProgressCallback* progressCb = nullptr);
158 
160 
163  static void SetScalarValueToNaN(const CCVector3& P,
164  ScalarType& scalarValue);
165 
167 
170  static void SetScalarValueToZero(const CCVector3& P,
171  ScalarType& scalarValue);
172 
173  static void SetScalarValueInverted(const CCVector3& P,
174  ScalarType& scalarValue);
175 
176 protected:
179 
191  static bool computeMeanGradientOnPatch(
192  const DgmOctree::octreeCell& cell,
193  void** additionalParameters,
194  NormalizedProgress* nProgress = nullptr);
195 
198 
211  static bool computeCellGaussianFilter(
212  const DgmOctree::octreeCell& cell,
213  void** additionalParameters,
214  NormalizedProgress* nProgress = nullptr);
215 };
216 
217 } // namespace cloudViewer
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
Empty class - for classification purpose only.
Definition: CVToolbox.h:15
The octree structure used throughout the library.
Definition: DgmOctree.h:39
A generic 3D point cloud with index-based and presistent access to points.
A generic 3D point cloud with index-based point access.
Several scalar field treatment algorithms (gradient, classification, etc.)
Generic file read and write utility for python interface.
cloudViewer::NormalizedProgress * nProgress
Octree cell descriptor.
Definition: DgmOctree.h:354
A K-mean class position and boundaries.
ScalarType mean
K-mean class mean value.
ScalarType minValue
K-mean class minimum value.
ScalarType maxValue
K-mean class maximum value.