Comparing files V3105\Dibdoc.cpp and V3032\DIBDOC.CPP
***** V3105\Dibdoc.cpp
#include "Dib.h"
//#include "DibBlankoutDialog.h"
***** V3032\DIBDOC.CPP
#include "Dib.h"
#include "CiConfig.h"
//#include "DibBlankoutDialog.h"
*****

***** V3105\Dibdoc.cpp
#include "DibDoc.h"
#include "DibView.h"
***** V3032\DIBDOC.CPP
#include "DibDoc.h"
#include <vfw.h>
#include "DibView.h"
*****

***** V3105\Dibdoc.cpp
#include "IResultDialog.h"
#include "CiConfig.h"
#include <vfw.h>

***** V3032\DIBDOC.CPP
#include "IResultDialog.h"

*****

***** V3105\Dibdoc.cpp

extern double PAR,Flecks;

***** V3032\DIBDOC.CPP

double PAR;

*****

***** V3105\Dibdoc.cpp


/*
***** V3032\DIBDOC.CPP

/*
*****

***** V3105\Dibdoc.cpp
                for (i=0; i<MAX_IMAGE_HEIGHT; i++)
      {
         BlankoutEndI[i] = -1;
         BlankoutEndI2[i] = -1;
                        BlankoutStartI2[i] = -1;
      }

***** V3032\DIBDOC.CPP
                for (i=0; i<MAX_IMAGE_HEIGHT; i++)
                        BlankoutEndI[i] = -1;

*****

***** V3105\Dibdoc.cpp
                {
                        double angle = (double)2.*CI_PI*j/ci_config_geometry->num_of_azmuthal_division+CI_PI/2.0;//start azimut
al divisions at N 5/8/06
                //      if(!ci_config_output->bSUNTRACK)
                        {
                                int dx = (int) (radius_min * ci_cos(angle));
                                int dy = (int) (radius_min * ci_sin(angle));
                                pDC->MoveTo(rc_center_x + dx, rc_center_y - dy);
                                dx = (LONG) (radius_max * ci_cos(angle));
                                dy = (LONG) (radius_max * ci_sin(angle));
                                //device cordinates start at upper left, use - for dy.
***** V3032\DIBDOC.CPP
                {
                        double angle = (double)2.*CI_PI*j/ci_config_geometry->num_of_azmuthal_division;
        //              if(!ci_config_output->bSUNTRACK)
        //              {
        //                      int dx = (int) (radius_min * ci_cos(angle));
        //                      int dy = (int) (radius_min * ci_sin(angle));
        //                      pDC->MoveTo(rc_center_x + dx, rc_center_y - dy);
        //                      dx = (LONG) (radius_max * ci_cos(angle));
        //                      dy = (LONG) (radius_max * ci_sin(angle));
        //                      //device cordinates start at upper left, use - for dy.
        //                      CPoint dest(rc_center_x + dx, rc_center_y - dy);
        //                      pDC->LineTo(dest);
        //              }
        //              else
                        {
                                int dx = (int) (radius_min * (-ci_sin(angle)));
                                int dy = (int) (radius_min * ci_cos(angle));
                                pDC->MoveTo(rc_center_x + dx, rc_center_y - dy);
                                dx = (LONG) (radius_max * (-ci_sin(angle)));
                                dy = (LONG) (radius_max * ci_cos(angle));
                                //device cordinates start at upper left, use - for dy.
*****

***** V3105\Dibdoc.cpp
                        }
        //              else
        //              {
        //                      int dx = (int) (radius_min * (-ci_sin(angle)));
        //                      int dy = (int) (radius_min * ci_cos(angle));
        //                      pDC->MoveTo(rc_center_x + dx, rc_center_y - dy);
        //                      dx = (LONG) (radius_max * (-ci_sin(angle)));
        //                      dy = (LONG) (radius_max * ci_cos(angle));
        //                      //device cordinates start at upper left, use - for dy.
        //                      CPoint dest(rc_center_x + dx, rc_center_y - dy);
        //                      pDC->LineTo(dest);
        //              }
                }
***** V3032\DIBDOC.CPP
                        }
                }
*****

***** V3105\Dibdoc.cpp
                        da += 360;
                int endangle = m_blankout_start + da +90; //added 90 for change from W=0 to N=0 before V3.1.0.1 Aug3,2005
                //draw a line every 3 degree.
                for (int j=m_blankout_start+90; j<=endangle; j++) //added 90 for change from W=0 to N=0 before V3.1.0.1 Aug3,20
5
                {
***** V3032\DIBDOC.CPP
                        da += 360;
                int endangle = m_blankout_start + da +90; // +90 V3.0.3.1 changed from when W=0, now N=0
                //draw a line every 3 degree.
                for (int j=m_blankout_start+90; j<=endangle; j++) // +90 V3.0.3.1 changed from when W=0, now N=0
                {
*****

***** V3105\Dibdoc.cpp
                                }
                        }
                }
***** V3032\DIBDOC.CPP
                                }
                }
                }
*****

***** V3105\Dibdoc.cpp
                return -1;
   // Added the following to avoid blankout problems in calculations 5/10/06 JRG
                                if (ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])
                                        return -1;
                                if (ci_config_geometry->blankout_flag
                                        && BlankoutStartI2[j] >=0
                                        && BlankoutStartI2[j] <= i
                                        && i <= BlankoutEndI2[j])
                                        return -1;


***** V3032\DIBDOC.CPP
                return -1;

*****

***** V3105\Dibdoc.cpp
        int dy = 0;
   int tmpstore;

***** V3032\DIBDOC.CPP
        int dy = 0;

*****

***** V3105\Dibdoc.cpp
                BlankoutEndI[j] = -1;
                BlankoutStartI2[j] = -1; // 5/8/06 allows two blackout regions on one line.
                BlankoutEndI2[j] = -1;

                for (int i=CropCircleStartIndex[j]; i<=CropCircleEndIndex[j]; i++)
***** V3032\DIBDOC.CPP
                BlankoutEndI[j] = -1;
                for (int i=CropCircleStartIndex[j]; i<=CropCircleEndIndex[j]; i++)
*****

***** V3105\Dibdoc.cpp
                                }
            else
            {
               if(BlankoutEndI[j] == i-1 && i>0)
               {
                  BlankoutStartI2[j] = BlankoutStartI[j];
                  BlankoutEndI2[j]=BlankoutEndI[j];
                  BlankoutStartI[j]=-1;
                  BlankoutEndI[j]=-1;
               }
            }
         }
                }
***** V3032\DIBDOC.CPP
                                }
                        }
                }
*****

***** V3105\Dibdoc.cpp

      tmpstore=BlankoutEndI2[j];
      BlankoutEndI2[j]=BlankoutEndI[j];
      BlankoutEndI[j]=tmpstore;
      tmpstore=BlankoutStartI2[j];
      BlankoutStartI2[j]=BlankoutStartI[j];
      BlankoutStartI[j]=tmpstore;

        }// end j loop
***** V3032\DIBDOC.CPP

        }// end j loop
*****

***** V3105\Dibdoc.cpp

            if (ci_config_geometry->blankout_flag
                                        && BlankoutStartI2[j] >=0
                                        && BlankoutStartI2[j] <= i
                                        && i <= BlankoutEndI2[j])
                                        inBlankout = true;


                                if (inBlankout)
***** V3032\DIBDOC.CPP

                                if (inBlankout)
*****

***** V3105\Dibdoc.cpp
                                {
                                        if ((ci_config_geometry->blankout_flag
                                                && BlankoutStartI[j] >=0
***** V3032\DIBDOC.CPP
                                {
                                        if (ci_config_geometry->blankout_flag
                                                && BlankoutStartI[j] >=0
*****

***** V3105\Dibdoc.cpp
                                                && BlankoutStartI[j] <= i
                                                && i <= BlankoutEndI[j])||
                  (ci_config_geometry->blankout_flag
                                                && BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j]))
                                        {
***** V3032\DIBDOC.CPP
                                                && BlankoutStartI[j] <= i
                                                && i <= BlankoutEndI[j])
                                        {
*****

***** V3105\Dibdoc.cpp
                                {
                                        if ((ci_config_geometry->blankout_flag
                                                && BlankoutStartI[j] >=0
***** V3032\DIBDOC.CPP
                                {
                                        if (ci_config_geometry->blankout_flag
                                                && BlankoutStartI[j] >=0
*****

***** V3105\Dibdoc.cpp
                                                && BlankoutStartI[j] <= i
                                                && i <= BlankoutEndI[j])||
                  (ci_config_geometry->blankout_flag
                                                && BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j]))
                                        {
***** V3032\DIBDOC.CPP
                                                && BlankoutStartI[j] <= i
                                                && i <= BlankoutEndI[j])
                                        {
*****

***** V3105\Dibdoc.cpp
                        {
                                if ((ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
***** V3032\DIBDOC.CPP
                        {
                                if (ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
*****

***** V3105\Dibdoc.cpp
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])||
                  (ci_config_geometry->blankout_flag
                                                && BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j]))
                                {
***** V3032\DIBDOC.CPP
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])
                                {
*****

***** V3105\Dibdoc.cpp
                        {
                                if ((ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
***** V3032\DIBDOC.CPP
                        {
                                if (ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
*****

***** V3105\Dibdoc.cpp
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])||
                  (ci_config_geometry->blankout_flag
                                                && BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j]))
                                {
***** V3032\DIBDOC.CPP
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])
                                {
*****

***** V3105\Dibdoc.cpp
        }
//      if(totalNumAll)PAR=(double)lintensity/(double)totalNumAll*ci_config_geometry->PARzerocal;
//      else PAR=(double)0.0;


***** V3032\DIBDOC.CPP
        }
        if(totalNumAll)PAR=(double)lintensity/(double)totalNumAll*ci_config_geometry->PARcalibration;
        else PAR=(double)0.0;

*****

***** V3105\Dibdoc.cpp
                        {
                                if ((ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
***** V3032\DIBDOC.CPP
                        {
                                if (ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
*****

***** V3105\Dibdoc.cpp
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])||
                  (ci_config_geometry->blankout_flag
                                                && BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j]))
                                {
***** V3032\DIBDOC.CPP
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])
                                {
*****

***** V3105\Dibdoc.cpp
                        {
                                if ((ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
***** V3032\DIBDOC.CPP
                        {
                                if (ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
*****

***** V3105\Dibdoc.cpp
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])||
                  (ci_config_geometry->blankout_flag
                                                && BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j]))
                                {
***** V3032\DIBDOC.CPP
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])
                                {
*****

***** V3105\Dibdoc.cpp
        {
      if(((tr->r1 - tr->r0)*(tr->a1 - tr->a0))!=0)
                return ((tr->f11*(r - tr->r0) + tr->f01*(tr->r1 - r))*(a - tr->a0)
***** V3032\DIBDOC.CPP
        {
                return ((tr->f11*(r - tr->r0) + tr->f01*(tr->r1 - r))*(a - tr->a0)
*****

***** V3105\Dibdoc.cpp
                          /((tr->r1 - tr->r0)*(tr->a1 - tr->a0));
      else return 127;
        }
***** V3032\DIBDOC.CPP
                          /((tr->r1 - tr->r0)*(tr->a1 - tr->a0));
        }
*****

***** V3105\Dibdoc.cpp
        {
                if ((BlankoutStartI[j] >=0
                        && BlankoutStartI[j] <= i
                        && i <= BlankoutEndI[j])||(
                  BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j]))
                {
***** V3032\DIBDOC.CPP
        {
                if (BlankoutStartI[j] >=0
                        && BlankoutStartI[j] <= i
                        && i <= BlankoutEndI[j])
                {
*****

***** V3105\Dibdoc.cpp
                                {
                                        if ((ci_config_geometry->blankout_flag
                                                && BlankoutStartI[j] >=0
***** V3032\DIBDOC.CPP
                                {
                                        if (ci_config_geometry->blankout_flag
                                                && BlankoutStartI[j] >=0
*****

***** V3105\Dibdoc.cpp
                                                && BlankoutStartI[j] <= i
                                                && i <= BlankoutEndI[j])||
                  (ci_config_geometry->blankout_flag
                                                && BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j]))
                                        {
***** V3032\DIBDOC.CPP
                                                && BlankoutStartI[j] <= i
                                                && i <= BlankoutEndI[j])
                                        {
*****

***** V3105\Dibdoc.cpp
                                {
                                        if ((ci_config_geometry->blankout_flag
                                                && BlankoutStartI[j] >=0
***** V3032\DIBDOC.CPP
                                {
                                        if (ci_config_geometry->blankout_flag
                                                && BlankoutStartI[j] >=0
*****

***** V3105\Dibdoc.cpp
                                                && BlankoutStartI[j] <= i
                                                && i <= BlankoutEndI[j])||
                  (ci_config_geometry->blankout_flag
                                                && BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j]))
                                        {
***** V3032\DIBDOC.CPP
                                                && BlankoutStartI[j] <= i
                                                && i <= BlankoutEndI[j])
                                        {
*****

***** V3105\Dibdoc.cpp
                                        if (BlankoutStartI[j] == -1 ||
                                                !((BlankoutStartI[j] <= i && BlankoutEndI[j] >= i)||
                  ( BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j])))
                                        {
***** V3032\DIBDOC.CPP
                                        if (BlankoutStartI[j] == -1 ||
                                                !(BlankoutStartI[j] <= i && BlankoutEndI[j] >= i))
                                        {
*****

***** V3105\Dibdoc.cpp
                                        if (BlankoutStartI[j] == -1 ||
                                                !((BlankoutStartI[j] <= i && BlankoutEndI[j] >= i)||
                  ( BlankoutStartI2[j] >=0
                                                && BlankoutStartI2[j] <= i
                                                && i <= BlankoutEndI2[j])))
                                        {
***** V3032\DIBDOC.CPP
                                        if (BlankoutStartI[j] == -1 ||
                                                !(BlankoutStartI[j] <= i && BlankoutEndI[j] >= i))
                                        {
*****

***** V3105\Dibdoc.cpp
                {
                        if (angle >= ci_config_geometry->blankout1 ||
                                angle <= (ci_config_geometry->blankout2 ))
                /*      if (angle >= ci_config_geometry->blankout1 &&
                                angle <= (ci_config_geometry->blankout2 + 360))*/
                                return TRUE;
