本文整理汇总了C++中geometry::IComponent_const_sptr::getComponentID方法的典型用法代码示例。如果您正苦于以下问题:C++ IComponent_const_sptr::getComponentID方法的具体用法?C++ IComponent_const_sptr::getComponentID怎么用?C++ IComponent_const_sptr::getComponentID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geometry::IComponent_const_sptr
的用法示例。
在下文中一共展示了IComponent_const_sptr::getComponentID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: componentToDetectors
/** Extract a component's detectors and return it within detectors array
* It is a generalized version of bankToDetectors()
*
* @param componentnames -- vector of component names to process
* @param detectors -- vector of detector ids, which belongs to components
*provided as input.
*/
void LoadMask::componentToDetectors(
const std::vector<std::string> &componentnames,
std::vector<detid_t> &detectors) {
Geometry::Instrument_const_sptr minstrument = m_maskWS->getInstrument();
for (auto &componentname : componentnames) {
g_log.debug() << "Component name = " << componentname << '\n';
// a) get component
Geometry::IComponent_const_sptr component =
minstrument->getComponentByName(componentname);
if (component)
g_log.debug() << "Component ID = " << component->getComponentID() << '\n';
else {
// A non-exiting component. Ignore
g_log.warning() << "Component " << componentname << " does not exist!\n";
continue;
}
// b) component -> component assembly --> children (more than detectors)
boost::shared_ptr<const Geometry::ICompAssembly> asmb =
boost::dynamic_pointer_cast<const Geometry::ICompAssembly>(component);
std::vector<Geometry::IComponent_const_sptr> children;
asmb->getChildren(children, true);
g_log.debug() << "Number of Children = " << children.size() << '\n';
size_t numdets(0);
detid_t id_min(std::numeric_limits<Mantid::detid_t>::max());
detid_t id_max(0);
for (const auto &child : children) {
// c) convert component to detector
Geometry::IDetector_const_sptr det =
boost::dynamic_pointer_cast<const Geometry::IDetector>(child);
if (det) {
detid_t detid = det->getID();
detectors.push_back(detid);
numdets++;
if (detid < id_min)
id_min = detid;
if (detid > id_max)
id_max = detid;
}
}
g_log.debug() << "Number of Detectors in Children = " << numdets
<< " Range = " << id_min << ", " << id_max << '\n';
} // for component
}
示例2: setByComponents
/*
* Convert Componenet -> Detector IDs -> Workspace Indices -> set group ID
*/
void LoadDetectorsGroupingFile::setByComponents() {
// 0. Check
if (!m_instrument) {
std::map<int, std::vector<std::string>>::iterator mapiter;
bool norecord = true;
for (mapiter = m_groupComponentsMap.begin();
mapiter != m_groupComponentsMap.end(); ++mapiter) {
if (mapiter->second.size() > 0) {
g_log.error() << "Instrument is not specified in XML file. "
<< "But tag 'component' is used in XML file for Group "
<< mapiter->first << " It is not allowed" << std::endl;
norecord = false;
break;
}
}
if (!norecord)
throw std::invalid_argument(
"XML definition involving component causes error");
}
// 1. Prepare
const detid2index_map indexmap =
m_groupWS->getDetectorIDToWorkspaceIndexMap(true);
// 2. Set
for (auto &componentMap : m_groupComponentsMap) {
g_log.debug() << "Group ID = " << componentMap.first << " With "
<< componentMap.second.size() << " Components" << std::endl;
for (auto &name : componentMap.second) {
// a) get component
Geometry::IComponent_const_sptr component =
m_instrument->getComponentByName(name);
// b) component -> component assembly --> children (more than detectors)
boost::shared_ptr<const Geometry::ICompAssembly> asmb =
boost::dynamic_pointer_cast<const Geometry::ICompAssembly>(component);
std::vector<Geometry::IComponent_const_sptr> children;
asmb->getChildren(children, true);
g_log.debug() << "Component Name = " << name
<< " Component ID = " << component->getComponentID()
<< "Number of Children = " << children.size() << std::endl;
for (auto child : children) {
// c) convert component to detector
Geometry::IDetector_const_sptr det =
boost::dynamic_pointer_cast<const Geometry::IDetector>(child);
if (det) {
// Component is DETECTOR:
int32_t detid = det->getID();
auto itx = indexmap.find(detid);
if (itx != indexmap.end()) {
size_t wsindex = itx->second;
m_groupWS->dataY(wsindex)[0] = componentMap.first;
} else {
g_log.error() << "Pixel w/ ID = " << detid << " Cannot Be Located"
<< std::endl;
}
} // ENDIF Detector
} // ENDFOR (children of component)
} // ENDFOR (component)
} // ENDFOR GroupID
return;
}