• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

/home/hauberg/Dokumenter/Capture/humim-tracker-0.1/src/OpenTissue/OpenTissue/collision/bvh/bvh_get_leaf_nodes.h

Go to the documentation of this file.
00001 #ifndef OPENTISSUE_COLLISION_BVH_BVH_GET_LEAF_NODES_H
00002 #define OPENTISSUE_COLLISION_BVH_BVH_GET_LEAF_NODES_H
00003 //
00004 // OpenTissue Template Library
00005 // - A generic toolbox for physics-based modeling and simulation.
00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
00007 //
00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
00009 //
00010 #include <OpenTissue/configuration.h>
00011 
00012 #include <boost/shared_ptr.hpp> //needed for boost::const_pointer_cast
00013 
00014 namespace OpenTissue
00015 {
00016   namespace bvh
00017   {
00018 
00022     template<typename bvh_type,typename bv_ptr_container>
00023     inline void get_leaf_nodes(bvh_type const & bvh,bv_ptr_container & leaves)
00024     {
00025       typedef typename bvh_type::bv_type             bv_type;
00026       typedef typename bvh_type::bv_ptr         bv_ptr;
00027       typedef typename bvh_type::bv_ptr_iterator     bv_ptr_iterator;
00028 
00029       leaves.clear();
00030 
00031       if ( !bvh.root() )
00032         return ;
00033 
00034       bv_ptr root = boost::const_pointer_cast<bv_type>( bvh.root() );
00035 
00036       bv_ptr_container Q;
00037       Q.push_back( root );
00038 
00039       while ( !Q.empty() )
00040       {
00041         bv_ptr  bv( Q.front() ); Q.pop_front();
00042 
00043         if(bv->is_leaf())
00044           leaves.push_back( bv );
00045         else
00046         {
00047           bv_ptr_iterator child = bv->child_ptr_begin();
00048           bv_ptr_iterator end   = bv->child_ptr_end();
00049           for(;child!=end;++child)
00050           {
00051             bv_ptr ptr( *child );
00052             Q.push_back( ptr );
00053           }
00054         }
00055       }
00056     }
00057 
00058   } // namespace bvh
00059 
00060 } // namespace OpenTissue
00061 
00062 // OPENTISSUE_COLLISION_BVH_BVH_GET_LEAF_NODES_H
00063 #endif

Generated on Thu Dec 1 2011 12:50:43 for HUMIM Tracker by  doxygen 1.7.1