ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvGeomFeaturesDlg.cpp
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 #include "ecvGeomFeaturesDlg.h"
9 
10 // Qt
11 #include <QDialogButtonBox>
12 #include <QPushButton>
13 
14 ccGeomFeaturesDlg::ccGeomFeaturesDlg(QWidget* parent /*=nullptr*/)
15  : QDialog(parent, Qt::Tool), Ui::GeomFeaturesDialog() {
16  setupUi(this);
17 
18  connect(buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked,
20 
21  try {
22  m_options.push_back(
23  Option(roughnessCheckBox,
25  m_options.push_back(
26  Option(firstOrderMomentCheckBox,
28  m_options.push_back(
29  Option(curvMeanCheckBox,
32  m_options.push_back(
33  Option(curvGaussCheckBox,
36  m_options.push_back(
37  Option(curvNCRCheckBox,
40  m_options.push_back(
41  Option(densityKnnCheckBox,
44  m_options.push_back(
45  Option(densitySurfCheckBox,
48  m_options.push_back(
49  Option(densityVolCheckBox,
52  m_options.push_back(Option(
55  m_options.push_back(
56  Option(eigOmnivarianceCheckBox,
59  m_options.push_back(
60  Option(eigenentropyCheckBox,
63  m_options.push_back(
64  Option(eigAnisotropyCheckBox,
67  m_options.push_back(Option(
70  m_options.push_back(
71  Option(eigLinearityCheckBox,
74  m_options.push_back(Option(
77  m_options.push_back(Option(
80  m_options.push_back(
81  Option(eigSurfaceVarCheckBox,
84  m_options.push_back(
85  Option(eigSphericityCheckBox,
88  m_options.push_back(
89  Option(eigVerticalityCheckBox,
92  m_options.push_back(
93  Option(eigenvalue1CheckBox,
96  m_options.push_back(
97  Option(eigenvalue2CheckBox,
100  m_options.push_back(
101  Option(eigenvalue3CheckBox,
104  } catch (...) {
105  }
106  m_options.shrink_to_fit();
107 }
108 
110  upDirXDoubleSpinBox->setValue(upDir.x);
111  upDirYDoubleSpinBox->setValue(upDir.y);
112  upDirZDoubleSpinBox->setValue(upDir.z);
113  upDirGroupBox->setChecked(true);
114 }
115 
117  if (roughnessCheckBox->isChecked() && upDirGroupBox->isChecked()) {
118  static CCVector3 UpDirection(0, 0, 1);
119  UpDirection.x =
120  static_cast<PointCoordinateType>(upDirXDoubleSpinBox->value());
121  UpDirection.y =
122  static_cast<PointCoordinateType>(upDirYDoubleSpinBox->value());
123  UpDirection.z =
124  static_cast<PointCoordinateType>(upDirZDoubleSpinBox->value());
125  return &UpDirection;
126  } else {
127  return nullptr;
128  }
129 }
130 
132  const ccLibAlgorithms::GeomCharacteristicSet& features) {
133  reset();
134 
135  for (const ccLibAlgorithms::GeomCharacteristic& f : features) {
136  // find the corresponding checkbox
137  for (const Option& opt : m_options) {
138  if (opt.charac == f.charac && opt.subOption == f.subOption) {
139  opt.checkBox->setChecked(true);
140  break;
141  }
142  }
143  }
144 }
145 
147  ccLibAlgorithms::GeomCharacteristicSet& features) const {
148  features.clear();
149 
150  try {
151  // test each check-box and add the corresponding feature descriptor if
152  // necessary
153  for (const Option& opt : m_options) {
154  assert(opt.checkBox);
155  if (opt.checkBox && opt.checkBox->isChecked())
156  features.push_back(opt);
157  }
158  features.shrink_to_fit();
159  } catch (const std::bad_alloc&) {
160  return false;
161  }
162  return true;
163 }
164 
166  return radiusDoubleSpinBox->value();
167 }
168 
170  radiusDoubleSpinBox->setValue(r);
171 }
172 
174  for (const Option& opt : m_options) opt.checkBox->setChecked(false);
175 }
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
void Reset(void)
Type y
Definition: CVGeom.h:137
Type x
Definition: CVGeom.h:137
Type z
Definition: CVGeom.h:137
CCVector3 * getUpDirection() const
Returns the 'up direction' if any is defined (nullptr otherwise)
void setUpDirection(const CCVector3 &upDir)
Sets the 'up direction' (and enables the group at the same time)
bool getSelectedFeatures(ccLibAlgorithms::GeomCharacteristicSet &features) const
Returns selected features.
void reset()
reset the whole dialog
void setSelectedFeatures(const ccLibAlgorithms::GeomCharacteristicSet &features)
Sets selected features.
double getRadius() const
Returns the kernel radius (for 'precise' mode only)
ccGeomFeaturesDlg(QWidget *parent=nullptr)
Default constructor.
std::vector< Option > m_options
void setRadius(double r)
Sets the default kernel radius (for 'precise' mode only)
std::vector< GeomCharacteristic > GeomCharacteristicSet
Set of GeomCharacteristic instances.
Geometric characteristic (with sub option)