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,
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
masc::NeighborhoodFeature::PLANA
@ PLANA
Definition: NeighborhoodFeature.h:43
masc::Feature::Shared
QSharedPointer< Feature > Shared
Shared type.
Definition: FeaturesInterface.h:49
masc::NeighborhoodFeature::FOM
@ FOM
Definition: NeighborhoodFeature.h:53
cloudViewer::Neighbourhood::Linearity
@ Linearity
Definition: Neighbourhood.h:167
masc::NeighborhoodFeature::SPHER
@ SPHER
Definition: NeighborhoodFeature.h:41
SFCollector::scalarFields
Map scalarFields
Definition: ScalarFieldCollector.h:61
Neighbourhood.h
masc::NeighborhoodFeature::computeValue
bool computeValue(cloudViewer::DgmOctree::NeighboursSet &pointsInNeighbourhood, const CCVector3 &queryPoint, double &outputValue) const
Compute the feature value on a set of points.
Definition: NeighborhoodFeature.cpp:196
masc
3DMASC classifier
Definition: ContextBasedFeature.h:30
masc::Feature::cloud2Label
QString cloud2Label
Definition: FeaturesInterface.h:233
DgmOctreeReferenceCloud.h
FeaturesInterface.h
cloudViewer::ScalarField::computeMinAndMax
virtual void computeMinAndMax()
Determines the min and max values.
Definition: ScalarField.h:123
masc::NeighborhoodFeature::getType
virtual Type getType() const override
Returns the type (must be reimplemented by child struct)
Definition: NeighborhoodFeature.h:160
masc::NeighborhoodFeature::toString
virtual QString toString() const override
Returns the formatted description.
Definition: NeighborhoodFeature.cpp:179
masc::NeighborhoodFeature::clone
virtual Feature::Shared clone() const override
Clones this feature.
Definition: NeighborhoodFeature.h:161
masc::Feature::source
Source source
Definition: FeaturesInterface.h:235
cloudViewer::Neighbourhood::SurfaceVariation
@ SurfaceVariation
Definition: Neighbourhood.h:170
masc::NeighborhoodFeature::PCA3
@ PCA3
Definition: NeighborhoodFeature.h:40
masc::NeighborhoodFeature::Zmax
@ Zmax
Definition: NeighborhoodFeature.h:50
SFCollector::ALWAYS_REMOVE
@ ALWAYS_REMOVE
Definition: ScalarFieldCollector.h:44
masc::NeighborhoodFeature::DipDir
@ DipDir
Definition: NeighborhoodFeature.h:45
cloudViewer::Neighbourhood::computeRoughness
ScalarType computeRoughness(const CCVector3 &P, const CCVector3 *roughnessUpDir=nullptr)
Definition: Neighbourhood.cpp:886
cloudViewer::ScalarField
A simple scalar field (to be associated to a point cloud)
Definition: ScalarField.h:25
masc::NeighborhoodFeature::ROUGH
@ ROUGH
Definition: NeighborhoodFeature.h:46
ccNormalVectors::ConvertNormalToDipAndDipDir
static void ConvertNormalToDipAndDipDir(const CCVector3 &N, PointCoordinateType &dip_deg, PointCoordinateType &dipDir_deg)
Converts a normal vector to geological 'dip direction & dip' parameters.
Definition: ecvNormalVectors.cpp:848
masc::NeighborhoodFeature::ANISO
@ ANISO
Definition: NeighborhoodFeature.h:52
cloudViewer::GenericProgressCallback
Definition: GenericProgressCallback.h:20
masc::NeighborhoodFeature::NeighborhoodFeatureType
NeighborhoodFeatureType
Definition: NeighborhoodFeature.h:36
cloudViewer::Neighbourhood::PCA1
@ PCA1
Definition: Neighbourhood.h:168
SFCollector::CAN_REMOVE
@ CAN_REMOVE
Definition: ScalarFieldCollector.h:44
masc::CorePoints
Core points descriptor.
Definition: CorePoints.h:39
cloudViewer::Neighbourhood::Verticality
@ Verticality
Definition: Neighbourhood.h:172
NeighborhoodFeature.h
cloudViewer::Neighbourhood::computeMomentOrder1
ScalarType computeMomentOrder1(const CCVector3 &P)
Definition: Neighbourhood.cpp:760
masc::NeighborhoodFeature::Dip
@ Dip
Definition: NeighborhoodFeature.h:44
masc::NeighborhoodFeature::FromUpperString
static NeighborhoodFeatureType FromUpperString(const QString &token)
Definition: NeighborhoodFeature.h:111
masc::NeighborhoodFeature::CURV
@ CURV
Definition: NeighborhoodFeature.h:48
Vector3Tpl< PointCoordinateType >
masc::Feature::PrepareSF
static cloudViewer::ScalarField * PrepareSF(ccPointCloud *cloud, const char *resultSFName, SFCollector *generatedScalarFields, SFCollector::Behavior behavior)
Definition: FeaturesInterface.cpp:29
cloudViewer::ScalarField::getName
const char * getName() const
Returns scalar field name.
Definition: ScalarField.h:43
masc::NeighborhoodFeature::ToString
static QString ToString(NeighborhoodFeatureType type)
Definition: NeighborhoodFeature.h:59
masc::NeighborhoodFeature::PCA1
@ PCA1
Definition: NeighborhoodFeature.h:38
cloudViewer::Neighbourhood::computeCurvature
ScalarType computeCurvature(const CCVector3 &P, CurvatureType cType)
Computes the curvature of a set of point (by fitting a 2.5D quadric)
Definition: Neighbourhood.cpp:906
masc::NeighborhoodFeature::Invalid
@ Invalid
Definition: NeighborhoodFeature.h:37
masc::NeighborhoodFeature::checkValidity
virtual bool checkValidity(QString corePointRole, QString &error) const override
Checks the feature definition validity.
Definition: NeighborhoodFeature.cpp:17
masc::NeighborhoodFeature
Neighborhood-based feature.
Definition: NeighborhoodFeature.h:32
masc::Feature::scale
double scale
Scale (diameter)
Definition: FeaturesInterface.h:230
masc::Feature::sf2WasAlreadyExisting
bool sf2WasAlreadyExisting
Definition: FeaturesInterface.h:241
masc::Feature::Source::name
QString name
Definition: FeaturesInterface.h:124
masc::NeighborhoodFeature::Shared
QSharedPointer< NeighborhoodFeature > Shared
Definition: NeighborhoodFeature.h:34
masc::NeighborhoodFeature::PCA2
@ PCA2
Definition: NeighborhoodFeature.h:39
cloudViewer::Neighbourhood
Definition: Neighbourhood.h:25
masc::NeighborhoodFeature::Zmin
@ Zmin
Definition: NeighborhoodFeature.h:51
masc::NeighborhoodFeature::type
NeighborhoodFeatureType type
Neighborhood feature type.
Definition: NeighborhoodFeature.h:184
masc::Feature::stat
Stat stat
Definition: FeaturesInterface.h:237
masc::Feature
Generic feature descriptor.
Definition: FeaturesInterface.h:46
masc::Feature::CheckSFExistence
static bool CheckSFExistence(ccPointCloud *cloud, const char *resultSFName)
Definition: FeaturesInterface.cpp:19
cloudViewer::Neighbourhood::computeFeature
double computeFeature(GeomFeature feature)
Computes the given feature on a set of point.
Definition: Neighbourhood.cpp:796
masc::Feature::Type
Type
Feature type.
Definition: FeaturesInterface.h:56
SFCollector::ALWAYS_KEEP
@ ALWAYS_KEEP
Definition: ScalarFieldCollector.h:44
Tuple3Tpl::z
Type z
Definition: CVGeom.h:137
masc::NeighborhoodFeature::FromString
static NeighborhoodFeatureType FromString(const QString &token)
Definition: NeighborhoodFeature.h:108
masc::Feature::OpToString
static QString OpToString(Operation op)
Definition: FeaturesInterface.h:97
cloudViewer::Neighbourhood::getLSPlaneNormal
const CCVector3 * getLSPlaneNormal()
Returns best interpolating plane (Least-square) normal vector.
Definition: Neighbourhood.cpp:102
masc::Feature::cloud1
ccPointCloud * cloud1
Definition: FeaturesInterface.h:232
cloudViewer::DgmOctreeReferenceCloud
A kind of ReferenceCloud based on the DgmOctree::NeighboursSet structure.
Definition: DgmOctreeReferenceCloud.h:17
masc::NeighborhoodFeature::NBPTS
@ NBPTS
Definition: NeighborhoodFeature.h:47
PC_ONE
constexpr PointCoordinateType PC_ONE
'1' as a PointCoordinateType value
Definition: CVConst.h:67
masc::Feature::PerformMathOp
static ScalarType PerformMathOp(double s1, double s2, Operation op)
Performs a mathematical operation between two scalars.
Definition: FeaturesInterface.cpp:72
masc::NeighborhoodFeature::sf2
cloudViewer::ScalarField * sf2
Definition: NeighborhoodFeature.h:187
masc::Feature::NO_OPERATION
@ NO_OPERATION
Definition: FeaturesInterface.h:95
cloudViewer::DgmOctree::NeighboursSet
std::vector< PointDescriptor > NeighboursSet
A set of neighbours.
Definition: DgmOctree.h:133
Jacobi.h
masc::NeighborhoodFeature::finish
virtual bool finish(const CorePoints &corePoints, QString &error) override
Finishes the feature preparation (update the scalar field, etc.)
Definition: NeighborhoodFeature.cpp:122
cloudViewer::Neighbourhood::GeomFeature
GeomFeature
Geometric feature computed from eigen values/vectors.
Definition: Neighbourhood.h:161
masc::Feature::Type::NeighborhoodFeature
@ NeighborhoodFeature
CVLog::Warning
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
SFCollector
SF collector.
Definition: ScalarFieldCollector.h:42
masc::NeighborhoodFeature::ZRANGE
@ ZRANGE
Definition: NeighborhoodFeature.h:49
masc::Feature::cloud1Label
QString cloud1Label
Definition: FeaturesInterface.h:233
cloudViewer::Neighbourhood::getGravityCenter
const CCVector3 * getGravityCenter()
Returns gravity center.
Definition: Neighbourhood.cpp:58
masc::Feature::NO_STAT
@ NO_STAT
Definition: FeaturesInterface.h:66
SFCollector::setBehavior
bool setBehavior(cloudViewer::ScalarField *sf, Behavior behavior)
Definition: ScalarFieldCollector.cpp:64
masc::NeighborhoodFeature::NeighborhoodFeature
NeighborhoodFeature(NeighborhoodFeatureType p_type)
Default constructor.
Definition: NeighborhoodFeature.h:156
PointCoordinateType
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
masc::Feature::op
Operation op
Definition: FeaturesInterface.h:238
masc::Feature::checkValidity
virtual bool checkValidity(QString corePointRole, QString &error) const
Checks the feature definition validity.
Definition: FeaturesInterface.h:179
cloudViewer::Neighbourhood::Sphericity
@ Sphericity
Definition: Neighbourhood.h:171
masc::Feature::sf1WasAlreadyExisting
bool sf1WasAlreadyExisting
Definition: FeaturesInterface.h:240
masc::NeighborhoodFeature::LINEA
@ LINEA
Definition: NeighborhoodFeature.h:42
cloudViewer::Neighbourhood::PCA2
@ PCA2
Definition: Neighbourhood.h:169
masc::Feature::cloud2
ccPointCloud * cloud2
Definition: FeaturesInterface.h:232
corePoints
cloudViewer::GenericIndexedCloud * corePoints
Definition: qCanupoTools.cpp:35
cloudViewer::Neighbourhood::Planarity
@ Planarity
Definition: Neighbourhood.h:166
masc::NeighborhoodFeature::prepare
virtual bool prepare(const CorePoints &corePoints, QString &error, cloudViewer::GenericProgressCallback *progressCb=nullptr, SFCollector *generatedScalarFields=nullptr) override
Prepares the feature (compute the scalar field, etc.)
Definition: NeighborhoodFeature.cpp:49
masc::NeighborhoodFeature::VERT
@ VERT
Definition: NeighborhoodFeature.h:54
masc::NeighborhoodFeature::sf1
cloudViewer::ScalarField * sf1
Feature values.
Definition: NeighborhoodFeature.h:187