File: ccInterpolationDlg.cpp

package info (click to toggle)
cloudcompare 2.11.3-7.1
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 58,224 kB
  • sloc: cpp: 229,982; ansic: 30,723; makefile: 84; sh: 20
file content (97 lines) | stat: -rw-r--r-- 3,591 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//##########################################################################
//#                                                                        #
//#                              CLOUDCOMPARE                              #
//#                                                                        #
//#  This program is free software; you can redistribute it and/or modify  #
//#  it under the terms of the GNU General Public License as published by  #
//#  the Free Software Foundation; version 2 or later of the License.      #
//#                                                                        #
//#  This program is distributed in the hope that it will be useful,       #
//#  but WITHOUT ANY WARRANTY; without even the implied warranty of        #
//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          #
//#  GNU General Public License for more details.                          #
//#                                                                        #
//#                    COPYRIGHT: Daniel Girardeau-Montaut                 #
//#                                                                        #
//##########################################################################

#include "ccInterpolationDlg.h"

//System
#include <assert.h>

ccInterpolationDlg::ccInterpolationDlg(QWidget* parent/*=0*/)
	: QDialog(parent, Qt::Tool)
	, Ui::InterpolationDlg()
{
	setupUi(this);

	connect(radiusDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &ccInterpolationDlg::onRadiusUpdated);
}

ccPointCloudInterpolator::Parameters::Method ccInterpolationDlg::getInterpolationMethod() const
{
	if (nnRadioButton->isChecked())
		return ccPointCloudInterpolator::Parameters::NEAREST_NEIGHBOR;
	else if (radiusRadioButton->isChecked())
		return ccPointCloudInterpolator::Parameters::RADIUS;
	else if (knnRadioButton->isChecked())
		return ccPointCloudInterpolator::Parameters::K_NEAREST_NEIGHBORS;

	assert(false);
	return ccPointCloudInterpolator::Parameters::NEAREST_NEIGHBOR;
}

void ccInterpolationDlg::setInterpolationMethod(ccPointCloudInterpolator::Parameters::Method method)
{
	switch (method)
	{
	case ccPointCloudInterpolator::Parameters::NEAREST_NEIGHBOR:
		nnRadioButton->setChecked(true);
		break;
	case ccPointCloudInterpolator::Parameters::RADIUS:
		radiusRadioButton->setChecked(true);
		break;
	case ccPointCloudInterpolator::Parameters::K_NEAREST_NEIGHBORS:
		knnRadioButton->setChecked(true);
		break;
	default:
		assert(false);
	}
}

ccPointCloudInterpolator::Parameters::Algo ccInterpolationDlg::getInterpolationAlgorithm() const
{
	if (averageRadioButton->isChecked())
		return ccPointCloudInterpolator::Parameters::AVERAGE;
	else if (medianRadioButton->isChecked())
		return ccPointCloudInterpolator::Parameters::MEDIAN;
	else if (normalDistribRadioButton->isChecked())
		return ccPointCloudInterpolator::Parameters::NORMAL_DIST;

	assert(false);
	return ccPointCloudInterpolator::Parameters::AVERAGE;
}

void ccInterpolationDlg::setInterpolationAlgorithm(ccPointCloudInterpolator::Parameters::Algo algo)
{
	switch (algo)
	{
	case ccPointCloudInterpolator::Parameters::AVERAGE:
		averageRadioButton->setChecked(true);
		break;
	case ccPointCloudInterpolator::Parameters::MEDIAN:
		medianRadioButton->setChecked(true);
		break;
	case ccPointCloudInterpolator::Parameters::NORMAL_DIST:
		normalDistribRadioButton->setChecked(true);
		break;
	default:
		assert(false);
	}
}

void ccInterpolationDlg::onRadiusUpdated(double radius)
{
	kernelDoubleSpinBox->setValue(radius / 2.5);
}