本文整理汇总了C++中FactoryResource::applyToDynamicObject方法的典型用法代码示例。如果您正苦于以下问题:C++ FactoryResource::applyToDynamicObject方法的具体用法?C++ FactoryResource::applyToDynamicObject怎么用?C++ FactoryResource::applyToDynamicObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FactoryResource
的用法示例。
在下文中一共展示了FactoryResource::applyToDynamicObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateResampledLibrary
//.........这里部分代码省略.........
unsuitableSignatures.push_back((*it)->getName());
continue;
}
resampledData.push_back(resampledValues);
resampledSignatures.push_back(*it);
}
if (resampledSignatures.empty())
{
std::string errMsg = "None of the signatures in the library cover the spectral range of the data.";
if (mpProgress != NULL)
{
mpProgress->updateProgress(errMsg, 0, ERRORS);
return false;
}
}
if (unsuitableSignatures.empty() == false)
{
std::string warningMsg = "The following library signatures do not cover the spectral range of the data:\n";
for (std::vector<std::string>::iterator it = unsuitableSignatures.begin();
it != unsuitableSignatures.end(); ++it)
{
warningMsg += *it + "\n";
}
warningMsg += "These signatures will not be searched for in the data.";
Service<DesktopServices>()->showMessageBox("SpectralLibraryManager", warningMsg);
StepResource pStep("Spectral LibraryManager", "spectral", "64B6C87A-A6C3-4378-9B6E-221D89D8707B");
pStep->finalize(Message::Unresolved, warningMsg);
}
std::string libName = "Resampled Spectral Library";
// Try to get the resampled lib element in case session was restored. If NULL, create a new raster element with
// num rows = num valid signatures, num cols = 1, num bands = pRaster num bands
RasterElement* pLib = dynamic_cast<RasterElement*>(Service<ModelServices>()->getElement(libName,
TypeConverter::toString<RasterElement>(), pRaster));
if (pLib != NULL)
{
// check that pLib has same number of sigs as SpectralLibraryManager
RasterDataDescriptor* pLibDesc = dynamic_cast<RasterDataDescriptor*>(pLib->getDataDescriptor());
VERIFY(pLibDesc != NULL);
if (pLibDesc->getRowCount() != mSignatures.size())
{
mpProgress->updateProgress("An error occurred during session restore and some signatures were not restored."
" Check the spectral library before using.", 0, ERRORS);
Service<ModelServices>()->destroyElement(pLib);
pLib = NULL;
}
}
bool isNewElement(false);
if (pLib == NULL)
{
pLib = RasterUtilities::createRasterElement(libName,
static_cast<unsigned int>(resampledData.size()), 1, pDesc->getBandCount(), FLT8BYTES, BIP,
true, const_cast<RasterElement*>(pRaster));
isNewElement = true;
}
if (pLib == NULL)
{
mpProgress->updateProgress("Error occurred while trying to create the resampled spectral library", 0, ERRORS);
return false;
}
RasterDataDescriptor* pLibDesc = dynamic_cast<RasterDataDescriptor*>(pLib->getDataDescriptor());
VERIFY(pLibDesc != NULL);
// copy resampled data into new element
if (isNewElement)
{
FactoryResource<DataRequest> pRequest;
pRequest->setWritable(true);
pRequest->setRows(pLibDesc->getActiveRow(0), pLibDesc->getActiveRow(pLibDesc->getRowCount()-1), 1);
DataAccessor acc = pLib->getDataAccessor(pRequest.release());
for (std::vector<std::vector<double> >::iterator sit = resampledData.begin(); sit != resampledData.end(); ++sit)
{
VERIFY(acc->isValid());
void* pData = acc->getColumn();
memcpy(acc->getColumn(), &(sit->begin()[0]), pLibDesc->getBandCount() * sizeof(double));
acc->nextRow();
}
// set wavelength info in resampled library
pWavelengths->applyToDynamicObject(pLib->getMetadata());
FactoryResource<Units> libUnits;
libUnits->setUnitType(mLibraryUnitType);
libUnits->setUnitName(StringUtilities::toDisplayString<UnitType>(mLibraryUnitType));
pLibDesc->setUnits(libUnits.get());
}
pLib->attach(SIGNAL_NAME(Subject, Deleted), Slot(this, &SpectralLibraryManager::resampledElementDeleted));
mLibraries[pRaster] = pLib;
mResampledSignatures[pLib] = resampledSignatures;
const_cast<RasterElement*>(pRaster)->attach(SIGNAL_NAME(Subject, Deleted),
Slot(this, &SpectralLibraryManager::elementDeleted));
return true;
}