[SESI logo]

Prisms Development Toolkit Documentation

Side Effects Software Inc. 1997

Programmers Reference Section

Winged-edge Subroutines

Conversion Routines

WingDetail Pointer WingFromPoly(PolyDetail *pdp) Given a PolyDetailPointer, return a WingDetailPointer that references an equivalent detail. The WingDetail will have circular, correctly numbered lists of vertices, edges and faces. The routine will return a null pointer if pdp is NULL, pdp contains open polys, pdp contains more than two polys sharing a single edge, pdp contains two adjacent polys with opposite PolyVertex ordering. The appropriate elements of WingError will be set. PolyDetailPointer WingToPoly(WingDetailPointer wdp) Given a WingDetailPointer, return a PolyDetailPointer that references an equivalent detail. The resulting PolyDetail will have circular, correctly numbered lists of PolyPoints and Polygons. All polygons will be CLOSED and have circular lists of vertices. void WingToPolyF(WingFacePointer wfp, PolyDetailPointer pdp) Convert the given WingFace into a Polygon in the given PolyDetail. Add the PolyPoints for each WingVertex referenced. The PolyDetail will have circular Point and Polygon lists after execution. The polygon will be CLOSED and have a circular list of vertices.

Adding & Deleting Detail

char *WingAlloc(int type) Types are WINGDETAIL, WINGVERTEX, WINGEDGE, WINGFACE. Allocates such an element. Nulls out all pointers and other data, and return a pointer to the element. This routine must be typecast to the appropriate type. int WingAddVertex(WingVertexPointer wvp, WingDetailPointer wdp) Add the given WingVertex to the vertex ring in wdp. Return the vertex number. (On error, -1 is returned.) int WingAddEdge(WingEdgePointer wep, WingDetailPointer wdp) Add the given WingEdge to the edge ring in wdp. Return the edge number. (On error, -1 is returned.) int WingAddFace(WingFacePointer wfp, WingDetailPointer wdp) Add the given WingFace to the face ring in wdp. Return the face number. (On error, -1 is returned.) WingDetailPointer WingFreeDetail(WingDetailPointer wdp) Free the memory allocated to the wing edge structure referenced by wdp. All WingVertices, WingEdges and WingFaces referenced by the structure will also be freed. Returns the value of wdp->next. WingFacePointer WingKillFace(WingFacePointer wfp, WingDetailPointer wdp) Removes the designated WingFace from the WingDetail. Removes all links to the face in the edge list. Any edge that is referenced only by this face is also removed. Edges used by two faces that have this face as face1, will have the information about face2 moved to face1. Returns value of wfp->next.

Cleaning Routines

int WingRenumVtx(WingDetailPointer wdp) Renumbers the vertices in the wdp->pvtx list. Returns number of vertices in the WingDetail. (On error, zero is returned.) int WingRenumEdge(WingDetailPointer wdp) Renumbers the edges in the wdp->pedge list. Returns number of edges in the WingDetail. (On error, zero is returned.) int WingRenumFace(WingDetailPointer wdp) Renumbers the faces in the wdp->pface list. Returns number of faces in the WingDetail. (On error, zero is returned.) int WingNumEdgesF(WingFacePointer wfp) Returns the number of edges used by the given WingFace. int WingNumEdgesV(WingVertexPointer wvp) Returns the number of edges that use the given WingVertex. Returns zero if wvp is null, and -1 if a hole is encountered adjacent the vertex. int WingNumFacesV(WingVertexPointer wvp) Returns the number of faces that use the given WingVertex. Returns zero if wvp is null, and -1 if a hole is encountered adjacent the vertex.

Miscellaneous Routines

