Class documentation of Concepts

Loading...
Searching...
No Matches
tree.hh
Go to the documentation of this file.
1
6#ifndef aglowavTree_hh
7#define aglowavTree_hh
8
9#ifdef __GUNG__
10 #pragma interface
11#endif
12
13#include "basics/exceptions.hh"
14#include "space/space.hh"
15#include "bem/element.hh"
16#include "cluster/tree.hh"
17
18namespace aglowav {
19
20 // **************************************************** One2ManyTreeTraits **
21
24 template<class o2mNode>
26 public:
27 static o2mNode* child(const o2mNode* nd, uint j) {return nd->child(j);}
28 };
29
30 // ********************************************************** One2ManyTree **
31
32 template<class o2mNode>
33 class One2ManyTree;
34
35 template<class o2mNode>
36 inline std::ostream& operator<<(std::ostream& os,
37 const One2ManyTree<o2mNode>& t) {
38 return t.info(os);
39 }
40
41 template<class o2mNode>
44 friend std::ostream& operator<< <>(std::ostream& os,
45 const One2ManyTree<o2mNode>& t);
46
47 public:
50 typedef o2mNode Node;
51
53 virtual ~One2ManyTree() {}
54
56 virtual const o2mNode* root() const = 0;
58 virtual uint nleaf() const = 0;
59
61 virtual std::ostream& info(std::ostream& os) const;
66 void sketch(std::ostream& os, const o2mNode* rt = 0, uint l = 0) const;
67 };
68
69 // ********************************************************** BiTreeTraits **
70
73 template<class Node>
74 class BiTreeTraits : public One2ManyTreeTraits<Node> {
75 public:
77 static Node* lft(const Node* nd) {return nd->lft();}
78 static Node*& lft(Node* nd) {return nd->lft();}
80 static Node* rght(const Node* nd) {return nd->rght();}
81 };
82
83 // **************************************************************** BiTree **
84
87 template<class biNode>
88 class BiTree : public One2ManyTree<biNode> {
89 public:
92
94 virtual const biNode* root() const = 0;
95 };
96
97 // ****************************************************** ClstBiTreeTraits **
98
101 template<class BiClNode>
102 class ClstBiTreeTraits : public BiTreeTraits<BiClNode>,
103 public cluster::TreeTraits<BiClNode> {
104 public:
107
109 static BiClNode* newNode(const concepts::Element<F>& elm,
110 const cluster::BBall<F>& ball, BiClNode* lft) {
111 return new BiClNode(elm, ball, lft);
112 }
114 static BiClNode* newNode(uint idx, BiClNode& lft, BiClNode& rght,
115 const concepts::Real3d& c,
116 concepts::Real r, uint nlf = 0) {
117 return new BiClNode(idx, lft, rght, c, r, nlf);
118 }
119 };
120
121 // ************************************************************ BiClNode00 **
122
123 template<class F>
124 class BiClNode00;
125
126 template<class F>
127 inline std::ostream& operator<<(std::ostream& os, const BiClNode00<F>& nd) {
128 os << "aglowav::BiClNode00(idx = " << nd.index()
129 << ", nleaf = " << nd.nleaf();
130 return os << ", r = " << nd.radius() << ", c = " << nd.center() << ')';
131 }
132
135 template<class F>
138 friend std::ostream& operator<< <> (std::ostream& os,
139 const BiClNode00<F>& nd);
140
141 public:
143 typedef F CF;
144
163 const concepts::Real3d& c, concepts::Real r, uint nleaf = 0);
164
166 BiClNode00<F>* child(uint j) const;
168 BiClNode00<F>* lft() const {return lft_;}
169 BiClNode00<F>*& lft() {return lft_;}
171 BiClNode00<F>* rght() const {return (nlf_) ? ne_.rght : (BiClNode00<F>*)0;}
175 const concepts::Real3d& center() const {return c_;}
177 uint nleaf() const {return nlf_;}
179 concepts::Real radius() const {return r_;}
181 uint index() const {return idx_;}
182
183 private:
185 union NE {
186 BiClNode00<F>* rght;
187 const bem::Constant3d001<F>* elm;
188 };
189
191 BiClNode00<F>* lft_;
193 NE ne_;
195 uint idx_;
197 uint nlf_;
202 };
203
204 template<class F>
205 inline BiClNode00<F>* BiClNode00<F>::child(uint j) const {
206 return (!j) ? lft_ : (nlf_ && j == 1) ? ne_.rght : (BiClNode00<F>*)0;
207 }
208
209 template<class F>
211 return (nlf_) ? (const bem::Constant3d001<F>*)0 : ne_.elm;
212 }
213
214} // namespace aglowav
215
216#endif // aglowavTree_hh
BiClNode00(uint idx, BiClNode00< F > &lft, BiClNode00< F > &rght, const concepts::Real3d &c, concepts::Real r, uint nleaf=0)
BiClNode00< F > * child(uint j) const
j-th child of the node
Definition tree.hh:205
const concepts::Real3d & center() const
Cluster center.
Definition tree.hh:175
F CF
Type of element (Real || Cmplx)
Definition tree.hh:143
BiClNode00< F > * lft() const
Left child of the node.
Definition tree.hh:168
uint nleaf() const
Number of leafs in the subtree of the node.
Definition tree.hh:177
BiClNode00(const concepts::Element< F > &elm, const cluster::BBall< F > &ball, BiClNode00< F > *lft)
concepts::Real radius() const
Cluster radius.
Definition tree.hh:179
const bem::Constant3d001< F > * element() const
Element of the node.
Definition tree.hh:210
BiClNode00< F > * rght() const
Right child of the node.
Definition tree.hh:171
uint index() const
Cluster number.
Definition tree.hh:181
static Node * lft(const Node *nd)
Left node.
Definition tree.hh:77
static Node * rght(const Node *nd)
Right node.
Definition tree.hh:80
virtual const biNode * root() const =0
Root of the tree.
BiTreeTraits< biNode > Traits
How a Node has to behave.
Definition tree.hh:91
cluster::TreeTraits< BiClNode >::F F
Type of element (Real || Cmplx)
Definition tree.hh:106
static BiClNode * newNode(uint idx, BiClNode &lft, BiClNode &rght, const concepts::Real3d &c, concepts::Real r, uint nlf=0)
Constructor of a new node (no leaf)
Definition tree.hh:114
static BiClNode * newNode(const concepts::Element< F > &elm, const cluster::BBall< F > &ball, BiClNode *lft)
Constructor of a new leaf list (next leaf = left child)
Definition tree.hh:109
virtual ~One2ManyTree()
Virtual destructor.
Definition tree.hh:53
One2ManyTreeTraits< o2mNode > Traits
How a Node has to behave.
Definition tree.hh:49
virtual const o2mNode * root() const =0
Root of the tree.
virtual uint nleaf() const =0
Number of leafs.
virtual std::ostream & info(std::ostream &os) const
Information about the tree.
void sketch(std::ostream &os, const o2mNode *rt=0, uint l=0) const
Node::CF F
Field of the node (Real or Cmplx)
Definition tree.hh:255
double Real
Definition typedefs.hh:39