File: SCADDSCON.c

package info (click to toggle)
qepcad 1.74%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,848 kB
  • sloc: ansic: 27,242; cpp: 2,995; makefile: 1,287; perl: 91
file content (67 lines) | stat: -rw-r--r-- 1,683 bytes parent folder | download | duplicates (2)
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
/*======================================================================
                      Cs <- SCADDSCON(C,A)

Sub-CAD data structure construct.

Inputs
  C : A partial cad.
  A : The ancestor of C.
  n : The highest level to allow the CAD to go.

Outputs
  Cs: A sub-CAD data structure representing the input cad.

Note:  The sub-cad data structure:

(c,L,a,i,S)  SC_REP 1  SC_PAR 2  SC_INX 3  SC_CDTV 4

c : A cell in C which represents c.
a : The ancestor of c (NIL if c is the root cell)
i : The index of c in its stack.
L : If c has children then a list of its children (each element being
    a sub-cad cell structure).  If c has no children, then its truth 
    value.

This is a recursive data structure, so trying to 'OWRITE' it, for
example, would be bad.
======================================================================*/
#include "qepcad.h"
#include "coarsecad.h"

Word SCADDSCON(Word C, Word A, Word n)
{
      Word c,a,i,Cs,X,L;

Step1: /* Construct a preliminary version of Cs, with all but the child
	  list filled in. */
      c = C;
      a = A;
      if (A == NIL)
	i = 0;
      else 
	i = LAST(LELTI(C,INDX));
      if (n == 0) {
	Cs = LIST4(c,a,i,CATV(C));
	goto Return; }
      else
	Cs = LIST4(c,a,i,NIL);

Step2: /* Fill in the child list, using the list handle for Cs for
	  recursive calls to SCADDSCON. */
      X = LELTI(C,CHILD);
      if (X == NIL)
	L = LELTI(C,TRUTH);
      else {
	X = CINV(X);
	L = NIL;
	while (X != NIL) {
	  L = COMP(SCADDSCON(FIRST(X),Cs,n-1),L);
	  X = RED(X); } }

Step3: /* Set the SC_CDTV element to L as constructed in Step2. */
      SLELTI(Cs,SC_CDTV,L);

Return: /* Prepare to return. */
      return (Cs);

}