29 #ifndef OCT_NODE_INCLUDED
30 #define OCT_NODE_INCLUDED
33 # pragma GCC system_header
36 #include "allocator.h"
37 #include "binary_node.h"
38 #include "marching_cubes_poisson.h"
47 template<
class NodeData ,
class Real=
float >
53 class AdjacencyCountFunction
59 template<
class NodeAdjacencyFunction>
60 void __processNodeFaces(
OctNode* node,NodeAdjacencyFunction* F,
int cIndex1,
int cIndex2,
int cIndex3,
int cIndex4);
61 template<
class NodeAdjacencyFunction>
62 void __processNodeEdges(
OctNode* node,NodeAdjacencyFunction* F,
int cIndex1,
int cIndex2);
63 template<
class NodeAdjacencyFunction>
64 void __processNodeNodes(
OctNode* node,NodeAdjacencyFunction* F);
65 template<
class NodeAdjacencyFunction>
66 static void __ProcessNodeAdjacentNodes(
int dx,
int dy,
int dz,
OctNode* node1,
int radius1,
OctNode* node2,
int radius2,
int cWidth2,NodeAdjacencyFunction* F);
67 template<
class TerminatingNodeAdjacencyFunction>
68 static void __ProcessTerminatingNodeAdjacentNodes(
int dx,
int dy,
int dz,
OctNode* node1,
int radius1,
OctNode* node2,
int radius2,
int cWidth2,TerminatingNodeAdjacencyFunction* F);
69 template<
class Po
intAdjacencyFunction>
70 static void __ProcessPointAdjacentNodes(
int dx,
int dy,
int dz,
OctNode* node2,
int radius2,
int cWidth2,PointAdjacencyFunction* F);
71 template<
class NodeAdjacencyFunction>
72 static void __ProcessFixedDepthNodeAdjacentNodes(
int dx,
int dy,
int dz,
OctNode* node1,
int radius1,
OctNode* node2,
int radius2,
int cWidth2,
int depth,NodeAdjacencyFunction* F);
73 template<
class NodeAdjacencyFunction>
74 static void __ProcessMaxDepthNodeAdjacentNodes(
int dx,
int dy,
int dz,
OctNode* node1,
int radius1,
OctNode* node2,
int radius2,
int cWidth2,
int depth,NodeAdjacencyFunction* F);
77 static inline int Overlap(
int c1,
int c2,
int c3,
int dWidth);
78 inline static int ChildOverlap(
int dx,
int dy,
int dz,
int d,
int cRadius2);
80 const OctNode* __faceNeighbor(
int dir,
int off)
const;
81 const OctNode* __edgeNeighbor(
int o,
const int i[2],
const int idx[2])
const;
82 OctNode* __faceNeighbor(
int dir,
int off,
int forceChildren);
83 OctNode* __edgeNeighbor(
int o,
const int i[2],
const int idx[2],
int forceChildren);
102 int depth(
void)
const;
103 static inline void DepthAndOffset(
const long long& index,
int&
depth,
int offset[DIMENSION]);
105 static inline int Depth(
const long long& index);
106 static inline void Index(
int depth,
const int offset[3],
short&
d,
short off[DIMENSION]);
112 int nodes(
void)
const;
131 template<
class NodeAdjacencyFunction>
133 template<
class NodeAdjacencyFunction>
135 template<
class NodeAdjacencyFunction>
137 template<
class NodeAdjacencyFunction>
140 template<
class NodeAdjacencyFunction>
142 template<
class NodeAdjacencyFunction>
144 template<
class TerminatingNodeAdjacencyFunction>
146 template<
class TerminatingNodeAdjacencyFunction>
148 template<
class Po
intAdjacencyFunction>
150 template<
class Po
intAdjacencyFunction>
152 template<
class NodeAdjacencyFunction>
154 template<
class NodeAdjacencyFunction>
155 static void ProcessFixedDepthNodeAdjacentNodes(
int dx,
int dy,
int dz,
OctNode* node1,
int radius1,
OctNode* node2,
int radius2,
int width2,
int depth,NodeAdjacencyFunction* F,
int processCurrent=1);
156 template<
class NodeAdjacencyFunction>
158 template<
class NodeAdjacencyFunction>
159 static void ProcessMaxDepthNodeAdjacentNodes(
int dx,
int dy,
int dz,
OctNode* node1,
int radius1,
OctNode* node2,
int radius2,
int width2,
int depth,NodeAdjacencyFunction* F,
int processCurrent=1);
182 template<
class NodeData2>
185 static inline int Overlap2(
const int &depth1,
const int offSet1[DIMENSION],
const Real& multiplier1,
const int &depth2,
const int offSet2[DIMENSION],
const Real& multiplier2);
188 int write(
const char* fileName)
const;
189 int write(FILE* fp)
const;
190 int read(
const char* fileName);
283 #include "octree_poisson.hpp"
This templated class assists in memory allocation and is well suited for instances when it is known t...
ConstNeighbors3 * neighbors
ConstNeighbors3 & getNeighbors(const OctNode *node)
ConstNeighbors3 & getNeighbors(const OctNode *node, int minDepth)
ConstNeighbors5 * neighbors
ConstNeighbors5 & getNeighbors(const OctNode *node)
const OctNode * neighbors[3][3][3]
const OctNode * neighbors[5][5][5]
Neighbors3 & getNeighbors(OctNode *root, Point3D< Real > p, int d)
Neighbors3 & getNeighbors(OctNode *node)
Neighbors3 & setNeighbors(OctNode *root, Point3D< Real > p, int d)
Neighbors3 & setNeighbors(OctNode *node)
Neighbors3 & setNeighbors(OctNode *node, bool flags[3][3][3])
Neighbors5 & setNeighbors(OctNode *node, int xStart=0, int xEnd=5, int yStart=0, int yEnd=5, int zStart=0, int zEnd=5)
Neighbors5 & getNeighbors(OctNode *node)
OctNode * neighbors[3][3][3]
OctNode * neighbors[5][5][5]
int maxDepthLeaves(int maxDepth) const
static const int OffsetShift1
void depthAndOffset(int &depth, int offset[DIMENSION]) const
static void ProcessNodeAdjacentNodes(int dx, int dy, int dz, OctNode *node1, int radius1, OctNode *node2, int radius2, int width2, NodeAdjacencyFunction *F, int processCurrent=1)
static void ProcessNodeAdjacentNodes(int maxDepth, OctNode *node1, int width1, OctNode *node2, int width2, NodeAdjacencyFunction *F, int processCurrent=1)
static void ProcessMaxDepthNodeAdjacentNodes(int dx, int dy, int dz, OctNode *node1, int radius1, OctNode *node2, int radius2, int width2, int depth, NodeAdjacencyFunction *F, int processCurrent=1)
static const int OffsetShift2
static int CompareBackwardDepths(const void *v1, const void *v2)
static int CompareForwardDepths(const void *v1, const void *v2)
const OctNode * prevBranch(const OctNode *current) const
int write(const char *fileName) const
static const int OffsetMask
void processNodeNodes(OctNode *node, NodeAdjacencyFunction *F, int processCurrent=1)
bool isInside(Point3D< Real > p) const
static void ProcessMaxDepthNodeAdjacentNodes(int maxDepth, OctNode *node1, int width1, OctNode *node2, int width2, int depth, NodeAdjacencyFunction *F, int processCurrent=1)
static void DepthAndOffset(const long long &index, int &depth, int offset[DIMENSION])
static void ProcessFixedDepthNodeAdjacentNodes(int dx, int dy, int dz, OctNode *node1, int radius1, OctNode *node2, int radius2, int width2, int depth, NodeAdjacencyFunction *F, int processCurrent=1)
static void CenterAndWidth(const long long &index, Point3D< Real > ¢er, Real &width)
static Allocator< OctNode > internalAllocator
void processNodeEdges(OctNode *node, NodeAdjacencyFunction *F, int eIndex, int processCurrent=1)
static void ProcessTerminatingNodeAdjacentNodes(int dx, int dy, int dz, OctNode *node1, int radius1, OctNode *node2, int radius2, int width2, TerminatingNodeAdjacencyFunction *F, int processCurrent=1)
int read(const char *fileName)
static int Depth(const long long &index)
static int CompareForwardPointerDepths(const void *v1, const void *v2)
OctNode * getNearestLeaf(const Point3D< Real > &p)
static int CornerIndex(const Point3D< Real > ¢er, const Point3D< Real > &p)
static int Overlap2(const int &depth1, const int offSet1[DIMENSION], const Real &multiplier1, const int &depth2, const int offSet2[DIMENSION], const Real &multiplier2)
OctNode * edgeNeighbor(int edgeIndex, int forceChildren=0)
static const int OffsetShift
const OctNode * nextBranch(const OctNode *current) const
static void ProcessPointAdjacentNodes(int maxDepth, const int center1[3], OctNode *node2, int width2, PointAdjacencyFunction *F, int processCurrent=1)
void setFullDepth(int maxDepth)
static void ProcessTerminatingNodeAdjacentNodes(int maxDepth, OctNode *node1, int width1, OctNode *node2, int width2, TerminatingNodeAdjacencyFunction *F, int processCurrent=1)
OctNode & operator=(const OctNode< NodeData2, Real > &node)
const OctNode * nextNode(const OctNode *currentNode=NULL) const
OctNode * cornerNeighbor(int cornerIndex, int forceChildren=0)
static void ProcessPointAdjacentNodes(int dx, int dy, int dz, OctNode *node2, int radius2, int width2, PointAdjacencyFunction *F, int processCurrent=1)
int width(int maxDepth) const
void printLeaves(void) const
void processNodeFaces(OctNode *node, NodeAdjacencyFunction *F, int fIndex, int processCurrent=1)
static int CommonEdge(const OctNode *node1, int eIndex1, const OctNode *node2, int eIndex2)
static void SetAllocator(int blockSize)
const OctNode * root(void) const
static int CompareByDepthAndZIndex(const void *v1, const void *v2)
void centerAndWidth(Point3D< Real > ¢er, Real &width) const
void centerIndex(int maxDepth, int index[DIMENSION]) const
const OctNode * nextLeaf(const OctNode *currentLeaf=NULL) const
static int CompareByDepthAndXYZ(const void *v1, const void *v2)
static void ProcessFixedDepthNodeAdjacentNodes(int maxDepth, OctNode *node1, int width1, OctNode *node2, int width2, int depth, NodeAdjacencyFunction *F, int processCurrent=1)
static int CompareBackwardPointerDepths(const void *v1, const void *v2)
static const int OffsetShift3
static int UseAllocator(void)
static void Index(int depth, const int offset[3], short &d, short off[DIMENSION])
void printRange(void) const
static const int DepthShift
static const int DepthMask
OctNode * faceNeighbor(int faceIndex, int forceChildren=0)
void processNodeCorners(OctNode *node, NodeAdjacencyFunction *F, int cIndex, int processCurrent=1)