本文整理汇总了C++中mantid::api::MatrixWorkspace_const_sptr::getSpectrumToWorkspaceIndexMap方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixWorkspace_const_sptr::getSpectrumToWorkspaceIndexMap方法的具体用法?C++ MatrixWorkspace_const_sptr::getSpectrumToWorkspaceIndexMap怎么用?C++ MatrixWorkspace_const_sptr::getSpectrumToWorkspaceIndexMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid::api::MatrixWorkspace_const_sptr
的用法示例。
在下文中一共展示了MatrixWorkspace_const_sptr::getSpectrumToWorkspaceIndexMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateSpectraIdIntervals
void MantidWSIndexDialog::generateSpectraIdIntervals()
{
// Get the list of available intervals for each of the workspaces, and then
// present the user with intervals which are the INTERSECTION of each of
// those lists of intervals.
QList<QString>::const_iterator it = m_wsNames.constBegin();
// Cycle through the workspaces ...
for ( ; it != m_wsNames.constEnd(); ++it )
{
Mantid::API::MatrixWorkspace_const_sptr ws = boost::dynamic_pointer_cast<const Mantid::API::MatrixWorkspace>(Mantid::API::AnalysisDataService::Instance().retrieve((*it).toStdString()));
if ( NULL == ws ) continue;
Mantid::spec2index_map * spec2index = ws->getSpectrumToWorkspaceIndexMap();
Mantid::spec2index_map::const_iterator last = spec2index->end();
--last;
Mantid::spec2index_map::const_iterator first = spec2index->begin();
const int startSpectrum = static_cast<int> (first->first);
const int endSpectrum = static_cast<int> (last->first);
const int size = static_cast<int> (spec2index->size());
if(size == (1 + endSpectrum - startSpectrum))
{
// Here we make the assumption (?) that the spectra IDs are sorted, and so
// are a list of ints from startSpectrum to endSpectrum without any gaps.
Interval interval(startSpectrum, endSpectrum);
if(it == m_wsNames.constBegin())
m_spectraIdIntervals.addInterval(interval);
else
m_spectraIdIntervals.setIntervalList(IntervalList::intersect(m_spectraIdIntervals,interval));
}
else
{
// The spectra IDs do not appear to be an uninterrupted list of numbers,
// and so we must go through each one and construct the intervals that way.
// TODO - is this at all feasible for large workspaces, and/or many workspaces?
++last;
for ( ; first != last; ++first)
{
const int spectraId = static_cast<int> (first->first);
Interval interval(spectraId);
if(it == m_wsNames.constBegin())
m_spectraIdIntervals.addInterval(interval);
else
m_spectraIdIntervals.setIntervalList(IntervalList::intersect(m_spectraIdIntervals,interval));
}
}
}
}
示例2: if
QMultiMap<QString,std::set<int> > MantidWSIndexDialog::getPlots() const
{
// Map of workspace names to set of indices to be plotted.
QMultiMap<QString,std::set<int> > plots;
// If the user typed in the wsField ...
if(m_wsIndexChoice.getList().size() > 0)
{
for(int i = 0; i < m_wsNames.size(); i++)
{
std::set<int> intSet = m_wsIndexChoice.getIntSet();
plots.insert(m_wsNames[i],intSet);
}
}
// Else if the user typed in the spectraField ...
else if(m_spectraIdChoice.getList().size() > 0)
{
for(int i = 0; i < m_wsNames.size(); i++)
{
// Convert the spectra choices of the user into workspace indices for us to use.
Mantid::API::MatrixWorkspace_const_sptr ws = boost::dynamic_pointer_cast<const Mantid::API::MatrixWorkspace>(Mantid::API::AnalysisDataService::Instance().retrieve(m_wsNames[i].toStdString()));
if ( NULL == ws ) continue;
Mantid::spec2index_map *spec2index = ws->getSpectrumToWorkspaceIndexMap();
std::set<int> origSet = m_spectraIdChoice.getIntSet();
std::set<int>::iterator it = origSet.begin();
std::set<int> convertedSet;
for( ; it != origSet.end(); ++it)
{
int origInt = (*it);
int convertedInt = static_cast<int>(spec2index->find(origInt)->second);
convertedSet.insert(convertedInt);
}
plots.insert(m_wsNames[i],convertedSet);
}
}
return plots;
}