From f4e94a02e67c78711df9ae0df96a165a329253a2 Mon Sep 17 00:00:00 2001 From: Paul Leroy Date: Mon, 13 May 2024 16:29:42 +0200 Subject: [PATCH] export results button connection --- include/ActionA.h | 1 + include/G3PointDialog.h | 2 ++ src/ActionA.cpp | 24 +++++++++--------------- src/G3PointDialog.cpp | 1 + src/GrainsAsEllipsoids.cpp | 11 +++++------ ui/qG3PointDialog.ui | 2 +- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/include/ActionA.h b/include/ActionA.h index a2abdca..0dbe906 100644 --- a/include/ActionA.h +++ b/include/ActionA.h @@ -34,6 +34,7 @@ public: void getBorders(); bool cluster(); void fit(); + void exportResults(); bool processNewStacks(std::vector>& newStacks, int pointCount); bool merge(XXb& condition); bool keep(Xb& condition); diff --git a/include/G3PointDialog.h b/include/G3PointDialog.h index ecebb2d..49a3c2b 100644 --- a/include/G3PointDialog.h +++ b/include/G3PointDialog.h @@ -23,6 +23,7 @@ public: void emitOnlyOneClicked(bool state){emit onlyOneClicked(state);} void emitOnlyOneChanged(int idx){emit onlyOneChanged(idx);} void emitFit(){emit fit();} + void emitExportResults(){emit exportResults();} void emitTransparencyChanged(double transparency){emit transparencyChanged(transparency);} void emitDrawSurfaces(bool state){emit drawSurfaces(state);} void emitDrawLines(bool state){emit drawLines(state);} @@ -51,6 +52,7 @@ signals: void clusterAndOrClean(); void getBorders(); void fit(); + void exportResults(); void allClicked(bool state); void onlyOneClicked(bool state); diff --git a/src/ActionA.cpp b/src/ActionA.cpp index 1577098..eeeb680 100644 --- a/src/ActionA.cpp +++ b/src/ActionA.cpp @@ -814,7 +814,6 @@ bool G3PointAction::cluster() // If the radius of the sink is above the distance to the other sink (by a factor of rad_factor), set Dist to 1 Eigen::ArrayXXi Dist = Eigen::ArrayXXi::Zero(nlabels, nlabels); Dist = (m_radiusFactor * D2 > D1).select(1, Dist); - std::cout << "Dist" << std::endl; for (int i = 0; i < 10; i++) // set the values of the diagonal to 0 { Dist(i, i) = 0; @@ -852,13 +851,6 @@ bool G3PointAction::cluster() int start = 15; int size = 5; - std::cout << "\n\nDist" << std::endl; - std::cout << Dist.block(start, start, size, size) << std::endl; - std::cout << "\n\nNneigh" << std::endl; - std::cout << Nneigh.block(start, start, size, size) << std::endl; - std::cout << "\n\nA" << std::endl; - std::cout << A.block(start, start, size, size) << std::endl; - if (!checkStacks(m_stacks, m_cloud->size())) { ccLog::Error("m_stacks is not valid"); @@ -870,9 +862,6 @@ bool G3PointAction::cluster() symmetrical_condition.count(); condition = symmetrical_condition; - std::cout << "\n\nsymmetrical_condition" << std::endl; - std::cout << symmetrical_condition.block(start, start, size, size) << std::endl; - // // eigenArrayToFile("C:/dev/python/g3point_python/data/debug/Dist.csv", Dist); // eigenArrayToFile("C:/dev/python/g3point_python/data/debug/Nneigh.csv", Nneigh); @@ -1006,6 +995,14 @@ void G3PointAction::fit() m_app->updateUI(); } +void G3PointAction::exportResults() +{ + if (m_grainsAsEllipsoids) + { + m_grainsAsEllipsoids->exportResultsAsCloud(); + } +} + bool G3PointAction::cleanLabels() { ccLog::Print("[cleanLabels]"); @@ -1409,10 +1406,6 @@ bool G3PointAction::computeNormalsWithOpen3D() // compute the normals pcd.EstimateNormals(open3d::geometry::KDTreeSearchParamKNN(m_kNN)); - for (int i = 0; i < 10; i++) - { - std::cout << pcd.normals_[i].x() << " " << pcd.normals_[i].y() << " " << pcd.normals_[i].z() << std::endl; - } // we 'compress' each normal int pointCount = m_cloud->size(); @@ -1652,6 +1645,7 @@ void G3PointAction::showDlg() connect(m_dlg, &G3PointDialog::getBorders, s_g3PointAction, &G3Point::G3PointAction::getBorders); connect(m_dlg, &G3PointDialog::fit, s_g3PointAction, &G3Point::G3PointAction::fit); + connect(m_dlg, &G3PointDialog::exportResults, s_g3PointAction, &G3Point::G3PointAction::exportResults); connect(m_dlg, &QDialog::finished, s_g3PointAction, &G3Point::G3PointAction::clean); connect(m_dlg, &QDialog::finished, s_g3PointAction, &G3Point::G3PointAction::resetDlg); // dialog is defined with Qt::WA_DeleteOnClose diff --git a/src/G3PointDialog.cpp b/src/G3PointDialog.cpp index 2bfcf84..d5da429 100644 --- a/src/G3PointDialog.cpp +++ b/src/G3PointDialog.cpp @@ -21,6 +21,7 @@ G3PointDialog::G3PointDialog(QString cloudName, QWidget *parent) connect(this->ui->spinBoxOnlyOne, qOverload(&QSpinBox::valueChanged), this, &::G3PointDialog::emitOnlyOneChanged); connect(this->ui->pushButtonFit, &QPushButton::clicked, this, &G3PointDialog::emitFit); + connect(this->ui->pushButtonExportResults, &QPushButton::clicked, this, &G3PointDialog::emitExportResults); connect(this->ui->checkBoxSurfaces, &QCheckBox::clicked, this, &G3PointDialog::emitDrawSurfaces); connect(this->ui->checkBoxWireframes, &QCheckBox::clicked, this, &::G3PointDialog::emitDrawLines); connect(this->ui->checkBoxPoints, &QCheckBox::clicked, this, &G3PointDialog::emitDrawPoints); diff --git a/src/GrainsAsEllipsoids.cpp b/src/GrainsAsEllipsoids.cpp index 3b0d928..ea91248 100644 --- a/src/GrainsAsEllipsoids.cpp +++ b/src/GrainsAsEllipsoids.cpp @@ -51,8 +51,6 @@ GrainsAsEllipsoids::GrainsAsEllipsoids(ccPointCloud *cloud, ccMainAppInterface * } m_ccBBoxAll.setValidity(true); - - exportResultsAsCloud(); } void GrainsAsEllipsoids::setShaderPath(const QString& path) @@ -81,7 +79,6 @@ void GrainsAsEllipsoids::setGrainColorsTable(const RGBAColorsTableType& colorTab bool GrainsAsEllipsoids::exportResultsAsCloud() { // create cloud - // QString cloudName = m_cloud->getName() + "_g3point"; QString cloudName = "g3point_results"; ccPointCloud *cloud = new ccPointCloud(cloudName); @@ -120,13 +117,15 @@ bool GrainsAsEllipsoids::exportResultsAsCloud() return false; } sf = cloud->getScalarField(sfIdx); - for (int index = 0; index < cloud->size(); index++) + int indexInResults = 0; + for (int index = 0; index < m_center.size(); index++) { - if (m_fitNotOK.count(index)) + if (m_fitNotOK.count(index)) // when the fit was not successful, the point is not exported { continue; } - sf->setValue(index, index); + sf->setValue(indexInResults, index); + indexInResults++; } sf->computeMinAndMax(); diff --git a/ui/qG3PointDialog.ui b/ui/qG3PointDialog.ui index 7d684ef..b2aa5ff 100644 --- a/ui/qG3PointDialog.ui +++ b/ui/qG3PointDialog.ui @@ -7,7 +7,7 @@ 0 0 357 - 749 + 608