1 /*
2  * This file is part of the Alliance CAD System
3  * Copyright (C) Laboratoire LIP6 - D�partement ASIM
4  * Universite Pierre et Marie Curie
5  *
6  * Home page          : http://www-asim.lip6.fr/alliance/
7  * E-mail             : mailto:alliance-users@asim.lip6.fr
8  *
9  * This progam is  free software; you can redistribute it  and/or modify it
10  * under the  terms of the GNU  General Public License as  published by the
11  * Free Software Foundation;  either version 2 of the License,  or (at your
12  * option) any later version.
13  *
14  * Alliance VLSI  CAD System  is distributed  in the hope  that it  will be
15  * useful, but WITHOUT  ANY WARRANTY; without even the  implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17  * Public License for more details.
18  *
19  * You should have received a copy  of the GNU General Public License along
20  * with the GNU C Library; see the  file COPYING. If not, write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 extern int s2rdebug;
25 
26 /******************************************************************************
27  *                                                                            *
28  *    Rectangle Data Base : Structures and Access functions                   *
29  *                                                                            *
30  *****************************************************************************/
31 
32 #include "maxima.h"
33 
34 /******************************************************************************
35  * definitions of flags
36  *****************************************************************************/
37 
38 #define is_remove(rectangle)        ( (rectangle)->FLAGS & REMOVE)
39 #define is_flattenres(rectangle)    ( (rectangle)->FLAGS & FLATTENRES)
40 #define is_used(rectangle)          ( (rectangle)->FLAGS & USED)
41 #define is_scotch(rectangle)        ( (rectangle)->FLAGS & SCOTCH)
42 #define is_old_scotch(rectangle)    ( (rectangle)->FLAGS & OLD_SCOTCH)
43 
44 #define	REC_INIT	0x00000000  /* rectangle: default */
45 #define	REMOVE		0x01000000  /* rectangle: to be removed */
46 #define	FLATTENRES	0x02000000  /* rectangle: resulted from a flatten */
47 #define	USED		0x04000000  /* rectangle: used in merge */
48 #define	SCOTCH		0x08000000  /* rectangle: a scotch */
49 #define	OLD_SCOTCH	0x10000000  /* rectangle: an old scotch */
50 
51 #define	EMPTY		1           /* model(specific for a layer):
52                                        it contains nothing in this layer */
53 #define	POST		1           /* model->FLAGS: the model is postrated */
54 #define	READ		2           /* model->FLAGS: model already read from disk */
55                                     /* when a cell contains a model which has been */
56                                     /* already read in another cell, this flag */
57                                     /* prevents from reading it twice from disk */
58 
59 /* Rectangles */
60 
61 typedef rdsrec_list *rds_rectanglep_typ;
62 
63 
64 /*****************************************************************************
65  * Instances :
66  * The coordinates and symetry semantics are the gds & cif 's one, that's
67  * completly different from mbk's
68  *****************************************************************************/
69 
70 /* Models */
71 
72 typedef rdsfig_list *rds_figurep_typ;
73 
74 /************************************************************************
75 * types and definitions of rectangle data base access
76 *************************************************************************/
77 
78 /************************************************************************
79  * free list of rectangles removed to be
80  * allocated when a creation of a rectangle is requested
81  ************************************************************************/
82 extern rdsrec_list *Free_List;
83 
84 /************************************************************************
85  * declaration of the functions defined in rds_access.c
86  ************************************************************************/
87 
88 extern rdsfig_list *S2Rfigmbkrds ();
89 extern void zero ();
90 extern rdsrec_list *rds_rectangle_in ();
91 extern rdsins_list *rds_instance_in ();
92 extern void rds_remove_model ();
93 extern rdsfig_list *rds_create_model ();
94 extern rdsfig_list *rds_model_out ();
95 extern rdsins_list *rds_instance_out ();
96 extern void rds_mbk_kill ();
97 extern void mark_treat ();
98 extern void mark_remove ();
99 extern void mark_flattenres ();
100 extern void mark_used ();
101 extern void mark_scotch ();
102 extern void mark_old_scotch ();
103 extern void mark_empty ();
104 extern void mark_post ();
105 extern void demark_flattenres ();
106 extern void demark_scotch ();
107 extern void demark_used ();
108 extern void push_free_list ();
109 extern rdsrec_list *pull_free_list ();
110 extern void rds_remove_rectangle ();
111 extern void rds_clean_layer ();
112 extern int side_intersec ();
113 extern int rect_intersec ();
114 
115 /*******************************************************************************
116  * macro definitions to test the flags fields of rectangles and models
117  ******************************************************************************/
118 
119 /******************************************************************************
120  * rectangles
121  *****************************************************************************/
122 
123 #define is_remove(rectangle)  		( (rectangle)->FLAGS & REMOVE)
124 #define is_flattenres(rectangle)  	( (rectangle)->FLAGS & FLATTENRES)
125 #define is_used(rectangle)  		   ( (rectangle)->FLAGS & USED)
126 #define is_scotch(rectangle)  		( (rectangle)->FLAGS & SCOTCH)
127 #define is_old_scotch(rectangle)  	( (rectangle)->FLAGS & OLD_SCOTCH)
128 
129 /*****************************************************************************
130  * are_rect_intersec: tests if the 2 given rectangles ( given by their
131  *                    coordinates) intersect or not.
132  ******************************************************************************/
133 
134 #define are_rect_intersec(x1,y1,dx1,dy1,x2,y2,dx2,dy2)     (\
135                  (( ((x2) >= (x1)) && ((x2) <= ((x1)+(dx1))))\
136             ||\
137                  (( (x2) <= (x1)) && ( ((x2)+(dx2)) >= (x1))))\
138         &&\
139                  (( ((y2) >= (y1)) && ((y2) <= ((y1)+(dy1))))\
140             ||\
141                  (( (y2) <= (y1)) && ( ((y2)+(dy2)) >= (y1))))\
142                                                            )
143 
144 /****************************************************************************
145  * models
146  ****************************************************************************/
147 
148 #define is_empty(model,layer_num)  	( (model)->FLAGTAB[layer_num] & EMPTY)
149 #define is_post(model)  		( (model)->FLAGS & POST)
150 #define is_read(model)  		( (model)->FLAGS & READ)
151