コード例 #1
0
ファイル: mri_mc.c プロジェクト: guo2004131/freesurfer
void allocateTesselation(tesselation_parms *parms) {
  int imgsize=parms->imgsize;
  parms->face = (quad_face_type *)lcalloc(MAXFACES,sizeof(quad_face_type));
  parms->maxfaces=MAXFACES;
  parms->face_index_table0 = (int *)lcalloc(6*imgsize,sizeof(int));
  parms->face_index_table1 = (int *)lcalloc(6*imgsize,sizeof(int));

  parms->vertex = 
    (quad_vertex_type *)lcalloc(MAXVERTICES,sizeof(quad_vertex_type));
  parms->maxvertices=MAXVERTICES;
  //  parms->vertex_index_table = (int *)lcalloc(8*imgsize,sizeof(int));

  parms->face_index=0;
  parms->vertex_index=0;

  if ((!parms->face) || (!parms->face_index_table0)
      || (!parms->face_index_table1)
      || (!parms->vertex))
    //     || (!parms->vertex_index_table))
    ErrorExit(ERROR_NO_MEMORY,"MRIStesselate: local tesselation tables");
}
コード例 #2
0
ファイル: str.c プロジェクト: simonz05/ludis
/* str_new allocates a new Str buf of size n.  
 * Returns a pointer Str */
Str *
str_new(size_t n)
{
    Str *s;

    s = lcalloc(1, offsetof(Str, data) + n + 1);
    s->len = 0;
    s->cap = n;
    s->data[n] = '\0';
    memset(s->data, 0, n);
    return s;
}
コード例 #3
0
ファイル: mri_mc.c プロジェクト: guo2004131/freesurfer
void reallocateVertices(tesselation_parms *parms) {
  quad_vertex_type *tmp;
  int k,n;
  int vertex_index=parms->vertex_index;

  parms->maxvertices=(int)(parms->maxvertices*VERTEXINCREASE);
  tmp=(quad_vertex_type*)lcalloc(parms->maxvertices,sizeof(quad_vertex_type));
  if (!tmp)
    ErrorExit(ERROR_NOMEMORY, "%s: max vertices %d exceeded",
              Progname,parms->maxvertices) ;
  for (k=0;k<vertex_index;k++) {
    tmp[k].imnr=parms->vertex[k].imnr;
    tmp[k].i=parms->vertex[k].i;
    tmp[k].j=parms->vertex[k].j;
    tmp[k].num=parms->vertex[k].num;
    for (n=0;n<9;n++)
      tmp[k].f[n]=parms->vertex[k].f[n];
  }
  free(parms->vertex);
  parms->vertex=tmp;
}
コード例 #4
0
ファイル: mri_mc.c プロジェクト: guo2004131/freesurfer
void reallocateFaces(tesselation_parms *parms) {
  quad_face_type *tmp;
  int k,n;
  int face_index=parms->face_index;

  parms->maxfaces=(int)(parms->maxfaces*FACEINCREASE);
  tmp=(quad_face_type*)lcalloc(parms->maxfaces,sizeof(quad_face_type));
  if (!tmp)
    ErrorExit(ERROR_NOMEMORY, "%s: max faces %d exceeded",
              Progname,parms->maxfaces) ;
  for (k=0;k<face_index;k++) {
    tmp[k].imnr=parms->face[k].imnr;
    tmp[k].i=parms->face[k].i;
    tmp[k].j=parms->face[k].j;
    tmp[k].f=parms->face[k].f;
    tmp[k].num=parms->face[k].num;
    for (n=0;n<4;n++)
      tmp[k].v[n]=parms->face[k].v[n];
  }

  free(parms->face);
  parms->face=tmp;
}
コード例 #5
0
int
dialog_box(int arg_color, char argc, ...)
{
  va_list ap;
  int i;
  int db_last_button = -1;
  int key;
  char * working_str;

  /* Try the locks */
  if (db_up) {
      printf("Already have a dialog box on screen!\n");
      return;
  } else {
      db_up = 1; /* XXX: Need to reconcile these - don't need both flags */
      db_flag = 1;
  }

  bn = 0; ln = 0; dbn = 0;
  db_longest_button = 0; db_longest_line = 0;
  bs = 0; bse = 0;
  color = arg_color;
  db_screen_fresh = 0;

  va_start(ap, argc);

  /* For each argument pair, get the arguments, determine line or button,
     calculate width/length, adjust total size accordingly, increment type
     count. */
  
  for (i = 0; i < argc; i++) {

      if (dbn >= MAX_DBOX_ENTRIES) {
	  fprintf(stderr,"Too many buttons in dialog_box!\n"
		  "Tweak MAX_DBOX_ENTRIES\n");
	  exit(212);
      }  

    db_entry[dbn].type = (short) va_arg(ap, int);
    db_entry[dbn].retval = (short) va_arg(ap, int);

    if (db_entry[dbn].type == 0) { /* Text strings: Chop a paragraph into
				    individual lines.*/
	char * newline;
	working_str = va_arg(ap, char *);
	do {
	    newline = (char *)strchr(working_str,'\n');
	    if (newline) {
		int linelen = newline - working_str;
		db_entry[dbn].text = (char *)lcalloc(1 + linelen);
		strncpy(db_entry[dbn].text,working_str,linelen);
		db_entry[dbn].text[linelen] = '\0';
		working_str = (newline + 1) != '\0' ? newline + 1 : NULL;
	    } else {
		db_entry[dbn].text = (char *)lcalloc(1 + strlen(working_str));
		strncpy(db_entry[dbn].text,working_str,strlen(working_str));
		db_entry[dbn].text[strlen(working_str)] = '\0';
		working_str = NULL;
	    }

	    db_entry[dbn].type = 0;
	    db_entry[dbn].retval = 0;

	    db_rect[dbn].w = (strlen(db_entry[dbn].text) * CHAR_WIDTH);
	    db_rect[dbn].h = CHAR_HEIGHT;
	    if (db_rect[dbn].w > db_longest_line) 
		db_longest_line = db_rect[dbn].w;

	    ln++;
	    dbn++;
	} while ((working_str != NULL) && (strlen(working_str) >= 1));
    } else {