}
-// calculate an "arbitrary" point inside the specified contour for
+// calculate some "arbitrary" point inside the specified contour for
// assigning attribute areas
void FGPolygon::calc_point_inside( const int contour,
const FGTriNodes& trinodes ) {
Point3D tmp, min, ln, p1, p2, p3, m, result;
- // 1. find point, min, with smallest y
+ // 1. find a point on the specified contour, min, with smallest y
// min.y() starts greater than the biggest possible lat (degrees)
min.sety( 100.0 );
if ( intersects(p1, p2, m.x(), &result) ) {
// cout << "intersection = " << result << endl;
if ( ( result.y() < p3.y() ) &&
- ( fabs(result.y() - m.y()) > FG_EPSILON ) ) {
+ ( result.y() > m.y() + FG_EPSILON ) ) {
p3 = result;
}
}
if ( intersects(p1, p2, m.x(), &result) ) {
// cout << "intersection = " << result << endl;
if ( ( result.y() < p3.y() ) &&
- ( fabs(result.y() - m.y()) > FG_EPSILON ) ) {
+ ( result.y() > m.y() + FG_EPSILON ) ) {
p3 = result;
}
}
const point_list& fit_list,
const FGgpcPolyList& gpc_polys )
{
+ int debug_counter = 0;
FGPolygon poly;
int index;
polylist[i].clear();
// cout << "area type = " << i << endl;
+ debug_counter = 0;
current = gpc_polys.polys[i].begin();
last = gpc_polys.polys[i].end();
for ( ; current != last; ++current ) {
exit(-1);
}
- if (gpc_poly->num_contours > 1 ) {
- cout << "FATAL ERROR! no multi-contour support" << endl;
- sleep(2);
- // exit(-1);
- }
-
poly.erase();
int j;
poly.set_hole_flag( j, gpc_poly->hole[j] );
}
- for ( j = 0; j < gpc_poly->num_contours; j++ ) {
+ for ( j = 0; j < gpc_poly->num_contours; ++j ) {
poly.calc_point_inside( j, in_nodes );
}
+ // temporary ... write out/hole polygon info for debugging
+ for ( j = 0; j < (int)poly.contours(); ++j ) {
+ char pname[256];
+ sprintf(pname, "poly%02d-%02d-%02d", i, debug_counter, j);
+ FILE *fp = fopen( pname, "w" );
+ int index;
+ Point3D point;
+ for ( int k = 0; k < poly.contour_size( j ); ++k ) {
+ index = poly.get_pt_index( j, k );
+ point = in_nodes.get_node( index );
+ fprintf( fp, "%.6f %.6f\n", point.x(), point.y() );
+ }
+ index = poly.get_pt_index( j, 0 );
+ point = in_nodes.get_node( index );
+ fprintf( fp, "%.6f %.6f\n", point.x(), point.y() );
+ fclose(fp);
+
+ char hname[256];
+ sprintf(hname, "hole%02d-%02d-%02d", i, debug_counter, j);
+ FILE *fh = fopen( hname, "w" );
+ point = poly.get_point_inside( j );
+ fprintf( fh, "%.6f %.6f\n", point.x(), point.y() );
+ fclose(fh);
+ }
+
polylist[i].push_back( poly );
+
+ ++debug_counter;
}
}