ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccPointDescriptor.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 // Qt
11 #include <QByteArray>
12 #include <QString>
13 
14 // cloudViewer
15 #include <ReferenceCloud.h>
16 
17 // system
18 #include <math.h>
19 
20 #include <vector>
21 
22 // Descriptors' ID must be declared here and then implemented in
23 // 'ccPointDescriptor.cpp'.
24 //
25 // WARNING: the ID must be unique and must not be changed once set!
26 //
27 // Once declared (and implemented) in ccPointDescriptor.cpp, the descriptor must
28 // be added to the static 'vault' (see ScaleParamsComputerVault's constructor).
29 
30 static const unsigned DESC_INVALID = 0; // Unknown descritpr
31 static const unsigned DESC_DIMENSIONALITY =
32  1; // Original CANUPO's "Dimensionality" descriptor
33 static const unsigned DESC_DIMENSIONALITY_SF =
34  2; // "Dimensionality" + scalar field descriptor
35 static const unsigned DESC_CURVATURE =
36  3; // Test: Gaussian curvature descriptor
37 // static const unsigned DESC_CUSTOM = ?;
38 // // Example of custom descriptor (to be reimplemented)
39 
41 
44 public:
46  static ScaleParamsComputer* GetByID(unsigned descID);
47 
48 public:
50  static unsigned AvailableCount();
51 
53  static ScaleParamsComputer* GetByIndex(unsigned index);
54 
55 public:
56  virtual ~ScaleParamsComputer() = default;
57 
59  virtual unsigned getID() const = 0;
60 
62  virtual QString getName() const = 0;
63 
65  virtual unsigned dimPerScale() const = 0;
66 
68  virtual bool needSF() const { return false; }
69 
71  virtual void reset() = 0;
72 
74 
83  double radius,
84  float params[],
85  bool& invalidScale) = 0;
86 
87 protected:
88 };
89 
91 
93 struct CorePointDesc {
96  std::vector<float> params;
97 };
98 
99 class ccPointCloud;
100 
102 class CorePointDescSet : public std::vector<CorePointDesc> {
103 public:
105  CorePointDescSet(size_t sz)
106  : std::vector<CorePointDesc>(sz), m_descriptorID(0), m_dimPerScale(0) {}
107  CorePointDescSet(size_t sz, const CorePointDesc& defaultVal)
108  : std::vector<CorePointDesc>(sz, defaultVal),
109  m_descriptorID(0),
110  m_dimPerScale(0) {}
112  : std::vector<CorePointDesc>(descSet),
114  m_dimPerScale(descSet.m_dimPerScale) {}
115 
117  QByteArray toByteArray() const;
119  bool fromByteArray(const QByteArray& data);
120 
122  bool loadFromMSC(QString filename,
123  QString& error,
124  ccPointCloud* corePoints = 0);
125 
127  inline const std::vector<float>& scales() const { return m_scales; }
128 
130 
134  bool setScales(const std::vector<float>& scales);
135 
137  inline const unsigned descriptorID() const { return m_descriptorID; }
139  inline void setDescriptorID(unsigned ID) { m_descriptorID = ID; }
140 
142  inline const unsigned dimPerScale() const { return m_dimPerScale; }
144  inline void setDimPerScale(unsigned dim) { m_dimPerScale = dim; }
145 
146 protected:
148  std::vector<float> m_scales;
149 
151  unsigned m_descriptorID;
152 
154  unsigned m_dimPerScale;
155 };
std::string filename
cmdLineReadable * params[]
static const unsigned DESC_DIMENSIONALITY
static const unsigned DESC_CURVATURE
static const unsigned DESC_INVALID
static const unsigned DESC_DIMENSIONALITY_SF
Set of (core) point descriptors.
const std::vector< float > & scales() const
Returns associated scales.
CorePointDescSet(const CorePointDescSet &descSet)
const unsigned descriptorID() const
Returns associated descriptor ID.
std::vector< float > m_scales
Associated scales.
CorePointDescSet(size_t sz, const CorePointDesc &defaultVal)
CorePointDescSet(size_t sz)
unsigned m_descriptorID
Associated descriptor ID.
bool setScales(const std::vector< float > &scales)
Sets associated scales.
const unsigned dimPerScale() const
Returns the number of dimensions per scale.
void setDescriptorID(unsigned ID)
Sets associated descriptor ID.
QByteArray toByteArray() const
Converts structure to a byte array.
void setDimPerScale(unsigned dim)
Sets associated descriptor ID.
bool fromByteArray(const QByteArray &data)
Inits structure from a byte array.
bool loadFromMSC(QString filename, QString &error, ccPointCloud *corePoints=0)
Loads structure of descriptors from an ".msc" file (see Brodu's version)
unsigned m_dimPerScale
Dimensions per scale.
Generic parameters 'computer' class (at a given scale)
static ScaleParamsComputer * GetByID(unsigned descID)
Vault: returns the computer corresponding to the given ID.
virtual unsigned dimPerScale() const =0
Returns the number of dimensions per scale for this descriptor.
static unsigned AvailableCount()
Returns the number of available 'descriptors'.
static ScaleParamsComputer * GetByIndex(unsigned index)
Vault: returns the ith computer.
virtual unsigned getID() const =0
Returns the associated descriptor ID.
virtual ~ScaleParamsComputer()=default
virtual bool computeScaleParams(cloudViewer::ReferenceCloud &neighbors, double radius, float params[], bool &invalidScale)=0
Computes the parameters at a given scale.
virtual QString getName() const =0
Returns the associated descriptor name.
virtual void reset()=0
Called once before computing parameters at first scale.
virtual bool needSF() const
Returns whether the computer requires a scalar field or not.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
A very simple point cloud (no point duplication)
static void error(char *msg)
Definition: lsd.c:159
Definition: Eigen.h:85
cloudViewer::GenericIndexedCloud * corePoints
Set of descriptors.
std::vector< float > params