Go to the documentation of this file.00001 #ifndef OPENTISSUE_BVH_BVH_SINGLE_COLLISION_QUERY_H
00002 #define OPENTISSUE_BVH_BVH_SINGLE_COLLISION_QUERY_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 {
00018
00023 template <typename collision_policy>
00024 class SingleCollisionQuery : public collision_policy
00025 {
00026 public:
00027
00037 template<typename coordsys_type,typename bvh_type, typename user_geometry_type,typename results_container>
00038 void run(
00039 coordsys_type const & xform,
00040 bvh_type const & bvh,
00041 user_geometry_type const & geometry,
00042 results_container & results
00043 )
00044 {
00045 typedef typename bvh_type::bv_type bv_type;
00046 typedef typename bvh_type::bv_ptr bv_ptr;
00047 typedef typename bvh_type::bv_ptr_container bv_ptr_container;
00048 typedef typename bvh_type::bv_ptr_iterator bv_ptr_iterator;
00049
00050 reset(results);
00051
00052 bv_ptr_container Q;
00053
00054 bv_ptr root = boost::const_pointer_cast<bv_type>( bvh.root() );
00055
00056 Q.push_back( root );
00057
00058 while ( !Q.empty() )
00059 {
00060 bv_ptr bv( Q.front() ); Q.pop_front();
00061 if( !this->overlap( xform, bv, geometry ) )
00062 continue;
00063 if ( bv->is_leaf() )
00064 {
00065 this->report( xform, bv, geometry, results );
00066 continue;
00067 }
00068 bv_ptr_iterator child = bv->child_ptr_begin();
00069 bv_ptr_iterator end = bv->child_ptr_end();
00070 for(;child!=end;++child)
00071 {
00072 bv_ptr ptr( *child );
00073 Q.push_back( ptr );
00074 }
00075 }
00076 }
00077
00078 };
00079
00080 }
00081 }
00082
00083
00084 #endif