-1

I have a tree structure like this:

struct TetrahedronStruct {
  int index;
  int region;
  TriangleFaces Faces[4];
  Vertex Vertices[4];
  struct TetrahedronStruct *adjTetrahedrons[4];
};

typedef struct {
  long double Nx, Ny, Nz;
  long double d;
  Vertex V[3];
} TriangleFaces;

typedef struct {
  long double x, y, z;
} Vertex;

How can I flatten the tree to a linear memory array to copy to CUDA device memory?

mrei
  • 121
  • 14
  • I don't know if this is what you are looking for, but try a [Prüfer code](http://en.wikipedia.org/wiki/Pr%C3%BCfer_sequence) and an array of nodes. –  Feb 02 '14 at 20:28
  • @H2CO3 Thanks! I'm gonna look into it. – mrei Feb 02 '14 at 20:31
  • @KerrekSB Not really the same question, but probably the answer to that other post is the question in this one. Do you think I should erase the other post? – mrei Feb 02 '14 at 20:33
  • 1
    @mrei: Either that, or improve it so that it can be answered and erase this one. I haven't looked too closely, but it seems that you're struggling to get the question right rather than have two separate questions, in which case improving one question is better than having two similar ones. – Kerrek SB Feb 02 '14 at 20:41

1 Answers1

0

You create an array of TetrahedronStruct, root is the first element, index 0.

For an index i, the children are located at 4 * i + j, with j in the range [0..4]

galop1n
  • 8,573
  • 22
  • 36