***** V3032\DIBDOC.CPP
                {
                        if (angle >= ci_config_geometry->blankout1 &&
                                angle <= (ci_config_geometry->blankout2 + 360))
                                return TRUE;
*****

***** V3105\Dibdoc.cpp
    int i, j;
    int firstblank=0;
        for( i=0; i<ci_config_geometry->num_of_zenith_division; i++ ) {
***** V3032\DIBDOC.CPP
    int i, j;
        for( i=0; i<ci_config_geometry->num_of_zenith_division; i++ ) {
*****

***** V3105\Dibdoc.cpp
                        {
                        //      if (BlankoutStartI[j] == -1 ||
                        //              !((BlankoutStartI[j] <= i && BlankoutEndI[j] >= i)||
         //         ( BlankoutStartI2[j] >=0
                        //                      && BlankoutStartI2[j] <= i
                        //                      && i <= BlankoutEndI2[j])))
                                {
***** V3032\DIBDOC.CPP
                        {
                                if (BlankoutStartI[j] == -1 ||
                                        !(BlankoutStartI[j] <= i && BlankoutEndI[j] >= i))
                                {
*****

***** V3105\Dibdoc.cpp
                        {
                //              if (BlankoutStartI[j] == -1 ||
                //                      !((BlankoutStartI[j] <= i && BlankoutEndI[j] >= i)||
      //            ( BlankoutStartI2[j] >=0
                //                              && BlankoutStartI2[j] <= i
                //                              && i <= BlankoutEndI2[j])))
                                {
***** V3032\DIBDOC.CPP
                        {
                                if (BlankoutStartI[j] == -1 ||
                                        !(BlankoutStartI[j] <= i && BlankoutEndI[j] >= i))
                                {
*****

***** V3105\Dibdoc.cpp
                        ci_result.tranmission_efficient[i] = 1. - (double)area[i]/(double)total_area[i];
      else ci_result.tranmission_efficient[i] = -1.;
    }
***** V3032\DIBDOC.CPP
                        ci_result.tranmission_efficient[i] = 1. - (double)area[i]/(double)total_area[i];
    }
*****

***** V3105\Dibdoc.cpp
{
                                if (ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])
                                        return -1;
                                if (ci_config_geometry->blankout_flag
                                        && BlankoutStartI[j] >=0
                                        && BlankoutStartI[j] <= i
                                        && i <= BlankoutEndI[j])
                                        return -1;

        int angle = Angle(i, j);
***** V3032\DIBDOC.CPP
{
        int angle = Angle(i, j);
*****

***** V3105\Dibdoc.cpp
        int dy = j - ci_config_image->center_y;
   int signflag;

   signflag=0;
   if(dx<0&&dy>0){signflag=1;dx=-dx;}
   if(dx>0&&dy<0){signflag=3;dy=-dy;}
   if(dx<0&&dy<0){signflag=2;}
   

***** V3032\DIBDOC.CPP
        int dy = j - ci_config_image->center_y;

*****

***** V3105\Dibdoc.cpp
                        angle = (int)((double)180 * ci_atan((double)dy / dx) / CI_PI);
                //      if (angle == 0 && dy < 0)
                        //      angle = -.0000000001;

***** V3032\DIBDOC.CPP
                        angle = (int)((double)180 * ci_atan((double)dy / dx) / CI_PI);
                        if (angle == 0 && dy < 0)
                                angle = -1;

*****

***** V3105\Dibdoc.cpp
                        }
        /*              if (dx > 0 && dy > 0)
                        {
***** V3032\DIBDOC.CPP
                        }
                        if (dx > 0 && dy > 0)
                        {
*****

***** V3105\Dibdoc.cpp
                                angle += 180;
                        }*/
         if(signflag==1)angle=180-angle;
         if(signflag==2)angle=180+angle;
         if(signflag==3)angle=360-angle;
                }
***** V3032\DIBDOC.CPP
                                angle += 180;
                        }
                }
*****

***** V3105\Dibdoc.cpp
        }
   angle-=90;
   if(angle<0)angle+=360; /* adjustments to angle in 3.1.0.1 to correct for earlier change from W=0 to N=0  Aug 3, 2005*/
        return angle;
***** V3032\DIBDOC.CPP
        }
   angle-=90; // -90 V3.0.3.1 changed from when W=0, now N=0
   if(angle<0)angle+=360; //  V3.0.3.1 changed from when W=0, now N=0

        return angle;
*****

***** V3105\Dibdoc.cpp
                        {
                //              if (BlankoutStartI[j] == -1 ||
                //                      !((BlankoutStartI[j] <= i && BlankoutEndI[j] >= i)||
        //          ( BlankoutStartI2[j] >=0
                        //                      && BlankoutStartI2[j] <= i
                        //                      && i <= BlankoutEndI2[j])))
                                {
***** V3032\DIBDOC.CPP
                        {
                                if (BlankoutStartI[j] == -1 ||
                                        !(BlankoutStartI[j] <= i && BlankoutEndI[j] >= i))
                                {
*****

***** V3105\Dibdoc.cpp
                        {
                        //      if (BlankoutStartI[j] == -1 ||
                        //              !((BlankoutStartI[j] <= i && BlankoutEndI[j] >= i)||
           //       ( BlankoutStartI2[j] >=0
                                //              && BlankoutStartI2[j] <= i
                                //              && i <= BlankoutEndI2[j])))
                                {
***** V3032\DIBDOC.CPP
                        {
                                if (BlankoutStartI[j] == -1 ||
                                        !(BlankoutStartI[j] <= i && BlankoutEndI[j] >= i))
                                {
*****

***** V3105\Dibdoc.cpp
                if(ci_result.tranmission_efficient[i]!=0) /* changed for WinME exceptions */
                        t[i] = ci_log(ci_result.tranmission_efficient[i]); /* natural log */
                else
                        t[i] = -8.6;
                //printf("zenith angle: %f, transmission_efficient %f.", zenith_ang[i], ci_result.tranmission_efficient[i]);
***** V3032\DIBDOC.CPP
                if(ci_result.tranmission_efficient[i]!=0) /* changed for WinME exceptions */
                        t[i] = ci_log(ci_result.tranmission_efficient[i]);
                else
                        t[i] = -18;
                //printf("zenith angle: %f, transmission_efficient %f.", zenith_ang[i], ci_result.tranmission_efficient[i]);
*****

***** V3105\Dibdoc.cpp

/*

        CIResultDialog dlg1;
        char result[10240];
        char line[256];
        memset(result, 0, 10240);
        memset(line, 0, 256);
        strcat(result, "Results:\r\n");


        for( i=0; i<ci_config_geometry->num_of_zenith_division; i++ ) {
                //elevation angle is 90 - zenith angle. Changed to Zenith angle 6/16/2000
                sprintf(line,"i %d, ZA %f, z[i] %f, te %f, da %f, n %d, t %f\r\n",i,zenith_ang[i],z[i],ci_result.tranmission_ef
icient[i],d_angle,ci_config_geometry->num_of_zenith_division,t[i]);
                strcat(result, line);
   }
        dlg1.m_ResultText = CString(result);
        dlg1.DoModal();
        dlg1.DestroyWindow();
*/


        /* calculate the transmission coefficient for diffuse penetration */
***** V3032\DIBDOC.CPP

        /* calculate the transmission coefficient for diffuse penetration */
*****

***** V3105\Dibdoc.cpp
        /* find x using bisection method */
    double xmax = 10.0, xmin = 0.1, x = 1.0;
        double s1, s2, s3, s4;
***** V3032\DIBDOC.CPP
        /* find x using bisection method */
    double xmax = 10, xmin = 0.1, x = 1;
        double s1, s2, s3, s4;
*****

***** V3105\Dibdoc.cpp
                for( int j=0; j<ci_config_geometry->num_of_zenith_division; j++ ) {
         tz = z[j];
                        ktmp = fnk( tz, x );
***** V3032\DIBDOC.CPP
                for( int j=0; j<ci_config_geometry->num_of_zenith_division; j++ ) {
                        tz = z[j];
                        ktmp = fnk( tz, x );
*****

***** V3105\Dibdoc.cpp
                }
                f = s2 * s4 - s1 * s3; /* this will always compute to close to zero???? As x increases f goes to zero*/
                if( f < 0 ) xmin = x;
***** V3032\DIBDOC.CPP
                }
                f = s2 * s4 - s1 * s3;
                if( f < 0 ) xmin = x;
*****

***** V3105\Dibdoc.cpp
        ci_result.lai = -s1/s2;
        ci_result.mean_leaf_angle = 90.0*(0.1+0.9*ci_exp((double)(-0.5*x)));


/*


        CIResultDialog dlg1;
        char result[10240];
***** V3032\DIBDOC.CPP
        ci_result.lai = -s1/s2;
        ci_result.mean_leaf_angle = 90*(0.1+0.9*ci_exp((double)(-0.5*x)));
        ci_result.x = x;

        ::SetCursor(::LoadCursor(NULL, IDC_ARROW));

        ShowResult();
}

BOOL CDibDoc::IsMeasurable()
{
        return (state == CI_SHOWCROPPEDIMAGE || state == CI_SHOWLEAFIMAGE);
}

void CDibDoc::ShowResult()
{
        CIResultDialog dlg;
        char result[10240];
*****

***** V3105\Dibdoc.cpp
        memset(line, 0, 256);
                sprintf(line," s1 %g, s2 %g, s3 %g, s4 %g, x %g, f %g\r\n",s1,s2,s3,s4,x,f);
                strcat(result, line);
                for( int j=0; j<ci_config_geometry->num_of_zenith_division; j++ ) {
      sprintf(line,"ZenithAngle %g, MeasuredT %g, PredictedT %g\r\n",180/3.14159*ci_atan(z[j]),ci_exp(t[j]),ci_exp(-fnk(z[j],x)
ci_result.lai));
                strcat(result, line);
      }
        dlg1.m_ResultText = CString(result);
        dlg1.DoModal();
        dlg1.DestroyWindow();



*/









        ci_result.x = x;

        ::SetCursor(::LoadCursor(NULL, IDC_ARROW));

        ShowResult();
}

BOOL CDibDoc::IsMeasurable()
{
        return (state == CI_SHOWCROPPEDIMAGE || state == CI_SHOWLEAFIMAGE);
}

void CDibDoc::ShowResult()
{
        CIResultDialog dlg;
        char result[10240];
        char line[256];
        memset(result, 0, 10240);
        memset(line, 0, 256);
        strcat(result, "Results:\r\n");
***** V3032\DIBDOC.CPP
        memset(line, 0, 256);
        strcat(result, "Results:\r\n");
*****

***** V3105\Dibdoc.cpp
                strcat(result, line);
                sprintf( line,          "   %6.1f         Sunflecks %6.1f%%\r\n",::PAR,::Flecks);
                strcat(result, line);
                bHasResult = TRUE;
        }
***** V3032\DIBDOC.CPP
                strcat(result, line);
                sprintf( line,          "  (with cap) %6.1f          (without cap) %6.1f\r\n",PAR,PAR/63.3);
                strcat(result, line);
        }
*****

***** V3105\Dibdoc.cpp

void CDibDoc::ShowResultSF()
{
        CIResultDialog dlg;
        char result[10240];
        char line[256];
        memset(result, 0, 10240);
        memset(line, 0, 256);
        strcat(result, "Results:\r\n");
        BOOL bHasResult = FALSE;
        double min_angle = CI_PI * ci_config_geometry->starting_zenith_angle / 180.;
        double max_angle = CI_PI * ci_config_geometry->ending_zenith_angle / 180.;
        double d_angle = (max_angle-min_angle)/ci_config_geometry->num_of_zenith_division;
        if (ci_config_output->bPAR)
        {
                sprintf( line,          "\r\nPAR: ");
                strcat(result, line);
                sprintf( line,          "   %6.1f         Sunflecks %6.1f%%\r\n",::PAR,::Flecks);
                strcat(result, line);
                bHasResult = TRUE;
        }

        if (!bHasResult)
                strcat(result, "You have chosen not to display any result.");
        dlg.m_ResultText = CString(result);
        dlg.DoModal();
        dlg.DestroyWindow();
}

void CDibDoc::PrintResult(CDC* pDC)
***** V3032\DIBDOC.CPP

void CDibDoc::PrintResult(CDC* pDC)
*****

***** V3105\Dibdoc.cpp

double CDibDoc::fnk2( double z, double x )
{
    return( ci_sqrt(x*x+1/(tan(1.570795-atan(z))*tan(1.570795-atan(z)))) / (1.47+(((.000509*x-.013)*x+.1223)*x+.45)*x));
}

void CDibDoc::SetDrawGeoDiv(BOOL bDraw)
***** V3032\DIBDOC.CPP

void CDibDoc::SetDrawGeoDiv(BOOL bDraw)
*****

