[go: up one dir, main page]

File: post_in_order.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 (74 lines) | stat: -rw-r--r-- 2,259 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "cp_types.h"
#include "cp_proto.h"

/* post faces and/or circles in drawingorder, recompute/post as you 
go along. E.g., post 'ghosts'. If pl set, place first face; else, 
leave it where it is. */

int post_in_order(FILE *fp,struct p_data *p,int cflag,int fflag,int pl)
{
  int nf,ind,a,b,c,ccol,col,ck=0,v,n0,indx;

  nf=p->first_face;
  ccol=col=FG_COLOR;
  if (pl) place_face(p,nf,p->faces[nf].index_flag);
  if (cflag & 1) /* circle? */
    {
      ind=p->faces[nf].index_flag;
      a=p->faces[nf].vert[ind];
      b=p->faces[nf].vert[(ind+1) % 3];
      c=p->faces[nf].vert[(ind+2) % 3];
      if (cflag & 16) col=p->packK_ptr[a].color;
      if (cflag & 8) ccol=p->packK_ptr[a].color;
      post_any_circle(fp,p,a,cflag,ccol,col);
      if (cflag & 16) col=p->packK_ptr[b].color;
      if (cflag & 8) ccol=p->packK_ptr[b].color;
      post_any_circle(fp,p,b,cflag,ccol,col);
      if (cflag & 16) col=p->packK_ptr[c].color;
      if (cflag & 8) ccol=p->packK_ptr[c].color;
      post_any_circle(fp,p,c,cflag,ccol,col);
      if (fflag & 1)
	{
	  post_cir_label(fp,p,a);
	  post_cir_label(fp,p,b);
	  post_cir_label(fp,p,c);
	}
    }
  ccol=col=FG_COLOR;
  if (fflag & 1) /* faces? */
    {
      if (fflag & 16) col=p->faces[nf].color;
      if (fflag & 8) ccol=p->faces[nf].color;
      post_any_face(fp,p,nf,fflag,ccol,col);
    }
  if (fflag & 32) post_face_label(fp,p,nf);
  while ( nf>0 && nf <= p->facecount
	  && (nf=p->faces[nf].next_face)!=p->first_face
	  && ck<2*p->facecount)
    {
      v=p->faces[nf].vert[(indx=(p->faces[nf].index_flag+2)%3)];
      n0=nghb(p,v,p->faces[nf].vert[(indx+1)%3]);
      fancy_comp_center(p,v,n0,n0,1,0,1,1,toler);
      col=ccol=FG_COLOR;
      if (cflag & 1) /* circle? */
	{
	  c=p->faces[nf].vert[(p->faces[nf].index_flag + 2) % 3];
	  if (cflag & 16) col=p->packK_ptr[c].color;
	  if (cflag & 8) ccol=p->packK_ptr[c].color;
	  post_any_circle(fp,p,c,cflag,ccol,col); 
				/* new circle */
	}
      ccol=col=FG_COLOR;
      if (fflag & 1) /* faces? */
	{
	  if (fflag & 16) col=p->faces[nf].color;
	  if (fflag & 8) ccol=p->faces[nf].color;
	  post_any_face(fp,p,nf,fflag,ccol,col);
	}
      ck++;
    }
  if (nf!=p->first_face) /* some error */
    return 0;
  return 1;
} /* post_in_order */