/************************************************************************ ** ** FILE : cellkaio.c ** ** ZWECK : ** ** AUTOR : Michael C. Ancutici ** Universitaet Stuttgart, Fakultaet Informatik ** ** DATUM : 14.03.93 ** *************************************************************************/ #include "cellkaio.h" #include "cell.H" #include "cell.h" #include "cellein.h" #include "celldel.h" #include "ka.h" #include "ste.h" #include "tra.h" #include #define vorzeichen( x) ((x)>0 ? 1 : ((x) == 0 ? 0 : (-1))) /************************************************************************* ** FUNKTION: CellGeradeIO ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ static void CellGeradeIO( mx1, my1, mx2, my2, O, CellKaIO) int mx1, my1; int mx2, my2; OBJECT *O; void CellKaIO( OBJECT **, OBJECT *); { int x1 = CellXKoord( mx1); int y1 = CellYKoord( my1); int x2 = CellXKoord( mx2); int y2 = CellYKoord( my2); int dx, dy; int dxabs, dyabs; int i, j; int px, py; int sdx, sdy; int x, y; dx = x2-x1; /* Steigung fuer x */ dy = y2-y1; /* Steigung fuer y */ sdx = vorzeichen( dx); /* Steigungsrichtung x */ sdy = vorzeichen( dy); /* Steigungsrichtung y */ dxabs = abs( dx); /* |Steigung x| */ dyabs = abs( dy); /* |Steigung y| */ x = 0; y = 0; px = x1; py = y1; if (dxabs >= dyabs) for (i=0; i= dxabs) { y -= dxabs; py += sdy; } CellKaIO( &(Cell[ px][ py]), O); px += sdx; } else for (i=0; i= dyabs) { x -= dyabs; px += sdx; } CellKaIO( &(Cell[ px][ py]), O); py += sdy; } } /************************************************************************* ** FUNKTION: CellSTKaEin ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void CellSTKaInsert( SNr, TNr) int SNr, TNr; { ECKE *e; OBJECT *O; KANTE *k; KOORDINATE *sk, *tk; sk = &(SteStelle[ SNr]->PosStelle); tk = &(TraTrans[ TNr]->PosTrans); k = KaKante[ SNr][ TNr].NachTrans; O = k->OrgKa; if (e=k->Ecke) { CellGeradeIO( e->x, e->y, tk->x, tk->y, O, CellKEin); while (e->next) { CellGeradeIO( e->next->x, e->next->y, e->x, e->y, O, CellKEin); e = e->next; } CellGeradeIO( sk->x, sk->y, e->x, e->y, O, CellKEin); } else CellGeradeIO( sk->x, sk->y, tk->x, tk->y, O, CellKEin); } /************************************************************************* ** FUNKTION: CellTSKaInsert ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void CellTSKaInsert( SNr, TNr) int SNr, TNr; { ECKE *e; OBJECT *O; KANTE *k; KOORDINATE *sk, *tk; sk = &(SteStelle[ SNr]->PosStelle); tk = &(TraTrans[ TNr]->PosTrans); k = KaKante[ SNr][ TNr].NachStelle; O = k->OrgKa; if (e=k->Ecke) { CellGeradeIO( e->x, e->y, sk->x, sk->y, O, CellKEin); while (e->next) { CellGeradeIO( e->next->x, e->next->y, e->x, e->y, O, CellKEin); e = e->next; } CellGeradeIO( tk->x, tk->y, e->x, e->y, O, CellKEin); } else CellGeradeIO( tk->x, tk->y, sk->x, sk->y, O, CellKEin); } /************************************************************************* ** FUNKTION: CellSTKaRemove ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void CellSTKaRemove( SNr, TNr) int SNr, TNr; { ECKE *e; OBJECT *O; KANTE *k; KOORDINATE *sk, *tk; sk = &(SteStelle[ SNr]->PosStelle); tk = &(TraTrans[ TNr]->PosTrans); k = KaKante[ SNr][ TNr].NachTrans; O = k->OrgKa; if (e=k->Ecke) { CellGeradeIO( e->x, e->y, tk->x, tk->y, O, CellKDel); while (e->next) { CellGeradeIO( e->next->x, e->next->y, e->x, e->y, O, CellKDel); e = e->next; } CellGeradeIO( sk->x, sk->y, e->x, e->y, O, CellKDel); } else CellGeradeIO( sk->x, sk->y, tk->x, tk->y, O, CellKDel); } /************************************************************************* ** FUNKTION: CellTSKaRemove ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void CellTSKaRemove( SNr, TNr) int SNr, TNr; { ECKE *e; OBJECT *O; KANTE *k; KOORDINATE *sk, *tk; sk = &(SteStelle[ SNr]->PosStelle); tk = &(TraTrans[ TNr]->PosTrans); k = KaKante[ SNr][ TNr].NachStelle; O = k->OrgKa; if (e=k->Ecke) { CellGeradeIO( e->x, e->y, sk->x, sk->y, O, CellKDel); while (e->next) { CellGeradeIO( e->next->x, e->next->y, e->x, e->y, O, CellKDel); e = e->next; } CellGeradeIO( tk->x, tk->y, e->x, e->y, O, CellKDel); } else CellGeradeIO( tk->x, tk->y, sk->x, sk->y, O, CellKDel); }