Automatically backup the previous 'Classification' SF (if any)

This commit is contained in:
Daniel Girardeau-Montaut
2019-03-27 16:48:19 +01:00
parent c743f43d92
commit 07a56c63d8
+20 -2
View File
@@ -121,9 +121,27 @@ bool Classifier::classify( const Feature::Source::Set& featureSources,
//look for the classification field
CCLib::ScalarField* classificationSF = GetClassificationSF(cloud);
if (!classificationSF)
if (classificationSF)
{
//create it if necessary
//save previous classification field (if any)
int sfIdx = cloud->getScalarFieldIndexByName("Classification_prev");
if (sfIdx < 0)
cloud->deleteScalarField(sfIdx);
try
{
ccScalarField* classifSFBackup = new ccScalarField(*static_cast<ccScalarField*>(classificationSF));
cloud->addScalarField(classifSFBackup);
}
catch (const std::bad_alloc)
{
ccLog::Warning("Not enough memory to backup the previous classification SF!");
}
}
else
{
//create the classification SF
ccScalarField* _classificationSF = new ccScalarField(LAS_FIELD_NAMES[LAS_CLASSIFICATION]);
if (!_classificationSF->resizeSafe(cloud->size()))
{