From 69001ab9d57e83ab839501bb44522571cbc76c80 Mon Sep 17 00:00:00 2001 From: Daniel Girardeau-Montaut Date: Fri, 29 Mar 2019 21:36:35 +0100 Subject: [PATCH] Various bug fixes --- NeighborhoodFeature.cpp | 12 ++---------- NeighborhoodFeature.h | 10 +++++----- PointFeature.cpp | 30 ++++++++++++++++-------------- PointFeature.h | 6 +++--- q3DMASCTools.cpp | 3 +++ 5 files changed, 29 insertions(+), 32 deletions(-) diff --git a/NeighborhoodFeature.cpp b/NeighborhoodFeature.cpp index c1f086e..ec17430 100644 --- a/NeighborhoodFeature.cpp +++ b/NeighborhoodFeature.cpp @@ -256,7 +256,7 @@ bool NeighborhoodFeature::computeValue(CCLib::DgmOctree::NeighboursSet& pointsIn } break; - case DipAng: + case Dip: case DipDir: if (kNN >= 3) { @@ -269,11 +269,7 @@ bool NeighborhoodFeature::computeValue(CCLib::DgmOctree::NeighboursSet& pointsIn CCVector3 Np = (N->z < 0 ? -PC_ONE * *N : *N); PointCoordinateType dip_deg, dipDir_deg; ccNormalVectors::ConvertNormalToDipAndDipDir(Np, dip_deg, dipDir_deg); - outputValue = (type == DipAng ? dip_deg : dipDir_deg); - } - else - { - return false; + outputValue = (type == Dip ? dip_deg : dipDir_deg); } } break; @@ -348,10 +344,6 @@ bool NeighborhoodFeature::computeValue(CCLib::DgmOctree::NeighboursSet& pointsIn outputValue = d / r; } } - else - { - return false; - } } break; diff --git a/NeighborhoodFeature.h b/NeighborhoodFeature.h index b853b57..b26aca1 100644 --- a/NeighborhoodFeature.h +++ b/NeighborhoodFeature.h @@ -38,7 +38,7 @@ namespace masc , SPHER , LINEA , PLANA - , DipAng + , Dip , DipDir , ROUGH , NBPTS @@ -70,8 +70,8 @@ namespace masc return "LINEA"; case PLANA: return "PLANA"; - case DipAng: - return "DipAng"; + case Dip: + return "Dip"; case DipDir: return "DipDir"; case ROUGH: @@ -116,8 +116,8 @@ namespace masc return LINEA; else if (token == "PLANA") return PLANA; - else if (token == "DIPANG") - return DipAng; + else if (token == "DIP") + return Dip; else if (token == "DIPDIR") return DipDir; else if (token == "ROUGH") diff --git a/PointFeature.cpp b/PointFeature.cpp index 0e04e99..db802a4 100644 --- a/PointFeature.cpp +++ b/PointFeature.cpp @@ -145,7 +145,7 @@ bool PointFeature::checkValidity(QString corePointRole, QString &error) const } return true; } - case PointFeature::DipAng: + case PointFeature::Dip: case PointFeature::DipDir: { if (!cloud1->hasNormals()) @@ -271,7 +271,7 @@ IScalarFieldWrapper::Shared PointFeature::retrieveField(ccPointCloud* cloud, QSt } return IScalarFieldWrapper::Shared(new ScalarFieldWrapper(sf)); } - case PointFeature::DipAng: + case PointFeature::Dip: case PointFeature::DipDir: { //we need normals to compute the dip and dip direction! @@ -280,7 +280,7 @@ IScalarFieldWrapper::Shared PointFeature::retrieveField(ccPointCloud* cloud, QSt error = "Cloud has no normals: can't compute dip or dip dir. angles"; return nullptr; } - return IScalarFieldWrapper::Shared(new NormDipAndDipDirFieldWrapper(cloud, type == PointFeature::DipAng ? NormDipAndDipDirFieldWrapper::Dip : NormDipAndDipDirFieldWrapper::DipDir)); + return IScalarFieldWrapper::Shared(new NormDipAndDipDirFieldWrapper(cloud, type == PointFeature::Dip ? NormDipAndDipDirFieldWrapper::Dip : NormDipAndDipDirFieldWrapper::DipDir)); } case PointFeature::M3C2: { @@ -496,17 +496,6 @@ bool PointFeature::prepare( const CorePoints& corePoints, return false; } resultSFName += QString("_") + Feature::StatToString(stat); - - //prepare the corresponding scalar field - assert(!statSF1); - statSF1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields); - if (!statSF1) - { - error = QString("Failed to prepare scalar field for field '%1' @ scale %2").arg(field1->getName()).arg(scale); - return false; - } - - source.name = statSF1->getName(); } else //not scaled { @@ -532,7 +521,20 @@ bool PointFeature::prepare( const CorePoints& corePoints, if (isScaled) { resultSFName += "@" + QString::number(scale); + } + //prepare the corresponding scalar field + assert(!statSF1); + statSF1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields); + if (!statSF1) + { + error = QString("Failed to prepare scalar field for field '%1' @ scale %2").arg(field1->getName()).arg(scale); + return false; + } + source.name = statSF1->getName(); + + if (isScaled) + { if (field2 && op != Feature::NO_OPERATION) { QString resultSFName2 = cloud2Label + "." + field2->getName() + QString("_") + Feature::StatToString(stat) + "@" + QString::number(scale); diff --git a/PointFeature.h b/PointFeature.h index e482781..6ed7821 100644 --- a/PointFeature.h +++ b/PointFeature.h @@ -47,7 +47,7 @@ namespace masc , G , B , NIR - , DipAng + , Dip , DipDir , M3C2 , PCV @@ -82,7 +82,7 @@ namespace masc return "B"; case NIR: return "NIR"; - case DipAng: + case Dip: return "NormDip"; case DipDir: return "NormDipDir"; @@ -125,7 +125,7 @@ namespace masc else if (token == "NIR") return NIR; else if (token == "NORMDIP") - return DipAng; + return Dip; else if (token == "NORMDIPDIR") return DipDir; else if (token == "M3C2") diff --git a/q3DMASCTools.cpp b/q3DMASCTools.cpp index e9a041d..aabfbc3 100644 --- a/q3DMASCTools.cpp +++ b/q3DMASCTools.cpp @@ -1205,6 +1205,7 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features if (!feature->computeValue(nNSS.pointsInNeighbourhood, nNSS.queryPoint, outputValue)) { //an error occurred + errorStr = "An error occurred during the computation of feature " + feature->toString() + "on cloud " + feature->cloud1->getName(); success = false; break; } @@ -1220,6 +1221,7 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features if (!feature->computeValue(nNSS.pointsInNeighbourhood, nNSS.queryPoint, outputValue)) { //an error occurred + errorStr = "An error occurred during the computation of feature " + feature->toString() + "on cloud " + feature->cloud2->getName(); success = false; break; } @@ -1238,6 +1240,7 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features if (!feature->computeValue(nNSS.pointsInNeighbourhood, nNSS.queryPoint, outputValue)) { //an error occurred + errorStr = "An error occurred during the computation of feature " + feature->toString() + "on cloud " + feature->cloud2->getName(); success = false; break; }