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 >
Wrap
C/C++ Source or Header
|
1995-04-14
|
3KB
|
125 lines
/****************************************************************************
#
# Hypothesize
#
# Hypothesize `Gestalt' features in the Feature Relation Graph (FRG)
# that can be used to close cycles.
#
# Note: Right now, a corner is hypothesized according to smoothness
# and symmetry constraints that will close a cycle. That is,
# we must have a chain of corners with only one vertex missing
# this final vertex will be generated and the polygon closed.
#
#
# Christopher Jaynes
# Feb. 22, 1994
# U. Mass.
#
# Change Summary and Comments:
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# DATE AUTHOR COMMENTS
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Feb 24, 1994 C. Jaynes Restrict the hypothesis to proper
# length cycles.
#
# Feb. 27, 1994 C. Jaynes Change the hypothesis location,
# according to the perspective transform.
#
# Feb. 12, 1995. C. Jaynes Virtual Features are placed by
# intersecting two feature lines from
# appropriate axes.
#
***************************************************************************/
#include "../polygons.h"
#define C_THRESH 0.97
/****
Return the location of a virtual feature
if a path of length one exists from
node to any other node in the visited list.
This is used to check for a "missing" feature in the
FRG. If there is a gap to be jumped in the FRG, we may
generate the new feature as a `gestalt' feature.
****/
Point TfeatureGap(cList *v1, int axis, cList *v2)
/*
* Compute the position of a virtual feature between the corners
* 'v1' and 'v2'.
*
* Create a ray from 'v1' along 'axis' and another ray along the
* opposite axis of 'v2'. The intersection point should be the location
* of the virtual feature. Return this point.
*
*/
{
Point Ipoint;
line ray1, ray2;
double parms[2];
double_2 result;
double_2 *res;
ray1.x1 = v1->x; ray1.y1 = v1->y;
ray2.x1 = v2->x; ray2.y1 = v2->y;
if (axis == AXIS1) {
ray1.x2 = ray1.x1 + LINE_SEARCH_DIST*v1->leg2Dx;
ray1.y2 = ray1.y1 + LINE_SEARCH_DIST*v1->leg2Dy;
ray2.x2 = ray2.x1 + LINE_SEARCH_DIST*v2->leg1Dx;
ray2.y2 = ray2.y1 + LINE_SEARCH_DIST*v2->leg1Dy;
} else {
ray1.x2 = ray1.x1 + LINE_SEARCH_DIST*v1->leg1Dx;
ray1.y2 = ray1.y1 + LINE_SEARCH_DIST*v1->leg1Dy;
ray2.x2 = ray2.x1 + LINE_SEARCH_DIST*v2->leg2Dx;
ray2.y2 = ray2.y1 + LINE_SEARCH_DIST*v2->leg2Dy;
}
intersect_point(ray1,ray2,&result);
computeParms(result,ray1,ray2,parms);
if (parms[0] > 0.0 && parms[0] < 1.0 && parms[1] > 0.0 &&
parms[1] < 1.0) {
res= (double_2 *)
lines_form_corner(projectionMat,ray1.x1,ray1.y1,ray1.x2,
ray1.y2,ray2.x1,ray2.y1,ray2.x2,ray2.y2,C_THRESH);
if (res->d1 != -1.0 && res->d2 != -1.0) {
Ipoint.x = ray1.x1 + parms[0]*(ray1.x2 - ray1.x1);
Ipoint.y = ray1.y1 + parms[0]*(ray1.y2 - ray1.y1);
Ipoint.z = TRUE;
}
else {
Ipoint.x = -1.0;
Ipoint.y = -1.0;
Ipoint.z = NONE;
}
}
else {
Ipoint.x = -1.0;
Ipoint.y = -1.0;
Ipoint.z = NONE;
}
/*
* Virtual Features must be at least MIN_LIN_LENGTH away!
*
*/
if ( (distance(Ipoint.x,Ipoint.y,(double)v1->x,(double)v1->y) <
MIN_LINE_LENGTH) ||
(distance(Ipoint.x,Ipoint.y,(double)v2->x,(double)v2->y) <
MIN_LINE_LENGTH) )
{
Ipoint.x = -1.0;
Ipoint.y = -1.0;
Ipoint.z = NONE;
}
return(Ipoint);
}