[SESI logo]

Prisms Development Toolkit Documentation

Side Effects Software Inc. 1997

Prisms Internal Formats

1. Winged-Edge Format

Some algorithms are better (or only) accomplished using winged-edge representation of the data. The basic elements are vertices, edges, faces and details. WingVertices correspond directly to the PolyPoint structures. WingFaces correspond to Polgons. WingDetail's correspond to PolyDetails. WingEdges are the only structure without a direct correspondence in the libpoly structure. A WingEdge connects two vertices and lies on the edge of one face or between two faces. It contains references to both of the vertices and edges as well as the next and previous edges in each face.

An abstract representation of this is

The core of this representatin is the edge. Each edge points to at least one and at most two faces of which it is a part. Each edge has next and previous pointers for each of the two lists of which it may be a member. And each edge points to two vertices, defining its two endpoints.

In programming terms, the structures look like this (this is include/wing.h):

typedef struct wing_vertex {
    int			flag;	/* flag for defined bits	     */
    char		*sparePointer; /* Program Dependent Data     */
    int			num;	/* Number in linked list of vertices */
    Point		pos;	/* Point coordinates 		     */
    Txtr		txt;	/* Texture Coordinates 		     */
    Color		clr;	/* Color Coordinates		     */
    Vector		nml;	/* Vertex normal		     */
    struct wing_edge	*pedge;	/* Pointer to an Edge using Vertex   */
    struct wing_vertex	*next;	/* Pointer to next vertex in Detail  */
    struct wing_vertex	*prev;	/* Pointer to previous vertex 	     */
} WingVertex, *WingVertexPointer;

typedef struct wing_edge {
    int 		flag;	/* Flag for defined bits	     */
    int 		num;	/* Number in linked list of Edges    */
    char 		*sparePointer; /* Program dependent data     */
    struct wing_vertex 	*vtx1;	/* One end point of edge	     */
    struct wing_vertex 	*vtx2;	/* Other end point of edge	     */
    struct wing_face 	*face1;	/* One Face containing edge	     */
    struct wing_face 	*face2;	/* Other Face containing edge        */
    struct wing_edge 	*face1Next; /* next edge for face1	     */
    struct wing_edge 	*face1Prev; /* previous edge for face1       */
    struct wing_edge 	*face2Next; /* next edge for face2	     */
    struct wing_edge 	*face2Prev; /* previous edge for face2       */
    struct wing_edge 	*next;	/* Next edge in linked list	     */
    struct wing_edge 	*prev;	/* Previous edge in linked list	     */
} WingEdge, *WingEdgePointer;

typedef struct wing_face {
    int			flag;	/* Flag for defined bits	  */
    int			num;	/* Number in linked list of faces */
    char		*sparePointer; /* Program dependent data  */
    Vector		nml;	/* Normal of Face		  */
    float		plane;	/* Plane constant for face	  */
    Color		clr;	/* Color of face		  */
    int			nvtx;	/* Number of Vertices in face	  */
    int			nedge;	/* Number of Edges in face	  */
    struct wing_edge	*pedge;	/* Pointer to first edge in face  */
    struct wing_face	*next;	/* Pointer to next face in Detail */
    struct wing_face	*prev;	/* Pointer to previous face 	  */
} WingFace, *WingFacePointer;

typedef struct wing_detail {
    int			flag;	/* Flag for defined bits	  */
    char		*sparePointer; /* Program dependent data  */
    int			nvtx;	/* Number of Vertices in Detail	  */
    int			nfaces;	/* Number of Faces in Detail	  */
    int			nedges;	/* Number of Edges in Detail	  */
    WingVertexPointer	pvtx;	/* Pointer to first vertex	  */
    WingEdgePointer	pedge;	/* Pointer to first edge	  */
    WingFacePointer	pface;	/* Pointer to first face	  */
    struct wing_detail	*next;	/* Pointer to next Detail	  */
    struct wing_detail	*prev;	/* Pointer to previous Detail	  */
} WingDetail, *WingDetailPointer;

/* extern define of error structure */
extern struct wing_error {
    int type;
    int poly1, poly2, poly3;
    int point1, point2;
} WingError;
Wing Error types are
WINGERR_FAIL
WINGERR_OPPOSE
WINGERR_MULTI
WINGERR_OPEN
WINGERR_DEGEN
WINGERR_HOLE
Some useful macros for running through winged-edge structures are
FOR_ALL_WING_LIST(head,    ptr,  count)
FOR_ALL_WINGFACE(head,     wfp,  nfaces) 
FOR_ALL_WINGEDGES(head,    edgep,nedges)
FOR_ALL_WINGVERTICES(head, wvp,  nvp)
FOR_ALL_WINGPDPS(head,     wdp,  Npd)
The second argument is a pointer to the type being traversed; the pointer starts at head, and visits each item. The third argument is a counter of which is visited for each element.
Tookit Overview
Expression Functions | User Functions | Custom SOPs
Prisms Internal Format | Programmer's Reference
Compiling SOPs | Using sopbuild | SOP Routine Reference
Dynamic SOPs | Prisms Types | Macros
Math Routines | Data Routines | Polygon Routines | Winged-edge Routines

Copyright © 1997 Side Effects Software Inc.
477 Richmond Street West, Toronto, Ontario, Canada M5V 3E7