Go to the documentation of this file.00001 #ifndef OPENTISSUE_COLLISION_BVH_BVH_GET_ALL_NODES_H
00002 #define OPENTISSUE_COLLISION_BVH_BVH_GET_ALL_NODES_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <boost/shared_ptr.hpp>
00013
00014 namespace OpenTissue
00015 {
00016 namespace bvh
00017 {
00021 template<typename bvh_type,typename bv_ptr_container>
00022 inline void get_all_nodes(bvh_type const & bvh,bv_ptr_container & nodes)
00023 {
00024 typedef typename bvh_type::bv_type bv_type;
00025 typedef typename bvh_type::bv_ptr bv_ptr;
00026 typedef typename bvh_type::bv_ptr_iterator bv_ptr_iterator;
00027
00028 nodes.clear();
00029
00030 if ( !bvh.root() )
00031 return ;
00032
00033 bv_ptr root = boost::const_pointer_cast<bv_type>( bvh.root() );
00034
00035 nodes.push_back( root );
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 bv_ptr_iterator child = bv->child_ptr_begin();
00043 bv_ptr_iterator end = bv->child_ptr_end();
00044 for(;child!=end;++child)
00045 {
00046 bv_ptr ptr( *child );
00047 nodes.push_back( ptr );
00048 Q.push_back( ptr );
00049 }
00050 }
00051 }
00052
00053 }
00054
00055 }
00056
00057
00058 #endif