MCPcopy Create free account
hub / github.com/SimHacker/micropolis / PolygonToPoint

Function PolygonToPoint

micropolis-activity/src/tk/tkcvpoly.c:596–632  ·  view source on GitHub ↗

ARGSUSED */

(canvasPtr, itemPtr, pointPtr)

Source from the content-addressed store, hash-verified

594 * point isn't inside the polygon then the return value is the
595 * distance from the point to the polygon.
596 *
597 * Side effects:
598 * None.
599 *
600 *--------------------------------------------------------------
601 */
602
603 /* ARGSUSED */
604static double
605PolygonToPoint(canvasPtr, itemPtr, pointPtr)
606 Tk_Canvas *canvasPtr; /* Canvas containing item. */
607 Tk_Item *itemPtr; /* Item to check against point. */
608 double *pointPtr; /* Pointer to x and y coordinates. */
609{
610 PolygonItem *polyPtr = (PolygonItem *) itemPtr;
611 double *coordPtr, distance;
612 double staticSpace[2*MAX_STATIC_POINTS];
613 int numPoints;
614
615 if (!polyPtr->smooth) {
616 return TkPolygonToPoint(polyPtr->coordPtr, polyPtr->numPoints,
617 pointPtr);
618 }
619
620 /*
621 * Smoothed polygon. Generate a new set of points and use them
622 * for comparison.
623 */
624
625 numPoints = 1 + polyPtr->numPoints*polyPtr->splineSteps;
626 if (numPoints <= MAX_STATIC_POINTS) {
627 coordPtr = staticSpace;
628 } else {
629 coordPtr = (double *) ckalloc((unsigned)
630 (2*numPoints*sizeof(double)));
631 }
632 numPoints = TkMakeBezierCurve(canvasPtr, polyPtr->coordPtr,
633 polyPtr->numPoints, polyPtr->splineSteps, (XPoint *) NULL,
634 coordPtr);
635 distance = TkPolygonToPoint(coordPtr, numPoints, pointPtr);

Callers

nothing calls this directly

Calls 2

TkPolygonToPointFunction · 0.85
TkMakeBezierCurveFunction · 0.85

Tested by

no test coverage detected