@@ -188,6 +188,11 @@ class Tree: public TreeBase
188188
189189 static const Index DEPTH = RootNodeType::LEVEL + 1 ;
190190
191+ using Accessor = ValueAccessor<Tree, true >;
192+ using ConstAccessor = ValueAccessor<const Tree, true >;
193+ using UnsafeAccessor = ValueAccessor<Tree, false >;
194+ using ConstUnsafeAccessor = ValueAccessor<const Tree, false >;
195+
191196 // / @brief ValueConverter<T>::Type is the type of a tree having the same
192197 // / hierarchy as this tree but a different value type, T.
193198 // /
@@ -623,6 +628,31 @@ class Tree: public TreeBase
623628 // / Remove all tiles from this tree and all nodes other than the root node.
624629 void clear ();
625630
631+ // / @brief Return an accessor that provides random read and write access
632+ // / to this tree's voxels.
633+ // / @details The accessor is safe in the sense that it is registered with this tree.
634+ Accessor getAccessor ();
635+ // / @brief Return an unsafe accessor that provides random read and write access
636+ // / to this tree's voxels.
637+ // / @details The accessor is unsafe in the sense that it is not registered
638+ // / with this tree's tree. In some rare cases this can give a performance advantage
639+ // / over a registered accessor, but it is unsafe if the tree topology is modified.
640+ // / @warning Only use this method if you're an expert and know the
641+ // / risks of using an unregistered accessor (see tree/ValueAccessor.h)
642+ UnsafeAccessor getUnsafeAccessor ();
643+ // / Return an accessor that provides random read-only access to this tree's voxels.
644+ ConstAccessor getAccessor () const ;
645+ // / Return an accessor that provides random read-only access to this tree's voxels.
646+ ConstAccessor getConstAccessor () const ;
647+ // / @brief Return an unsafe accessor that provides random read-only access
648+ // / to this tree's voxels.
649+ // / @details The accessor is unsafe in the sense that it is not registered
650+ // / with this tree. In some rare cases this can give a performance advantage
651+ // / over a registered accessor, but it is unsafe if the tree topology is modified.
652+ // / @warning Only use this method if you're an expert and know the
653+ // / risks of using an unregistered accessor (see tree/ValueAccessor.h)
654+ ConstUnsafeAccessor getConstUnsafeAccessor ();
655+
626656 // / Clear all registered accessors.
627657 void clearAllAccessors ();
628658
@@ -1318,6 +1348,41 @@ Tree<RootNodeType>::clear()
13181348// //////////////////////////////////////
13191349
13201350
1351+ template <typename RootNodeType>
1352+ typename Tree<RootNodeType>::Accessor
1353+ Tree<RootNodeType>::getAccessor()
1354+ {
1355+ return Accessor (*this );
1356+ }
1357+
1358+ template <typename RootNodeType>
1359+ typename Tree<RootNodeType>::UnsafeAccessor
1360+ Tree<RootNodeType>::getUnsafeAccessor()
1361+ {
1362+ return UnsafeAccessor (*this );
1363+ }
1364+
1365+ template <typename RootNodeType>
1366+ typename Tree<RootNodeType>::ConstAccessor
1367+ Tree<RootNodeType>::getAccessor() const
1368+ {
1369+ return ConstAccessor (*this );
1370+ }
1371+
1372+ template <typename RootNodeType>
1373+ typename Tree<RootNodeType>::ConstAccessor
1374+ Tree<RootNodeType>::getConstAccessor() const
1375+ {
1376+ return ConstAccessor (*this );
1377+ }
1378+
1379+ template <typename RootNodeType>
1380+ typename Tree<RootNodeType>::ConstUnsafeAccessor
1381+ Tree<RootNodeType>::getConstUnsafeAccessor()
1382+ {
1383+ return ConstUnsafeAccessor (*this );
1384+ }
1385+
13211386template <typename RootNodeType>
13221387inline void
13231388Tree<RootNodeType>::attachAccessor(ValueAccessorBase<Tree, true >& accessor) const
0 commit comments