ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

mesh.h
Go to the documentation of this file.
00001 /*
00002 ** License Applicability. Except to the extent portions of this file are
00003 ** made subject to an alternative license as permitted in the SGI Free
00004 ** Software License B, Version 1.1 (the "License"), the contents of this
00005 ** file are subject only to the provisions of the License. You may not use
00006 ** this file except in compliance with the License. You may obtain a copy
00007 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
00008 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
00009 **
00010 ** http://oss.sgi.com/projects/FreeB
00011 **
00012 ** Note that, as provided in the License, the Software is distributed on an
00013 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
00014 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
00015 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
00016 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
00017 **
00018 ** Original Code. The Original Code is: OpenGL Sample Implementation,
00019 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
00020 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
00021 ** Copyright in any portions created by third parties is as indicated
00022 ** elsewhere herein. All Rights Reserved.
00023 **
00024 ** Additional Notice Provisions: The application programming interfaces
00025 ** established by SGI in conjunction with the Original Code are The
00026 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
00027 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
00028 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
00029 ** Window System(R) (Version 1.3), released October 19, 1998. This software
00030 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
00031 ** published by SGI, but has not been independently verified as being
00032 ** compliant with the OpenGL(R) version 1.2.1 Specification.
00033 **
00034 */
00035 /*
00036 ** Author: Eric Veach, July 1994.
00037 **
00038 ** $Date: 2007-10-19 23:21:45 +0000 (Fri, 19 Oct 2007) $ $Revision: 1.1 $
00039 ** $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libtess/mesh.h,v 1.1 2004/02/02 16:39:15 navaraf Exp $
00040 */
00041 
00042 #ifndef __mesh_h_
00043 #define __mesh_h_
00044 
00045 #include <GL/glu.h>
00046 
00047 typedef struct GLUmesh GLUmesh;
00048 
00049 typedef struct GLUvertex GLUvertex;
00050 typedef struct GLUface GLUface;
00051 typedef struct GLUhalfEdge GLUhalfEdge;
00052 
00053 typedef struct ActiveRegion ActiveRegion;   /* Internal data */
00054 
00055 /* The mesh structure is similar in spirit, notation, and operations
00056  * to the "quad-edge" structure (see L. Guibas and J. Stolfi, Primitives
00057  * for the manipulation of general subdivisions and the computation of
00058  * Voronoi diagrams, ACM Transactions on Graphics, 4(2):74-123, April 1985).
00059  * For a simplified description, see the course notes for CS348a,
00060  * "Mathematical Foundations of Computer Graphics", available at the
00061  * Stanford bookstore (and taught during the fall quarter).
00062  * The implementation also borrows a tiny subset of the graph-based approach
00063  * use in Mantyla's Geometric Work Bench (see M. Mantyla, An Introduction
00064  * to Sold Modeling, Computer Science Press, Rockville, Maryland, 1988).
00065  *
00066  * The fundamental data structure is the "half-edge".  Two half-edges
00067  * go together to make an edge, but they point in opposite directions.
00068  * Each half-edge has a pointer to its mate (the "symmetric" half-edge Sym),
00069  * its origin vertex (Org), the face on its left side (Lface), and the
00070  * adjacent half-edges in the CCW direction around the origin vertex
00071  * (Onext) and around the left face (Lnext).  There is also a "next"
00072  * pointer for the global edge list (see below).
00073  *
00074  * The notation used for mesh navigation:
00075  *  Sym   = the mate of a half-edge (same edge, but opposite direction)
00076  *  Onext = edge CCW around origin vertex (keep same origin)
00077  *  Dnext = edge CCW around destination vertex (keep same dest)
00078  *  Lnext = edge CCW around left face (dest becomes new origin)
00079  *  Rnext = edge CCW around right face (origin becomes new dest)
00080  *
00081  * "prev" means to substitute CW for CCW in the definitions above.
00082  *
00083  * The mesh keeps global lists of all vertices, faces, and edges,
00084  * stored as doubly-linked circular lists with a dummy header node.
00085  * The mesh stores pointers to these dummy headers (vHead, fHead, eHead).
00086  *
00087  * The circular edge list is special; since half-edges always occur
00088  * in pairs (e and e->Sym), each half-edge stores a pointer in only
00089  * one direction.  Starting at eHead and following the e->next pointers
00090  * will visit each *edge* once (ie. e or e->Sym, but not both).
00091  * e->Sym stores a pointer in the opposite direction, thus it is
00092  * always true that e->Sym->next->Sym->next == e.
00093  *
00094  * Each vertex has a pointer to next and previous vertices in the
00095  * circular list, and a pointer to a half-edge with this vertex as
00096  * the origin (NULL if this is the dummy header).  There is also a
00097  * field "data" for client data.
00098  *
00099  * Each face has a pointer to the next and previous faces in the
00100  * circular list, and a pointer to a half-edge with this face as
00101  * the left face (NULL if this is the dummy header).  There is also
00102  * a field "data" for client data.
00103  *
00104  * Note that what we call a "face" is really a loop; faces may consist
00105  * of more than one loop (ie. not simply connected), but there is no
00106  * record of this in the data structure.  The mesh may consist of
00107  * several disconnected regions, so it may not be possible to visit
00108  * the entire mesh by starting at a half-edge and traversing the edge
00109  * structure.
00110  *
00111  * The mesh does NOT support isolated vertices; a vertex is deleted along
00112  * with its last edge.  Similarly when two faces are merged, one of the
00113  * faces is deleted (see __gl_meshDelete below).  For mesh operations,
00114  * all face (loop) and vertex pointers must not be NULL.  However, once
00115  * mesh manipulation is finished, __gl_MeshZapFace can be used to delete
00116  * faces of the mesh, one at a time.  All external faces can be "zapped"
00117  * before the mesh is returned to the client; then a NULL face indicates
00118  * a region which is not part of the output polygon.
00119  */
00120 
00121 struct GLUvertex {
00122   GLUvertex *next;      /* next vertex (never NULL) */
00123   GLUvertex *prev;      /* previous vertex (never NULL) */
00124   GLUhalfEdge   *anEdge;    /* a half-edge with this origin */
00125   void      *data;      /* client's data */
00126 
00127   /* Internal data (keep hidden) */
00128   GLdouble  coords[3];  /* vertex location in 3D */
00129   GLdouble  s, t;       /* projection onto the sweep plane */
00130   long      pqHandle;   /* to allow deletion from priority queue */
00131 };
00132 
00133 struct GLUface {
00134   GLUface   *next;      /* next face (never NULL) */
00135   GLUface   *prev;      /* previous face (never NULL) */
00136   GLUhalfEdge   *anEdge;    /* a half edge with this left face */
00137   void      *data;      /* room for client's data */
00138 
00139   /* Internal data (keep hidden) */
00140   GLUface   *trail;     /* "stack" for conversion to strips */
00141   GLboolean marked;     /* flag for conversion to strips */
00142   GLboolean inside;     /* this face is in the polygon interior */
00143 };
00144 
00145 struct GLUhalfEdge {
00146   GLUhalfEdge   *next;      /* doubly-linked list (prev==Sym->next) */
00147   GLUhalfEdge   *Sym;       /* same edge, opposite direction */
00148   GLUhalfEdge   *Onext;     /* next edge CCW around origin */
00149   GLUhalfEdge   *Lnext;     /* next edge CCW around left face */
00150   GLUvertex *Org;       /* origin vertex (Overtex too long) */
00151   GLUface   *Lface;     /* left face */
00152 
00153   /* Internal data (keep hidden) */
00154   ActiveRegion  *activeRegion;  /* a region with this upper edge (sweep.c) */
00155   int       winding;    /* change in winding number when crossing
00156                                    from the right face to the left face */
00157 };
00158 
00159 #define Rface   Sym->Lface
00160 #define Dst Sym->Org
00161 
00162 #define Oprev   Sym->Lnext
00163 #define Lprev   Onext->Sym
00164 #define Dprev   Lnext->Sym
00165 #define Rprev   Sym->Onext
00166 #define Dnext   Rprev->Sym  /* 3 pointers */
00167 #define Rnext   Oprev->Sym  /* 3 pointers */
00168 
00169 
00170 struct GLUmesh {
00171   GLUvertex vHead;      /* dummy header for vertex list */
00172   GLUface   fHead;      /* dummy header for face list */
00173   GLUhalfEdge   eHead;      /* dummy header for edge list */
00174   GLUhalfEdge   eHeadSym;   /* and its symmetric counterpart */
00175 };
00176 
00177 /* The mesh operations below have three motivations: completeness,
00178  * convenience, and efficiency.  The basic mesh operations are MakeEdge,
00179  * Splice, and Delete.  All the other edge operations can be implemented
00180  * in terms of these.  The other operations are provided for convenience
00181  * and/or efficiency.
00182  *
00183  * When a face is split or a vertex is added, they are inserted into the
00184  * global list *before* the existing vertex or face (ie. e->Org or e->Lface).
00185  * This makes it easier to process all vertices or faces in the global lists
00186  * without worrying about processing the same data twice.  As a convenience,
00187  * when a face is split, the "inside" flag is copied from the old face.
00188  * Other internal data (v->data, v->activeRegion, f->data, f->marked,
00189  * f->trail, e->winding) is set to zero.
00190  *
00191  * ********************** Basic Edge Operations **************************
00192  *
00193  * __gl_meshMakeEdge( mesh ) creates one edge, two vertices, and a loop.
00194  * The loop (face) consists of the two new half-edges.
00195  *
00196  * __gl_meshSplice( eOrg, eDst ) is the basic operation for changing the
00197  * mesh connectivity and topology.  It changes the mesh so that
00198  *  eOrg->Onext <- OLD( eDst->Onext )
00199  *  eDst->Onext <- OLD( eOrg->Onext )
00200  * where OLD(...) means the value before the meshSplice operation.
00201  *
00202  * This can have two effects on the vertex structure:
00203  *  - if eOrg->Org != eDst->Org, the two vertices are merged together
00204  *  - if eOrg->Org == eDst->Org, the origin is split into two vertices
00205  * In both cases, eDst->Org is changed and eOrg->Org is untouched.
00206  *
00207  * Similarly (and independently) for the face structure,
00208  *  - if eOrg->Lface == eDst->Lface, one loop is split into two
00209  *  - if eOrg->Lface != eDst->Lface, two distinct loops are joined into one
00210  * In both cases, eDst->Lface is changed and eOrg->Lface is unaffected.
00211  *
00212  * __gl_meshDelete( eDel ) removes the edge eDel.  There are several cases:
00213  * if (eDel->Lface != eDel->Rface), we join two loops into one; the loop
00214  * eDel->Lface is deleted.  Otherwise, we are splitting one loop into two;
00215  * the newly created loop will contain eDel->Dst.  If the deletion of eDel
00216  * would create isolated vertices, those are deleted as well.
00217  *
00218  * ********************** Other Edge Operations **************************
00219  *
00220  * __gl_meshAddEdgeVertex( eOrg ) creates a new edge eNew such that
00221  * eNew == eOrg->Lnext, and eNew->Dst is a newly created vertex.
00222  * eOrg and eNew will have the same left face.
00223  *
00224  * __gl_meshSplitEdge( eOrg ) splits eOrg into two edges eOrg and eNew,
00225  * such that eNew == eOrg->Lnext.  The new vertex is eOrg->Dst == eNew->Org.
00226  * eOrg and eNew will have the same left face.
00227  *
00228  * __gl_meshConnect( eOrg, eDst ) creates a new edge from eOrg->Dst
00229  * to eDst->Org, and returns the corresponding half-edge eNew.
00230  * If eOrg->Lface == eDst->Lface, this splits one loop into two,
00231  * and the newly created loop is eNew->Lface.  Otherwise, two disjoint
00232  * loops are merged into one, and the loop eDst->Lface is destroyed.
00233  *
00234  * ************************ Other Operations *****************************
00235  *
00236  * __gl_meshNewMesh() creates a new mesh with no edges, no vertices,
00237  * and no loops (what we usually call a "face").
00238  *
00239  * __gl_meshUnion( mesh1, mesh2 ) forms the union of all structures in
00240  * both meshes, and returns the new mesh (the old meshes are destroyed).
00241  *
00242  * __gl_meshDeleteMesh( mesh ) will free all storage for any valid mesh.
00243  *
00244  * __gl_meshZapFace( fZap ) destroys a face and removes it from the
00245  * global face list.  All edges of fZap will have a NULL pointer as their
00246  * left face.  Any edges which also have a NULL pointer as their right face
00247  * are deleted entirely (along with any isolated vertices this produces).
00248  * An entire mesh can be deleted by zapping its faces, one at a time,
00249  * in any order.  Zapped faces cannot be used in further mesh operations!
00250  *
00251  * __gl_meshCheckMesh( mesh ) checks a mesh for self-consistency.
00252  */
00253 
00254 GLUhalfEdge *__gl_meshMakeEdge( GLUmesh *mesh );
00255 int     __gl_meshSplice( GLUhalfEdge *eOrg, GLUhalfEdge *eDst );
00256 int     __gl_meshDelete( GLUhalfEdge *eDel );
00257 
00258 GLUhalfEdge *__gl_meshAddEdgeVertex( GLUhalfEdge *eOrg );
00259 GLUhalfEdge *__gl_meshSplitEdge( GLUhalfEdge *eOrg );
00260 GLUhalfEdge *__gl_meshConnect( GLUhalfEdge *eOrg, GLUhalfEdge *eDst );
00261 
00262 GLUmesh     *__gl_meshNewMesh( void );
00263 GLUmesh     *__gl_meshUnion( GLUmesh *mesh1, GLUmesh *mesh2 );
00264 void        __gl_meshDeleteMesh( GLUmesh *mesh );
00265 void        __gl_meshZapFace( GLUface *fZap );
00266 
00267 #ifdef NDEBUG
00268 #define     __gl_meshCheckMesh( mesh )
00269 #else
00270 void        __gl_meshCheckMesh( GLUmesh *mesh );
00271 #endif
00272 
00273 #endif

Generated on Sun May 27 2012 04:23:50 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.