ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvNormalVectors.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 // cloudViewer
12 
13 // Local
14 #include "ecvGenericPointCloud.h"
15 
16 // System
17 #include <vector>
18 
21 public:
24 
26 
28  static void ReleaseUniqueInstance();
29 
31  static inline unsigned GetNumberOfVectors() {
32  return static_cast<unsigned>(
33  GetUniqueInstance()->m_theNormalVectors.size());
34  }
35 
37  static inline const CCVector3& GetNormal(unsigned normIndex) {
38  return GetUniqueInstance()->getNormal(normIndex);
39  }
40  static inline CCVector3& GetNormalPtr(unsigned normIndex) {
41  return GetUniqueInstance()->getNormal(normIndex);
42  }
43  static inline const std::vector<CCVector3>& GetNormals() {
44  return GetUniqueInstance()->getNormals();
45  }
46  static inline std::vector<CCVector3>& GetNormalsPtr() {
47  return GetUniqueInstance()->getNormals();
48  }
49 
51  inline const CCVector3& getNormal(unsigned normIndex) const {
52  return m_theNormalVectors[normIndex];
53  }
54  inline CCVector3& getNormal(unsigned normIndex) {
55  return m_theNormalVectors[normIndex];
56  }
57  inline const std::vector<CCVector3>& getNormals() const {
58  return m_theNormalVectors;
59  }
60  inline std::vector<CCVector3>& getNormals() { return m_theNormalVectors; }
61 
65  static inline CompressedNormType GetNormIndex(const CCVector3& N) {
66  return GetNormIndex(N.u);
67  }
68 
70  enum Orientation {
71  PLUS_X = 0,
72  MINUS_X = 1,
73  PLUS_Y = 2,
74  MINUS_Y = 3,
75  PLUS_Z = 4,
76  MINUS_Z = 5,
77  PLUS_BARYCENTER =
78  6,
79  MINUS_BARYCENTER = 7,
80  PLUS_ORIGIN = 8,
81  MINUS_ORIGIN = 9,
82  PREVIOUS = 10,
83  PLUS_SENSOR_ORIGIN =
84  11,
86  MINUS_SENSOR_ORIGIN =
87  12,
89  UNDEFINED = 255
90  };
91 
93 
102  static bool ComputeCloudNormals(
103  ccGenericPointCloud* cloud,
104  NormsIndexesTableType& theNormsCodes,
105  CV_LOCAL_MODEL_TYPES localModel,
106  PointCoordinateType localRadius,
107  Orientation preferredOrientation = UNDEFINED,
108  cloudViewer::GenericProgressCallback* progressCb = nullptr,
109  cloudViewer::DgmOctree* inputOctree = nullptr);
110 
113 
117 
120 
127  ccGenericPointCloud* cloud,
128  cloudViewer::DgmOctree* cloudOctree = nullptr,
129  cloudViewer::GenericProgressCallback* progressCb = nullptr);
130 
132 
138  NormsIndexesTableType& theNormsCodes,
139  Orientation preferredOrientation);
140 
143 
148  PointCoordinateType& strike_deg,
149  PointCoordinateType& dip_deg);
150 
152 
160  PointCoordinateType& dip_deg,
161  PointCoordinateType& dipDir_deg);
162 
165 
171  PointCoordinateType dipDir_deg,
172  bool upward = true);
173 
176 
180  static QString ConvertStrikeAndDipToString(double& strike_deg,
181  double& dip_deg);
182 
184 
190  PointCoordinateType dipDir_deg);
191 
193 
199  static void ConvertNormalToHSV(const CCVector3& N,
200  float& H,
201  float& S,
202  float& V);
203 
205 
210 
211 public:
213  virtual ~ccNormalVectors();
214 
216 
219 
221  const ecvColor::Rgb& getNormalHSVColor(unsigned index) const;
222 
224  inline const std::vector<ecvColor::Rgb>& getNormalHSVColorArray() const {
225  return m_theNormalHSVColors;
226  }
227 
229  static bool ComputeNormalWithLS(
230  cloudViewer::GenericIndexedCloudPersist* pointAndNeighbors,
231  CCVector3& N);
232 
234 
237  static bool ComputeNormalWithTri(
238  cloudViewer::GenericIndexedCloudPersist* pointAndNeighbors,
239  CCVector3& N);
240 
242 
247  const CCVector3& P,
248  CCVector3& N);
249 
250 protected:
252 
255 
257  bool init();
258 
260  std::vector<CCVector3> m_theNormalVectors;
261 
263 
266  std::vector<ecvColor::Rgb> m_theNormalHSVColors;
267 
271  void** additionalParameters,
276  void** additionalParameters,
281  void** additionalParameters,
283 };
CV_LOCAL_MODEL_TYPES
Definition: CVConst.h:121
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
#define CV_DB_LIB_API
Definition: CV_db.h:15
int points
Array of compressed 3D normals (single index)
Type u[3]
Definition: CVGeom.h:139
A 3D cloud interface with associated features (color, normals, octree, etc.)
Compressed normal vectors handler.
static PointCoordinateType GuessBestRadius(ccGenericPointCloud *cloud, cloudViewer::DgmOctree *cloudOctree=nullptr, cloudViewer::GenericProgressCallback *progressCb=nullptr)
static CCVector3 ConvertDipAndDipDirToNormal(PointCoordinateType dip_deg, PointCoordinateType dipDir_deg, bool upward=true)
bool init()
Inits internal structures.
static bool UpdateNormalOrientations(ccGenericPointCloud *theCloud, NormsIndexesTableType &theNormsCodes, Orientation preferredOrientation)
Updates normals orientation based on a preferred orientation.
static bool ComputeNormsAtLevelWithLS(const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=nullptr)
Cellular method for octree-based normal computation.
static bool ComputeNormalWithTri(cloudViewer::GenericIndexedCloudPersist *pointAndNeighbors, CCVector3 &N)
Helper: computes the normal (with Delaunay 2.5D)
const std::vector< CCVector3 > & getNormals() const
static QString ConvertDipAndDipDirToString(PointCoordinateType dip_deg, PointCoordinateType dipDir_deg)
Converts geological 'dip direction & dip' parameters to a string.
const std::vector< ecvColor::Rgb > & getNormalHSVColorArray() const
Returns the HSV color array.
static CompressedNormType GetNormIndex(const CCVector3 &N)
Returns the compressed index corresponding to a normal vector (shortcut)
const ecvColor::Rgb & getNormalHSVColor(unsigned index) const
Returns the HSV color equivalent to a given compressed normal index.
const CCVector3 & getNormal(unsigned normIndex) const
Returns the precomputed normal corresponding to a given compressed index.
static ecvColor::Rgb ConvertNormalToRGB(const CCVector3 &N)
Converts a normal vector to RGB color space.
std::vector< CCVector3 > m_theNormalVectors
Compressed normal vectors.
static bool ComputeNormsAtLevelWithTri(const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=nullptr)
Cellular method for octree-based normal computation.
static void ConvertNormalToStrikeAndDip(const CCVector3 &N, PointCoordinateType &strike_deg, PointCoordinateType &dip_deg)
ccNormalVectors()
Default constructor.
std::vector< CCVector3 > & getNormals()
static void ConvertNormalToDipAndDipDir(const CCVector3 &N, PointCoordinateType &dip_deg, PointCoordinateType &dipDir_deg)
Converts a normal vector to geological 'dip direction & dip' parameters.
static void ConvertNormalToHSV(const CCVector3 &N, float &H, float &S, float &V)
Converts a normal vector to HSV color space.
std::vector< ecvColor::Rgb > m_theNormalHSVColors
'HSV' colors corresponding to each compressed normal index
static std::vector< CCVector3 > & GetNormalsPtr()
static bool ComputeNormalWithLS(cloudViewer::GenericIndexedCloudPersist *pointAndNeighbors, CCVector3 &N)
Helper: computes the normal (with best LS fit)
static ccNormalVectors * GetUniqueInstance()
Returns unique instance.
static QString ConvertStrikeAndDipToString(double &strike_deg, double &dip_deg)
static const CCVector3 & GetNormal(unsigned normIndex)
Static access to ccNormalVectors::getNormal.
static PointCoordinateType GuessNaiveRadius(ccGenericPointCloud *cloud)
static unsigned GetNumberOfVectors()
Returns the number of compressed normal vectors.
Orientation
'Default' orientations
static bool ComputeNormalWithQuadric(cloudViewer::GenericIndexedCloudPersist *points, const CCVector3 &P, CCVector3 &N)
Helper: computes the normal (with Delaunay 2.5D)
static const std::vector< CCVector3 > & GetNormals()
static CCVector3 & GetNormalPtr(unsigned normIndex)
CCVector3 & getNormal(unsigned normIndex)
static CompressedNormType GetNormIndex(const PointCoordinateType N[])
Returns the compressed index corresponding to a normal vector.
virtual ~ccNormalVectors()
Default destructor.
static bool ComputeCloudNormals(ccGenericPointCloud *cloud, NormsIndexesTableType &theNormsCodes, CV_LOCAL_MODEL_TYPES localModel, PointCoordinateType localRadius, Orientation preferredOrientation=UNDEFINED, cloudViewer::GenericProgressCallback *progressCb=nullptr, cloudViewer::DgmOctree *inputOctree=nullptr)
Computes normal at each point of a given cloud.
static bool ComputeNormsAtLevelWithQuadric(const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=nullptr)
Cellular method for octree-based normal computation.
bool enableNormalHSVColorsArray()
Allocates normal HSV colors array.
static void ReleaseUniqueInstance()
Releases unique instance.
The octree structure used throughout the library.
Definition: DgmOctree.h:39
A generic 3D point cloud with index-based and presistent access to points.
RGB color structure.
Definition: ecvColorTypes.h:49
unsigned int CompressedNormType
Compressed normals type.
Definition: ecvBasicTypes.h:16
cloudViewer::NormalizedProgress * nProgress
Octree cell descriptor.
Definition: DgmOctree.h:354