Go to the documentation of this file.00001
00002
00003
00004 #ifndef clusterTree03_hh
00005 #define clusterTree03_hh
00006
00007 #include "toolbox/hashMap.hh"
00008 #include "cluster/tree.hh"
00009
00010 namespace cluster {
00011
00012
00013
00018 template<class Node>
00019 class TreeTraits03 : public TreeTraits<Node> {
00020 public:
00021 typedef typename TreeTraits<Node>::F F;
00022
00023 static Node* newNode(const concepts::Element<F>& elm, const BBall<F>& ball,
00024 Node* lnk) {return new Node(elm, ball, lnk);}
00025 static Node* newNode(uint idx, Node& chld, const concepts::Real3d& c,
00026 concepts::Real r, uint nlf = 0) {
00027 return new Node(idx, chld, c, r, nlf);
00028 }
00029
00030 static Node* child(const Node* nd) {return nd->child();}
00031 static Node* link(const Node* nd) {return nd->link();}
00032 static Node*& link(Node* nd) {return nd->link();}
00033 };
00034
00035
00036
00041 template<class Node>
00042 class CebyCenter {
00043 public:
00045 typedef TreeTraits03<Node> Traits;
00046 typedef typename Traits::F F;
00047
00051 inline CebyCenter(uint nvtx);
00052 inline ~CebyCenter() {delete[] vtx_;}
00053
00062 void operator()(const Node* lfset, concepts::Real3d& c, concepts::Real& r,
00063 const concepts::Real3d* (&e)[4], uint& ne);
00064
00065 private:
00066 static concepts::Real eps_;
00068 uint nvtx_;
00070 const concepts::Real3d** vtx_;
00072 __gnu_cxx::hash_map<uint, uint> vtxtag_;
00074 uint tag_;
00075 };
00076
00077 template<class Node>
00078 inline CebyCenter<Node>::CebyCenter(uint nvtx)
00079 : nvtx_(nvtx), vtxtag_(), tag_(0) {
00080 vtx_ = new const concepts::Real3d*[nvtx_];
00081 }
00082
00083
00084
00090 template<class CNode>
00091 class Tree03 : public Tree<CNode> {
00092 public:
00094 typedef TreeTraits03<CNode> Traits;
00095 typedef typename Traits::F F;
00096
00103 Tree03(const concepts::Space<F>& spc, const BBall<F>& ball,
00104 uint nlfmin = 1);
00105 inline ~Tree03() {destructor_(root_); delete root_;}
00106
00108 inline uint nclst() const {return nclst_;}
00110 inline uint nleaf() const {return nlf_;}
00112 inline const CNode* root() const {return root_;}
00113
00119 void sketch(std::ostream& os, const CNode* lnk = 0, uint l = 0);
00120
00121 private:
00123 uint nlfmin_;
00125 uint nlf_;
00127 uint nclst_;
00129 CNode* root_;
00130
00134 CNode* constructor_(CNode* lfset, CebyCenter<CNode>& cby);
00136 void destructor_(CNode* clst);
00138 CNode* concat_(CNode* a, CNode* b);
00139 };
00140
00141 }
00142
00143 #endif // clusterTree03_hh