42 unsigned& finalPointCount,
44 bool useDataSFAsWeights ,
45 bool useModelSFAsWeights ,
47 bool restoreColorState =
false;
48 bool restoreSFState =
false;
52 QScopedPointer<ecvProgressDialog> progressDlg;
76 CVLog::Error(
"[ICP] Failed to sample points on 'data' mesh!");
79 cloudGarbage.
add(dataCloud);
87 int oldDataSfIdx = -1;
105 "[ICP] Couldn't create temporary scalar field! Not enough "
112 "[ICP] Couldn't create temporary scalar field! Not enough "
119 static double s_overlapMarginRatio = 0.2;
120 params.finalOverlapRatio =
125 if (
params.finalOverlapRatio < 1.0 - s_overlapMarginRatio) {
130 static_cast<int>(
floor(log10(
static_cast<double>(
136 cloudViewer::DistanceComputationTools::
137 Cloud2MeshDistancesComputationParams c2mParams;
156 "Failed to determine the max (overlap) distance (not "
163 ScalarType maxSearchDist = 0;
166 std::vector<ScalarType> distances;
168 distances.resize(
count);
169 }
catch (
const std::bad_alloc&) {
173 for (
unsigned i = 0; i <
count; ++i) {
182 distances[
static_cast<size_t>(
std::max(
184 s_overlapMarginRatio))) -
193 cloudGarbage.
add(refCloud);
194 unsigned countBefore = dataCloud->
size();
195 unsigned baseIncrement =
static_cast<unsigned>(
std::max(
196 100.0, countBefore *
params.finalOverlapRatio * 0.05));
197 for (
unsigned i = 0; i < countBefore; ++i) {
200 !refCloud->
reserve(refCloud->
size() + baseIncrement)) {
208 dataCloud = refCloud;
210 unsigned countAfter = dataCloud->
size();
211 double keptRatio =
static_cast<double>(countAfter) / countBefore;
212 CVLog::Print(QString(
"[ICP][Partial overlap] Selecting %1 points "
213 "out of %2 (%3%) for registration")
216 .arg(
static_cast<int>(100 * keptRatio)));
219 params.finalOverlapRatio /= keptRatio;
224 params.modelWeights =
nullptr;
225 params.dataWeights =
nullptr;
227 if (!modelMesh && useModelSFAsWeights) {
236 "[ICP] 'useDataSFAsWeights' is true but model has "
237 "no displayed scalar field!");
240 "[ICP] 'useDataSFAsWeights' is true but only point "
241 "cloud scalar fields can be used as weights!");
245 if (useDataSFAsWeights) {
246 if (!dataDisplayedSF) {
249 "[ICP] 'useDataSFAsWeights' is true but data has "
250 "no displayed scalar field!");
253 "[ICP] 'useDataSFAsWeights' is true but only point "
254 "cloud scalar fields can be used as weights!");
256 params.dataWeights = dataDisplayedSF;
265 modelCloud, modelMesh, dataCloud,
params, transform, finalRMS,
268 progressDlg.data()));
271 CVLog::Error(
"Registration failed: an error occurred (code %i)",
274 transMat = FromCCLibMatrix<double, float>(transform.
R, transform.
T,
276 finalScale = transform.
s;
280 if (dataSfIdx >= 0) {
286 pc->
showSF(restoreSFState);
cmdLineReadable * params[]
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Print(const char *format,...)
Prints out a formatted message in console.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
Garbage container (automatically deletes pointers when destroyed)
void add(C *item)
Puts an item in the trash.
virtual bool colorsShown() const
Returns whether colors are shown or not.
virtual bool sfShown() const
Returns whether active scalar field is visible.
virtual void showColors(bool state)
Sets colors visibility.
virtual void showSF(bool state)
Sets active scalarfield visibility.
Float version of ccGLMatrixTpl.
virtual ccGenericPointCloud * getAssociatedCloud() const =0
Returns the vertices cloud.
static ccPointCloud * ToPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccPointCloud.
static ccGenericPointCloud * ToGenericPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccGenericPointCloud.
static ccGenericMesh * ToGenericMesh(ccHObject *obj)
Converts current object to ccGenericMesh (if possible)
Hierarchical CLOUDVIEWER Object.
bool isA(CV_CLASS_ENUM type) const
bool isKindOf(CV_CLASS_ENUM type) const
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
int addScalarField(const char *uniqueName) override
Creates a new scalar field and registers it.
void deleteScalarField(int index) override
Deletes a specific scalar field.
ccScalarField * getCurrentDisplayedScalarField() const
Returns the currently displayed scalar (or 0 if none)
virtual bool enableScalarField()=0
Enables the scalar field associated to the cloud.
virtual unsigned size() const =0
Returns the number of points.
virtual ScalarType getPointScalarValue(unsigned pointIndex) const =0
Returns the ith point associated scalar value.
A generic 3D point cloud with index-based and presistent access to points.
int getScalarFieldIndexByName(const char *name) const
Returns the index of a scalar field represented by its name.
int getCurrentInScalarFieldIndex()
Returns current INPUT scalar field index (or -1 if none)
void setCurrentScalarField(int index)
Sets both the INPUT & OUTPUT scalar field.
A very simple point cloud (no point duplication)
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
unsigned size() const override
Returns the number of points.
virtual bool resize(unsigned n)
Presets the size of the vector used to store point references.
virtual unsigned capacity() const
Returns max capacity.
virtual bool reserve(unsigned n)
Reserves some memory for hosting the point references.
A simple scalar field (to be associated to a point cloud)
Graphical progress indicator (thread-safe)
MiniVec< float, N > floor(const MiniVec< float, N > &a)