WingEdge *WingEdgeAdjVtx(WingVertexPointer wvp, WingEdge *wep) Returns a pointer to the next clockwise edge (from given edge) that uses the given vertex. If a hole is encountered instead of a face clockwise from the given edge, (WingEdge *)0 is returned. WingVertex *WingIntersectPlaneEdge(Vector n, float d, WingEdge *wep) Return a WingVertex at the intersection of the given WingEdge and the plane defined by the Vector n and the pland constant d. Assumes the vertex data has already been classified ABOVE, BELOW or ONPLANE. WingEdge *WingSplitEdge(WingVertex *newV, WingEdge *origE, WingDetail *wdp) Split the given WingEdge at the given WingVertex and replace the edge in the WingDetail wdp with the two new edges. WARNING: This routine calls exit(1) on some error conditions. WingCrease(Vector n, float d, WingDetailPointer srcWdp) Crease the given WingDetail with the plane defined by the Vector n and the plane constant d. Any WingFace that intersects the plane will be split into two faces sharing an edge that lies in the plane. Will mark the vertex, edge and face data ABOVE, BELOW or ONPLANE. WARNING: This routine calls exit(1) on some error conditions.

Debugging Routines

void WingPrintError(void) Prints error messages to stderr based on the contents of WingError. See DIAGNOSTICS below. void WingDump(WingDetail *wdp, int type) Print a ascii dump of the WingDetail data structure on stderr. The type parameter is one of WINGDETAIL, WINGVERTEX, WINGEDGE or WINGFACE, as defined in wing.h. It determines which (or all) of the linked lists is to be dumped. void WingDumpVertex(WingVertex *wvp) Print an ascii dump of the given WingVertex on stderr. void WingDumpEdge(WingEdge *wep) Print an ascii dump of the given WingEdge on stderr. void WingDumpFace(WingFace *wfp) Print an ascii dump of the given WingFace on stderr. WARNING: This routine calls exit(1) on some error conditions.

Diagnostic Messages

If an error occurs while converting from a PolyDetail to a WingDetail, the WingFromPoly routine will return (WingDetail *)0 and set the elements of the WingError buffer accordingly. The client program has the choice of handling the error itself or calling the WingPrintError() routine, to print an appropriate error message to stderr from the contents of WingError. An error can also occur if a hole is encountered while attempting to locate edges and faces adjacent to a vertex. The elements of WingError will be set for specfic errors as follows: Null Poly Detail WingError.type = WINGERR_FAIL No other elements are used. Polygons Sharing Edge have Opposite Ordering WingError.type = WINGERR_OPPOSE WingError.poly1 = number of first Polygon to use the edge. WingError.poly2 = number of 2nd Polygon to use the edge. WingError.point = Number of PolyPoint at one vertex of edge. WingError.point = Number of PolyPoint at other vertex of edge. More Than 2 Faces Per Edge WingError.type = WINGERR_MULTI. WingError.poly1 = number of first Polygon to use the edge. WingError.poly2 = number of 2nd Polygon to use the edge. WingError.poly3 = number of 3rd Polygon to use the edge. WingError.point = Number of PolyPoint at one vertex of edge. WingError.point = Number of PolyPoint at other vertex of edge. Open Polygons WingError.type = WINGERR_OPEN WingError.poly1 = number of first open Polygon encountered. Degenerate Polygons WingError.type = WINGERR_DEGEN WingError.poly1 = number of first degenerate Polygon encountered. Hole Encountered WingError.type = WINGERR_HOLE WingError.poly1 = number of the face next to the hole. WingError.point1 = number of one WingVertex on edge next to hole. WingError.point2 = number of other WingVertex on edge next to hole.

Bugs and Caveats

Has no provisions for saving the edges bounding holes or sheets. Thus is an incomplete topological structure not readily solving the Euler Formula. Holes can cause errors in the WingEdgeAdjVtx(), WingNumEdgesV() and WingNumFacesV() because of the inability to continue the adjacency walk past the hole. The pedge element of a WingVertex can point to any edge that uses the vertex. Care must be taken by client programs deleting edges to keep these pointers correct. Several Routines in the library use the Prev pointers for vertices, edges and faces and the circularity of all lists. Client programs should maintain the validity of these pointers.

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