10 #include <boost/shared_ptr.hpp>
11 #include <boost/weak_ptr.hpp>
12 #include <boost/enable_shared_from_this.hpp>
35 template <
typename Tree>
38 typedef boost::shared_ptr<Tree>
Ptr;
43 template <
typename Tree>
46 typedef boost::weak_ptr<Tree>
Ptr;
67 unsigned int Dimensions = 3,
70 typename BoundsType =
double
73 :
public boost::enable_shared_from_this< DtNTree<T,Dimensions,Mutex,SubcellTraits,BoundsType> >
77 template <
unsigned int A,
unsigned int B>
82 template <
unsigned int A>
85 static const unsigned int value = 1;
93 static boost::shared_ptr<Z>
Get(
const boost::shared_ptr<Z>& p) {
return p ;}
96 static boost::shared_ptr<Z>
Get(
const boost::weak_ptr<Z>& p) {
return p.lock(); }
99 static void Set(boost::shared_ptr<Z>& p,
const boost::shared_ptr<Z>& to) { p = to; }
101 template <
typename Z>
102 static void Set(boost::shared_ptr<Z>& p,
const boost::weak_ptr<Z>& to) { p = to.lock(); }
104 template <
typename Z>
105 static void Set(boost::weak_ptr<Z>& p,
const boost::shared_ptr<Z>& to) { p = to; }
107 template <
typename Z>
108 static void Set(boost::weak_ptr<Z>& p,
const boost::weak_ptr<Z>& to) { p = to; }
111 typedef typename SubcellTraits<DtNTree>::Ptr
Ptr;
112 typedef typename SubcellTraits<DtNTree>::ParentPtr
ParentPtr;
126 :
minimum(std::numeric_limits<BoundsType>::min())
127 ,
maximum(std::numeric_limits<BoundsType>::max()) { }
130 Range(BoundsType min, BoundsType max)
161 for (
unsigned int bit=1, d=0; d < Dimensions; ++d, bit=bit<<1)
188 for (
unsigned int d=0; d < Dimensions; ++d)
199 for (
unsigned int d=0; d < Dimensions; ++d)
231 boost::shared_ptr<DtNTree> child;
234 typename Mutex::scoped_lock lock(
myMutex,
false);
244 return boost::shared_ptr<DtNTree>();
249 if (!lock.upgrade_to_writer())
286 return boost::shared_ptr<DtNTree>(
new DtNTree(bounds, 0));
309 :
myParent(parent.shared_from_this())
335 return boost::shared_ptr<DtNTree>(
new DtNTree(*
this, cell.
bounds()));
398 unsigned int Dimensions,
400 template <
typename>
class SubcellPolicy,
413 virtual bool matches(
const Subcell& cell) = 0;
418 virtual bool shouldCreateSubcell(
const Subcell& cell) = 0;