From a3f596e81a24bc89c81eaf4dcee3a69e78559c0f Mon Sep 17 00:00:00 2001 From: Daniel Girardeau-Montaut Date: Sun, 30 Jun 2024 17:23:57 +0200 Subject: [PATCH] Improving the code syntax and robustness (Coverity scan) --- include/CutPursuit.h | 2 ++ include/CutPursuit_SPG.h | 2 +- include/Graph.h | 1 + src/TreeIso.cpp | 4 +--- src/qTreeIso.cpp | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/CutPursuit.h b/include/CutPursuit.h index df2e86a..ef60cdb 100644 --- a/include/CutPursuit.h +++ b/include/CutPursuit.h @@ -61,6 +61,8 @@ namespace CP this->dim = 1; this->nVertex = 1; this->nEdge = 0; + this->parameter.reg_strenth = 0; + this->parameter.cutoff = 0; this->parameter.flow_steps = 3; this->parameter.kmeans_ite = 5; this->parameter.kmeans_resampling = 3; diff --git a/include/CutPursuit_SPG.h b/include/CutPursuit_SPG.h index 7aee270..4d3d9f0 100644 --- a/include/CutPursuit_SPG.h +++ b/include/CutPursuit_SPG.h @@ -120,7 +120,7 @@ namespace CP uint32_t nb_comp = static_cast(this->components.size()); // ind_com; //#pragma omp parallel for private(ind_com) //if (nb_comp>=8) schedule(dynamic) - uint32_t dim_spat = spatial_part ? this->dim - 0 : dim_spat = this->dim; + uint32_t dim_spat = spatial_part ? this->dim - 0 : this->dim; #ifdef OPENMP #pragma omp parallel for if (nb_comp >= omp_get_num_threads()) schedule(dynamic) diff --git a/include/Graph.h b/include/Graph.h index b326a78..d44df76 100644 --- a/include/Graph.h +++ b/include/Graph.h @@ -23,6 +23,7 @@ namespace CP , value(dim, 0.) , color(-1) , isBorder(false) + , in_component(0) {} T weight; //weight of the observation diff --git a/src/TreeIso.cpp b/src/TreeIso.cpp index cd82e54..a71313f 100644 --- a/src/TreeIso.cpp +++ b/src/TreeIso.cpp @@ -201,7 +201,6 @@ bool TreeIso::Intermediate_seg_pcd(ccPointCloud* pc, const unsigned PR_MIN_NN2, } CCCoreLib::ScalarField* initSF = pc->getScalarField(initSFIndex); - initSF->size(); std::vector in_component; try { @@ -491,7 +490,7 @@ bool TreeIso::Final_seg_pcd(ccPointCloud* pc, const unsigned PR_MIN_NN3, const f } CCCoreLib::ScalarField* initSF = pc->getScalarField(initIdx); - initSF->size(); + std::vector segs_init_ids; segs_init_ids.resize(pointCount); for (unsigned i = 0; i < pointCount; ++i) @@ -506,7 +505,6 @@ bool TreeIso::Final_seg_pcd(ccPointCloud* pc, const unsigned PR_MIN_NN3, const f return false; } - groupSF->size(); std::vector segs_group_ids; segs_group_ids.resize(pointCount); diff --git a/src/qTreeIso.cpp b/src/qTreeIso.cpp index c421898..f3c40e4 100644 --- a/src/qTreeIso.cpp +++ b/src/qTreeIso.cpp @@ -107,7 +107,7 @@ QList qTreeIso::getActions() void qTreeIso::doAction() { Parameters parameters; - ccTreeIsoDlg treeisoDlg(m_app->getMainWindow()); + ccTreeIsoDlg treeisoDlg(m_app ? m_app->getMainWindow() : nullptr); connect(treeisoDlg.pushButtonInitSeg, &QPushButton::clicked, [&] {