Files
q3DMASC/ScalarFieldCollector.cpp
T

63 lines
2.2 KiB
C++
Raw Normal View History

//##########################################################################
//# #
//# CLOUDCOMPARE PLUGIN: q3DMASC #
//# #
//# This program is free software; you can redistribute it and/or modify #
//# it under the terms of the GNU General Public License as published by #
//# the Free Software Foundation; version 2 or later of the License. #
//# #
//# This program is distributed in the hope that it will be useful, #
//# but WITHOUT ANY WARRANTY; without even the implied warranty of #
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
//# GNU General Public License for more details. #
//# #
//# COPYRIGHT: Dimitri Lague / CNRS / UEB #
//# #
//##########################################################################
#include "ScalarFieldCollector.h"
//qCC_db
#include <ccPointCloud.h>
//CCLib
#include <ScalarField.h>
//system
#include <assert.h>
2019-05-03 23:52:33 +02:00
void SFCollector::push(ccPointCloud* cloud, CCLib::ScalarField* sf, Behavior behavior)
{
2019-05-03 23:52:33 +02:00
assert(!scalarFields.contains(sf));
SFDesc desc;
desc.behavior = behavior;
desc.cloud = cloud;
scalarFields[sf] = desc;
}
2019-05-03 23:52:33 +02:00
void SFCollector::releaseSFs(bool keepByDefault)
{
2019-05-03 23:52:33 +02:00
for (Map::iterator it = scalarFields.begin(); it != scalarFields.end(); ++it)
{
2019-05-03 23:52:33 +02:00
const SFDesc& desc = it.value();
if (desc.behavior == ALWAYS_KEEP || (keepByDefault && desc.behavior == CAN_REMOVE))
{
2019-05-03 23:52:33 +02:00
//keep this SF
continue;
}
CCLib::ScalarField* sf = it.key();
int sfIdx = desc.cloud->getScalarFieldIndexByName(sf->getName());
if (sfIdx >= 0)
{
desc.cloud->deleteScalarField(sfIdx);
}
else
{
ccLog::Warning(QString("[SFCollector] Scalar field '%1' can't be found anymore").arg(sf->getName()));
}
}
2019-05-03 23:52:33 +02:00
scalarFields.clear();
}