mirror of
https://github.com/dgirardeau/q3DMASC.git
synced 2026-08-29 16:40:49 +08:00
useExistingScalarFields implementation
This commit is contained in:
+21
-5
@@ -72,7 +72,8 @@ bool ContextBasedFeature::checkValidity(QString corePointRole, QString &error) c
|
||||
bool ContextBasedFeature::prepare( const CorePoints& corePoints,
|
||||
QString& errorMessage,
|
||||
CCCoreLib::GenericProgressCallback* progressCb/*=nullptr*/,
|
||||
SFCollector* generatedScalarFields/*=nullptr*/)
|
||||
SFCollector* generatedScalarFields/*=nullptr*/,
|
||||
bool useExistingScalarFields /*=false*/)
|
||||
{
|
||||
if (!cloud1 || !corePoints.cloud)
|
||||
{
|
||||
@@ -117,9 +118,24 @@ bool ContextBasedFeature::prepare( const CorePoints& corePoints,
|
||||
resultSFName += "@kNN=" + QString::number(kNN);
|
||||
}
|
||||
|
||||
//and the scalar field
|
||||
assert(!sf);
|
||||
sf = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::CAN_REMOVE);
|
||||
// check if there exists a scalar field with the same name
|
||||
int sfIdx = corePoints.cloud->getScalarFieldIndexByName(qPrintable(resultSFName));
|
||||
if (sfIdx >= 0)
|
||||
{
|
||||
if (useExistingScalarFields)
|
||||
{
|
||||
ccLog::Warning("use existing scalar field: " + resultSFName);
|
||||
sf = corePoints.cloud->getScalarField(sfIdx);
|
||||
generatedScalarFields->push(corePoints.cloud, sf, SFCollector::ALWAYS_KEEP);
|
||||
this->valueAlreadyComputed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(!sf);
|
||||
sf = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::CAN_REMOVE);
|
||||
}
|
||||
|
||||
if (!sf)
|
||||
{
|
||||
errorMessage = QString("Failed to prepare scalar %1 @ scale %2").arg(resultSFName).arg(scale);
|
||||
@@ -127,7 +143,7 @@ bool ContextBasedFeature::prepare( const CorePoints& corePoints,
|
||||
}
|
||||
source.name = sf->getName();
|
||||
|
||||
if (!scaled()) //with 'kNN' neighbors, we can compute the values right away
|
||||
if (!scaled() && !this->valueAlreadyComputed) //with 'kNN' neighbors, we can compute the values right away (skip if value is already computed)
|
||||
{
|
||||
unsigned pointCount = corePoints.size();
|
||||
QString logMessage = QString("Computing %1 on cloud %2 with context cloud %3\n(core points: %4)").arg(typeStr).arg(corePoints.cloud->getName()).arg(cloud2Label).arg(pointCount);
|
||||
|
||||
Reference in New Issue
Block a user