From 95dff93c415765af702050ee37d9e1c4dd482148 Mon Sep 17 00:00:00 2001 From: Paul Leroy Date: Thu, 16 May 2024 00:46:48 +0200 Subject: [PATCH] code cleaning --- src/ActionA.cpp | 71 ++++++++++++++-------------------------- ui/qG3PointDialog.ui | 9 +++++ ui/qG3PointDisclaimer.ui | 6 ++++ 3 files changed, 39 insertions(+), 47 deletions(-) diff --git a/src/ActionA.cpp b/src/ActionA.cpp index e4bba7e..2b0606b 100644 --- a/src/ActionA.cpp +++ b/src/ActionA.cpp @@ -1,42 +1,48 @@ #include "ActionA.h" -#include - +// CCPluginAPI #include -#include #include + +// qCC_db +#include +#include #include #include #include -#include #include + +// CCCoreLib +#include +#include + +// qCC_glWindow #include +// Qt #include #include #include #include #include +#include +#include #include #include #include #include -#include -#include -#include - +// Open3D #include +// Eigen #include #include - #include -#include - +#include #include namespace G3Point @@ -629,7 +635,7 @@ bool G3PointAction::merge(XXb& condition) int countNewLabels = 0; size_t nlabels = m_stacks.size(); - if (condition.rows() != m_stacks.size()) // check that condition is validd + if (condition.rows() != m_stacks.size()) // check that condition is valid { ccLog::Error("[G3PointAction::merge] the shape of the condition (" + QString::number(condition.rows()) + ", " + QString::number(condition.cols()) @@ -658,7 +664,6 @@ bool G3PointAction::merge(XXb& condition) // shall we merge otherLabel with label? if (!condition(label, otherLabel)) { - std::vector& labelStack = newStacks[newLabels(label)]; if (newLabels(otherLabel) != -1) // the other label has already been merged @@ -714,6 +719,7 @@ bool G3PointAction::merge(XXb& condition) if (!processNewStacks(newStacks, m_cloud->size())) { ccLog::Error("[G3PointAction::merge] processing newStacks failed"); + return false; } return true; @@ -833,10 +839,8 @@ bool G3PointAction::cluster() // merge labels if sinks are // => close to each other (Dist == 1) // => neighbours (Nneigh == 1) - // => normals are similar - - int start = 15; - int size = 5; + // => normals are similar (A < m_maxAngle1) + // => A is not NaN if (!checkStacks(m_stacks, m_cloud->size())) { @@ -849,13 +853,6 @@ bool G3PointAction::cluster() symmetrical_condition.count(); condition = symmetrical_condition; - // -// eigenArrayToFile("C:/dev/python/g3point_python/data/debug/Dist.csv", Dist); -// eigenArrayToFile("C:/dev/python/g3point_python/data/debug/Nneigh.csv", Nneigh); -// eigenArrayToFile("C:/dev/python/g3point_python/data/debug/A.csv", A); -// eigenArrayToFile("C:/dev/python/g3point_python/data/debug/symmetrical_condition.csv", symmetrical_condition); -// - std::vector> newStacks; Eigen::ArrayXi newLabels = Eigen::ArrayXi::Ones(m_labels.size()) * (-1); int countNewLabels = 0; @@ -926,19 +923,9 @@ bool G3PointAction::cluster() newStacksWithoutEmpty.push_back(stack); } } - std::cout << "m_stacks.size() " << m_stacks.size() - << " newStacks.size() " << newStacks.size() - << " newStacksWithoutEmpty.size() " << newStacksWithoutEmpty.size() << std::endl; newStacks = newStacksWithoutEmpty; - std::cout << "(a) m_stacks.size() " << m_stacks.size() << std::endl; - std::cout << "(a) m_labels.size() " << m_labels.size() << std::endl; - for (int k = 0; k < 10; k++) - { - std::cout << m_stacks[k].size() << " " << newStacks[k].size() << std::endl; - } - ccLog::Print("[G3PointAction::merge] keep " + QString::number(newStacks.size()) + "/" + QString::number(m_stacks.size()) + " labels (" + QString::number(m_stacks.size() - newStacks.size()) + " removed)"); @@ -949,9 +936,6 @@ bool G3PointAction::cluster() return false; } - std::cout << "(b) m_stacks.size() " << m_stacks.size() << std::endl; - std::cout << "(b) m_labels.size() " << m_labels.size() << std::endl; - return true; } @@ -1002,17 +986,10 @@ bool G3PointAction::cleanLabels() { ccLog::Print("[cleanLabels] merge points considering the normals at the border"); Eigen::ArrayXXd A = computeMeanAngleBetweenNormalsAtBorders(); - size_t nGrains = m_stacks.size(); - XXb condition = (A > m_maxAngle2) || (A != A) || (Eigen::MatrixXi::Identity(nGrains, nGrains).array() == 1); // add true on the diagonal (important for the if hereafter) + XXb condition = (A > m_maxAngle2) || (A != A); // add true on the diagonal (important for the if hereafter) XXb symmetrical_condition = (condition == condition.transpose()).select(condition, true); - if (condition.all()) - { - ccLog::Print("[cleanLabels] nothing to merge, continue"); - } - else - { - merge(condition); - } + + merge(symmetrical_condition); QApplication::processEvents(); } diff --git a/ui/qG3PointDialog.ui b/ui/qG3PointDialog.ui index 9c6c93c..2e8db4d 100644 --- a/ui/qG3PointDialog.ui +++ b/ui/qG3PointDialog.ui @@ -114,6 +114,12 @@ + + true + + + false + @@ -178,6 +184,9 @@ + + true + diff --git a/ui/qG3PointDisclaimer.ui b/ui/qG3PointDisclaimer.ui index 2a832ba..e0e42fb 100644 --- a/ui/qG3PointDisclaimer.ui +++ b/ui/qG3PointDisclaimer.ui @@ -16,6 +16,12 @@ + + true + + + true + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">