CMS 3D CMS Logo

DDNumberingScheme.cc
Go to the documentation of this file.
2 
3 #include <ostream>
4 #include <utility>
5 
8 // Message logger.
10 
12 
13 
15 {
16  // extremely memory consuming & slow.
17 
18  /* - assign a node-number (from 0, ...) to every node in the view
19  - save the node-number in a map, key is the stack of sibling-numbers of the node
20  -> enables node to id calculation (slow O(log(max. node-number))).
21  - save in a std::vector the stack of sibling-numbers; index in the std::vector is the
22  assigned node number -> enables id to node calculation (fast)
23  */
24  typedef std::map<nav_type,int>::iterator m_it;
25 
26  DDExpandedView e = ex;
27  e.reset();
28  bool go = true;
29  int count = 0;
30  while (go) {
31  std::pair<m_it,bool> res = path2id_.insert(std::make_pair(e.navPos(),count));
32  id2path_.push_back(res.first);
33  ++count;
34  go = e.next();
35  }
36 }
37 
38 
40 {
41  // very memory consuming & slow, depending on the amount of nodes
42  // selected by the FilteredView; same algorithm then in ctor above
43  typedef std::map<nav_type,int>::iterator m_it;
44 
45  DDFilteredView f = fv;
46  f.reset();
47  bool go = true;
48  int count = 0;
49  while (go) {
50  std::pair<m_it,bool> res = path2id_.insert(std::make_pair(f.navPos(),count));
51  id2path_.push_back(res.first);
52  ++count;
53  go = f.next();
54  }
55 }
56 
57 
59 { }
60 
61 
63 {
64  return id(e.navPos());
65 }
66 
67 
69 {
70  return id(f.navPos());
71 }
72 
73 
75 {
76  std::map<nav_type,int>::const_iterator it = path2id_.find(n);
77  int result = -1;
78  if (it != path2id_.end())
79  result = it->second;
80  return result;
81 }
82 
83 
85 {
86  return view.goTo(idToNavType(id));
87 }
88 
89 
91 {
92  edm::LogError("DDNumberingScheme") << "DDDefaultNumberingScheme::node(int,DDFilteredView&) NOT IMPLEMENTED!"
93  << std::endl;
94  return view.goTo(idToNavType(id));
95 }
96 
97 
99 {
102  if ( (id>=(int)id2path_.size()) || ( id < 0) )
103  ;
104 
105  else {
106  std::map<nav_type,int>::iterator it = id2path_[pos];
107  result = it->first;
108  }
109  return result;
110 }
111 
bool next()
set current node to the next node in the expanded tree
DDNumberingScheme::nav_type idToNavType(int id) const
virtual int id(const DDExpandedView &) const =0
calculate the id of a given node
virtual bool node(int id, DDExpandedView &view) const
calculate the node given an id
virtual ~DDNumberingScheme()
nav_type navPos() const
return the stack of sibling numbers
uint16_t size_type
Definition: Electron.h:4
std::vector< int > nav_type
nav_type navPos() const
return the stack of sibling numbers which indicates the current position in the DDExpandedView ...
bool goTo(const nav_type &)
virtual int id(const DDExpandedView &) const
calculate the id of a given node
bool next()
set current node to the next node in the filtered tree
double f[11][100]
DDNumberingScheme::nav_type nav_type
void reset()
true, if a call to firstChild() would succeed (current node has at least one child) ...
bool goTo(const nav_type &)
transversed the DDExpandedView according to the given stack of sibling numbers
void reset()
clears the scope and sets the filtered view to its root-node
Provides an exploded view of the detector (tree-view)
DDDefaultNumberingScheme(const DDExpandedView &e)