mirror of
https://github.com/dgirardeau/q3DMASC.git
synced 2026-08-30 00:50:49 +08:00
0.10
code cleaning
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ if (INSTALL_Q3DMASC_PLUGIN)
|
||||
project( Q3DMASC_PLUGIN )
|
||||
|
||||
AddPlugin( NAME ${PROJECT_NAME} )
|
||||
set(Q3DMASC_PLUGIN_VERSION "0.9")
|
||||
set(Q3DMASC_PLUGIN_VERSION "0.9+")
|
||||
|
||||
include( CMakePolicies NO_POLICY_SCOPE )
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ bool ContextBasedFeature::prepare( const CorePoints& corePoints,
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // classCount >= kNN
|
||||
else // classCount < kNN
|
||||
{
|
||||
//specific case: not enough points of this class in the whole cloud!
|
||||
|
||||
+16
-16
@@ -534,10 +534,10 @@ bool PointFeature::prepare( const CorePoints& corePoints,
|
||||
bool isScaled = scaled();
|
||||
|
||||
//build the final SF name
|
||||
QString resultSFName = field1->getName();
|
||||
QString resultSF1Name = field1->getName();
|
||||
if (cloud2 || corePoints.role != cloud1Label)
|
||||
{
|
||||
resultSFName += "_" + cloud1Label;
|
||||
resultSF1Name += "_" + cloud1Label;
|
||||
}
|
||||
|
||||
if (isScaled)
|
||||
@@ -549,7 +549,7 @@ bool PointFeature::prepare( const CorePoints& corePoints,
|
||||
error = "Scaled features (SCx) must have an associated STAT measure";
|
||||
return false;
|
||||
}
|
||||
resultSFName += QString("_") + Feature::StatToString(stat);
|
||||
resultSF1Name += QString("_") + Feature::StatToString(stat);
|
||||
}
|
||||
else //not scaled
|
||||
{
|
||||
@@ -564,29 +564,29 @@ bool PointFeature::prepare( const CorePoints& corePoints,
|
||||
if (field2 && op != Feature::NO_OPERATION)
|
||||
{
|
||||
//include the math operation as well if necessary!
|
||||
resultSFName += "_" + Feature::OpToString(op) + "_" + field2->getName() + "_" + cloud2Label;
|
||||
resultSF1Name += "_" + Feature::OpToString(op) + "_" + field2->getName() + "_" + cloud2Label;
|
||||
if (isScaled)
|
||||
{
|
||||
assert(stat != Feature::NO_STAT);
|
||||
resultSFName += QString("_") + Feature::StatToString(stat);
|
||||
resultSF1Name += QString("_") + Feature::StatToString(stat);
|
||||
}
|
||||
}
|
||||
|
||||
if (isScaled)
|
||||
{
|
||||
resultSFName += "@" + QString::number(scale);
|
||||
resultSF1Name += "@" + QString::number(scale);
|
||||
|
||||
//prepare the corresponding scalar field
|
||||
statSF1WasAlreadyExisting = CheckSFExistence(corePoints.cloud, qPrintable(resultSFName));
|
||||
statSF1WasAlreadyExisting = CheckSFExistence(corePoints.cloud, qPrintable(resultSF1Name));
|
||||
if (statSF1WasAlreadyExisting)
|
||||
{
|
||||
// if the SF is not existing, it is not added to generatedScalarFields
|
||||
statSF1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::ALWAYS_KEEP);
|
||||
// if the SF exists, it is not added to generatedScalarFields
|
||||
statSF1 = PrepareSF(corePoints.cloud, qPrintable(resultSF1Name), generatedScalarFields, SFCollector::ALWAYS_KEEP);
|
||||
if (generatedScalarFields->scalarFields.contains(statSF1)) // i.e. the SF is existing but was not present at the startup of the plugin
|
||||
generatedScalarFields->setBehavior(statSF1, SFCollector::CAN_REMOVE);
|
||||
}
|
||||
else
|
||||
statSF1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::CAN_REMOVE);
|
||||
statSF1 = PrepareSF(corePoints.cloud, qPrintable(resultSF1Name), generatedScalarFields, SFCollector::CAN_REMOVE);
|
||||
if (!statSF1)
|
||||
{
|
||||
error = QString("Failed to prepare scalar field for field '%1' @ scale %2").arg(field1->getName()).arg(scale);
|
||||
@@ -596,15 +596,15 @@ bool PointFeature::prepare( const CorePoints& corePoints,
|
||||
|
||||
if (field2 && op != Feature::NO_OPERATION && !statSF1WasAlreadyExisting) // nothing to do if statSF1 was already there
|
||||
{
|
||||
QString resultSFName2 = field2->getName() + QString("_") + cloud2Label + "_" + Feature::StatToString(stat) + "@" + QString::number(scale);
|
||||
QString resultSF2Name = field2->getName() + QString("_") + cloud2Label + "_" + Feature::StatToString(stat) + "@" + QString::number(scale);
|
||||
//keepStatSF2 = (corePoints.cloud->getScalarFieldIndexByName(qPrintable(resultSFName2)) >= 0); //we remember that the scalar field was already existing!
|
||||
|
||||
assert(!statSF2);
|
||||
statSF2WasAlreadyExisting = CheckSFExistence(corePoints.cloud, qPrintable(resultSFName2));
|
||||
statSF2WasAlreadyExisting = CheckSFExistence(corePoints.cloud, qPrintable(resultSF2Name));
|
||||
if (statSF2WasAlreadyExisting)
|
||||
statSF2 = PrepareSF(corePoints.cloud, qPrintable(resultSFName2), generatedScalarFields, SFCollector::ALWAYS_KEEP);
|
||||
statSF2 = PrepareSF(corePoints.cloud, qPrintable(resultSF2Name), generatedScalarFields, SFCollector::ALWAYS_KEEP);
|
||||
else
|
||||
statSF2 = PrepareSF(corePoints.cloud, qPrintable(resultSFName2), generatedScalarFields, SFCollector::ALWAYS_REMOVE);
|
||||
statSF2 = PrepareSF(corePoints.cloud, qPrintable(resultSF2Name), generatedScalarFields, SFCollector::ALWAYS_REMOVE);
|
||||
if (!statSF2)
|
||||
{
|
||||
error = QString("Failed to prepare scalar field for field '%1' @ scale %2").arg(field2->getName()).arg(scale);
|
||||
@@ -619,7 +619,7 @@ bool PointFeature::prepare( const CorePoints& corePoints,
|
||||
assert(cloud1 == corePoints.cloud || cloud1 == corePoints.origin);
|
||||
|
||||
//retrieve/create a SF to host the result
|
||||
int sfIdx = corePoints.cloud->getScalarFieldIndexByName(qPrintable(resultSFName));
|
||||
int sfIdx = corePoints.cloud->getScalarFieldIndexByName(qPrintable(resultSF1Name));
|
||||
|
||||
CCCoreLib::ScalarField* resultSF = nullptr;
|
||||
if (sfIdx >= 0)
|
||||
@@ -630,7 +630,7 @@ bool PointFeature::prepare( const CorePoints& corePoints,
|
||||
else
|
||||
{
|
||||
//copy the SF1 field
|
||||
resultSF = new ccScalarField(qPrintable(resultSFName));
|
||||
resultSF = new ccScalarField(qPrintable(resultSF1Name));
|
||||
if (!resultSF->resizeSafe(corePoints.cloud->size()))
|
||||
{
|
||||
error = "Not enough memory";
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ ConfusionMatrix::ConfusionMatrix(const std::vector<ScalarType> &actual, const st
|
||||
this->ui->tableWidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
|
||||
QSize tableSize = this->ui->tableWidget->sizeHint();
|
||||
QSize labelSize = this->ui->label->sizeHint();
|
||||
QSize widgetSize = QSize(tableSize.width() + 20, tableSize.height() + 50);
|
||||
QSize widgetSize = QSize(tableSize.width() + 30, tableSize.height() + 50);
|
||||
this->setMinimumSize(widgetSize);
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -604,7 +604,6 @@ void q3DMASCPlugin::doTrainAction()
|
||||
for (size_t i = 0; i < originalFeaturesTest.size(); ++i)
|
||||
{
|
||||
originalFeaturesTest[i].selected = trainDlg.isFeatureSelected(originalFeatures[i].feature->toString());
|
||||
|
||||
//if the feature is selected
|
||||
if (originalFeaturesTest[i].selected)
|
||||
{
|
||||
@@ -625,7 +624,7 @@ void q3DMASCPlugin::doTrainAction()
|
||||
masc::CorePoints corePointsTest;
|
||||
corePointsTest.cloud = corePointsTest.origin = testCloud;
|
||||
corePointsTest.role = mainCloudLabel;
|
||||
if (!masc::Tools::PrepareFeatures(corePointsTest, toPrepareTest, error, &progressDlg, &generatedScalarFieldsTest))
|
||||
if (!masc::Tools::PrepareFeatures(corePointsTest, toPrepareTest, error, &progressDlg, &generatedScalarFieldsTest))
|
||||
{
|
||||
m_app->dispToConsole(error, ccMainAppInterface::ERR_CONSOLE_MESSAGE);
|
||||
generatedScalarFields.releaseSFs(false);
|
||||
|
||||
+19
-15
@@ -299,7 +299,7 @@ static bool CreateFeaturesFromCommand(const QString& command, QString corePoints
|
||||
}
|
||||
else
|
||||
{
|
||||
//read the specific scale index (is it really an index? it looks like a scale value!)
|
||||
//read the specific scale value
|
||||
bool ok = true;
|
||||
feature->scale = scaleStr.mid(2).toDouble(&ok);
|
||||
if (!ok)
|
||||
@@ -427,7 +427,7 @@ static bool CreateFeaturesFromCommand(const QString& command, QString corePoints
|
||||
}
|
||||
else
|
||||
{
|
||||
ccLog::Warning(QString("ContextBasedFeature: you are using the DEPRECATED syntax (for instance, DZ1_SC0_CTX_10 is correct)").arg(token).arg(lineNumber));
|
||||
ccLog::Warning(QString("ContextBasedFeature: you are using the DEPRECATED syntax, the feature should contain only one cloud, as in DZ1_SC0_CTX_10)").arg(token).arg(lineNumber));
|
||||
qSharedPointerCast<ContextBasedFeature>(feature)->ctxClassLabel = classLabel;
|
||||
++i;
|
||||
}
|
||||
@@ -1091,11 +1091,12 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
||||
//build the scaled feature list attached to the second cloud (if any)
|
||||
if (feature->cloud2
|
||||
&& feature->cloud2 != feature->cloud1
|
||||
&& feature->op != Feature::NO_OPERATION
|
||||
&& !static_cast<PointFeature*>(feature.data())->statSF1WasAlreadyExisting) // nothing to compute if the scalar field was already there
|
||||
&& feature->op != Feature::NO_OPERATION)
|
||||
{
|
||||
if (!static_cast<PointFeature*>(feature.data())->statSF2WasAlreadyExisting)
|
||||
if(!static_cast<PointFeature*>(feature.data())->statSF1WasAlreadyExisting) // nothing to compute if the scalar field was already there
|
||||
{
|
||||
if (!static_cast<PointFeature*>(feature.data())->statSF2WasAlreadyExisting)
|
||||
{
|
||||
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
|
||||
++fas.featureCount;
|
||||
fas.pointFeaturesPerScale[feature->scale].push_back(qSharedPointerCast<PointFeature>(feature));
|
||||
@@ -1103,6 +1104,7 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
||||
{
|
||||
fas.scales.push_back(feature->scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1127,17 +1129,19 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
||||
//build the scaled feature list attached to the second cloud (if any)
|
||||
if (feature->cloud2
|
||||
&& feature->cloud2 != feature->cloud1
|
||||
&& feature->op != Feature::NO_OPERATION
|
||||
&& !static_cast<NeighborhoodFeature*>(feature.data())->sf1WasAlreadyExisting) // nothing to compute if the scalar field was already there
|
||||
&& feature->op != Feature::NO_OPERATION)
|
||||
{
|
||||
if (!static_cast<NeighborhoodFeature*>(feature.data())->sf2WasAlreadyExisting)
|
||||
if (!static_cast<NeighborhoodFeature*>(feature.data())->sf1WasAlreadyExisting) // nothing to compute if the scalar field was already there
|
||||
{
|
||||
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
|
||||
fas.neighborhoodFeaturesPerScale[feature->scale].push_back(qSharedPointerCast<NeighborhoodFeature>(feature));
|
||||
++fas.featureCount;
|
||||
if (std::find(fas.scales.begin(), fas.scales.end(), feature->scale) == fas.scales.end())
|
||||
if (!static_cast<NeighborhoodFeature*>(feature.data())->sf2WasAlreadyExisting)
|
||||
{
|
||||
fas.scales.push_back(feature->scale);
|
||||
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
|
||||
fas.neighborhoodFeaturesPerScale[feature->scale].push_back(qSharedPointerCast<NeighborhoodFeature>(feature));
|
||||
++fas.featureCount;
|
||||
if (std::find(fas.scales.begin(), fas.scales.end(), feature->scale) == fas.scales.end())
|
||||
{
|
||||
fas.scales.push_back(feature->scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1357,9 +1361,9 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
} //for each scale
|
||||
|
||||
} //for each scale
|
||||
}
|
||||
|
||||
if (progressCb)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user