Ejemplo n.º 1
0
  private void calcLineMin() {
    m_kImagePointsDual.DetachAllEffects();
    m_kImagePointsDual.AttachEffect(m_kImageLineMinDual);
    boolean bEarly = false;
    Texture kTarget = null;
    OpenGLFrameBuffer kCurrentBracket = m_kBracketOut;
    OpenGLFrameBuffer kNewBracket = m_kBracketNewOut;
    OpenGLFrameBuffer kTempBracket;
    for (int i = 0; i < 100; i++) {
      m_kCalcTransform.SetTexture(kCurrentBracket.GetTarget(0), 0, 0);
      m_kImageLineMinPass2a.SetTexture(kCurrentBracket.GetTarget(0), 0, 0);

      // 1. Create the transform matrix based on the current bracket.
      m_pkRenderer.Resize(
          m_kTransformOut.GetTarget(0).GetImage().GetBound(0),
          m_kTransformOut.GetTarget(0).GetImage().GetBound(1));
      m_kTransformOut.Enable();
      m_pkRenderer.ClearColorDepth();
      // m_pkRenderer.ClearBuffers();
      m_pkRenderer.Draw(m_kTransformPoints);
      m_kTransformOut.Disable();
      /*
      kTarget = m_kTransformOut.GetTarget(0);
      m_pkRenderer.GetTexImage( kTarget );
      for ( int j = 0; j < kTarget.GetImage().GetFloatData().length; j++ )
      {
          System.err.print( kTarget.GetImage().GetFloatData()[j] + " " );
      }
      System.err.println( " " ); */

      // 1. Render all image points w/LineMin1 shaders
      m_pkRenderer.Resize(
          m_kHistogramOutput.GetTarget(0).GetImage().GetBound(0),
          m_kHistogramOutput.GetTarget(0).GetImage().GetBound(1));
      m_kHistogramOutput.Enable();
      m_pkRenderer.ClearColorDepth();
      // m_pkRenderer.ClearBuffers();
      m_pkRenderer.Draw(m_kImagePointsDual);
      m_kHistogramOutput.Disable();

      // 2. Render Histogram points
      m_pkRenderer.Resize(
          m_kHistogramOutputB.GetTarget(0).GetImage().GetBound(0),
          m_kHistogramOutputB.GetTarget(0).GetImage().GetBound(1));
      m_kHistogramOutputB.Enable();
      m_pkRenderer.ClearColorDepth();
      // m_pkRenderer.ClearBuffers();
      m_pkRenderer.Draw(m_kHistogramPoints2D);
      m_kHistogramOutputB.Disable();

      // 3. Render Entropy points w/LineMin1 shader
      m_pkRenderer.Resize(
          m_kEntropyOut.GetTarget(0).GetImage().GetBound(0),
          m_kEntropyOut.GetTarget(0).GetImage().GetBound(1));
      m_kEntropyOut.Enable();
      m_pkRenderer.ClearColorDepth();
      // m_pkRenderer.ClearBuffers();
      m_pkRenderer.Draw(m_kEntropyPoints2D);
      m_kEntropyOut.Disable();

      // 4. Render bracket points w/LineMin2 shader
      m_kBracketPoints.DetachAllEffects();
      m_kBracketPoints.AttachEffect(m_kImageLineMinPass2a);
      m_pkRenderer.Resize(
          kNewBracket.GetTarget(0).GetImage().GetBound(0),
          kNewBracket.GetTarget(0).GetImage().GetBound(1));
      kNewBracket.Enable();
      m_pkRenderer.ClearColorDepth();
      // m_pkRenderer.ClearBuffers();
      m_pkRenderer.Draw(m_kBracketPoints);
      kNewBracket.Disable();
      kTempBracket = kCurrentBracket;
      kCurrentBracket = kNewBracket;
      kNewBracket = kTempBracket;

      if ((i % 6) == 0) {
        // kTarget = m_kBracketOut.GetTarget(0);
        kTarget = kCurrentBracket.GetTarget(0);
        m_pkRenderer.GetTexImage(kTarget);
        /*
        System.err.println("");
        System.err.println("");
        System.err.println( "GPU BracketA = " + kTarget.GetImage().GetFloatData()[0] + " " + kTarget.GetImage().GetFloatData()[1]);
        System.err.println( "GPU BracketB = " + kTarget.GetImage().GetFloatData()[4] + " " + kTarget.GetImage().GetFloatData()[5]);
        System.err.println( "GPU BracketC = " + kTarget.GetImage().GetFloatData()[8] + " " + kTarget.GetImage().GetFloatData()[9]);
        System.err.println( "   " + i + " xNew = " + kTarget.GetImage().GetFloatData()[3] + " yNew = " +
                kTarget.GetImage().GetFloatData()[6]  + " case: " + kTarget.GetImage().GetFloatData()[7] + " " +
                kTarget.GetImage().GetFloatData()[10] + " " +
                kTarget.GetImage().GetFloatData()[11]);
                */
        if ((Math.abs(kTarget.GetImage().GetFloatData()[8] - kTarget.GetImage().GetFloatData()[0])
            <= m_fUnitTolerance)) {
          m_afBracketB[0] = kTarget.GetImage().GetFloatData()[4];
          m_afBracketB[1] = kTarget.GetImage().GetFloatData()[5];
          bEarly = true;
          break;
        }
        if (kTarget.GetImage().GetFloatData()[3] == 0) {
          m_afBracketB[0] = kTarget.GetImage().GetFloatData()[4];
          m_afBracketB[1] = kTarget.GetImage().GetFloatData()[5];
          bEarly = true;
          System.err.println("BREAK EARLY BAD");
          break;
        }
      }
    }
    if (!bEarly) {
      // kTarget = m_kBracketOut.GetTarget(0);
      kTarget = kCurrentBracket.GetTarget(0);
      m_pkRenderer.GetTexImage(kTarget);
      m_afBracketB[0] = kTarget.GetImage().GetFloatData()[4];
      m_afBracketB[1] = kTarget.GetImage().GetFloatData()[5];
      /*
          System.err.println("");
          System.err.println("");
          System.err.println( "GPU BracketA = " + kTarget.GetImage().GetFloatData()[0] + " " + kTarget.GetImage().GetFloatData()[1]);
          System.err.println( "GPU BracketB = " + kTarget.GetImage().GetFloatData()[4] + " " + kTarget.GetImage().GetFloatData()[5]);
          System.err.println( "GPU BracketC = " + kTarget.GetImage().GetFloatData()[8] + " " + kTarget.GetImage().GetFloatData()[9]);
      */
    }
    // System.err.println( m_afBracketB[0] + " " + m_afBracketB[1] );
  }
Ejemplo n.º 2
0
 // utility for contains takes an offset so we can check the two parts of the portal
 public boolean contains(int offset, int x, int y) {
   Edge2D e = new Edge2D(pts2d.get(offset), pts2d.get(offset + 1));
   Point2D pe = e.toLineSpace(new Point(x, y));
   return (pe.getX() > 0 && pe.getX() < 1 && Math.abs(pe.getY()) < EPSILON);
 }