Back to index

tetex-bin  3.0
Classes | Defines | Functions
curves.c File Reference
#include "types.h"
#include "objects.h"
#include "spaces.h"
#include "paths.h"
#include "regions.h"
#include "curves.h"
#include "lines.h"
#include "arith.h"

Go to the source code of this file.

Classes

struct  bezierinfo

Defines

#define BITS   (sizeof(LONG)*8)
#define HIGHTEST(p)   (((p)>>(BITS-4)) != 0) /* includes sign bit */
#define TOOBIG(xy)   ((xy < 0) ? HIGHTEST(-xy) : HIGHTEST(xy))

Functions

int BezierTerminationTest (fractpel xa, fractpel ya, fractpel xb, fractpel yb, fractpel xc, fractpel yc, fractpel xd, fractpel yd)
static struct segmentStepBezierRecurse (struct bezierinfo *I, fractpel xA, fractpel yA, fractpel xB, fractpel yB, fractpel xC, fractpel yC, fractpel xD, fractpel yD)
struct segmentStepBezier (struct region *R, fractpel xA, fractpel yA, fractpel xB, fractpel yB, fractpel xC, fractpel yC, fractpel xD, fractpel yD)

Class Documentation

struct bezierinfo

Definition at line 77 of file curves.c.

Collaboration diagram for bezierinfo:
Class Members
struct region * region

Define Documentation

#define BITS   (sizeof(LONG)*8)

Definition at line 183 of file curves.c.

#define HIGHTEST (   p)    (((p)>>(BITS-4)) != 0) /* includes sign bit */

Definition at line 184 of file curves.c.

#define TOOBIG (   xy)    ((xy < 0) ? HIGHTEST(-xy) : HIGHTEST(xy))

Definition at line 185 of file curves.c.


Function Documentation

int BezierTerminationTest ( fractpel  xa,
fractpel  ya,
fractpel  xb,
fractpel  yb,
fractpel  xc,
fractpel  yc,
fractpel  xd,
fractpel  yd 
)

Definition at line 92 of file curves.c.

{
  fractpel dmax;
  dmax =          TYPE1_ABS(xa - xb);
  dmax = TYPE1_MAX(dmax,TYPE1_ABS(ya - yb));
  dmax = TYPE1_MAX(dmax,TYPE1_ABS(xd - xc));
  dmax = TYPE1_MAX(dmax,TYPE1_ABS(yd - yc));
  if(dmax > FPHALF)
    return(0); /* not done yet */
  else
    return(1); /* done */
}

Here is the caller graph for this function:

struct segment* StepBezier ( struct region R,
fractpel  xA,
fractpel  yA,
fractpel  xB,
fractpel  yB,
fractpel  xC,
fractpel  yC,
fractpel  xD,
fractpel  yD 
) [read]

Definition at line 193 of file curves.c.

{
       struct bezierinfo Info;
 
       Info.region = R;
       Info.origin.x = xA;
       Info.origin.y = yA;
 
       xB -= xA;
       xC -= xA;
       xD -= xA;
       yB -= yA;
       yC -= yA;
       yD -= yA;
 
       if ( TOOBIG(xB) || TOOBIG(yB) || TOOBIG(xC) || TOOBIG(yC)
            || TOOBIG(xD) || TOOBIG(yD) )
               abort("Beziers this big not yet supported", 3);
 
       return(StepBezierRecurse(&Info,
                                (fractpel) 0, (fractpel) 0, xB, yB, xC, yC, xD, yD));
}

Here is the call graph for this function:

static struct segment* StepBezierRecurse ( struct bezierinfo I,
fractpel  xA,
fractpel  yA,
fractpel  xB,
fractpel  yB,
fractpel  xC,
fractpel  yC,
fractpel  xD,
fractpel  yD 
) [static, read]

Definition at line 116 of file curves.c.

{
 if (BezierTerminationTest(xA,yA,xB,yB,xC,yC,xD,yD))
 {
  if (I->region == NULL)
   return(PathSegment(LINETYPE, xD - xA, yD - yA));
  else
   StepLine(I->region, I->origin.x + xA, I->origin.y + yA,
                       I->origin.x + xD, I->origin.y + yD);
 }
 else
 {
  fractpel xAB,yAB;
  fractpel xBC,yBC;
  fractpel xCD,yCD;
  fractpel xABC,yABC;
  fractpel xBCD,yBCD;
  fractpel xABCD,yABCD;
 
  xAB = xA + xB;  yAB = yA + yB;
  xBC = xB + xC;  yBC = yB + yC;
  xCD = xC + xD;  yCD = yC + yD;
 
  xABC = xAB + xBC;  yABC = yAB + yBC;
  xBCD = xBC + xCD;  yBCD = yBC + yCD;
 
  xABCD = xABC + xBCD;  yABCD = yABC + yBCD;
 
  xAB >>= 1;   yAB >>= 1;
  xBC >>= 1;   yBC >>= 1;
  xCD >>= 1;   yCD >>= 1;
  xABC >>= 2;   yABC >>= 2;
  xBCD >>= 2;   yBCD >>= 2;
  xABCD >>= 3;   yABCD >>= 3;
 
  if (I->region == NULL)
  {
   return( Join(
    StepBezierRecurse(I, xA, yA, xAB, yAB, xABC, yABC, xABCD, yABCD),
    StepBezierRecurse(I, xABCD, yABCD, xBCD, yBCD, xCD, yCD, xD, yD)
                )
         );
  }
  else
  {
   StepBezierRecurse(I, xA, yA, xAB, yAB, xABC, yABC, xABCD, yABCD);
   StepBezierRecurse(I, xABCD, yABCD, xBCD, yBCD, xCD, yCD, xD, yD);
  }
 }
 /*NOTREACHED*/
 /* To make ANSI-C-comnpiler happy (RMz): */
 return(0);
}

Here is the call graph for this function:

Here is the caller graph for this function: