mFES - molecular Finite Element Solver  0.4
adtree.h
Go to the documentation of this file.
00001 #include <mystdlib.h>
00002 
00003 
00004 #include <myadt.hpp>
00005 // class DenseMatrix;
00006 #include <gprim.hpp>
00007 
00008 namespace netgen
00009 {
00010 
00011 
00012   /* ******************************* ADTree ******************************* */
00013 
00014 
00015   void ADTree3 :: GetIntersecting (const float * bmin, 
00016                                    const float * bmax,
00017                                    Array<int> & pis) const
00018   {
00019     ArrayMem<ADTreeNode3*,1001> stack(1000);
00020     ArrayMem<int,1001> stackdir(1000);
00021     ADTreeNode3 * node;
00022     int dir, stacks;
00023 
00024     stack.SetSize (1000);
00025     stackdir.SetSize(1000);
00026     pis.SetSize(0);
00027 
00028     stack.Elem(1) = root;
00029     stackdir.Elem(1) = 0;
00030     stacks = 1;
00031 
00032     while (stacks)
00033       {
00034         node = stack.Get(stacks);
00035         dir = stackdir.Get(stacks); 
00036         stacks--;
00037 
00038         if (node->pi != -1)
00039           {
00040             if (node->data[0] >= bmin[0] && node->data[0] <= bmax[0] &&
00041                 node->data[1] >= bmin[1] && node->data[1] <= bmax[1] &&
00042                 node->data[2] >= bmin[2] && node->data[2] <= bmax[2])
00043 
00044               pis.Append (node->pi);
00045           }
00046 
00047 
00048         int ndir = dir+1;
00049         if (ndir == 3)
00050           ndir = 0;
00051 
00052         if (node->left && bmin[dir] <= node->sep)
00053           {
00054             stacks++;
00055             stack.Elem(stacks) = node->left;
00056             stackdir.Elem(stacks) = ndir;
00057           }
00058         if (node->right && bmax[dir] >= node->sep)
00059           {
00060             stacks++;
00061             stack.Elem(stacks) = node->right;
00062             stackdir.Elem(stacks) = ndir;
00063           }
00064       }
00065   }
00066 
00067 }