CMS 3D CMS Logo

DDScope.cc
Go to the documentation of this file.
2 
3 #include <ostream>
4 
6  const DDGeoHistory & right ) const
7 {
9  DDGeoHistory::const_iterator lit = left.begin(); // left-iterator
10  DDGeoHistory::const_iterator rit = right.begin(); // right-iterator
11 
12  while( lit != left.end() && rit != right.end())
13  {
14  if( lit->siblingno() != rit->siblingno())
15  {
16  result = different_branch;
17  break;
18  }
19  ++lit;
20  ++rit;
21  }
22 
23  if( result != different_branch )
24  {
25  if( lit == left.end()) { // left history leaf node marks the root of a subtree which contains
26  result = supertree; // the leaf node of the right history or both roots are the same ...
27  }
28  else
29  {
30  result = subtree;
31  }
32  }
33  return result;
34 }
35 
37  : depth_( 0 )
38 {}
39 
41  : depth_( depth )
42 {
43  subtrees_.push_back( h );
44 }
45 
47 {}
48 
49 bool
51 {
52  bool result = false;
53  scope_type::iterator it = subtrees_.begin();
54  scope_type buf;
55  int supertreeCount = 0;
56  bool diffBranch = false;
57  bool subTree = false;
58 
59  for(; it != subtrees_.end(); ++it )
60  {
61  dd_scope_class classification = classify_( h, *it );
62  switch( classification )
63  {
64  case different_branch:
65  buf.push_back( *it );
66  diffBranch = true;
67  break;
68 
69  case subtree:
70  buf.push_back( *it );
71  subTree = true;
72  break;
73 
74  case supertree:
75  ++supertreeCount;
76  if( supertreeCount == 1 )
77  buf.push_back(h);
78  break;
79 
80  default:
81  break;
82  }
83  }
84 
85  if( diffBranch )
86  {
87  if( subTree == false )
88  {
89  buf.push_back(h);
90  }
91  }
92 
93  if( !subtrees_.size())
94  subtrees_.push_back( h );
95  else
96  subtrees_ = buf;
97 
98  return result;
99 }
100 
101 void
103 {
104  depth_ = d;
105 }
106 
107 int
108 DDScope::depth( void ) const
109 {
110  return depth_;
111 }
112 
113 const DDScope::scope_type &
114 DDScope::scope( void ) const
115 {
116  return subtrees_;
117 }
118 
119 std::ostream & operator<<( std::ostream & os, const DDScope & scope )
120 {
121  DDScope::scope_type::const_iterator it = scope.subtrees_.begin();
122  for(; it != scope.subtrees_.end(); ++ it )
123  {
124  os << *it << std::endl;
125  }
126  return os;
127 }
scope_type subtrees_
Definition: DDScope.h:59
bool addScope(const DDGeoHistory &s)
Adds a scope. No new scope will be added if s is already contained in one of the subtrees.
Definition: DDScope.cc:50
dd_scope_class
Definition: DDScope.h:9
DDScopeClassification classify_
Definition: DDScope.h:60
std::vector< DDGeoHistory > scope_type
Definition: DDScope.h:33
int depth(void) const
return the depth to wich the subtrees are restricted
Definition: DDScope.cc:108
std::vector< DDExpandedNode > DDGeoHistory
Geometrical &#39;path&#39; of the current node up to the root-node.
defines subtrees in the expanded-view
Definition: DDScope.h:28
friend std::ostream & operator<<(std::ostream &, const DDScope &)
Definition: DDScope.cc:119
void setDepth(int)
subtrees of the scope are only transversed down to the given level
Definition: DDScope.cc:102
Definition: DDScope.h:9
dd_scope_class operator()(const DDGeoHistory &, const DDGeoHistory &) const
Definition: DDScope.cc:5
~DDScope(void)
Definition: DDScope.cc:46
DDScope(void)
empty scope
Definition: DDScope.cc:36
int depth_
Definition: DDScope.h:61
const scope_type & scope(void) const
returns the scope container
Definition: DDScope.cc:114