ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
NeighborhoodFeature.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 // ##########################################################################
11 // # #
12 // # ACLOUDVIEWER PLUGIN: q3DMASC #
13 // # #
14 // # This program is free software; you can redistribute it and/or modify #
15 // # it under the terms of the GNU General Public License as published by #
16 // # the Free Software Foundation; version 2 or later of the License. #
17 // # #
18 // # This program is distributed in the hope that it will be useful, #
19 // # but WITHOUT ANY WARRANTY; without even the implied warranty of #
20 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
21 // # GNU General Public License for more details. #
22 // # #
23 // # COPYRIGHT: Dimitri Lague / CNRS / UEB #
24 // # #
25 // ##########################################################################
26 
27 // Local
28 #include "FeaturesInterface.h"
29 
30 namespace masc {
32 struct NeighborhoodFeature : public Feature {
33 public: // NeighborhoodFeatureType
34  typedef QSharedPointer<NeighborhoodFeature> Shared;
35 
37  Invalid = 0,
44  Dip,
53  FOM,
54  VERT
55  //, LINEF
56  //, ORIENF
57  };
58 
60  switch (type) {
61  case Invalid:
62  return "Invalid";
63  case PCA1:
64  return "PCA1";
65  case PCA2:
66  return "PCA2";
67  case PCA3:
68  return "PCA3";
69  case SPHER:
70  return "SPHER";
71  case LINEA:
72  return "LINEA";
73  case PLANA:
74  return "PLANA";
75  case Dip:
76  return "Dip";
77  case DipDir:
78  return "DipDir";
79  case ROUGH:
80  return "ROUGH";
81  case NBPTS:
82  return "NBPTS";
83  case CURV:
84  return "CURV";
85  case ZRANGE:
86  return "ZRANGE";
87  case Zmax:
88  return "Zmax";
89  case Zmin:
90  return "Zmin";
91  case ANISO:
92  return "ANISO";
93  case FOM:
94  return "FOM";
95  case VERT:
96  return "VERT";
97  // case LINEF:
98  // return "LINEF";
99  // case ORIENF:
100  // return "ORIENF";
101  default:
102  assert(false);
103  break;
104  }
105  return "Invalid";
106  }
107 
108  static inline NeighborhoodFeatureType FromString(const QString& token) {
109  return FromUpperString(token.toUpper());
110  }
111  static NeighborhoodFeatureType FromUpperString(const QString& token) {
112  if (token == "PCA1")
113  return PCA1;
114  else if (token == "PCA2")
115  return PCA2;
116  else if (token == "PCA3")
117  return PCA3;
118  else if (token == "SPHER")
119  return SPHER;
120  else if (token == "LINEA")
121  return LINEA;
122  else if (token == "PLANA")
123  return PLANA;
124  else if (token == "DIP")
125  return Dip;
126  else if (token == "DIPDIR")
127  return DipDir;
128  else if (token == "ROUGH")
129  return ROUGH;
130  else if (token == "NBPTS")
131  return NBPTS;
132  else if (token == "CURV")
133  return CURV;
134  else if (token == "ZRANGE")
135  return ZRANGE;
136  else if (token == "ZMAX")
137  return Zmax;
138  else if (token == "ZMIN")
139  return Zmin;
140  else if (token == "ANISO")
141  return ANISO;
142  else if (token == "FOM")
143  return FOM;
144  else if (token == "VERT")
145  return VERT;
146  // else if (token == "LINEF")
147  // return LINEF;
148  // else if (token == "ORIENF")
149  // return ORIENF;
150 
151  return Invalid;
152  }
153 
154 public: // methods
157  : type(p_type), sf1(nullptr), sf2(nullptr) {}
158 
159  // inherited from Feature
160  virtual Type getType() const override { return Type::NeighborhoodFeature; }
161  virtual Feature::Shared clone() const override {
162  return Feature::Shared(new NeighborhoodFeature(*this));
163  }
164  virtual bool prepare(
165  const CorePoints& corePoints,
166  QString& error,
167  cloudViewer::GenericProgressCallback* progressCb = nullptr,
168  SFCollector* generatedScalarFields = nullptr) override;
169  virtual bool finish(const CorePoints& corePoints, QString& error) override;
170  virtual bool checkValidity(QString corePointRole,
171  QString& error) const override;
172  virtual QString toString() const override;
173 
175  bool computeValue(
176  cloudViewer::DgmOctree::NeighboursSet& pointsInNeighbourhood,
177  const CCVector3& queryPoint,
178  double& outputValue) const;
179 
180 public: // members
182 
185 
188 };
189 } // namespace masc
SF collector.
std::vector< PointDescriptor > NeighboursSet
A set of neighbours.
Definition: DgmOctree.h:133
A simple scalar field (to be associated to a point cloud)
Definition: ScalarField.h:25
static void error(char *msg)
Definition: lsd.c:159
3DMASC classifier
cloudViewer::GenericIndexedCloud * corePoints
Core points descriptor.
Definition: CorePoints.h:39
Generic feature descriptor.
QSharedPointer< Feature > Shared
Shared type.
Type
Feature type.
Neighborhood-based feature.
bool computeValue(cloudViewer::DgmOctree::NeighboursSet &pointsInNeighbourhood, const CCVector3 &queryPoint, double &outputValue) const
Compute the feature value on a set of points.
QSharedPointer< NeighborhoodFeature > Shared
cloudViewer::ScalarField * sf1
Feature values.
virtual bool prepare(const CorePoints &corePoints, QString &error, cloudViewer::GenericProgressCallback *progressCb=nullptr, SFCollector *generatedScalarFields=nullptr) override
Prepares the feature (compute the scalar field, etc.)
virtual bool checkValidity(QString corePointRole, QString &error) const override
Checks the feature definition validity.
static NeighborhoodFeatureType FromString(const QString &token)
virtual bool finish(const CorePoints &corePoints, QString &error) override
Finishes the feature preparation (update the scalar field, etc.)
virtual QString toString() const override
Returns the formatted description.
NeighborhoodFeatureType type
Neighborhood feature type.
cloudViewer::ScalarField * sf2
virtual Feature::Shared clone() const override
Clones this feature.
virtual Type getType() const override
Returns the type (must be reimplemented by child struct)
static QString ToString(NeighborhoodFeatureType type)
static NeighborhoodFeatureType FromUpperString(const QString &token)
NeighborhoodFeature(NeighborhoodFeatureType p_type)
Default constructor.