[go: up one dir, main page]

File: gen_mark.c

package info (click to toggle)
circlepack 5.1-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 2,828 kB
  • ctags: 1,683
  • sloc: ansic: 43,152; makefile: 46
file content (48 lines) | stat: -rw-r--r-- 1,369 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "cp_types.h"
#include "cp_proto.h"

int gen_mark(struct p_data *p,char *datastr)
     /* mark generations, starting from given seeds as first generation.
util_flag's used to pass seed info to label_generations routine.
Command -m to set max generation; rest of input describes 'seed'
vertices. */
{
  int i,max=-1,*list,last_vert=0,hits,vert_count;
  char *nextpoint,*endptr;
  struct Vertlist *seedlist=NULL,*vtrace;
  struct K_data *pK_ptr;

  pK_ptr=p->packK_ptr;
  nextpoint=datastr;
  stripsp(datastr);
  /* is a max generation specified? */
  if (nextpoint[0]=='-' && nextpoint[1]=='m') 
    {
      nextpoint += 2;
      if (!sscanf(nextpoint,"%d",&max) || max<1)
	max=0;
    }
  /* get list of verts in generation 1; alpha is default */
  if (!(seedlist=Node_link_parse(p,nextpoint,&endptr,&hits,&Vlist,
				 &Elist,&Flist,&region,pathlist,pathlength)))
    {
      seedlist=(struct Vertlist *)
	calloc((size_t)1,sizeof(struct Vertlist));
      seedlist->v=p->alpha;
    }
  for (i=1;i<=p->nodecount;i++) pK_ptr[i].util_flag=0;
  vtrace=seedlist;
  while (vtrace)
    {
      pK_ptr[vtrace->v].util_flag=1;
      vtrace=vtrace->next;
    }
  vert_free(&seedlist);
  
  if (!(list=label_generations(p,max,&last_vert,&vert_count)))
    return 0;
  for (i=1;i<=p->nodecount;i++) pK_ptr[i].mark=list[i];
  free(list);

  return last_vert;
} /* gen_mark */