void gridfont_write ( gridfont* gf, char* str ) { float x, y, nextpos; char *cptr, c; glPushMatrix(); glBegin(GL_QUADS); x = 0.0, y = 0.0; for (cptr = str, c = *cptr; c != '\0'; cptr++, c = *cptr) { switch (c) { default: break; } if (gf->chars[(int)c] == NULL) { if (gf->emptychar != NULL) { for (int i = 0; i < gf->maxheight * gf->maxwidth; i++) { if (bitvector_get(gf->emptychar, i) == 1) { glVertex2d(x, y); glVertex2d(x+1.0, y); glVertex2d(x+1.0, y+1.0); glVertex2d(x, y+1.0); } if ((i+1) % gf->maxwidth == 0) { x -= (float)(gf->maxwidth-1); y += 1.0; } else { x += 1.0; } } } nextpos = gf->wordspace; } else { for (int i = 0; i < gf->maxheight * gf->maxwidth; i++) { if (bitvector_get(gf->chars[(int)c], i) == 1) { glVertex2d(x, y); glVertex2d(x+1.0, y); glVertex2d(x+1.0, y+1.0); glVertex2d(x, y+1.0); } if ((i+1) % gf->maxwidth == 0) { x -= (float)(gf->maxwidth-1); y += 1.0; } else { x += 1.0; } } nextpos = gf->widths[(int)c]; } y = 0.0; x += nextpos; } glEnd(); glPopMatrix(); }
void gridfont_drawchar ( gridfont *gf, int c ) { float x, y; if (gf->chars[c] == NULL) return; glPushMatrix(); glBegin(GL_QUADS); x = 0.0, y = 0.0; for (int i = 0; i < gf->maxheight * gf->maxwidth; i++) { if (bitvector_get(gf->chars[c], i) == 1) { glVertex2d(x, y); glVertex2d(x+1.0, y); glVertex2d(x+1.0, y+1.0); glVertex2d(x, y+1.0); } if ((i+1) % gf->maxwidth == 0) { x -= (float)(gf->maxwidth-1); y += 1.0; } else { x += 1.0; } } glEnd(); glPopMatrix(); }
unsigned int bitvector_count_slow(bitvector_t b, unsigned int nbits) { unsigned int i,j,k,c=0,ncells=1+((nbits-1)>>5); for (i=0; i<ncells; i++) { for (j=0; j<32; j++) if ((k=32*i+j)<nbits) c+=bitvector_get(b,k); } return c; }
/* * walk from v toward a while keeping f (v) == 1 */ void walk (void *info, membership_t membership, bitvector *v, bitvector *a) { uscalar_t i; assert (bitvector_length (v) == bitvector_length (a)); i = bitvector_length (a) - 1; while (i > 0) { if (bitvector_get (v, i) != bitvector_get (a, i)) { bool b = bitvector_get (v, i); bitvector_set (v, i, !b); if ((*membership) (info, v)) { i = bitvector_length (a); } else { bitvector_set (v, i, b); } } i--; } }
/* * bv : an assignment to variables (indexed from 1) * I == { i : bv[i]} * M_DNF (bv) == /\_{i in I} X_i if I != empty == T if I == empty */ inline monomial *cdnfformula_monomial_M_DNF (bitvector *bv) { uscalar_t i; monomial *result; result = cdnfformula_monomial_unit (); for (i = bitvector_length (bv) - 1; i > 0; i--) { if (bitvector_get (bv, i)) result = cdnfformula_monomial_add (result, i); } assert (vector_length (result) > 0); return result; }
monomial *compute_m_of_x_xor_a (monomial *m, bitvector *a) { uscalar_t i, length; length = vector_length (m); for (i = 0; i < length; i++) { lit l; l = (lit) vector_get (m, i); assert (boolformula_var_from_lit (l) < bitvector_length (a)); if (bitvector_get (a, boolformula_var_from_lit (l))) { l = boolformula_lit_complement (l); } vector_set (m, i, (pointer_t) l); } return m; }
static bool cdnfformula_eval_monomial (monomial *m, bitvector *bv) { uscalar_t i, length; length = vector_length (m); for (i = 0; i < length; i++) { lit l; var v; l = (lit) vector_get (m, i); v = boolformula_var_from_lit (l); assert (0 < v); assert (v < bitvector_length (bv)); if (boolformula_positive_lit (l) != bitvector_get (bv, v)) return false; } return true; }