M
Mark Mackey
Hi all.
I've got a rather complicated circular type definition, and would
appreciate help getting it sorted out
. Cut-down code below :
8<--------------------------------------------------------
typedef enum { SOLID, NEARESTATOM } surfcoloropt;
typedef float (*FunctionCalc)(MOLECULE *, float, int *, int *, surfcoloropt, unsigned char[4]);
/* Defines a rectangle in 3D space. We store the central point c
* the u and v axes, the number of grid points in the u and v
* directions. Note that the grid
* goes from -nu to +nu, so the total size is (2*nu+1)*(2*nv+1) points.
* Likewise, the extent of the plane in 3D is (c-u-v) to (c+u+v);
*/
struct planestruct {
int nu, nv;
p3 c,u,v;
struct planeoptionstruct *options;
struct planestruct *next;
struct planestruct *prev;
};
typedef struct planestruct PLANE;
typedef struct planeoptionstruct {
float probesize;
float clipmax,clipmin;
FunctionCalc *calc;
} PLANEOPTS;
typedef struct molstr {
//blah
//lots more blah
PLANE *plane
} MOLECULE;
8<--------------------------------------------------------
So, a MOLECULE contains a PLANE, which contains a PLANEOPTS, which
contains a FunctionCalc pointer, which takes a MOLECULE * as one
of its arguments. Is there an easy way of sorting this lot out? I can
do circular references for structs, but this one involving a function
has me confused.
I've got a rather complicated circular type definition, and would
appreciate help getting it sorted out
8<--------------------------------------------------------
typedef enum { SOLID, NEARESTATOM } surfcoloropt;
typedef float (*FunctionCalc)(MOLECULE *, float, int *, int *, surfcoloropt, unsigned char[4]);
/* Defines a rectangle in 3D space. We store the central point c
* the u and v axes, the number of grid points in the u and v
* directions. Note that the grid
* goes from -nu to +nu, so the total size is (2*nu+1)*(2*nv+1) points.
* Likewise, the extent of the plane in 3D is (c-u-v) to (c+u+v);
*/
struct planestruct {
int nu, nv;
p3 c,u,v;
struct planeoptionstruct *options;
struct planestruct *next;
struct planestruct *prev;
};
typedef struct planestruct PLANE;
typedef struct planeoptionstruct {
float probesize;
float clipmax,clipmin;
FunctionCalc *calc;
} PLANEOPTS;
typedef struct molstr {
//blah
//lots more blah
PLANE *plane
} MOLECULE;
8<--------------------------------------------------------
So, a MOLECULE contains a PLANE, which contains a PLANEOPTS, which
contains a FunctionCalc pointer, which takes a MOLECULE * as one
of its arguments. Is there an easy way of sorting this lot out? I can
do circular references for structs, but this one involving a function
has me confused.