Octree< Content, GivenDimension >::__SubTree Class Reference

Inheritance diagram for Octree< Content, GivenDimension >::__SubTree:

Inheritance graph
[legend]
Collaboration diagram for Octree< Content, GivenDimension >::__SubTree:

Collaboration graph
[legend]

List of all members.

Public Types

enum  Type { subtree, leaf }

Public Member Functions

__Nodenode (const size_t i)
const __Node::Type type () const
Octree< Content, Dimension >
::iterator
fuzzySearch (const TinyVector< Dimension, real_t > &X, const TinyVector< Dimension, real_t > &center, const real_t size, typename Octree< Content, Dimension >::iterator &cell)
void addLeaf (const TinyVector< Dimension, real_t > &center, const real_t s, __Leaf *l)
iterator begin ()
 __SubTree ()
 __SubTree (const __SubTree &s)
 ~__SubTree ()

Private Attributes

TinyVector< StaticPow
< 2, Dimension >::value,
__Node * > 
__nodes


Detailed Description

template<typename Content, size_t GivenDimension>
class Octree< Content, GivenDimension >::__SubTree

Definition at line 123 of file Octree.hpp.


Member Enumeration Documentation

template<typename Content, size_t GivenDimension>
enum Octree::__Node::Type [inherited]

Enumerator:
subtree 
leaf 

Definition at line 47 of file Octree.hpp.

00047               {
00048       subtree,
00049       leaf
00050     };


Constructor & Destructor Documentation

template<typename Content, size_t GivenDimension>
Octree< Content, GivenDimension >::__SubTree::__SubTree (  )  [inline]

Definition at line 229 of file Octree.hpp.

Referenced by Octree< Content, GivenDimension >::__SubTree::addLeaf().

00230       : __nodes(0)
00231     {
00232       ;
00233     }

template<typename Content, size_t GivenDimension>
Octree< Content, GivenDimension >::__SubTree::__SubTree ( const __SubTree s  )  [inline]

Definition at line 235 of file Octree.hpp.

00236       : __Node(s),
00237         __nodes(s)
00238     {
00239       ;
00240     }

template<typename Content, size_t GivenDimension>
Octree< Content, GivenDimension >::__SubTree::~__SubTree (  )  [inline]

Definition at line 242 of file Octree.hpp.

00243     {
00244       ;
00245     }


Member Function Documentation

template<typename Content, size_t GivenDimension>
__Node* Octree< Content, GivenDimension >::__SubTree::node ( const size_t  i  )  [inline]

Definition at line 131 of file Octree.hpp.

References Octree< Content, GivenDimension >::__SubTree::__nodes.

Referenced by Octree< Content, GivenDimension >::iterator::operator++().

00132     {
00133       return __nodes[i];
00134     }

template<typename Content, size_t GivenDimension>
const __Node::Type Octree< Content, GivenDimension >::__SubTree::type (  )  const [inline, virtual]

Implements Octree< Content, GivenDimension >::__Node.

Definition at line 136 of file Octree.hpp.

References Octree< Content, GivenDimension >::__Node::subtree.

00137     {
00138       return __Node::subtree;
00139     }

template<typename Content, size_t GivenDimension>
Octree<Content, Dimension>::iterator& Octree< Content, GivenDimension >::__SubTree::fuzzySearch ( const TinyVector< Dimension, real_t > &  X,
const TinyVector< Dimension, real_t > &  center,
const real_t  size,
typename Octree< Content, Dimension >::iterator cell 
) [inline]

if no cell is found there, it is bad ... But there is at least one cell in this subtree which contains a leaf. To ensure the returned iterator is not to far, the local number is reset so that the complet tree is candidate.

Definition at line 142 of file Octree.hpp.

References Octree< Content, GivenDimension >::__SubTree::__nodes, Octree< Content, GivenDimension >::Dimension, and Octree< Content, GivenDimension >::__Node::subtree.

00146     {
00147       int num=0;
00148       TinyVector<Dimension,int> I;
00149 
00150       for (size_t i=0; i<Dimension; ++i) {
00151         I[i] = (X[i]>center[i]);
00152         num += (I[i] << (Dimension-1-i));
00153       }
00154 
00155       cell.addAddress(this);
00156       cell.localNumber() = num;
00157 
00158       if (__nodes[num]==0) {
00166         cell.localNumber() = -1;        
00167         cell++;
00168       } else {
00169         double newS = 0.5*size;
00170 
00171         TinyVector<Dimension> newCenter = center;
00172         for (size_t i=0; i<Dimension; ++i) {
00173           newCenter[i] += (I[i]*2-1)*newS;
00174         }
00175 
00176         if ((*__nodes[num]).type() ==  __Node::subtree) {
00177           (static_cast<__SubTree&>(*__nodes[num])).fuzzySearch(X,newCenter,newS,cell);
00178         } else {
00179           cell.__leaf = static_cast<__Leaf*>(__nodes[num]);
00180         }
00181       }
00182 
00183       return cell;
00184     }

template<typename Content, size_t GivenDimension>
void Octree< Content, GivenDimension >::__SubTree::addLeaf ( const TinyVector< Dimension, real_t > &  center,
const real_t  s,
__Leaf l 
) [inline]

Definition at line 186 of file Octree.hpp.

References Octree< Content, GivenDimension >::__SubTree::__nodes, Octree< Content, GivenDimension >::__SubTree::__SubTree(), Octree< Content, GivenDimension >::__SubTree::addLeaf(), Octree< Content, GivenDimension >::Dimension, and Octree< Content, GivenDimension >::__Node::subtree.

Referenced by Octree< Content, GivenDimension >::__SubTree::addLeaf().

00189     {
00190       int num=0;
00191       TinyVector<Dimension,int> I;
00192 
00193       for (size_t i=0; i<Dimension; ++i) {
00194         I[i] = ((*l).position()[i]>center[i]);
00195 
00196         num += (I[i] << (Dimension-1-i));
00197       }
00198 
00199       if (__nodes[num]==0) {
00200         __nodes[num] = l;
00201       } else {
00202         double newS = 0.5*s;
00203 
00204         TinyVector<Dimension> newCenter = center;
00205         for (size_t i=0; i<Dimension; ++i) {
00206           newCenter[i] += (I[i]*2-1)*newS;
00207         }
00208 
00209         if ((*__nodes[num]).type() ==  __Node::subtree) {
00210           (static_cast<__SubTree&>(*__nodes[num])).addLeaf(newCenter,newS,l);
00211         } else {
00212           __Leaf* oldleaf=static_cast<__Leaf*>(__nodes[num]);
00213           __SubTree* s =new __SubTree();
00214           __nodes[num]=s;
00215           s->addLeaf(newCenter, newS, l);
00216           s->addLeaf(newCenter, newS, oldleaf);
00217         }
00218       }
00219     }

Here is the call graph for this function:

template<typename Content, size_t GivenDimension>
iterator Octree< Content, GivenDimension >::__SubTree::begin (  )  [inline]

Definition at line 221 of file Octree.hpp.

References Octree< Content, GivenDimension >::iterator::addAddress().

00222     {
00223       iterator i;
00224       i.addAddress(this);
00225       i++;
00226       return i;
00227     }

Here is the call graph for this function:


Member Data Documentation

template<typename Content, size_t GivenDimension>
TinyVector<StaticPow<2,Dimension>::value, __Node*> Octree< Content, GivenDimension >::__SubTree::__nodes [private]


The documentation for this class was generated from the following file:

Generated on Wed Nov 19 00:10:43 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6