Example #1
0
File: cylin.c Project: cheque/s3d
iMesh *cylin_uv_decomp(Prim *p, Real level)
{
  int i, j, nu = 20 * level, nv = 20 * level;
  Real u, v, iu = ULEN/(Real)nu, iv = VLEN/(Real)nv;
  Vector3 *pts = NEWARRAY((nu+3)*(nv+1), Vector3);
  Vector3 *pvals = NEWARRAY((nu+3)*(nv+1), Vector3);
  iTri *tl = NULL;
  iMesh *m = NULL;

  for (u = UMIN - iu, i = 0; i <= nu+2; u += iu, i++) {
    for (v = VMIN, j = 0; j <= nv; v += iv, j++) {
      pts[IDX2(i,j,nu+3)] = v3_make(u,v,0);
      pvals[IDX2(i,j,nu+3)] = prim_point(p,u,v);
    }
  }
  m = imesh_alloc((nu+3) * (nv+1), NULL, NULL);
  m->m = pts;
  m->p = pvals;
  for (i = 0; i < nu+2; i++) {
    for (j = 0; j < nv; j++) {
      tl = itri_insert(tl,
		       itri_make(IDX2(i,j,nu+3),IDX2(i,j+1,nu+3),IDX2(i+1,j,nu+3), m));
      tl = itri_insert(tl,
		       itri_make(IDX2(i+1,j+1,nu+3),IDX2(i+1,j,nu+3),IDX2(i,j+1,nu+3), m));
    }
  }
  m->t = tl;
  return m;
}
Example #2
0
static int
compose_sym2(nameprep_prohibited_, VERSION) (unsigned long v) {
	int idx0 = IDX0(PROH, v);
	int idx1 = IDX1(PROH, v);
	int idx2 = IDX2(PROH, v);
	const unsigned char *bm;

#define IMAP	compose_sym3(nameprep_, VERSION, _prohibited_imap)
#define BITMAP	compose_sym3(nameprep_, VERSION, _prohibited_bitmap)
	bm = BITMAP[IMAP[IMAP[idx0] + idx1]].bm;
	return (bm[idx2 / 8] & (1 << (idx2 % 8)));
#undef IMAP
#undef BITMAP
}
Example #3
0
static idn_biditype_t
compose_sym2(nameprep_biditype_, VERSION) (unsigned long v) {
	int idx0 = IDX0(BIDI, v);
	int idx1 = IDX1(BIDI, v);
	int idx2 = IDX2(BIDI, v);
	int offset;

#define IMAP	compose_sym3(nameprep_, VERSION, _bidi_imap)
#define TABLE	compose_sym3(nameprep_, VERSION, _bidi_table)
#define DATA	compose_sym3(nameprep_, VERSION, _bidi_data)
	offset = TABLE[IMAP[IMAP[idx0] + idx1]].tbl[idx2];
	return DATA[offset];
#undef IMAP
#undef TABLE
#undef DATA
}
Example #4
0
static const char *
compose_sym2(nameprep_map_, VERSION) (unsigned long v) {
	int idx0 = IDX0(MAP, v);
	int idx1 = IDX1(MAP, v);
	int idx2 = IDX2(MAP, v);
	int offset;

#define IMAP	compose_sym3(nameprep_, VERSION, _map_imap)
#define TABLE	compose_sym3(nameprep_, VERSION, _map_table)
#define DATA	compose_sym3(nameprep_, VERSION, _map_data)
	offset = TABLE[IMAP[IMAP[idx0] + idx1]].tbl[idx2];
	if (offset == 0)
		return (NULL);	/* no mapping */
	return (const char *)(DATA + offset);
#undef IMAP
#undef TABLE
#undef DATA
}
Example #5
0
__attribute__((noinline)) static void smooth2(float* v) {
  /* top */
  for(size_t x=1; x < dims[0]-1; ++x) {
    IDX2(x,0) = (IDX2(x-1,0) + IDX2(x,0) + IDX2(x+1,0) +
                 IDX2(x-1,1) + IDX2(x,1) + IDX2(x+1,1)) / 6.0f;
  }
  for(size_t y=1; y < dims[1]-1; ++y) {
    for(size_t x=1; x < dims[0]-1; ++x) {
      IDX2(x,y) = (IDX2(x-1,y-1) + IDX2(x,y-1) + IDX2(x+1,y-1) +
                   IDX2(x-1,y)   + IDX2(x,y)   + IDX2(x+1,y) +
                   IDX2(x-1,y+1) + IDX2(x,y+1) + IDX2(x+1,y+1)) / 9.0f;
    }
  }
  /* blah for correctness we need to do sides and bottom too, but blah. */
}