/*<html><pre>*/
#ifndef V_PPROF_H
#define V_PPROF_H

/*		V_PPROF_H: Gridding and creating profiles of tesselated poly meshes */

/*		TODO : this code must be moved to standalone project. */

/*		Base plane for two-dimensional functions */
#define BASE_XOY            0
#define BASE_XOZ            1
#define BASE_YOZ            2

/*		Lenght of graph_label_t.text */
#define MAX_GRAPH_LABEL     64
/*		Bits of graph_label_t.flags */
#define LF_NOLABEL          1	/*	No label */
#define LF_DIRECTION        2	/*	Text can be in any point of given line */
#define LF_CENTER           4	/*	Text must be aligned at center */

/*		Text label */
typedef struct graph_label_s
{
	vec3_t		dir, center;	/* TODO: convert to use line2_t */
	int			flags;          /* LF_XXX */
	vec_t		elem_size;		/* Dimensions of labeled element */
	vec_t		value;			/* Scalar value to be displayed */
	char		text[MAX_GRAPH_LABEL]; /* Text to be displayed */
}	graph_label_t, *graph_label_p;

/*		Set of polylines */
typedef struct	wirechains_s
{
	int			numvert_total;		/* Total number of vertices */
	int			numchains;			/* Number of polylines */
	vec3_t		*vlist;				/* Vertices */
	int			*numvert;           /* Lengths of polylines */
	int			**clist;            /* Offsets of polylines in 'ilist' */
	int			*ilist;				/* Indices of lines of polylines */
	graph_label_t	*llist;			/* Labels */
}	wirechains_t, *wirechains_p;

/*		Scalars: two- and three-dimensional. */
typedef mvec_t	(V_CALL *planar_func_t)(mvec_t x,mvec_t y);
typedef mvec_t	(V_CALL *spatial_func_t)(mvec_t x,mvec_t y,mvec_t z);

/*		Set of profiles of tesselated polygonal mesh */
typedef struct		patchprofile_s
{
	planar_func_t	planar;			/* == NULL for triangular contour */
	spatial_func_t  spatial;        /* == NULL for general contour */
	int             baseplane;      /* 0 - xOy, 1 - xOz, 2 - yOz */
	vec3_t          base[4];        /* fourth vert not used for triangle */
	vec_t           fmin, fmax;     /* range of function */
	int             splits;         /* number of sets of polylines */
	wirechains_p    *wires;         /* polylines */
	vec_t           *chainvals;     /* function's values on polylines */
}	patchprofile_t, *patchprofile_p;

#ifdef  __cplusplus
extern  "C" {
#endif	/* __cplusplus */
	tripatch_p	V_GLOBAL	ppGridFunction(
		vec_t l,vec_t t,vec_t r,vec_t b,	/* rectangle on base plane */
		int hsplit,int vsplit,				/* number of splits */
		vboolean extinfo,					/* create geom info */
		planar_func_t planar,				/* function to grid */
		int basenum							/* base plane */
		);
	tripatch_p	V_GLOBAL	ppGridSheffePolynom(
		/* triangle on base plane; angle0 specified direction to the
		 * first corner */
		vec3_t center,vec_t radius,vec_t angle0,
		int split,							/* number of splits */
		vboolean extinfo,					/* create geom info */
		/* logical coordinated (pseudo-components) of triangle's corners
		 * to interpolate and use as function's arguments */
		vec3_t *gibbs_abc,
		spatial_func_t sheffe,				/* function to grid */
		int basenum							/* base plane */
		);
	patchprofile_p	V_GLOBAL	ppCreateRectangular(
		vec_t l,vec_t t,vec_t r,vec_t b,
		planar_func_t func,
		int zsplits,						/* number of polylines */
		int baseplane);
	patchprofile_p	V_GLOBAL	ppCreateTriangular(
		vec3_t center,vec_t radius,vec_t angle0,
		vec3_t *gibbs_abc,
		spatial_func_t sheffe,
		int zsplits,						/* number of splits */
		int baseplane);
	void			V_GLOBAL	ppFree(patchprofile_p pp);
#ifdef  __cplusplus
}
#endif	/* __cplusplus */

#endif	/* V_PPROF_H */
/*</pre></html>*/
/*EOF*/
