Ejemplo n.º 1
0
  /**
   * Calculate possible hull of a pair of polygons
   *
   * @param a
   * @param b
   * @return possible hull
   */
  private static EdPolygon calcPHull(EdPolygon aPoly, EdPolygon bPoly) {
    final boolean db = true;

    if (db && T.update())
      T.msg(
          "calc possible hull of two polygons"
              + T.show(aPoly, MyColor.cBLUE, STRK_THICK, -1)
              + T.show(bPoly, MyColor.cDARKGREEN, STRK_THICK, -1));
    PtEntry a = PtEntry.buildFrom(aPoly);
    PtEntry b = PtEntry.buildFrom(bPoly);

    PtEntry aHull = PtEntry.convexHull(a);
    PtEntry bHull = PtEntry.convexHull(b);

    inf = Inf.create();

    if (db && T.update()) {
      T.msg(
          "convex hulls"
              + T.show(aHull.toPolygon(), MyColor.cBLUE, STRK_THICK, -1)
              + T.show(bHull.toPolygon(), MyColor.cDARKGREEN, STRK_THICK, -1));
    }

    PtEntry ph = hullOfPolygons(a, b, aHull, bHull);
    traceHullPt = ph;

    insertValleys(ph, a.source(), b.source());

    expandHull(ph, aHull, bHull, true);
    expandHull(ph, aHull, bHull, false);

    return ph.toPolygon();
  }