1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
/* tree.h */
#ifndef TREE_H
#define TREE_H
#include "vector.h"
#include "mol.h"
#define NSUBS 8
#define BODY 0
#define CELL 1
struct node {
// tree structure
node *parent;
node **subs;
// data
int type;
real mass;
vector r;
node(void);
void split(int nsubs = NSUBS);
};
struct body : node {
vector rv;
vector ra;
body(void);
};
struct cell : node {
cell(void);
};
struct tree {
node *root;
int nnode; // number of node
int depth; // tree levels
void print(void);
void print_tree(node *);
};
// Memory allocation wrappers
body * newbody(void);
cell * newcell(void);
#endif /* TREE_H */
|