/************************************************************************ ** ** FILE : cellkaget.c ** ** ZWECK : ** ** AUTOR : Michael C. Ancutici ** Universitaet Stuttgart, Fakultaet Informatik ** ** DATUM : 14.03.93 ** *************************************************************************/ #include "cellkaget.h" #include "cell.H" #include "cell.h" #include "netsize.h" #include "misc.h" #include /************************************************************************* ** FUNKTION: SearchForTrans ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ static int SearchForTrans( c) OBJECT *c; { while (c) if (c->typ != CE_TRANSITION) c = c->next; else return (c->Nr1); return (CE_NOTHING); } /************************************************************************* ** FUNKTION: CellKaGetStart ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ BOOLEAN CellKaGetStart( mx, my, typ, nr) int mx, my; char *typ; int *nr; { OBJECT *c; int rx, ry; int cX = CellXKoord( mx); int cY = CellYKoord( my); int erg; /**** IST HIER EINE STELLE ODER EINE TRANS ? *************************/ if ( (c=Cell[ cX][ cY]) ) do if ( (c->typ != CE_STELLE) && (c->typ != CE_TRANSITION) ) c = c->next; else { *nr = c->Nr1; *typ = c->typ; return OK; } while (c); /**** SUCHE NACH EINER TRANS IN DER UMGEBUNG *************************/ if ( (mx / CELLSIZE - cX) < 0.5) rx = -1; else rx = 1; if ( (my / CELLSIZE - cY) < 0.5) ry = -1; else ry = 1; /******************************************************************** ** Suchweise: 8 7 4 fuer einen Punkt, der rechts unten in ** 6 c 1 c liegt. ** 5 2 3 ********************************************************************/ if ( ((erg = SearchForTrans( Cell[ cX+rx][ cY] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX][ cY+ry] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX+rx][ cY+ry] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX+rx][ cY-ry] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX-rx][ cY] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX][ cY-ry] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX-rx][ cY-ry] )) != CE_NOTHING) ) { *typ = CE_TRANSITION; *nr = erg; return OK; } return FALSE; } /************************************************************************* ** FUNKTION: CellKaGetZiel ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ BOOLEAN CellKaGetZiel( mx, my, typ, nr) int mx, my; char typ; int *nr; { OBJECT *c; int rx, ry; int cX = CellXKoord( mx); int cY = CellYKoord( my); int erg; /**** IST HIER DAS GESUCHTE OBJEKT ? **********************************/ if ( (c=Cell[ cX][ cY]) ) do if (c->typ != typ) c = c->next; else { *nr = c->Nr1; return OK; } while (c); /**** SUCHE NACH EINER TRANS IN DER UMGEBUNG **************************/ if (typ == CE_TRANSITION) { if ( (mx / CELLSIZE - cX) < 0.5) rx = -1; else rx = 1; if ( (my / CELLSIZE - cY) < 0.5) ry = -1; else ry = 1; /******************************************************************** ** Suchweise: 8 7 4 fuer einen Punkt, der rechts unten in ** 6 c 1 c liegt. ** 5 2 3 ********************************************************************/ if ( ((erg = SearchForTrans( Cell[ cX+rx][ cY] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX][ cY+ry] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX+rx][ cY+ry] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX+rx][ cY-ry] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX-rx][ cY] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX][ cY-ry] )) != CE_NOTHING) || ((erg = SearchForTrans( Cell[ cX-rx][ cY-ry] )) != CE_NOTHING) ) { *nr = erg; return OK; } } return FALSE; }