示例#1
0
static void
bezctx_ff_quadto(bezctx *z, double xm, double ym, double x3, double y3)
{
    bezctx_ff *bc = (bezctx_ff *)z;
    double x0, y0;
    double x1, y1;
    double x2, y2;
    SplinePoint *sp;

    if ( !finite(xm) || !finite(ym) || !finite(x3) || !finite(y3)) {
	nancheck(bc);
	xm = ym = x3 = y3 = 0;
    }
    sp = SplinePointCreate(x3,y3);
    x0 = bc->ss->last->me.x;
    y0 = bc->ss->last->me.y;
    x1 = xm + (1./3) * (x0 - xm);
    y1 = ym + (1./3) * (y0 - ym);
    x2 = xm + (1./3) * (x3 - xm);
    y2 = ym + (1./3) * (y3 - ym);
    bc->ss->last->nextcp.x = x1;
    bc->ss->last->nextcp.y = y1;
    bc->ss->last->nonextcp = false;
    sp->prevcp.x = x2;
    sp->prevcp.y = y2;
    sp->noprevcp = false;
    SplineMake3(bc->ss->last,sp);
    bc->ss->last = sp;
}
示例#2
0
/* This routine creates a linear spline from the previous point specified to this one */
static void bezctx_ff_lineto(bezctx *z,double x,double y) {
   bezctx_ff *bc=(bezctx_ff *) z;
   SplinePoint *sp;

   if (!isfinite(x) || !isfinite(y)) {
      nancheck(bc);
      x=y=0;
   }
   sp=SplinePointCreate(x, y);
   if (sp != NULL && SplineMake3(bc->ss->last, sp) != NULL)
      bc->ss->last=sp;
}
示例#3
0
static void
bezctx_ff_moveto(bezctx *z, double x, double y, int is_open) {
    bezctx_ff *bc = (bezctx_ff *)z;

    if ( !finite(x) || !finite(y)) {
	nancheck(bc);
	x = y = 0;
    }
    if (!bc->is_open) {
	SplineSet *ss = chunkalloc(sizeof(SplineSet));
	ss->next = bc->ss;
	bc->ss = ss;
    }
    bc->ss->first = bc->ss->last = SplinePointCreate(x,y);
    bc->is_open = is_open;
}
示例#4
0
/* So we allocate a new SplineSet, and then add the first point to it */
static void bezctx_ff_moveto(bezctx *z,double x,double y,int is_open) {
   bezctx_ff *bc=(bezctx_ff *) z;

   if (!isfinite(x) || !isfinite(y)) {	/* Protection against NaNs */
      nancheck(bc);
      x=y=0;
   }
   if (!bc->is_open) {
      SplineSet *ss;

      if ((ss=(SplineSet *) calloc(1, sizeof(SplineSet)))==NULL)
	 return;
      ss->next=bc->ss;
      bc->ss=ss;
   }
   bc->ss->first=bc->ss->last=SplinePointCreate(x, y);
   bc->is_open=is_open;
}
示例#5
0
static void
bezctx_ff_curveto(bezctx *z, double x1, double y1, double x2, double y2,
		  double x3, double y3)
{
    bezctx_ff *bc = (bezctx_ff *)z;
    SplinePoint *sp;

    if ( !finite(x1) || !finite(y1) || !finite(x2) || !finite(y2) || !finite(x3) || !finite(y3)) {
	nancheck(bc);
	x1 = y1 = x2 = y2 = x3 = y3 = 0;
    }
    sp = SplinePointCreate(x3,y3);
    bc->ss->last->nextcp.x = x1;
    bc->ss->last->nextcp.y = y1;
    bc->ss->last->nonextcp = false;
    sp->prevcp.x = x2;
    sp->prevcp.y = y2;
    sp->noprevcp = false;
    SplineMake3(bc->ss->last,sp);
    bc->ss->last = sp;
}
示例#6
0
文件: c_source.c 项目: hovr2pi/MASA
int main()
{
  double out;
  double x = 0;
  int    i = 1;

  // reroute stdout for regressions: TODO remove when logger mechanism
  // is used inside masa; these tests currently just verify functions
  // run successfully.
  freopen("/dev/null","w",stdout);

  masa_init("source term","euler_2d");


  // 1D
  out = masa_eval_1d_source_u(x);
  nancheck(out);

  out = masa_eval_1d_source_e(x);
  nancheck(out);

  out = masa_eval_1d_grad_u(x);
  nancheck(out);
  out = masa_eval_1d_grad_p(x);
  nancheck(out);

  out = masa_eval_1d_grad_rho(x);
  nancheck(out);

  // 2D

  out = masa_eval_2d_source_u(x,x);
  nancheck(out);
  out = masa_eval_2d_source_v(x,x);
  nancheck(out);
  out = masa_eval_2d_source_e(x,x);
  nancheck(out);
  out = masa_eval_2d_source_rho_w(x,x);
  nancheck(out);

  out = masa_eval_2d_grad_u(x,x,i);
  nancheck(out);
  out = masa_eval_2d_grad_v(x,x,i);
  nancheck(out);
  out = masa_eval_2d_grad_w(x,x,i);
  nancheck(out);
  out = masa_eval_2d_grad_p(x,x,i);
  nancheck(out);
  out = masa_eval_2d_grad_rho(x,x,i);
  nancheck(out);

  // 3D

  out = masa_eval_3d_source_u(x,x,x);
  nancheck(out);
  out = masa_eval_3d_source_v(x,x,x);
  nancheck(out);
  out = masa_eval_3d_source_w(x,x,x);
  nancheck(out);
  out = masa_eval_3d_source_e(x,x,x);
  nancheck(out);

  //tests passed
  return 0;

}