/* solid.h  (Steve Hill)  1.1  3/9/90$ */

/* solid.h
 *
 * Herein we define the structures that represent a solid.
 *
 *
 */

/* solid_join_s, solid_join_t
 *
 * If a solid is the join of two solids, then this structure
 * contains pointers to the left and right operands.
 */

typedef
struct solid_join_s
{
	struct solid_s	*left, *right;
}
solid_join_t;

/* solid_meet_s, solid_meet_t
 *
 * If a solid is the meet of two solids, then this structure
 * contains pointers to the left and right operands.
 */

typedef
struct solid_meet_s
{
	struct solid_s	*left, *right;
}
solid_meet_t;

/* solid_atom_s, solid_atom_t
 *
 * At the leaves of the expression for a solid will be these atomic
 * objects.  Atoms contain all the information necessary to render
 * this solid.  This will include colour and pattern information.
 */

typedef
struct solid_atom_s
{
	quadric_t		*quadric;
	quadric_sort_t		sort;
	surface_t		*surface;
	struct pattern_s	*pattern;
}
solid_atom_t;

/* solid_body_u, solid_body_t
 *
 * The body of a solid structure is a union of the three types
 * of solid: join, meet and atom.
 */

typedef
union solid_body_u
{
	solid_join_t	join;
	solid_meet_t	meet;
	solid_atom_t	atom;
}
solid_body_t;

/* solid_type_t
 *
 * This type serves to identify the type type of solid.
 */

typedef
enum
{
	JOIN, MEET, ATOM
}
solid_type_t;

/* solid_s, solid_t
 *
 * The type of solids comes in three flavours.
 *
 * JOIN - combines two solids such that all points inside both of them
 *        are in the resultant solid.
 *
 * MEET - combines two solids such that only points inside both of them
 *        are in the resultant solid.
 *
 * ATOM - Primitive solid represented by a quadric.  Has surface
 *        properties such as colour and pattern.
 */

typedef
struct solid_s
{
	solid_type_t	type;
	bool_t		bounded;
	struct bbox_s	*bbox;
	solid_body_t	body;
}
solid_t;

#define SolidNull	((solid_t *) NULL)

solid_t		*SolidJoin PROTO((solid_t *, solid_t *)),
		*SolidMeet PROTO((solid_t *, solid_t *)),
		*Solid PROTO((quadric_t *, quadric_sort_t)),
		*SolidNegate PROTO((solid_t *)),
		*SolidPaint PROTO((solid_t *, surface_t *)),
		*SolidPattern PROTO((solid_t *, struct pattern_s *)),
		*SolidBbox PROTO((solid_t *)),
		*SolidCopy PROTO((solid_t *));

void		SolidPrint PROTO((FILE *, solid_t *)),
		PatternCall PROTO((struct solid_s *, point_t *));
