home *** CD-ROM | disk | FTP | other *** search
/ vis-ftp.cs.umass.edu / vis-ftp.cs.umass.edu.tar / vis-ftp.cs.umass.edu / pub / Software / ASCENDER / ascendMar8.tar / UMass / BuildingFinder / Staging / hypothesize.c < prev    next >
C/C++ Source or Header  |  1995-04-14  |  3KB  |  125 lines

  1. /****************************************************************************
  2. #
  3. #    Hypothesize 
  4. #
  5. #    Hypothesize `Gestalt' features in the Feature Relation Graph (FRG)
  6. #    that can be used to close cycles.
  7. #
  8. #    Note: Right now, a corner is hypothesized according to smoothness
  9. #          and symmetry constraints that will close a cycle.  That is,
  10. #          we must have a chain of corners with only one vertex missing
  11. #          this final vertex will be generated and the polygon closed.
  12. #
  13. #    
  14. #       Christopher Jaynes
  15. #    Feb. 22, 1994
  16. #    U. Mass.  
  17. #
  18. #    Change Summary and Comments:
  19. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  20. # DATE            AUTHOR        COMMENTS
  21. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. #
  23. # Feb 24, 1994        C. Jaynes    Restrict the hypothesis to proper 
  24. #                    length cycles.
  25. #
  26. # Feb. 27, 1994        C. Jaynes    Change the hypothesis location, 
  27. #                        according to the perspective transform.
  28. #
  29. # Feb. 12, 1995.    C. Jaynes    Virtual Features are placed by 
  30. #                    intersecting two feature lines from
  31. #                    appropriate axes.
  32. #
  33. ***************************************************************************/
  34.  
  35. #include "../polygons.h"
  36.  
  37. #define C_THRESH    0.97
  38.  
  39. /****
  40.     Return the location of a virtual feature
  41.         if a path of length one exists from
  42.     node to any other node in the visited list.
  43.     This is used to check for a "missing" feature in the 
  44.     FRG.  If there is a gap to be jumped in the FRG, we may
  45.     generate the new feature as a `gestalt' feature.
  46. ****/
  47.  
  48. Point TfeatureGap(cList *v1, int axis, cList *v2)
  49. /* 
  50.  * Compute the position of a virtual feature between the corners 
  51.  * 'v1' and 'v2'.
  52.  *
  53.  *  Create a ray from 'v1' along 'axis' and another ray along the 
  54.  *  opposite axis of 'v2'.  The intersection point should be the location
  55.  *  of the virtual feature. Return this point.
  56.  *
  57.  */ 
  58. {
  59.  
  60.  
  61.     Point Ipoint;
  62.     line ray1, ray2;
  63.     double parms[2];
  64.     double_2 result;
  65.     double_2 *res;
  66.  
  67.     ray1.x1 = v1->x; ray1.y1 = v1->y;
  68.  
  69.     ray2.x1 = v2->x; ray2.y1 = v2->y;
  70.  
  71.     if (axis == AXIS1) {
  72.        ray1.x2 = ray1.x1 + LINE_SEARCH_DIST*v1->leg2Dx;
  73.        ray1.y2 = ray1.y1 + LINE_SEARCH_DIST*v1->leg2Dy;
  74.  
  75.        ray2.x2 = ray2.x1 + LINE_SEARCH_DIST*v2->leg1Dx;
  76.        ray2.y2 = ray2.y1 + LINE_SEARCH_DIST*v2->leg1Dy;
  77.     } else {
  78.        ray1.x2 = ray1.x1 + LINE_SEARCH_DIST*v1->leg1Dx;
  79.        ray1.y2 = ray1.y1 + LINE_SEARCH_DIST*v1->leg1Dy;
  80.  
  81.        ray2.x2 = ray2.x1 + LINE_SEARCH_DIST*v2->leg2Dx;
  82.        ray2.y2 = ray2.y1 + LINE_SEARCH_DIST*v2->leg2Dy;
  83.     }
  84.  
  85.     intersect_point(ray1,ray2,&result);
  86.     computeParms(result,ray1,ray2,parms);
  87.  
  88.     if (parms[0] > 0.0 && parms[0] < 1.0 && parms[1] > 0.0  &&
  89.          parms[1] < 1.0) {
  90.         res= (double_2 *)
  91.           lines_form_corner(projectionMat,ray1.x1,ray1.y1,ray1.x2,
  92.             ray1.y2,ray2.x1,ray2.y1,ray2.x2,ray2.y2,C_THRESH);
  93.         if (res->d1 != -1.0 && res->d2 != -1.0) {
  94.             Ipoint.x = ray1.x1 + parms[0]*(ray1.x2 - ray1.x1);
  95.                 Ipoint.y = ray1.y1 + parms[0]*(ray1.y2 - ray1.y1);
  96.             Ipoint.z = TRUE;
  97.         }
  98.         else {
  99.             Ipoint.x = -1.0;
  100.             Ipoint.y = -1.0;
  101.             Ipoint.z = NONE;
  102.         }
  103.     }
  104.     else {
  105.         Ipoint.x = -1.0;
  106.         Ipoint.y = -1.0;
  107.         Ipoint.z = NONE;
  108.     }
  109.  
  110.     /*
  111.      * Virtual Features must be at least MIN_LIN_LENGTH away! 
  112.       *
  113.      */
  114.      if ( (distance(Ipoint.x,Ipoint.y,(double)v1->x,(double)v1->y) <
  115.                 MIN_LINE_LENGTH) ||
  116.          (distance(Ipoint.x,Ipoint.y,(double)v2->x,(double)v2->y) <
  117.                 MIN_LINE_LENGTH) )
  118.          {
  119.         Ipoint.x = -1.0;
  120.         Ipoint.y = -1.0;
  121.         Ipoint.z = NONE;
  122.       }
  123.     return(Ipoint);
  124. }
  125.