Example #1
0
  public void runAlgorithm() {
    //  traceHull = null;
    COper3.dbClear();

    traceHullPt = null;
    traceValley = null;
    simple = null;
    focusPt = null;
    possHull = null;
    valleyTri = null;
    PtEntry.resetIds();

    EdPolygon[] rgn = UHullMain.getPolygons();

    if (rgn.length < 2) return;

    if (C.vb(OLDALG)) {
      T.disable();
      simple = PossHullOper.buildPossibleHull(rgn);
      T.enable();
    }

    possHull = calcPHullRange(rgn, 0, rgn.length - 1);
  }
Example #2
0
  private static void insertValleys(
      PtEntry hullPt, Object aSrc, Object bSrc) { // pa, MyPolygon pb) {
    boolean db = C.vb(DB_INSERTVALLEY);
    PtEntry ent = hullPt;

    if (db && T.update()) T.msg("insertValleys");
    do {
      PtEntry next = ent.next(true);

      if (ent.source() == next.source()) {
        PtEntry orig = ent.orig();

        if (orig.next(true) != next.orig()) {

          PtEntry vPeak0 = ent;
          PtEntry vPeak1 = next;

          EdPolygon opp = (EdPolygon) (vPeak0.source() == aSrc ? bSrc : aSrc);

          FPoint2 kernelPt = opp.getPointMod(C.vi(KERNELVERT));

          // construct a chain from the vertices of the valley
          PtEntry handle = new PtEntry(vPeak0);
          PtEntry hNext = handle;
          PtEntry e = vPeak0.orig();
          while (e != vPeak1.orig()) {
            inf.update();
            e = e.next(true);
            hNext = hNext.insert(new PtEntry(e), true);
          }

          if (C.vb(SKIPCONTOUR)) {
            PtEntry h0 = handle.next(true);
            PtEntry h1 = hNext.prev(true);
            PtEntry.join(vPeak0, h0);
            PtEntry.join(h1, vPeak1);
            if (db && T.update())
              T.msg("inserted unmodified valley" + T.show(vPeak0) + T.show(vPeak1));

          } else {
            if (!C.vb(DB_CONTOUR)) T.disable();
            PtEntry hull = COper3.buildHullForChain(handle, kernelPt);
            if (!C.vb(DB_CONTOUR)) T.enable();
            // find entries corresponding to start, end of hull
            PtEntry peak0 = null, peak1 = null;
            {
              PtEntry hEnt = hull;
              while (peak0 == null || peak1 == null) {
                inf.update();
                if (hEnt.orig() == vPeak0.orig()) peak0 = hEnt;
                if (hEnt.orig() == vPeak1.orig()) peak1 = hEnt;
                hEnt = hEnt.next(true);
              }
            }
            PtEntry.join(vPeak0, peak0.next(true));
            PtEntry.join(peak1.prev(true), vPeak1);
            if (db && T.update())
              T.msg("inserted monotonic valley" + T.show(vPeak0) + T.show(vPeak1));
          }
        }
      }
      ent = next;
    } while (ent != hullPt);
  }