/* * boundpoly.c Simon Towers 19-02-88 * * test version which just returns straight line * joining boundary points. */ #include #include #include #include struct object *boundpoly(bdom, cndp, obj) struct polygondomain *bdom; struct cand *cndp; struct object *obj; { struct object *makemain(); struct polygondomain *pdom, *makepolydmn(); struct ivertex *vtx; int index, dir, index_l, index_r, i; pdom = makepolydmn(1, NULL, 0, 2, 1); pdom->nvertices = 2; vtx = pdom->vtx; index_l = cndp->lboundpos; index_r = cndp->rboundpos; if (index_l == -1) { pdom->vtx->vtX = leftline(obj, (bdom->vtx + index_r)->vtY); pdom->vtx->vtY = (bdom->vtx + index_r)->vtY; } else *(pdom->vtx) = *(bdom->vtx + index_l); if (index_r == -1) { (pdom->vtx + 1)->vtX = rightline(obj, (bdom->vtx + index_l)->vtY); (pdom->vtx + 1)->vtY = (bdom->vtx + index_l)->vtY; } else *(pdom->vtx + 1) = *(bdom->vtx + index_r); pdom->vtx->vtY *= 8; pdom->vtx->vtX *= 8; (pdom->vtx + 1)->vtY *= 8; (pdom->vtx + 1)->vtX *= 8; return(makemain(10, (struct idom *) pdom, NULL, NULL, NULL)); } leftline(obj, y) struct object *obj; int y; { struct intervaldomain *idom; struct intervalline *intvline; idom = obj->idom; /* * Trap a rare bug - why I don't know just yet. */ if (y < idom->line1 || y > idom->lastln) { fprintf(stderr,"Out of bounds - leftline (boundpoly)\n"); return(idom->kol1); } intvline = &idom->intvlines[y-idom->line1]; return(idom->kol1 + intvline->intvs->ileft); } rightline(obj, y) struct object *obj; int y; { struct intervaldomain *idom; struct intervalline *intvline; idom = obj->idom; /* * Trap a rare bug - why I don't know just yet. */ if (y < idom->line1 || y > idom->lastln) { fprintf(stderr,"Out of bounds - rightline (boundpoly)\n"); return(idom->lastkl); } intvline = &idom->intvlines[y-idom->line1]; return(idom->kol1 + intvline->intvs->iright); }