26 double maxCloudRadius,
28 : QDialog(parent, Qt::Tool),
29 Ui::SubsamplingDialog(),
30 m_maxPointCount(maxPointCount),
31 m_maxRadius(maxCloudRadius),
32 m_sfModEnabled(false),
37 samplingMethod->addItem(
"Random");
38 samplingMethod->addItem(
"Space");
39 samplingMethod->addItem(
"Octree");
41 connect(slider, &QSlider::sliderMoved,
this,
43 connect(samplingValue,
44 static_cast<void (QDoubleSpinBox::*)(
double)
>(
45 &QDoubleSpinBox::valueChanged),
47 connect(samplingMethod,
48 static_cast<void (QComboBox::*)(
int)
>(
49 &QComboBox::currentIndexChanged),
52 samplingMethod->setCurrentIndex(1);
59 if (!cloud || cloud->
size() == 0) {
61 "[ccSubsamplingDlg::getSampledCloud] Invalid input cloud!");
65 switch (samplingMethod->currentIndex()) {
67 assert(samplingValue->value() >= 0);
68 unsigned count =
static_cast<unsigned>(samplingValue->value());
70 cloud,
count, progressCb);
78 samplingValue->value());
81 sfGroupBox->isEnabled() && sfGroupBox->isChecked();
87 minSFSpacingDoubleSpinBox->value();
89 maxSFSpacingDoubleSpinBox->value();
90 modParams.
a = (sfMaxSpacing - sfMinSpacing) / deltaSF;
93 modParams.
a *
static_cast<double>(
m_sfMin);
96 modParams.
b =
static_cast<double>(
m_sfMin);
100 cloud, minDist, modParams,
octree.data(), progressCb);
103 QString(
"[ccSubsamplingDlg::getSampledCloud] Failed to "
104 "compute octree for cloud '%1'")
113 assert(samplingValue->value() >= 0);
114 unsigned char level =
115 static_cast<unsigned char>(samplingValue->value());
120 NEAREST_POINT_TO_CELL_CENTER,
121 progressCb,
octree.data());
124 QString(
"[ccSubsamplingDlg::getSampledCloud] Failed to "
125 "compute octree for cloud '%1'")
136 switch (samplingMethod->currentIndex()) {
138 labelSliderMin->setText(
"none");
139 labelSliderMax->setText(
"all");
140 valueLabel->setText(
"remaining points");
143 labelSliderMin->setText(
"large");
144 labelSliderMax->setText(
"small");
145 valueLabel->setText(
"min. space between points");
148 labelSliderMin->setText(
"min");
149 labelSliderMax->setText(
"max");
150 valueLabel->setText(
"subdivision level");
159 static_cast<double>(slider->maximum() - slider->minimum());
160 double rate =
static_cast<double>(sliderPos) / sliderRange;
161 if (samplingMethod->currentIndex() ==
SPACE) {
166 double valueRange =
static_cast<double>(samplingValue->maximum() -
167 samplingValue->minimum());
168 samplingValue->setValue(samplingValue->minimum() + rate * valueRange);
172 double valueRange =
static_cast<double>(samplingValue->maximum() -
173 samplingValue->minimum());
175 static_cast<double>(value - samplingValue->minimum()) / valueRange;
179 if (method ==
SPACE) {
184 minSFSpacingDoubleSpinBox->setValue(value);
185 maxSFSpacingDoubleSpinBox->setValue(value);
189 slider->blockSignals(
true);
191 static_cast<double>(slider->maximum() - slider->minimum());
192 slider->setSliderPosition(slider->minimum() +
193 static_cast<int>(rate * sliderRange));
194 slider->blockSignals(
false);
198 int oldSliderPos = slider->sliderPosition();
199 sfGroupBox->setEnabled(
false);
202 samplingValue->blockSignals(
true);
205 samplingValue->setDecimals(0);
206 samplingValue->setMinimum(1);
208 samplingValue->setSingleStep(1);
209 samplingValue->setEnabled(
true);
212 samplingValue->setDecimals(4);
213 samplingValue->setMinimum(0.0);
216 samplingValue->setSingleStep(step);
217 minSFSpacingDoubleSpinBox->setMaximum(
m_maxRadius);
218 minSFSpacingDoubleSpinBox->setSingleStep(step);
219 maxSFSpacingDoubleSpinBox->setMaximum(
m_maxRadius);
220 maxSFSpacingDoubleSpinBox->setSingleStep(step);
222 samplingValue->setDisabled(sfGroupBox->isEnabled() &&
223 sfGroupBox->isChecked());
226 samplingValue->setDecimals(0);
227 samplingValue->setMinimum(1);
228 samplingValue->setMaximum(
static_cast<double>(
230 samplingValue->setSingleStep(1);
231 samplingValue->setEnabled(
true);
236 samplingValue->blockSignals(
false);
248 "[ccSubsamplingDlg::enableSFModulation] Invalid input SF "
256 sfGroupBox->setEnabled(samplingMethod->currentIndex() ==
SPACE);
257 minSFlabel->setText(QString::number(sfMin));
258 maxSFlabel->setText(QString::number(sfMax));
float PointCoordinateType
Type of the coordinates of a (N-D) point.
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
A 3D cloud interface with associated features (color, normals, octree, etc.)
virtual ccOctree::Shared computeOctree(cloudViewer::GenericProgressCallback *progressCb=nullptr, bool autoAddChild=true)
Computes the cloud octree.
virtual ccOctree::Shared getOctree() const
Returns the associated octree (if any)
virtual QString getName() const
Returns object name.
QSharedPointer< ccOctree > Shared
Shared pointer.
ccSubsamplingDlg(unsigned maxPointCount, double maxCloudRadius, QWidget *parent=0)
Default constructor.
cloudViewer::ReferenceCloud * getSampledCloud(ccGenericPointCloud *cloud, cloudViewer::GenericProgressCallback *progressCb=0)
Returns subsampled version of a cloud according to current parameters.
CC_SUBSAMPLING_METHOD
Sub-sampling method.
void enableSFModulation(ScalarType sfMin, ScalarType sfMax)
Enables the SF modulation option (SPATIAL method)
ScalarType m_sfMax
Scalar modulation (max SF value)
void updateLabels()
Updates the dialog labels depending on the active mode.
ScalarType m_sfMin
Scalar modulation (min SF value)
void samplingRateChanged(double value)
void changeSamplingMethod(int index)
void sliderMoved(int sliderPos)
bool m_sfModEnabled
Scalar modulation.
unsigned m_maxPointCount
Max point count (for RANDOM method)
double m_maxRadius
Max radius (for SPACE method)
static const int MAX_OCTREE_LEVEL
Max octree subdivision level.
virtual unsigned size() const =0
Returns the number of points.
A very simple point cloud (no point duplication)
static bool ValidValue(ScalarType value)
Returns whether a scalar value is valid or not.
static const double SPACE_RANGE_EXPONENT
bool GreaterThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).