home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / CFDFront / TRow.cp < prev    next >
Encoding:
Text File  |  1992-02-21  |  22.1 KB  |  628 lines  |  [TEXT/MPS ]

  1. #pragma segment Matrix
  2. // **********************************************************************
  3. //    TBoundry Class
  4. //        Contains a list of pointers to TBoundry points stored in TGridMatrix
  5. // **********************************************************************
  6. // --------------------------------------------------------------------------------------------------
  7. //    TBoundry    :    Initialize the Class
  8. // --------------------------------------------------------------------------------------------------
  9. void TBoundry::IRow(TPoint * p1, TPoint * p2, short side)
  10.     {
  11.     inherited::IRow(p1,p2);                                                                // initialize the list
  12.     
  13.     fSide = side;
  14.     return;
  15.     }
  16.     
  17. // **********************************************************************
  18. //    TRow Class
  19. //        Contains a list of pointers to TPoint
  20. // **********************************************************************
  21. // --------------------------------------------------------------------------------------------------
  22. //    TRow    :    Initialize the Class
  23. // --------------------------------------------------------------------------------------------------
  24. void TRow::IRow(TPoint * p1, TPoint * p2)
  25.     {
  26.     inherited::IList();                                                                            // initialize the list
  27.     
  28.     InsertFirst ((TObject *) p1);                                                        // store pointer to segment in list
  29.     InsertLast ((TObject *) p2);                                                            // store pointer to segment in list
  30.     return;
  31.     }
  32.         
  33. // --------------------------------------------------------------------------------------------------
  34. //    TRow    :    For Each point in the list Do the DoToItem Function
  35. // --------------------------------------------------------------------------------------------------
  36. pascal void TRow::Each(pascal void (*DoToItem)(TObject *, void *), void *DoToItem_StaticLink)
  37.     {
  38.     TPoint        *    tPt;                                                                            // the point to process
  39.     PointInfo    *    info;                                                                            // information structure
  40.     short        index;
  41.      
  42.     info = (PointInfo *) DoToItem_StaticLink;                                        // cast the structure
  43.     if (fSize > 0)                                                                                    // anything in the list?
  44.         {
  45.         tPt                    = NULL;                                                            // initialize the current point
  46.         info->below         = NULL;                                                            // initialize the point below
  47.         info->left            = (TPoint *) this->At(fSize);                            // get last point in this row
  48.         if (info->aboveRow != NULL)                                                        // on top row?
  49.             info->oPt         = (TPoint *) info->aboveRow->At(fSize);            // get last point in the row above
  50.         else
  51.             info->oPt        = NULL;                                                            // no point
  52.         
  53.         if (info->boundry == cNotOnBoundry)
  54.             info->boundry = cRight;
  55.         
  56.         for (index = (short) fSize; index > 0; index--)                            // all points in the row
  57.             {
  58.             info->right    = tPt;                                                                // assign point to right
  59.             tPt                 = info->left;                                                        // assign current point    
  60.             info->above    = info->oPt;                                                        // assign point above
  61.             if (index > 1)                                                                        // not on left boundry
  62.                 {
  63.                 info->left = (TPoint *) this->At(index-1);                            // get new left point
  64.                 if (info->aboveRow != NULL)                                                // on top row?
  65.                     info->oPt = (TPoint *) info->aboveRow->At(index-1);    // get new obstacle point
  66.                 }
  67.             else
  68.                 {
  69.                 info->left = info->oPt = NULL;                                            // no point
  70.                 if (info->boundry == cNotOnBoundry)
  71.                     info->boundry = cLeft;
  72.                 }
  73.                 
  74.             if (info->belowRow != NULL)                                                    // on bottom row?
  75.                 info->below = (TPoint *) info->belowRow->At(index);        // get point below
  76.             info->column = index;
  77.                         
  78.             DoToItem((TObject *)tPt,info);                                                // perform the function
  79.             if (info->boundry != cTop && info->boundry != cBottom)
  80.                 info->boundry = cNotOnBoundry;
  81.             info->lrc = NULL;
  82.             }
  83.         }
  84.     return;
  85.     }
  86.     
  87. // --------------------------------------------------------------------------------------------------
  88. //    TRow    :    SearchRow .... 
  89. //        try to match the location of the mouse point to an object point in this row
  90. // -------------------------------------------------------------------------------------------------
  91. short TRow::SearchPoint(Point * tMouse)
  92.     {
  93.     short rIndex;
  94.     TPoint * tPt;
  95.     
  96.     for (rIndex = 1; rIndex <= fSize; rIndex++)
  97.         {
  98.         tPt = (TPoint *) this->At(rIndex);
  99.         if (tPt->OnPoint(tMouse))
  100.             return rIndex;
  101.         }
  102.     return 0;
  103.     }
  104.     
  105. // --------------------------------------------------------------------------------------------------
  106. //    TPointMatrix    :    SearchRow .... 
  107. //        try to match the location of the mouse point to a line between point objects
  108. // --------------------------------------------------------------------------------------------------
  109. short TRow::SearchSection(Point * tMouse)
  110.     {
  111.     short cIndex;
  112.     TPoint * tPt1, * tPt2;
  113.     Point    pt1, pt2;
  114.     
  115.     tPt1    = (TPoint *) this->First();                                                            // first point in column
  116.     pt1    = tPt1->fStart;                                                                            // actual location
  117.     for (cIndex = 2; cIndex <= fSize; cIndex++)
  118.         {
  119.         tPt2    = (TPoint *) this->At(cIndex);
  120.         pt2    = tPt2->fStart;
  121.         if (this->PointOnLine(pt1,pt2,tMouse))
  122.             return cIndex;
  123.  
  124.         tPt1    = tPt2;
  125.         pt1    = pt2;
  126.         }
  127.     return 0;
  128.     }
  129.     
  130. // --------------------------------------------------------------------------------------------------
  131. //    Is the point, theMouse contained by the line segment terminated by last and next.
  132. //    theMouse is changed so that it falls exactly on the line.
  133. // --------------------------------------------------------------------------------------------------
  134. Boolean TRow::PointOnLine (Point tpt1, Point tpt2, Point  * tMouse)
  135.     {
  136.     lineSlope     tSlope;                                                                            // slope structure
  137.     Point        cpt1, cpt2;                                                                    // center of the points
  138.     short         testPoint;
  139.     extended    mMousev;
  140.     extended    mMouseh;
  141.     
  142.     cpt1.v    =    (short) (tpt1.v + .50 * (gPensize_V+1));
  143.     cpt1.h    =    (short) (tpt1.h + .50 * (gPensize_H+1));
  144.     cpt2.v    =    (short) (tpt2.v + .50 * (gPensize_V+1));
  145.     cpt2.h    =    (short) (tpt2.h + .50 * (gPensize_H+1));
  146.  
  147.     mMouseh = tMouse->h;
  148.     mMousev = tMouse->v;
  149.  
  150.     tSlope.first        =    cpt1;                                                                // initialize the slope structure
  151.     tSlope.second    =    cpt2;
  152.     HLock((Handle) this);
  153.     SlopeIntercept(&tSlope);                                                                // get the slope of this line
  154.     HUnlock((Handle) this);
  155.     
  156. //    handle the case where the denominator of the the slope equation would be zero.
  157. //    a zero denominator would indicate a HORIZONTAL line.
  158.  
  159.     if (tSlope.horizontal)                                                                        // line is horizontal
  160.         {
  161.         testPoint = cpt2.v - tMouse->v;                                                // determine v distance from pt to line
  162.  
  163.         snap.v =  tpt1.v;                                                                        // later want to snap to the line
  164.         snap.h =  tMouse->h;
  165.  
  166.         if (testPoint < cMousePlay && testPoint > -cMousePlay)            // within Play limits?
  167.             if (cpt1.h > cpt2.h)                                                                 // it is on the ray, is it on the line?
  168.                 if (tMouse->h <= cpt1.h && tMouse->h >= cpt2.h)                // is it between next & last horiz points?
  169.                     return true;                                                                    // inform caller.
  170.                 else;
  171.             else                                                                                        // last.h <= next.h
  172.                 if (tMouse->h >= cpt1.h && tMouse->h <= cpt2.h)                // on line?
  173.                     return true;
  174.                 else;
  175.         else;
  176.         }    
  177.     else    if (tSlope.vertical)                                                                // Line is NOT HORIZONTAL
  178.         {
  179.         testPoint = cpt1.h - tMouse->h;
  180.             
  181.         snap.v =  tMouse->v;                                                                // later want to snap to the line
  182.         snap.h = tpt1.h;
  183.             
  184.         if (testPoint < cMousePlay && testPoint > -cMousePlay)             // if testPoint = 0 point is on line
  185.                                                                                                         // within play limits?
  186.                 if (cpt1.v > cpt2.v)                                                             // it is on the ray, is it on the line?
  187.                     if (tMouse->v <= cpt1.v && tMouse->v >= cpt2.v)         // is on line
  188.                         return true;                                                                // inform caller.
  189.                     else;
  190.                 else                                                                                    // last.v <= next.v
  191.                     if (tMouse->v >= cpt1.v && tMouse->v <= cpt2.v)         // on line?
  192.                         return true;
  193.                     else;
  194.         else;
  195.         }
  196.     else                                                                                                // line NOT horizontal or vertical
  197.         {
  198. //
  199. //    To calculate the closest point on the boundry line to the mouse click find the intersection point on the boundry line
  200. //    and the perpendicular which passes through the mouse click point.
  201. //
  202. //     struct tSlope contains the slope & intercept of the original boundry line.  
  203. //        This is represented by the intercept formula : y = yInterceptA - slopeA * x
  204. //     Line B is perpendicular to the boundry line.  It contains  the mouse point.  It's slope is the inverse of the slope of line A.
  205. //    The intercept formula for line B is : y = bB - mB * x
  206. //    Since the two lines intersect, the system of equations can be solved to find a single X,Y that satisfies both equations.
  207. //        tSlope.m * x + tSlope.b = mB * x + bB    .... (Then solve for x).
  208. //
  209.         extended    mB;                                                                                    // slope of line B
  210.         extended     bB;                                                                                    // y intercept point of line B
  211.         extended    x,y;                                                                                    // X,Y coordinate on boundry line.
  212.         extended    testDistance;                                                                    // distance between X,Y & mouse click point
  213.         extended my, mx;
  214.             
  215. // compute the slope for the boundry line            
  216.         mB = -1/tSlope.m;                                                                            // calculate slope B
  217.         bB  = (extended) tMouse->v - (mB * (extended) tMouse->h);                // calculate y Intercept of line B
  218.             
  219.         x = (bB - tSlope.b) / (tSlope.m - mB);                                                // calculate X coordinate on boundry line
  220.         y = (tSlope.m * x) + tSlope.b;                                                             // calculate Y coordinate on boundry line
  221.             
  222.         mx = x - (extended) tMouse->h;
  223.         my = y - (extended) tMouse->v;
  224.         testDistance = sqrt((mx*mx) + (my*my));                                        // calculate distance between X,Y & mMouse.
  225.     
  226.         if (testDistance <= cMousePlay && testDistance >= -cMousePlay)     // inside mouse play limits?
  227.             {
  228. //
  229. //    We now know that the point is within the slope of the line.  Now determine whether the point is within
  230. //    the limits of the line defined by points: last & next.  Determine this by calculating the distance between
  231. //    last & next then last & mMouse.  If the mMouse distance is less then the point is within the limits of the line
  232. //
  233. //    calculate the distance between last & mMouse
  234. //
  235.             extended LineSize;
  236.             extended testDistance2;
  237.                 
  238.             snap.v = (short) (y - .50 *(gPensize_V+1));                                    // later want to snap to the line
  239.             snap.h = (short) (x - .50 *(gPensize_H+1));
  240.                 
  241.             testDistance = CalculateDistance(cpt1,*tMouse);                            // calculate distance mouse to left point
  242.             testDistance2 = CalculateDistance(cpt2,*tMouse);                        // calculate distance mouse to right point
  243.             if (testDistance < testDistance2)
  244.                 testDistance = testDistance2;
  245.  
  246. //    calculate the distance between last & next
  247.             LineSize = CalculateDistance(cpt1,cpt2);                                        // total length of section
  248.                 
  249.             if (testDistance <= LineSize)
  250.                 return true;                                                                                // yes return true
  251.             }
  252.         }
  253.     return false;                                                                                                // not in the section
  254.     }
  255.  
  256. // --------------------------------------------------------------------------------------------------
  257. //    TRow    :    SnaptoSection .... 
  258. //        snap the point to the current line...  
  259. //        Point Snap is set in PointOnLine method
  260. // --------------------------------------------------------------------------------------------------
  261. void TRow::SnaptoSection (Point * theMouse)
  262.     {
  263. //
  264. //    odds are the user will not click exactly on the line.
  265. //     it is therefore necessary to snap the point to the line.  This prevents the line
  266. //    from jumping all over the place.
  267. //    The snap point is set in PointOnLine.
  268. //
  269.     theMouse->v = snap.v;
  270.     theMouse->h = snap.h;
  271.     return;
  272.     }
  273.  
  274. // --------------------------------------------------------------------------------------------------
  275. //    TRow    :    GetLength .... 
  276. //        determines the total length of the row   
  277. // --------------------------------------------------------------------------------------------------
  278. extended TRow::GetLength (TPoint * t)
  279.     {
  280.     extended total;
  281.     Point     t1, t2;
  282.     short x, y;                                                                                            // counter
  283.     
  284.     if (t == NULL)
  285.         y = 2;
  286.     else if ((y = (short) this->GetSameItemNo((TObject *) t)) ==  0)
  287.         y = 2;
  288.         
  289.     total = 0L;
  290.     t1 = ((TPoint *) this->At(1))->fStart;
  291.     for (x = y; x <= (short) fSize; x++)
  292.         {
  293.         t2 = ((TPoint *) this->At(x))->fStart;
  294.         total += CalculateDistance(t1,t2);
  295.         t1 = t2;
  296.         }
  297.         
  298.     return total;
  299.     }
  300.     
  301. // --------------------------------------------------------------------------------------------------
  302. //    TRow    :    GetLength .... 
  303. //        determines the total length of the row   
  304. // --------------------------------------------------------------------------------------------------
  305. extended TRow::GetDifferance (short start, ArrayIndex index, Boolean xCalc)
  306.     {
  307.     extended totalh, totalv;
  308.     Point     t1, t2;
  309.     short     x;                                                                                        
  310.             
  311.     if (index == 0)
  312.         return 0;
  313.         
  314.     if (start == 0)
  315.         start = 1;
  316.     if (index == 0)
  317.         index = (short) fSize;
  318.         
  319.     totalv = totalh = 0L;
  320.     t1 = ((TPoint *) this->At(start))->fStart;
  321.     for (x = start+1; x <= index; x++)
  322.         {
  323.         t2 = ((TPoint *) this->At(x))->fStart;
  324.         totalh += (abs(t2.h  - t1.h));
  325.         totalv += (abs(t2.v  - t1.v));
  326.         t1 = t2;
  327.         }
  328.         
  329.     if (xCalc)
  330.         return totalh;
  331.     return totalv;
  332.     }
  333.     
  334. // --------------------------------------------------------------------------------------------------
  335. //    TRow    :    FixHold .... 
  336. //        Adds the point into the list at the specified index 
  337. // --------------------------------------------------------------------------------------------------
  338. void TRow::FixHold (void)
  339.     {
  340.     TPoint * tPt;
  341.     short    i;
  342.     for (i = 1; i <= (short) fSize; i++)
  343.         {
  344.         tPt = (TPoint *) this->At(i);
  345.         tPt->FixHold();
  346.         }
  347.     }
  348.     
  349. // --------------------------------------------------------------------------------------------------
  350. //    TRow    :    RememberRow .... 
  351. //        All Points in the row remember yourself
  352. // --------------------------------------------------------------------------------------------------
  353. void TRow::RememberRow (void)
  354.     {
  355.     TPoint * tPt;
  356.     short    i;
  357.     for (i = 1; i <= (short) fSize; i++)
  358.         {
  359.         tPt = (TPoint *) this->At(i);
  360.         tPt->RememberPoint();
  361.         }
  362.     }
  363.  
  364. // --------------------------------------------------------------------------------------------------
  365. //    TRow    :    RetrieveAndFixRow
  366. //        Retrieves the saved coordinates and places them in hold & fixes to fStart
  367. // --------------------------------------------------------------------------------------------------
  368. void TRow::RetrieveAndFixRow(void)
  369.     {
  370.     short    i;
  371.     TPoint    * tPt;
  372.     Point    temp;
  373.     
  374.     for (i = 1; i <= (short) fSize; i++)
  375.         {
  376.         tPt = (TPoint *) this->At(i);
  377.         temp = tPt->RetrievePoint();
  378.         tPt->RememberPoint();
  379.         tPt->SetStart(temp.v,temp.h);
  380.         }
  381.     }
  382.     
  383. // --------------------------------------------------------------------------------------------------
  384. //    TRow    :    AddPointAt .... 
  385. //        Adds the point into the list at the specified index 
  386. // --------------------------------------------------------------------------------------------------
  387. TGridPoint * TRow::AddPointAt (short index, Point tPoint, float mag)
  388.     {
  389.     TGridPoint * nPoint;
  390.  
  391.     if (fSize > 0)
  392.         {
  393.         nPoint = new TGridPoint;                                                                // allocate memory
  394.         if (nPoint == NULL)                                                                        // not enough memory
  395.             return NULL;
  396.         nPoint->IPoint(tPoint.v, tPoint.h,    Grid, mag);                                // initialize point
  397.         this->InsertBefore(index, (TObject *) nPoint);                                // register point in list
  398.         return nPoint;
  399.         }
  400.     return NULL;
  401.     }
  402.         
  403. // --------------------------------------------------------------------------------------------------
  404. //    TRow    :    GetNumberSegments .... 
  405. //        Adds the point into the list at the specified index 
  406. // --------------------------------------------------------------------------------------------------
  407. short TRow::GetNumberSegments (void)
  408.     {
  409.     short index, num;
  410.     TPoint * tPt;
  411.     
  412.     num = 1;
  413.     for (index = 2; index < (short) fSize; index++)
  414.         {
  415.         tPt = (TPoint *) this->At(index);
  416.         if (tPt->IsSegment())
  417.             num++;
  418.         }
  419.     return  num;
  420.     }
  421.  
  422. // --------------------------------------------------------------------------------------------------
  423. //    TRow    :    GetSegments .... 
  424. //        Finds the segment adjacent to supplied point
  425. //        True     = Previous Segment
  426. //        False    = Next Segment
  427. // --------------------------------------------------------------------------------------------------
  428. TPoint * TRow::GetAdjacentSegment (Boolean direction, TPoint * tPt)
  429.     {
  430.     short    index, y;
  431.     TPoint    * sPt;
  432.     
  433.     y = (short) this->GetSameItemNo(tPt);                                                    // find original point
  434.     if (direction)
  435.         {
  436.         for (index = y-1; index > 0; index--)                                                // search for previous segment
  437.             {
  438.             sPt = (TPoint *) this->At(index);                                                    // get point
  439.             if (sPt->IsSegment())                                                                    // is segment?
  440.                 return sPt;                                                                                // got it
  441.             }
  442.         return  (TPoint *) this->First();                                                        // return the corner
  443.         }
  444.     
  445.     for (index = y+1; index < (short) this->fSize; index++)                                // search for next segment
  446.         {
  447.         sPt = (TPoint *) this->At(index);                                                        // get point
  448.         if (sPt->IsSegment())                                                                        // is segment?
  449.             return sPt;                                                                                    // got it
  450.         }
  451.     return  (TPoint *) this->Last();                                                            // return corner
  452.     }
  453.  
  454. // --------------------------------------------------------------------------------------------------
  455. //    TRow    :    GetNumBaffle .... 
  456. //        returns the number of baffles in the grid
  457. // --------------------------------------------------------------------------------------------------
  458. short TRow::GetNumBaffle(Boolean vert)
  459.     {
  460.     TPoint     * tPt;
  461.     short     i, total;
  462.     
  463.     total = 0;
  464.     for (i = 1; i <= (short) fSize; i++)
  465.         {
  466.         tPt = (TPoint *) this->At(i);
  467.         if (vert && tPt->fBaffAbove != NULL)
  468.             total++;
  469.         else if (!vert && tPt->fBaffLeft != NULL)
  470.             total++;
  471.         }
  472.     return total;
  473.     }
  474.     
  475. // --------------------------------------------------------------------------------------------------
  476. //    TRow    :    GetNumObstacle .... 
  477. //        returns the number of baffles in the grid
  478. // --------------------------------------------------------------------------------------------------
  479. short TRow::GetNumObstacle(void)
  480.     {
  481.     TPoint     * tPt;
  482.     short     i, total;
  483.     
  484.     total = 0;
  485.     for (i = 1; i <= (short) fSize; i++)
  486.         {
  487.         tPt = (TPoint *) this->At(i);
  488.         if (tPt->fObsLwRight != NULL)
  489.             total++;
  490.         }
  491.     return total;
  492.     }
  493.     
  494. // --------------------------------------------------------------------------------------------------
  495. //    TRow    :    WriteSegment .... 
  496. //        Writes the information for each segment on the boundry
  497. // --------------------------------------------------------------------------------------------------
  498. void TRow::WForward (TOutput * output, short aRefNum, char * export,long fine)
  499.     {
  500.     char string[80];
  501.     short index, i, fst;
  502.     TPoint * tPt;
  503.     WallRecord data;
  504.     long temp;
  505.     
  506.     string[0] = 0;                                                                                        // null the string
  507.     fst         = 1;
  508.     i             = 0;
  509.     data.u    = 0.0;
  510.     for (index = 2; index <= (short) fSize; index++)                    // do entire boundry
  511.         {
  512.         tPt = (TPoint *) this->At(index);                                                // get point
  513.         if (tPt->IsSegment())                                                                        // is a new segment
  514.             {
  515.             data        = ((TSegPoint *) tPt)->GetData();                            // get point data
  516.             i = sprintf(string,"%d ",tPt->GetSectionType());            // boundry type
  517.     
  518.             if (strcmp(export,"\n") == 0)
  519.                 {
  520.                 i += sprintf(string+i,"%d ",fst);                                        // jf    -    first cell
  521.                 i += sprintf(string+i,"%d",index-1);                                // jl    -    last cell
  522.                 }
  523.             else
  524.                 {
  525.                 temp = (pow(2,fine)) * (fst - 1) + 1;
  526.                 i += sprintf(string+i,"%ld ",temp);
  527.                 temp = (pow(2,fine)) * (index-1);
  528.                 i += sprintf(string+i,"%ld",temp);
  529.                 }
  530.             sprintf(string+i,export);
  531.             output->Write(aRefNum,string);                                                // write the string
  532.             
  533.             HLock((Handle) this);
  534.             this->WriteSegmentData(&data,output,aRefNum,export);
  535.             HUnlock((Handle) this);
  536.             
  537.             fst        = index;                                                                                // start cell
  538.             }
  539.         }
  540.     }
  541.  
  542. // --------------------------------------------------------------------------------------------------
  543. //    TRow    :    WriteSegment .... 
  544. //        Writes the information for each segment on the boundry
  545. // --------------------------------------------------------------------------------------------------
  546. void TRow::WBack (TOutput * output, short aRefNum, char * export,long fine)
  547.     {
  548.     char string[80];
  549.     short index, i, fst,lst;
  550.     long temp;
  551.     TPoint * tPt;
  552.     WallRecord data;
  553.     
  554.     string[0] = 0;                                                                                    // null the string
  555.     fst             = 1;
  556.     i                 = 0;
  557.     data.u        = 0.0;
  558.     tPt = (TPoint *) this->Last();                                                    // get point
  559.     data        = ((TSegPoint *) tPt)->GetData();                                // get point data
  560.     i = sprintf(string,"%d ",tPt->GetSectionType());                // boundry type
  561.     
  562.     for (index = (short) fSize-1; index > 0; index--)                // do entire boundry
  563.         {
  564.         tPt = (TPoint *) this->At(index);                                            // get point
  565.         if (tPt->IsSegment())                                                                    // is a new segment
  566.             {
  567.             lst = (short) fSize - index;
  568.             if (strcmp(export,"\n") == 0)
  569.                 {
  570.                 i += sprintf(string+i,"%d ",fst);                                    // jf        -    first cell
  571.                 i += sprintf(string+i,"%d",lst);                                    // jl        -    last cell
  572.                 }
  573.             else
  574.                 {
  575.                 temp = (pow(2,fine)) * (fst - 1) + 1;
  576.                 i += sprintf(string+i,"%ld ",temp);
  577.                 temp = (pow(2,fine)) * lst;
  578.                 i += sprintf(string+i,"%ld",temp);
  579.                 }
  580.             sprintf(string+i,export);
  581.             output->Write(aRefNum,string);                                            // write the string
  582.                 
  583.             HLock((Handle) this);
  584.             this->WriteSegmentData(&data,output,aRefNum,export);
  585.             HUnlock((Handle) this);
  586.                 
  587.             data = ((TSegPoint *) tPt)->GetData();                            // get point data
  588.             i = sprintf(string,"%d ",tPt->GetSectionType());        // boundry type
  589.  
  590.             fst = (short) fSize - index + 1;
  591.             }
  592.         }
  593.     }
  594.     
  595. // --------------------------------------------------------------------------------------------------
  596. //    TRow    :    WriteSegment .... 
  597. //        Writes the information for each segment on the boundry
  598. // --------------------------------------------------------------------------------------------------
  599. void TRow::WriteSegmentData (WallRecord * data, TOutput * output, short aRefNum, char * export)
  600.     {
  601.     char string[80];
  602.     short i;
  603.     
  604.     i = sprintf(string,"%f ",data->u);                                            // ub        -    u velocity
  605.     i += sprintf(string+i,"%f ",data->v);                                        // vb        -    v velocity
  606.     i += sprintf(string+i,"%f ",data->w);                                        // wb        -    w velocity
  607.     i += sprintf(string+i,"%f ",data->visc);                                // vscty    -    viscosity
  608.     i += sprintf(string+i,"%f",data->temp);                                    // tx        -    temperature
  609.     sprintf(string+i,export);
  610.     output->Write(aRefNum,string);                                                    // write the string
  611.                 
  612.     i = sprintf(string,"%f ",data->density);                                // rh        -    density
  613.     i += sprintf(string+i,"%f ",data->mixfrac);                            // fx        -    mixture fraction
  614.     i += sprintf(string+i,"%f ",data->concfrac);                        // gx        -    concentration fraction
  615.     i += sprintf(string+i,"%f ",data->kenergy);                            // tx        -    kinetic energy
  616.     i += sprintf(string+i,"%f",data->dissip);                                // td        -    dissipation
  617.     sprintf(string+i,export);
  618.     output->Write(aRefNum,string);                                                    // write the string
  619.                 
  620.     i = sprintf(string,"%f ",data->fuelfrac);                                // fu        -    fuel fraction
  621.     i += sprintf(string+i,"0 ");                                                        // co2        -    (always 0)
  622.     i += sprintf(string+i,"0 ");                                                        // h2o        -    (always 0)
  623.     i += sprintf(string+i,"0 ");                                                        // o2        -     (always 0)
  624.     i += sprintf(string+i,"0");                                                            // wm        -    (always 0)
  625.     sprintf(string+i,export);
  626.     output->Write(aRefNum,string);                                                    // write the string
  627.     }
  628.