Пример #1
0
static struct FaceCount MaximumFan(GLUhalfEdge* eOrig)
{
   /* eOrig->Lface is the face we want to render.  We want to find the size
    * of a maximal fan around eOrig->Org.  To do this we just walk around
    * the origin vertex as far as possible in both directions.
    */
   struct FaceCount newFace={0, NULL, &RenderFan};
   GLUface* trail=NULL;
   GLUhalfEdge* e;

   for (e=eOrig; !Marked(e->Lface); e=e->Onext)
   {
      AddToTrail(e->Lface, trail);
      ++newFace.size;
   }
   for (e=eOrig; !Marked(e->Rface); e=e->Oprev)
   {
      AddToTrail( e->Rface, trail);
      ++newFace.size;
   }

   newFace.eStart=e;

   /*LINTED*/
   FreeTrail(trail);
   return newFace;
}
Пример #2
0
static struct FaceCount MaximumStrip( GLUhalfEdge *eOrig )
{
  /* Here we are looking for a maximal strip that contains the vertices
   * eOrig->Org, eOrig->Dst, eOrig->Lnext->Dst (in that order or the
   * reverse, such that all triangles are oriented CCW).
   *
   * Again we walk forward and backward as far as possible.  However for
   * strips there is a twist: to get CCW orientations, there must be
   * an *even* number of triangles in the strip on one side of eOrig.
   * We walk the strip starting on a side with an even number of triangles;
   * if both side have an odd number, we are forced to shorten one side.
   */
  struct FaceCount newFace = { 0, NULL, &RenderStrip };
  long headSize = 0, tailSize = 0;
  GLUface *trail = NULL;
  GLUhalfEdge *e, *eTail, *eHead;

  for( e = eOrig; ! Marked( e->Lface ); ++tailSize, e = e->Onext ) {
    AddToTrail( e->Lface, trail );
    ++tailSize;
    e = e->Dprev;
    if( Marked( e->Lface )) break;
    AddToTrail( e->Lface, trail );
  }
  eTail = e;

  for( e = eOrig; ! Marked( e->Rface ); ++headSize, e = e->Dnext ) {
    AddToTrail( e->Rface, trail );
    ++headSize;
    e = e->Oprev;
    if( Marked( e->Rface )) break;
    AddToTrail( e->Rface, trail );
  }
  eHead = e;

  newFace.size = tailSize + headSize;
  if( IsEven( tailSize )) {
    newFace.eStart = eTail->Sym;
  } else if( IsEven( headSize )) {
    newFace.eStart = eHead;
  } else {
    /* Both sides have odd length, we must shorten one of them.  In fact,
     * we must start from eHead to guarantee inclusion of eOrig->Lface.
     */
    --newFace.size;
    newFace.eStart = eHead->Onext;
  }
  /*LINTED*/
  FreeTrail( trail );
  return newFace;
}