File: drawps.hc

package info (click to toggle)
maxima 5.6-17
  • links: PTS
  • area: main
  • in suites: woody
  • size: 30,572 kB
  • ctags: 47,715
  • sloc: ansic: 154,079; lisp: 147,553; asm: 45,843; tcl: 16,744; sh: 11,057; makefile: 7,198; perl: 1,842; sed: 334; fortran: 24; awk: 5
file content (63 lines) | stat: -rw-r--r-- 1,107 bytes parent folder | download
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


/* 
number of ngons
ngons   {number of vertices to each polygon}
[i1,i2,i3,j1,j2,j3, ] 
[p1,p2,p3,p4,p5,p6,....]

*/



#define ZVAL(pts,verti,i) (pts)[3*verti[i]+2]  

static int n_vertices;
static double *pt_array;
  
static int pt_compare(p,q)
     short *p,*q;
{ double m = ZVAL(pt_array,p,n_vertices) -  ZVAL(pt_array,q,n_vertices);
  return (m < 0.0 ? -1 : m > 0.0 ? 1 : 0);
  }
	      

static int
sort_ngons(pts,vertex,ngons)
object vertex,pts;
int ngons;
{
sort_ngons1(pts->lfa.lfa_self,vertex->ust.ust_self,ngons,
  (vertex->ust.ust_fillp)/(ngons+1));

 return 0;
}
  
static int  
sort_ngons1(pts,vertex,ngons,number_ngons)
short *vertex;
double *pts;
int ngons,number_ngons;
{short *p = vertex;
 int i;

   for (i=0; i < number_ngons ; i++) {
  { short * maxz_at = p;
      {int n = ngons;
       while (--n > 0)
         if (ZVAL(pts,p,n) > ZVAL(pts,maxz_at,0))
           maxz_at = p+n;
       p[ngons] = maxz_at[0];
       p += (1+ ngons);
     }}}
  n_vertices = ngons;
  pt_array = pts;
  qsort(vertex,number_ngons,sizeof(short)*(ngons+1),pt_compare);
  return 0;
}