not ANSI_DECLARATORS */
(m, b, searchpoint, searchtri)
| 7650 | vertex searchpoint, struct otri *searchtri) |
| 7651 | #else /* not ANSI_DECLARATORS */ |
| 7652 | enum locateresult locate(m, b, searchpoint, searchtri) |
| 7653 | struct mesh *m; |
| 7654 | struct behavior *b; |
| 7655 | vertex searchpoint; |
| 7656 | struct otri *searchtri; |
| 7657 | #endif /* not ANSI_DECLARATORS */ |
| 7658 | |
| 7659 | { |
| 7660 | VOID **sampleblock; |
| 7661 | char *firsttri; |
| 7662 | struct otri sampletri; |
| 7663 | vertex torg, tdest; |
| 7664 | size_t alignptr; |
| 7665 | REAL searchdist, dist; |
| 7666 | REAL ahead; |
| 7667 | long samplesperblock, totalsamplesleft, samplesleft; |
| 7668 | long population, totalpopulation; |
| 7669 | triangle ptr; /* Temporary variable used by sym(). */ |
| 7670 | |
| 7671 | if (b->verbose > 2) { |
| 7672 | printf(" Randomly sampling for a triangle near point (%.12g, %.12g).\n", |
| 7673 | searchpoint[0], searchpoint[1]); |
| 7674 | } |
| 7675 | /* Record the distance from the suggested starting triangle to the */ |
| 7676 | /* point we seek. */ |
| 7677 | org(*searchtri, torg); |
| 7678 | searchdist = (searchpoint[0] - torg[0]) * (searchpoint[0] - torg[0]) + |
| 7679 | (searchpoint[1] - torg[1]) * (searchpoint[1] - torg[1]); |
| 7680 | if (b->verbose > 2) { |
| 7681 | printf(" Boundary triangle has origin (%.12g, %.12g).\n", |
| 7682 | torg[0], torg[1]); |
| 7683 | } |
| 7684 | |
| 7685 | /* If a recently encountered triangle has been recorded and has not been */ |
| 7686 | /* deallocated, test it as a good starting point. */ |
| 7687 | if (m->recenttri.tri != (triangle *) NULL) { |
| 7688 | if (!deadtri(m->recenttri.tri)) { |
| 7689 | org(m->recenttri, torg); |
| 7690 | if ((torg[0] == searchpoint[0]) && (torg[1] == searchpoint[1])) { |
| 7691 | otricopy(m->recenttri, *searchtri); |
| 7692 | return ONVERTEX; |
| 7693 | } |
| 7694 | dist = (searchpoint[0] - torg[0]) * (searchpoint[0] - torg[0]) + |
| 7695 | (searchpoint[1] - torg[1]) * (searchpoint[1] - torg[1]); |
| 7696 | if (dist < searchdist) { |
| 7697 | otricopy(m->recenttri, *searchtri); |
| 7698 | searchdist = dist; |
| 7699 | if (b->verbose > 2) { |
| 7700 | printf(" Choosing recent triangle with origin (%.12g, %.12g).\n", |
| 7701 | torg[0], torg[1]); |
| 7702 | } |
| 7703 | } |
| 7704 | } |
| 7705 | } |
| 7706 | |
| 7707 | /* The number of random samples taken is proportional to the cube root of */ |
| 7708 | /* the number of triangles in the mesh. The next bit of code assumes */ |
| 7709 | /* that the number of triangles increases monotonically (or at least */ |
no test coverage detected