-
Notifications
You must be signed in to change notification settings - Fork 4
/
ccRegistrationDlg.cpp
226 lines (191 loc) · 6.35 KB
/
ccRegistrationDlg.cpp
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
//##########################################################################
//# #
//# 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 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: EDF R&D / TELECOM ParisTech (ENST-TSI) #
//# #
//##########################################################################
#include "ccRegistrationDlg.h"
//Local
#include "ccDisplayOptionsDlg.h"
#include "mainwindow.h"
//CCLib
#include <DgmOctree.h>
#include <CloudSamplingTools.h>
#include <GeometricalAnalysisTools.h>
#include <ReferenceCloud.h>
//qCC_db
#include <ccHObject.h>
//system
#include <assert.h>
//semi-persistent options
static bool s_adjustScale = false;
static unsigned s_randomSamplingLimit = 50000;
static double s_rmsDifference = 1.0e-5;
static int s_maxIterationCount = 20;
static bool s_useErrorDifferenceCriterion = true;
static int s_finalOverlap = 100;
static int s_rotComboIndex = 0;
static bool s_transCheckboxes[3] = {true, true, true};
ccRegistrationDlg::ccRegistrationDlg(ccHObject *data, ccHObject *model, QWidget* parent/*=0*/)
: QDialog(parent)
, Ui::RegistrationDialog()
{
assert(data && model);
dataEntity = data;
modelEntity = model;
setupUi(this);
rmsDifferenceLineEdit->setValidator(new QDoubleValidator(rmsDifferenceLineEdit));
setWindowFlags(Qt::Tool);
setColorsAndLabels();
QColor qRed(255,0,0);
QColor qYellow(255,255,0);
ccDisplayOptionsDlg::SetButtonColor(dataColorButton,qRed);
ccDisplayOptionsDlg::SetButtonColor(modelColorButton,qYellow);
//restore semi-persistent settings
adjustScaleCheckBox->setChecked(s_adjustScale);
randomSamplingLimitSpinBox->setValue(s_randomSamplingLimit);
rmsDifferenceLineEdit->setText(QString::number(s_rmsDifference,'e',1));
maxIterationCount->setValue(s_maxIterationCount);
if (s_useErrorDifferenceCriterion)
errorCriterion->setChecked(true);
else
iterationsCriterion->setChecked(true);
overlapSpinBox->setValue(s_finalOverlap);
rotComboBox->setCurrentIndex(s_rotComboIndex);
TxCheckBox->setChecked(s_transCheckboxes[0]);
TyCheckBox->setChecked(s_transCheckboxes[1]);
TzCheckBox->setChecked(s_transCheckboxes[2]);
connect(swapButton, SIGNAL(clicked()), this, SLOT(swapModelAndData()));
}
ccRegistrationDlg::~ccRegistrationDlg()
{
if (modelEntity)
{
modelEntity->enableTempColor(false);
modelEntity->prepareDisplayForRefresh_recursive();
}
if (dataEntity)
{
dataEntity->enableTempColor(false);
dataEntity->prepareDisplayForRefresh_recursive();
}
MainWindow::RefreshAllGLWindow(false);
}
void ccRegistrationDlg::saveParameters() const
{
s_adjustScale = adjustScale();
s_randomSamplingLimit = randomSamplingLimit();
s_rmsDifference = getMinRMSDecrease();
s_maxIterationCount = getMaxIterationCount();
s_useErrorDifferenceCriterion = errorCriterion->isChecked();
s_finalOverlap = overlapSpinBox->value();
s_rotComboIndex = rotComboBox->currentIndex();
s_transCheckboxes[0] = TxCheckBox->isChecked();
s_transCheckboxes[1] = TyCheckBox->isChecked();
s_transCheckboxes[2] = TzCheckBox->isChecked();
}
ccHObject *ccRegistrationDlg::getDataEntity()
{
return dataEntity;
}
ccHObject *ccRegistrationDlg::getModelEntity()
{
return modelEntity;
}
bool ccRegistrationDlg::useDataSFAsWeights() const
{
return checkBoxUseDataSFAsWeights->isChecked();
}
bool ccRegistrationDlg::useModelSFAsWeights() const
{
return checkBoxUseModelSFAsWeights->isChecked();
}
bool ccRegistrationDlg::adjustScale() const
{
return adjustScaleCheckBox->isChecked();
}
bool ccRegistrationDlg::removeFarthestPoints() const
{
return pointsRemoval->isChecked();
}
unsigned ccRegistrationDlg::randomSamplingLimit() const
{
return randomSamplingLimitSpinBox->value();
}
unsigned ccRegistrationDlg::getMaxIterationCount() const
{
return static_cast<unsigned>(std::max(1,maxIterationCount->value()));
}
unsigned ccRegistrationDlg::getFinalOverlap() const
{
return static_cast<unsigned>(std::max(10,overlapSpinBox->value()));
}
double ccRegistrationDlg::getMinRMSDecrease() const
{
bool ok = true;
double val = rmsDifferenceLineEdit->text().toDouble(&ok);
assert(ok);
return val;
}
ccRegistrationDlg::ConvergenceMethod ccRegistrationDlg::getConvergenceMethod() const
{
if (errorCriterion->isChecked())
return CCLib::ICPRegistrationTools::MAX_ERROR_CONVERGENCE;
else
return CCLib::ICPRegistrationTools::MAX_ITER_CONVERGENCE;
}
int ccRegistrationDlg::getTransformationFilters() const
{
int filters = 0;
switch (rotComboBox->currentIndex())
{
case 1:
filters |= CCLib::RegistrationTools::SKIP_RYZ;
break;
case 2:
filters |= CCLib::RegistrationTools::SKIP_RXZ;
break;
case 3:
filters |= CCLib::RegistrationTools::SKIP_RXY;
break;
default:
//nothing to do
break;
}
if (!TxCheckBox->isChecked())
filters |= CCLib::RegistrationTools::SKIP_TX;
if (!TyCheckBox->isChecked())
filters |= CCLib::RegistrationTools::SKIP_TY;
if (!TzCheckBox->isChecked())
filters |= CCLib::RegistrationTools::SKIP_TZ;
return filters;
}
void ccRegistrationDlg::setColorsAndLabels()
{
if (!modelEntity || !dataEntity)
return;
modelLineEdit->setText(modelEntity->getName());
modelEntity->setVisible(true);
modelEntity->setTempColor(ccColor::yellow);
modelEntity->prepareDisplayForRefresh_recursive();
dataLineEdit->setText(dataEntity->getName());
dataEntity->setVisible(true);
dataEntity->setTempColor(ccColor::red);
dataEntity->prepareDisplayForRefresh_recursive();
MainWindow::RefreshAllGLWindow(false);
}
void ccRegistrationDlg::swapModelAndData()
{
std::swap(dataEntity,modelEntity);
setColorsAndLabels();
}