5 #include "GeoModelKernel/GeometryMap.h" 6 #include "GeoModelKernel/GeoVolumeCursor.h" 17 std::vector<std::string> geometryRegex;
18 std::vector<regex_t *> geometryPreg;
19 std::vector<std::vector<std::string> > pathList;
20 std::vector<PVConstLink> physicalVolumes;
27 GeometryMap::GeometryMap():
32 GeometryMap::~GeometryMap() {
36 void GeometryMap::add(
const std::string &
Path) {
37 std::vector <std::string> pathList;
39 std::string path=Path;
43 size_t end = path.find(
'/',pos);
44 if (end==path.npos)
break;
46 std::string sub0(path,pos,end-pos);
47 pathList.push_back(sub0);
48 std::string sub1(path,end+1,path.npos-end-1);
53 m_c->pathList.push_back(pathList);
55 std::string regex=
"^";
58 size_t end = path.find(
'*',pos);
59 std::string sub(path,pos,end-pos);
61 if (end==path.npos)
break;
64 if (pos==path.npos)
break;
67 m_c->geometryRegex.push_back(regex);
68 regex_t *preg =
new regex_t;
69 regcomp(preg,regex.c_str(),REG_EXTENDED);
70 m_c->geometryPreg.push_back(preg);
76 for (
size_t i=0;i<m_c->pathList.size();i++) {
83 void GeometryMap::Clockwork::finalize(
unsigned int i,
PVConstLink v) {
85 static const size_t NMATCH=11;
86 regmatch_t pmatch[NMATCH];
89 if (lV>pathList[i].size()) {
92 if (lV==pathList[i].size()) {
93 std::string name = v->
getLogVol()->getName();
94 if (regexec((geometryPreg[i]),name.c_str(), NMATCH, pmatch, 0)==0) {
95 physicalVolumes.push_back(v);
114 GeometryMap::Iterator GeometryMap::begin()
const {
115 return m_c->physicalVolumes.begin();
118 GeometryMap::Iterator GeometryMap::end()
const {
119 return m_c->physicalVolumes.end();
PVConstLink getVolume() const
Returns the selected physical volume or nullptr if not found.
Represents a path from one point in the general tree, to the present point.
bool atEnd() const
Check if we are at the last volume.
const GeoLogVol * getLogVol() const
Returns the logical volume.
Smart pointer to physical volume... constant.