19template<
size_t IndexSize,
int NumDimensions>
30template<
typename Scalar,
typename Index,
int NumDimensions = 3>
48 LeftRight = Left | RightSecond,
49 RightLeft = Left | RightFirst,
90 template<
class BoundsFunctor>
91 bool validateTree(BoundsFunctor &func)
const;
94 const Scalar *
min()
const {
return &(d()->m_bounds)[0]; }
95 Scalar *
max() {
return &(d()->m_bounds)[NumDimensions]; }
96 const Scalar *
max()
const {
return &(d()->m_bounds)[NumDimensions]; }
102 template<
class InnerNodeFunctor,
class ElementFunctor>
103 void traverse(InnerNodeFunctor &visitNode, ElementFunctor &visitElement)
const
105 if (!visitNode.checkBounds(
min(), max()))
107 traverseNode(0, nodes().data(), cells().data(), visitNode, visitElement);
111 template<
class BoundsFunctor>
112 bool validateNode(BoundsFunctor &func,
Index nodenum,
const Vector &
min,
const Vector &max)
const;
113 template<
class InnerNodeFunctor,
class ElementFunctor>
114 bool traverseNode(
Index curNode,
const Node *nodes,
const Index *cells, InnerNodeFunctor &visitNode,
115 ElementFunctor &visitElement)
const
117 const Node &node = nodes[curNode];
119 for (
Index i = node.start; i < node.start + node.size; ++i) {
120 const Index cell = cells[i];
121 if (!visitElement(cell))
127 const typename VisitFunctor::Order order = visitNode(node);
128 assert(!((order & VisitFunctor::RightFirst) && (order & VisitFunctor::RightSecond)));
129 bool continueTraversal =
true;
130 if (continueTraversal && (order & VisitFunctor::RightFirst)) {
131 continueTraversal = traverseNode(node.child + 1, nodes, cells, visitNode, visitElement);
133 if (continueTraversal && (order & VisitFunctor::Left)) {
134 continueTraversal = traverseNode(node.child, nodes, cells, visitNode, visitElement);
136 if (continueTraversal && (order & VisitFunctor::RightSecond)) {
137 continueTraversal = traverseNode(node.child + 1, nodes, cells, visitNode, visitElement);
140 return continueTraversal;
143 template<
class Functor>
144 bool traverseNode(
Index curNode, Functor &func)
const;
147 Scalar m_bounds[NumDimensions * 2];
148 ShmVector<Index> m_cells;
149 ShmVector<Node> m_nodes;
151 static Data *create(
const std::string &name =
"",
const Index numCells = 0,
const Meta &m = Meta());
152 Data(
const std::string &name =
"",
const Index numCells = 0,
const Meta &m = Meta());
Definition: celltree.h:172
virtual Celltree::const_ptr getCelltree() const =0
virtual bool validateCelltree() const =0
vistle::Celltree< Scalar, Index, Dim > Celltree
Definition: celltree.h:174
virtual bool hasCelltree() const =0
compute bounding box of a cell
Definition: celltree.h:78
bool operator()(Index elem, Vector *min, Vector *max)
Definition: celltree.h:80
return whether further cells have to be visited
Definition: celltree.h:69
bool operator()(Index elem)
Definition: celltree.h:71
Definition: celltree.h:40
Order
Definition: celltree.h:42
Order operator()(const Node &node)
return whether and in which order to visit children of a node
Definition: celltree.h:61
bool checkBounds(const Scalar *min, const Scalar *max)
check whether the celltree is within bounds min and max, otherwise no traversal
Definition: celltree.h:53
Definition: celltree.h:31
const shm< Index >::array & cells() const
Definition: celltree.h:100
shm< Index >::array & cells()
Definition: celltree.h:99
const shm< Node >::array & nodes() const
Definition: celltree.h:98
Scalar * min()
Definition: celltree.h:93
VistleScalarVector< NumDimensions >::type Vector
Definition: celltree.h:37
const Scalar * min() const
Definition: celltree.h:94
const Scalar * max() const
Definition: celltree.h:96
shm< Node >::array & nodes()
Definition: celltree.h:97
Object Base
Definition: celltree.h:35
Scalar * max()
Definition: celltree.h:95
void traverse(InnerNodeFunctor &visitNode, ElementFunctor &visitElement) const
Definition: celltree.h:103
Definition: geometry.h:23
std::shared_ptr< const Object > const_ptr
Definition: object.h:68
Definition: shm_array.h:19
#define V_COREEXPORT
Definition: export.h:9
static T min(T a, T b)
Definition: messages.cpp:28
Definition: allobjects.cpp:30
Celltree< Scalar, Index, 2 > Celltree2
Definition: celltree.h:159
Vector3 Vector
Definition: vector.h:36
float Scalar
Definition: scalar.h:14
Celltree< Scalar, Index, 3 > Celltree3
Definition: celltree.h:162
Eigen::Matrix< Scalar, d, 1 > type
Definition: vector.h:28
Celltree< Scalar, Index, 1 > Celltree1
Definition: celltree.h:156
uint32_t Index
Definition: index.h:13
Definition: celltree.h:20
#define V_DATA_BEGIN(ObjType)
Definition: object.h:474
#define V_DATA_END(ObjType)
Definition: object.h:481
#define V_OBJECT(ObjType)
declare a new Object type
Definition: object.h:381
#define V_DECLARE_SHMREF(T)
Definition: shm_reference.h:206