1
0
Fork 0

Contributed by Bruce Finney:

The following files have been changed to enable the latest Terragear CVS
to compile with MSVC++ 5.0

.\construct\clipper\clipper.cxx
        for( int i - lots of places

.\construct\genoutput\genobj.cxx
        fix directory logic for windows, line 320 and following

.\construct\main\main.cxx
        windows does not have an opendir function
        added code for windows directory functions
        disabled the mem allocation limit code - windows does not
        have similar functions
        for ( int i - several places

.\construct\match\match.cxx
        moved the definition of file and command outside of the ifdef line 420

.\lib\e00\e00.cxx
        for( int i  - several places

.\lib\e00\e00.cxx
        use simgear/compiler.h constructs

.\lib\geometry\contour_tree.hxx
        removed a cout statement

.\lib\geometry\poly_support.cxx
        added float.h  changed 1.0e+999 to DBL_MAX, windows doesn't go that big
        lots of for ( int i changes
        lines 193 and 208 no != operator defined - changed logic
        line 801 flag should be int, not bool, get_hole_flag returns int

.\lib\landcover\landcover.cxx
.\lib\landcover\landcover.hxx
        add include simgear/compiler.h
        see comments

.\lib\optimize\genfans.cxx
        function canonify added return at end, windows complains
        added using std  for cout and endl

.\lib\optimize\genstrips.cxx
        function tgGenStrips no return value, moved by_node into outer scope
        fix for ( int i ...

.\lib\poly2tri\construct.c
        added include <memory.h> for windows
        remove unused variables lines 435 & 437

.\lib\poly2tri\misc.c
        added HAVE_SYS_TIME_H logic for sys/time.h include file
        added logic to uses windows functions for time and rand

.\lib\poly2tri\monotone.c
        added include <memory.h> for windows
        lines 286-288 remove unused variables

.\lib\poly2tri\tri.c
        remove sys/time.h - no time functions called
        added include <memory.h> for windows

.\lib\polygon\polygon.cxx
        function polygon_to_tristrip will not compile I don't think the
        logic is complete, no returned data  added if else endif around
        function and polygon_to_tristrip_old, renamed _old function.
        Search of code reveals that function is not called by anyone.

.\lib\polygon\superpoly.cxx
        changed include <superpoly.hxx> to "superpoly.hxx"

.\lib\polygon\superpoly.hxx
        add include <windows.h> for windows before include <gl.h>
        needed for definitions used in Microsoft version of opengl

.\lib\shapelib\dbfopen.c
        added include files for windows
        lines 195-197 271-272 515-517 removed unused variables

.\lib\shapelib\shpopen.c
        added #include <stdlib.h> for malloc() and friends
        added include files for windows
        line 279 527 813 1127 removed unused variables
        line 827 cast result to int

.\lib\win32\mkdir.cpp
        documented function, remove debug lines

.\prep\demraw2ascii\main.c
        lines 46-50 remove unused variables

.\prep\demraw2ascii\rawdem.c
        line 47 changed logic to compile with MSVC
        line 244-256 set real constants to float, windows complains with
                double constants

.\prep\genairports\build.cxx
        lots of for ( int i  changes

.\prep\genairports\main.cxx
        fix mkdir logic for windows

.\prep\genairports\output.cxx
        added  using std  cout endl
        lots of for ( int i  changes
        fix mkdir logic for windows

.\prep\genairports\runway.cxx
        for ( int i  changes
        lines 117-118 161-162  remove default values for function parameters

.\prep\gshhs\main.cxx
        added using std cout

.\prep\shapefile\noaa_decode.cxx
.\prep\shapefile\shape_decode.cxx
        added using std  for cout
        lines 45-49 moved unused variables inside #if 0 block
This commit is contained in:
curt 2000-11-25 19:39:46 +00:00
parent e08b755290
commit c8cc7e2a61
32 changed files with 702 additions and 252 deletions

View file

@ -68,6 +68,7 @@
static FGPolygon rwy_section_tex_coords( const FGPolygon& in_poly,
const FGTexParams& tp )
{
int i, j;
FGPolygon result;
result.erase();
// double length = rwy.length * FEET_TO_METER;
@ -84,8 +85,8 @@ static FGPolygon rwy_section_tex_coords( const FGPolygon& in_poly,
Point3D p, t;
double x, y, tx, ty;
for ( int i = 0; i < in_poly.contours(); ++i ) {
for ( int j = 0; j < in_poly.contour_size( i ); ++j ) {
for ( i = 0; i < in_poly.contours(); ++i ) {
for ( j = 0; j < in_poly.contour_size( i ); ++j ) {
p = in_poly.get_pt( i, j );
cout << "point = " << p << endl;
@ -190,14 +191,15 @@ void add_intermediate_nodes( int contour, const Point3D& start,
static FGPolygon add_nodes_to_poly( const FGPolygon& poly,
const FGTriNodes& tmp_nodes ) {
int i, j;
FGPolygon result;
Point3D p0, p1;
// cout << "add_nodes_to_poly" << endl;
for ( int i = 0; i < poly.contours(); ++i ) {
for ( i = 0; i < poly.contours(); ++i ) {
// cout << "contour = " << i << endl;
for ( int j = 0; j < poly.contour_size(i) - 1; ++j ) {
for ( j = 0; j < poly.contour_size(i) - 1; ++j ) {
p0 = poly.get_pt( i, j );
p1 = poly.get_pt( i, j + 1 );
@ -236,12 +238,13 @@ static FGPolygon add_nodes_to_poly( const FGPolygon& poly,
static FGPolygon split_long_edges( const FGPolygon &poly, double max_len ) {
FGPolygon result;
Point3D p0, p1;
int i, j, k;
cout << "split_long_edges()" << endl;
for ( int i = 0; i < poly.contours(); ++i ) {
for ( i = 0; i < poly.contours(); ++i ) {
// cout << "contour = " << i << endl;
for ( int j = 0; j < poly.contour_size(i) - 1; ++j ) {
for ( j = 0; j < poly.contour_size(i) - 1; ++j ) {
p0 = poly.get_pt( i, j );
p1 = poly.get_pt( i, j + 1 );
@ -258,7 +261,7 @@ static FGPolygon split_long_edges( const FGPolygon &poly, double max_len ) {
double dx = (p1.x() - p0.x()) / segments;
double dy = (p1.y() - p0.y()) / segments;
for ( int k = 0; k < segments; ++k ) {
for ( k = 0; k < segments; ++k ) {
Point3D tmp( p0.x() + dx * k, p0.y() + dy * k, 0.0 );
cout << tmp << endl;
result.add_node( i, tmp );
@ -286,7 +289,7 @@ static FGPolygon split_long_edges( const FGPolygon &poly, double max_len ) {
double dx = (p1.x() - p0.x()) / segments;
double dy = (p1.y() - p0.y()) / segments;
for ( int k = 0; k < segments; ++k ) {
for ( k = 0; k < segments; ++k ) {
Point3D tmp( p0.x() + dx * k, p0.y() + dy * k, 0.0 );
cout << tmp << endl;
result.add_node( i, tmp );
@ -308,7 +311,7 @@ static FGPolygon split_long_edges( const FGPolygon &poly, double max_len ) {
point_list calc_elevations( const string& root, const point_list& geod_nodes ) {
bool done = false;
point_list result = geod_nodes;
int i;
int i, j;
FGArray array;
// set all elevations to -9999
@ -351,7 +354,7 @@ point_list calc_elevations( const string& root, const point_list& geod_nodes ) {
// this dem file
double elev;
done = true;
for ( int j = 0; j < (int)result.size(); ++j ) {
for ( j = 0; j < (int)result.size(); ++j ) {
if ( result[j].z() < -9000 ) {
done = false;
cout << "interpolating for " << result[j] << endl;
@ -391,6 +394,8 @@ static void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
texparams_list *texparams,
FGPolygon *accum )
{
int j, k;
FGPolygon runway = gen_runway_w_mid( rwy_info );
// runway half "a"
@ -411,12 +416,12 @@ static void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
Point3D p;
cout << "raw runway pts (a half)" << endl;
for ( int j = 0; j < runway_a.contour_size( 0 ); ++j ) {
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
p = runway_a.get_pt(0, j);
cout << " point = " << p << endl;
}
cout << "raw runway pts (b half)" << endl;
for ( int j = 0; j < runway_b.contour_size( 0 ); ++j ) {
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
p = runway_b.get_pt(0, j);
cout << " point = " << p << endl;
}
@ -471,8 +476,8 @@ static void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
// print runway points
cout << "clipped runway pts (a)" << endl;
for ( int j = 0; j < clipped_a.contours(); ++j ) {
for ( int k = 0; k < clipped_a.contour_size( j ); ++k ) {
for ( j = 0; j < clipped_a.contours(); ++j ) {
for ( k = 0; k < clipped_a.contour_size( j ); ++k ) {
p = clipped_a.get_pt(j, k);
cout << " point = " << p << endl;
}
@ -480,8 +485,8 @@ static void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
// print runway points
cout << "clipped runway pts (b)" << endl;
for ( int j = 0; j < clipped_b.contours(); ++j ) {
for ( int k = 0; k < clipped_b.contour_size( j ); ++k ) {
for ( j = 0; j < clipped_b.contours(); ++j ) {
for ( k = 0; k < clipped_b.contour_size( j ); ++k ) {
p = clipped_b.get_pt(j, k);
cout << " point = " << p << endl;
}
@ -502,6 +507,8 @@ static void gen_runway_section( const FGRunway& rwy_info,
texparams_list *texparams,
FGPolygon *accum ) {
int j, k;
Point3D a0 = runway.get_pt(0, 1);
Point3D a1 = runway.get_pt(0, 2);
Point3D a2 = runway.get_pt(0, 0);
@ -587,8 +594,8 @@ static void gen_runway_section( const FGRunway& rwy_info,
// print runway points
cout << "pre clipped runway pts " << prefix << material << endl;
for ( int j = 0; j < section.contours(); ++j ) {
for ( int k = 0; k < section.contour_size( j ); ++k ) {
for ( j = 0; j < section.contours(); ++j ) {
for ( k = 0; k < section.contour_size( j ); ++k ) {
Point3D p = section.get_pt(j, k);
cout << " point = " << p << endl;
}
@ -625,8 +632,8 @@ static void gen_runway_section( const FGRunway& rwy_info,
// print runway points
cout << "clipped runway pts " << prefix + material << endl;
for ( int j = 0; j < clipped.contours(); ++j ) {
for ( int k = 0; k < clipped.contour_size( j ); ++k ) {
for ( j = 0; j < clipped.contours(); ++j ) {
for ( k = 0; k < clipped.contour_size( j ); ++k ) {
Point3D p = clipped.get_pt(j, k);
cout << " point = " << p << endl;
}
@ -705,6 +712,8 @@ static void gen_precision_rwy( const FGRunway& rwy_info,
// Generate the basic runway outlines
//
int i, j;
FGPolygon runway = gen_runway_w_mid( rwy_info );
// runway half "a"
@ -726,12 +735,12 @@ static void gen_precision_rwy( const FGRunway& rwy_info,
Point3D p;
cout << "raw runway pts (a half)" << endl;
for ( int j = 0; j < runway_a.contour_size( 0 ); ++j ) {
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
p = runway_a.get_pt(0, j);
cout << " point = " << p << endl;
}
cout << "raw runway pts (b half)" << endl;
for ( int j = 0; j < runway_b.contour_size( 0 ); ++j ) {
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
p = runway_b.get_pt(0, j);
cout << " point = " << p << endl;
}
@ -779,7 +788,7 @@ static void gen_precision_rwy( const FGRunway& rwy_info,
int len = rwy_info.rwy_no.length();
string letter = "";
string rev_letter = "";
for ( int i = 0; i < len; ++i ) {
for ( i = 0; i < len; ++i ) {
string tmp = rwy_info.rwy_no.substr(i, 1);
if ( tmp == "L" ) {
letter = "L";
@ -823,7 +832,7 @@ static void gen_precision_rwy( const FGRunway& rwy_info,
len = rwy_info.rwy_no.length();
string snum = rwy_info.rwy_no;
for ( int i = 0; i < len; ++i ) {
for ( i = 0; i < len; ++i ) {
string tmp = rwy_info.rwy_no.substr(i, 1);
if ( tmp == "L" || tmp == "R" || tmp == "C" || tmp == " " ) {
snum = rwy_info.rwy_no.substr(0, i);
@ -1015,6 +1024,7 @@ static void gen_non_precision_rwy( const FGRunway& rwy_info,
texparams_list *texparams,
FGPolygon *accum )
{
int i, j;
//
// Generate the basic runway outlines
@ -1040,12 +1050,12 @@ static void gen_non_precision_rwy( const FGRunway& rwy_info,
Point3D p;
cout << "raw runway pts (a half)" << endl;
for ( int j = 0; j < runway_a.contour_size( 0 ); ++j ) {
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
p = runway_a.get_pt(0, j);
cout << " point = " << p << endl;
}
cout << "raw runway pts (b half)" << endl;
for ( int j = 0; j < runway_b.contour_size( 0 ); ++j ) {
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
p = runway_b.get_pt(0, j);
cout << " point = " << p << endl;
}
@ -1093,7 +1103,7 @@ static void gen_non_precision_rwy( const FGRunway& rwy_info,
int len = rwy_info.rwy_no.length();
string letter = "";
string rev_letter = "";
for ( int i = 0; i < len; ++i ) {
for ( i = 0; i < len; ++i ) {
string tmp = rwy_info.rwy_no.substr(i, 1);
if ( tmp == "L" ) {
letter = "L";
@ -1137,7 +1147,7 @@ static void gen_non_precision_rwy( const FGRunway& rwy_info,
len = rwy_info.rwy_no.length();
string snum = rwy_info.rwy_no;
for ( int i = 0; i < len; ++i ) {
for ( i = 0; i < len; ++i ) {
string tmp = rwy_info.rwy_no.substr(i, 1);
if ( tmp == "L" || tmp == "R" || tmp == "C" || tmp == " " ) {
snum = rwy_info.rwy_no.substr(0, i);
@ -1255,6 +1265,7 @@ static void gen_visual_rwy( const FGRunway& rwy_info,
texparams_list *texparams,
FGPolygon *accum )
{
int i, j;
//
// Generate the basic runway outlines
@ -1280,12 +1291,12 @@ static void gen_visual_rwy( const FGRunway& rwy_info,
Point3D p;
cout << "raw runway pts (a half)" << endl;
for ( int j = 0; j < runway_a.contour_size( 0 ); ++j ) {
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
p = runway_a.get_pt(0, j);
cout << " point = " << p << endl;
}
cout << "raw runway pts (b half)" << endl;
for ( int j = 0; j < runway_b.contour_size( 0 ); ++j ) {
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
p = runway_b.get_pt(0, j);
cout << " point = " << p << endl;
}
@ -1315,7 +1326,7 @@ static void gen_visual_rwy( const FGRunway& rwy_info,
int len = rwy_info.rwy_no.length();
string letter = "";
string rev_letter = "";
for ( int i = 0; i < len; ++i ) {
for ( i = 0; i < len; ++i ) {
string tmp = rwy_info.rwy_no.substr(i, 1);
if ( tmp == "L" ) {
letter = "L";
@ -1359,7 +1370,7 @@ static void gen_visual_rwy( const FGRunway& rwy_info,
len = rwy_info.rwy_no.length();
string snum = rwy_info.rwy_no;
for ( int i = 0; i < len; ++i ) {
for ( i = 0; i < len; ++i ) {
string tmp = rwy_info.rwy_no.substr(i, 1);
if ( tmp == "L" || tmp == "R" || tmp == "C" || tmp == " " ) {
snum = rwy_info.rwy_no.substr(0, i);
@ -1481,6 +1492,8 @@ void build_runway( const FGRunway& rwy_info,
texparams_list *texparams,
FGPolygon *accum,
point_list *apt_pts ) {
int j;
string surface_flag = rwy_info.surface_flags.substr(1, 1);
cout << "surface flag = " << surface_flag << endl;
@ -1537,7 +1550,7 @@ void build_runway( const FGRunway& rwy_info,
FGPolygon base = gen_runway_area( rwy_info, 1.05, 1.5 );
// add base to apt_pts (for convex hull of airport area)
for ( int j = 0; j < base.contour_size( 0 ); ++j ) {
for ( j = 0; j < base.contour_size( 0 ); ++j ) {
Point3D p = base.get_pt(0, j);
// cout << " point = " << p << endl;
apt_pts->push_back( p );
@ -1549,6 +1562,8 @@ void build_runway( const FGRunway& rwy_info,
void build_airport( string airport_raw, string_list& runways_raw,
const string& root ) {
int i, j, k;
superpoly_list rwy_polys;
texparams_list texparams;
@ -1607,7 +1622,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
runways.clear();
string rwy_str;
for (int i = 0; i < (int)runways_raw.size(); ++i ) {
for ( i = 0; i < (int)runways_raw.size(); ++i ) {
rwy_str = runways_raw[i];
FGRunway rwy;
@ -1654,7 +1669,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
// First pass: generate the precision runways since these have
// precidence
for ( int i = 0; i < (int)runways.size(); ++i ) {
for ( i = 0; i < (int)runways.size(); ++i ) {
string type_flag = runways[i].surface_flags.substr(2, 1);
if ( type_flag == "P" ) {
build_runway( runways[i],
@ -1663,7 +1678,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
}
// 2nd pass: generate the non-precision and visual runways
for ( int i = 0; i < (int)runways.size(); ++i ) {
for ( i = 0; i < (int)runways.size(); ++i ) {
string type_flag = runways[i].surface_flags.substr(2, 1);
if ( type_flag == "R" || type_flag == "V" ) {
build_runway( runways[i],
@ -1672,7 +1687,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
}
// Last pass: generate all remaining runways not covered in the first pass
for ( int i = 0; i < (int)runways.size(); ++i ) {
for ( i = 0; i < (int)runways.size(); ++i ) {
string type_flag = runways[i].surface_flags.substr(2, 1);
if ( type_flag != "P" && type_flag != "R" && type_flag != "V" ) {
build_runway( runways[i],
@ -1696,16 +1711,16 @@ void build_airport( string airport_raw, string_list& runways_raw,
FGTriNodes tmp_nodes;
// build temporary node list
for ( int k = 0; k < (int)rwy_polys.size(); ++k ) {
for ( k = 0; k < (int)rwy_polys.size(); ++k ) {
FGPolygon poly = rwy_polys[k].get_poly();
for ( int i = 0; i < poly.contours(); ++i ) {
for ( int j = 0; j < poly.contour_size( i ); ++j ) {
for ( i = 0; i < poly.contours(); ++i ) {
for ( j = 0; j < poly.contour_size( i ); ++j ) {
tmp_nodes.unique_add( poly.get_pt(i, j) );
}
}
}
for ( int i = 0; i < base_poly.contours(); ++i ) {
for ( int j = 0; j < base_poly.contour_size( i ); ++j ) {
for ( i = 0; i < base_poly.contours(); ++i ) {
for ( j = 0; j < base_poly.contour_size( i ); ++j ) {
tmp_nodes.unique_add( base_poly.get_pt(i, j) );
}
}
@ -1714,17 +1729,17 @@ void build_airport( string airport_raw, string_list& runways_raw,
// dump info for debugging purposes
point_list ttt = tmp_nodes.get_node_list();
FILE *fp = fopen( "tmp_nodes", "w" );
for ( int i = 0; i < (int)ttt.size(); ++i ) {
for ( i = 0; i < (int)ttt.size(); ++i ) {
fprintf(fp, "%.8f %.8f\n", ttt[i].x(), ttt[i].y());
}
fclose(fp);
for ( int i = 0; i < base_poly.contours(); ++i ) {
for ( i = 0; i < base_poly.contours(); ++i ) {
char name[256];
sprintf(name, "l%d", i );
FILE *fp = fopen( name, "w" );
for ( int j = 0; j < base_poly.contour_size( i ) - 1; ++j ) {
for ( j = 0; j < base_poly.contour_size( i ) - 1; ++j ) {
Point3D p0 = base_poly.get_pt(i, j);
Point3D p1 = base_poly.get_pt(i, j + 1);
fprintf(fp, "%.8f %.8f\n", p0.x(), p0.y());
@ -1738,13 +1753,13 @@ void build_airport( string airport_raw, string_list& runways_raw,
}
#endif
for ( int k = 0; k < (int)rwy_polys.size(); ++k ) {
for ( k = 0; k < (int)rwy_polys.size(); ++k ) {
cout << "add nodes/remove dups section = " << k
<< " " << rwy_polys[k].get_material() << endl;
FGPolygon poly = rwy_polys[k].get_poly();
cout << "total size before = " << poly.total_size() << endl;
for ( int i = 0; i < poly.contours(); ++i ) {
for ( int j = 0; j < poly.contour_size(i); ++j ) {
for ( i = 0; i < poly.contours(); ++i ) {
for ( j = 0; j < poly.contour_size(i); ++j ) {
Point3D tmp = poly.get_pt(i, j);
printf(" %.7f %.7f %.7f\n", tmp.x(), tmp.y(), tmp.z() );
}
@ -1754,8 +1769,8 @@ void build_airport( string airport_raw, string_list& runways_raw,
cout << "total size after remove_dups() = "
<< poly.total_size() << endl;
for ( int i = 0; i < poly.contours(); ++i ) {
for ( int j = 0; j < poly.contour_size(i); ++j ) {
for ( i = 0; i < poly.contours(); ++i ) {
for ( j = 0; j < poly.contour_size(i); ++j ) {
Point3D tmp = poly.get_pt(i, j);
printf(" %.7f %.7f %.7f\n", tmp.x(), tmp.y(), tmp.z() );
}
@ -1765,8 +1780,8 @@ void build_airport( string airport_raw, string_list& runways_raw,
cout << "total size after reduce_degeneracy() = "
<< poly.total_size() << endl;
for ( int i = 0; i < poly.contours(); ++i ) {
for ( int j = 0; j < poly.contour_size(i); ++j ) {
for ( i = 0; i < poly.contours(); ++i ) {
for ( j = 0; j < poly.contour_size(i); ++j ) {
Point3D tmp = poly.get_pt(i, j);
printf(" %.7f %.7f %.7f\n", tmp.x(), tmp.y(), tmp.z() );
}
@ -1798,7 +1813,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
// tesselate the polygons and prepair them for final output
for ( int i = 0; i < (int)rwy_polys.size(); ++i ) {
for ( i = 0; i < (int)rwy_polys.size(); ++i ) {
cout << "Tesselating section = " << i << endl;
FGPolygon poly = rwy_polys[i].get_poly();
@ -1819,12 +1834,12 @@ void build_airport( string airport_raw, string_list& runways_raw,
#if 0
// dump more debugging output
for ( int i = 0; i < base_strips.contours(); ++i ) {
for ( i = 0; i < base_strips.contours(); ++i ) {
char name[256];
sprintf(name, "s%d", i );
FILE *fp = fopen( name, "w" );
for ( int j = 0; j < base_strips.contour_size( i ) - 1; ++j ) {
for ( j = 0; j < base_strips.contour_size( i ) - 1; ++j ) {
Point3D p0 = base_strips.get_pt(i, j);
Point3D p1 = base_strips.get_pt(i, j + 1);
fprintf(fp, "%.8f %.8f\n", p0.x(), p0.y());
@ -1863,8 +1878,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
int_list tri_v;
int_list tri_tc;
// for ( int k = 0; k < (int)rwy_tris.size(); ++k ) {
for ( int k = 0; k < (int)rwy_polys.size(); ++k ) {
for ( k = 0; k < (int)rwy_polys.size(); ++k ) {
cout << "tri " << k << endl;
// FGPolygon tri_poly = rwy_tris[k];
FGPolygon tri_poly = rwy_polys[k].get_tris();
@ -1873,10 +1887,10 @@ void build_airport( string airport_raw, string_list& runways_raw,
cout << "material = " << material << endl;
cout << "poly size = " << tri_poly.contours() << endl;
cout << "texs size = " << tri_txs.contours() << endl;
for ( int i = 0; i < tri_poly.contours(); ++i ) {
for ( i = 0; i < tri_poly.contours(); ++i ) {
tri_v.clear();
tri_tc.clear();
for ( int j = 0; j < tri_poly.contour_size(i); ++j ) {
for ( j = 0; j < tri_poly.contour_size(i); ++j ) {
p = tri_poly.get_pt( i, j );
index = nodes.unique_add( p );
tri_v.push_back( index );
@ -1893,10 +1907,10 @@ void build_airport( string airport_raw, string_list& runways_raw,
// add base points
point_list base_txs;
int_list base_tc;
for ( int i = 0; i < base_tris.contours(); ++i ) {
for ( i = 0; i < base_tris.contours(); ++i ) {
tri_v.clear();
tri_tc.clear();
for ( int j = 0; j < base_tris.contour_size(i); ++j ) {
for ( j = 0; j < base_tris.contour_size(i); ++j ) {
p = base_tris.get_pt( i, j );
index = nodes.unique_add( p );
tri_v.push_back( index );
@ -1908,7 +1922,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
base_txs = calc_tex_coords( b, nodes.get_node_list(), tri_v );
base_tc.clear();
for ( int j = 0; j < (int)base_txs.size(); ++j ) {
for ( j = 0; j < (int)base_txs.size(); ++j ) {
tc = base_txs[j];
// cout << "base_tc = " << tc << endl;
index = texcoords.simple_add( tc );
@ -1923,7 +1937,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
// calculate wgs84 mapping of nodes
point_list wgs84_nodes;
for ( int i = 0; i < (int)geod_nodes.size(); ++i ) {
for ( i = 0; i < (int)geod_nodes.size(); ++i ) {
p.setx( geod_nodes[i].x() * DEG_TO_RAD );
p.sety( geod_nodes[i].y() * DEG_TO_RAD );
p.setz( geod_nodes[i].z() );
@ -1945,7 +1959,7 @@ void build_airport( string airport_raw, string_list& runways_raw,
sgdNormalizeVec3( vn );
point_list normals;
normals.clear();
for ( int i = 0; i < (int)nodes.size(); ++i ) {
for ( i = 0; i < (int)nodes.size(); ++i ) {
normals.push_back( Point3D( vn[0], vn[1], vn[2] ) );
}
cout << "found normal for this airport = " << tmp << endl;

View file

@ -47,6 +47,9 @@
#include "build.hxx"
#include "convex_hull.hxx"
#ifdef _MSC_VER
# include <Win32/mkdir.hpp>
#endif
int nudge = 10;
@ -103,8 +106,12 @@ int main( int argc, char **argv ) {
}
// make work directory
#ifdef _MSC_VER
fg_mkdir( work_dir.c_str() );
#else
string command = "mkdir -p " + work_dir;
system( command.c_str() );
#endif
// initialize persistant polygon counter
string counter_file = work_dir + "/poly_counter";

View file

@ -45,6 +45,13 @@
#include "output.hxx"
#ifdef _MSC_VER
# include <Win32/mkdir.hpp>
#endif
FG_USING_STD( cout );
FG_USING_STD( endl );
void write_polygon( const FGPolygon& poly, const string& base ) {
for ( int i = 0; i < poly.contours(); ++i ) {
@ -121,10 +128,15 @@ void write_obj( const string& base, const FGBucket& b, const string& name,
const string_list& fan_materials )
{
Point3D p;
int i, j;
string dir = base + "/" + b.gen_base_path();
string command = "mkdir -p " + dir;
#ifdef _MSC_VER
fg_mkdir( dir.c_str() );
#else
system(command.c_str());
#endif
// string file = dir + "/" + b.gen_index_str();
string file = dir + "/" + name;
@ -164,7 +176,7 @@ void write_obj( const string& base, const FGBucket& b, const string& name,
// dump vertex list
fprintf(fp, "# vertex list\n");
for ( int i = 0; i < (int)wgs84_nodes.size(); ++i ) {
for ( i = 0; i < (int)wgs84_nodes.size(); ++i ) {
p = wgs84_nodes[i] - gbs_center;
fprintf(fp, "v %.5f %.5f %.5f\n", p.x(), p.y(), p.z() );
@ -172,7 +184,7 @@ void write_obj( const string& base, const FGBucket& b, const string& name,
fprintf(fp, "\n");
fprintf(fp, "# vertex normal list\n");
for ( int i = 0; i < (int)normals.size(); ++i ) {
for ( i = 0; i < (int)normals.size(); ++i ) {
p = normals[i];
fprintf(fp, "vn %.5f %.5f %.5f\n", p.x(), p.y(), p.z() );
}
@ -180,7 +192,7 @@ void write_obj( const string& base, const FGBucket& b, const string& name,
// dump texture coordinates
fprintf(fp, "# texture coordinate list\n");
for ( int i = 0; i < (int)texcoords.size(); ++i ) {
for ( i = 0; i < (int)texcoords.size(); ++i ) {
p = texcoords[i];
fprintf(fp, "vt %.5f %.5f\n", p.x(), p.y() );
}
@ -209,8 +221,8 @@ void write_obj( const string& base, const FGBucket& b, const string& name,
group_nodes.clear();
Point3D bs_center;
double bs_radius = 0;
for ( int i = start; i < end; ++i ) {
for ( int j = 0; j < (int)tris_v[i].size(); ++j ) {
for ( i = start; i < end; ++i ) {
for ( j = 0; j < (int)tris_v[i].size(); ++j ) {
group_nodes.push_back( wgs84_nodes[ tris_v[i][j] ] );
bs_center = calc_center( group_nodes );
bs_radius = calc_bounding_radius( bs_center, group_nodes );
@ -224,9 +236,9 @@ void write_obj( const string& base, const FGBucket& b, const string& name,
bs_center.x(), bs_center.y(), bs_center.z(), bs_radius);
// write groups
for ( int i = start; i < end; ++i ) {
for ( i = start; i < end; ++i ) {
fprintf(fp, "f");
for ( int j = 0; j < (int)tris_v[i].size(); ++j ) {
for ( j = 0; j < (int)tris_v[i].size(); ++j ) {
fprintf(fp, " %d/%d", tris_v[i][j], tris_tc[i][j] );
}
fprintf(fp, "\n");
@ -260,8 +272,8 @@ void write_obj( const string& base, const FGBucket& b, const string& name,
group_nodes.clear();
Point3D bs_center;
double bs_radius = 0;
for ( int i = start; i < end; ++i ) {
for ( int j = 0; j < (int)strips_v[i].size(); ++j ) {
for ( i = start; i < end; ++i ) {
for ( j = 0; j < (int)strips_v[i].size(); ++j ) {
group_nodes.push_back( wgs84_nodes[ strips_v[i][j] ] );
bs_center = calc_center( group_nodes );
bs_radius = calc_bounding_radius( bs_center, group_nodes );
@ -275,9 +287,9 @@ void write_obj( const string& base, const FGBucket& b, const string& name,
bs_center.x(), bs_center.y(), bs_center.z(), bs_radius);
// write groups
for ( int i = start; i < end; ++i ) {
for ( i = start; i < end; ++i ) {
fprintf(fp, "ts");
for ( int j = 0; j < (int)strips_v[i].size(); ++j ) {
for ( j = 0; j < (int)strips_v[i].size(); ++j ) {
fprintf(fp, " %d/%d", strips_v[i][j], strips_tc[i][j] );
}
fprintf(fp, "\n");
@ -299,8 +311,12 @@ void write_obj( const string& base, const FGBucket& b, const string& name,
// update index
void write_index(const string& base, const FGBucket& b, const string& name) {
string dir = base + "/" + b.gen_base_path();
#ifdef _MSC_VER
fg_mkdir( dir.c_str() );
#else
string command = "mkdir -p " + dir;
system(command.c_str());
#endif
string file = dir + "/" + b.gen_index_str() + ".ind";
// string file = dir + "/" + name;
@ -323,8 +339,12 @@ void write_boundary( const string& base, const FGBucket& b,
Point3D p;
string dir = base + "/" + b.gen_base_path();
#ifdef _MSC_VER
fg_mkdir( dir.c_str() );
#else
string command = "mkdir -p " + dir;
system(command.c_str());
#endif
string file = dir + "/" + b.gen_index_str();

View file

@ -67,19 +67,20 @@ FGPolygon gen_area(Point3D origin, double angle, const FGPolygon& cart_list) {
FGPolygon rad_list;
FGPolygon result_list;
Point3D p;
int i;
// convert to polar coordinates
rad_list = batch_cart_to_polar_2d(cart_list);
// display points
// cout << "converted to polar" << endl;
// for ( int i = 0; i < rad_list.contour_size( 0 ); ++i ) {
// for ( i = 0; i < rad_list.contour_size( 0 ); ++i ) {
// cout << " " << rad_list.get_pt(0, i) << endl;
// }
// rotate by specified angle
// cout << "Rotating points by " << angle << endl;
for ( int i = 0; i < rad_list.contour_size( 0 ); ++i) {
for ( i = 0; i < rad_list.contour_size( 0 ); ++i) {
p = rad_list.get_pt( 0, i );
double theta = p.y() + angle;
while ( theta < FG_2PI ) {
@ -92,7 +93,7 @@ FGPolygon gen_area(Point3D origin, double angle, const FGPolygon& cart_list) {
// find actual lon,lat of coordinates
// cout << "convert to lon, lat relative to " << origin << endl;
for ( int i = 0; i < (int)rad_list.contour_size( 0 ); ++i ) {
for ( i = 0; i < (int)rad_list.contour_size( 0 ); ++i ) {
// p = calc_lon_lat(origin_rad, rad_list.get_pt(0, i) );
double lat2, lon2, az2;
@ -114,8 +115,8 @@ FGPolygon gen_area(Point3D origin, double angle, const FGPolygon& cart_list) {
// generate an area for a runway
FGPolygon gen_runway_area( const FGRunway& runway,
double len_scale = 1.0,
double width_scale = 1.0 ) {
double len_scale,
double width_scale ) {
FGPolygon result_list;
FGPolygon tmp_list;
@ -158,8 +159,8 @@ FGPolygon gen_runway_area( const FGRunway& runway,
// generate an area for a runway and include midpoints
FGPolygon gen_runway_w_mid( const FGRunway& runway,
double len_scale = 1.0,
double width_scale = 1.0 ) {
double len_scale,
double width_scale ) {
FGPolygon result_list;
FGPolygon tmp_list;

View file

@ -162,6 +162,8 @@ void FGClipper::move_slivers( FGPolygon& in, FGPolygon& out ) {
// cout << "Begin move slivers" << endl;
int i;
out.erase();
double angle_cutoff = 10.0 * DEG_TO_RAD;
@ -174,7 +176,7 @@ void FGClipper::move_slivers( FGPolygon& in, FGPolygon& out ) {
// process contours in reverse order so deleting a contour doesn't
// foul up our sequence
for ( int i = in.contours() - 1; i >= 0; --i ) {
for ( i = in.contours() - 1; i >= 0; --i ) {
// cout << "contour " << i << endl;
min_angle = in.minangle_contour( i );
@ -220,8 +222,9 @@ void FGClipper::merge_slivers( FGPolyList& clipped, FGPolygon& slivers ) {
point_list contour;
int original_contours, result_contours;
bool done;
int area, i, j, k;
for ( int i = 0; i < slivers.contours(); ++i ) {
for ( i = 0; i < slivers.contours(); ++i ) {
// cout << "Merging sliver = " << i << endl;
// make the sliver polygon
@ -230,7 +233,7 @@ void FGClipper::merge_slivers( FGPolyList& clipped, FGPolygon& slivers ) {
sliver.add_contour( contour, 0 );
done = false;
for ( int area = 0; area < FG_MAX_AREA_TYPES && !done; ++area ) {
for ( area = 0; area < FG_MAX_AREA_TYPES && !done; ++area ) {
if ( area == HoleArea ) {
// don't merge a non-hole sliver in with a hole
@ -239,7 +242,7 @@ void FGClipper::merge_slivers( FGPolyList& clipped, FGPolygon& slivers ) {
// cout << " testing area = " << area << " with "
// << clipped.polys[area].size() << " polys" << endl;
for ( int j = 0;
for ( j = 0;
j < (int)clipped.polys[area].size() && !done;
++j )
{
@ -265,7 +268,7 @@ void FGClipper::merge_slivers( FGPolyList& clipped, FGPolygon& slivers ) {
cout << " original = " << original_contours
<< " result = " << result_contours << endl;
cout << " sliver = " << endl; */
for ( int k = 0; k < (int)contour.size(); ++k ) {
for ( k = 0; k < (int)contour.size(); ++k ) {
// cout << " " << contour[k].x() << ", "
// << contour[k].y() << endl;
}
@ -284,6 +287,8 @@ void FGClipper::merge_slivers( FGPolyList& clipped, FGPolygon& slivers ) {
bool FGClipper::clip_all(const point2d& min, const point2d& max) {
FGPolygon accum, tmp;
FGPolygon slivers, remains;
int i, j;
// gpcpoly_iterator current, last;
FG_LOG( FG_CLIPPER, FG_INFO, "Running master clipper" );
@ -306,7 +311,7 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
// clip it.
FGPolygon land_mask;
land_mask.erase();
for ( int i = 0; i < (int)polys_in.polys[DefaultArea].size(); ++i ) {
for ( i = 0; i < (int)polys_in.polys[DefaultArea].size(); ++i ) {
land_mask =
polygon_union( land_mask, polys_in.polys[DefaultArea][i] );
}
@ -314,7 +319,7 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
// set up island mask, for cutting holes in lakes
FGPolygon island_mask;
island_mask.erase();
for ( int i = 0; i < (int)polys_in.polys[IslandArea].size(); ++i ) {
for ( i = 0; i < (int)polys_in.polys[IslandArea].size(); ++i ) {
island_mask =
polygon_union( island_mask, polys_in.polys[IslandArea][i] );
}
@ -324,20 +329,20 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
// set up pond mask, for cutting holes in islands
FGPolygon pond_mask;
pond_mask.erase();
for ( int i = 0; i < (int)polys_in.polys[PondArea].size(); ++i ) {
for ( i = 0; i < (int)polys_in.polys[PondArea].size(); ++i ) {
pond_mask =
polygon_union( pond_mask, polys_in.polys[PondArea][i] );
}
#endif
// process polygons in priority order
for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
cout << "num polys of type (" << i << ") = "
<< polys_in.polys[i].size() << endl;
// current = polys_in.polys[i].begin();
// last = polys_in.polys[i].end();
// for ( ; current != last; ++current ) {
for( int j = 0; j < (int)polys_in.polys[i].size(); ++j ) {
for( j = 0; j < (int)polys_in.polys[i].size(); ++j ) {
FGPolygon current = polys_in.polys[i][j];
FG_LOG( FG_CLIPPER, FG_DEBUG, get_area_name( (AreaType)i )
<< " = " << current.contours() );
@ -393,20 +398,20 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
/*
cout << "original contours = " << tmp.num_contours << endl;
for ( int j = 0; j < tmp.num_contours; j++ ) {
for (int k = 0;k < tmp.contour[j].num_vertices;k++ ) {
cout << tmp.contour[j].vertex[k].x << ","
<< tmp.contour[j].vertex[k].y << endl;
}
for ( j = 0; j < tmp.num_contours; j++ ) {
for ( k = 0;k < tmp.contour[j].num_vertices;k++ ) {
cout << tmp.contour[j].vertex[k].x << ","
<< tmp.contour[j].vertex[k].y << endl;
}
}
cout << "clipped contours = " << result_diff->num_contours << endl;
for ( int j = 0; j < result_diff->num_contours; j++ ) {
for (int k = 0;k < result_diff->contour[j].num_vertices;k++ ) {
cout << result_diff->contour[j].vertex[k].x << ","
<< result_diff->contour[j].vertex[k].y << endl;
}
for ( j = 0; j < result_diff->num_contours; j++ ) {
for ( k = 0; k < result_diff->contour[j].num_vertices; k++ ) {
cout << result_diff->contour[j].vertex[k].x << ","
<< result_diff->contour[j].vertex[k].y << endl;
}
}
*/

View file

@ -318,8 +318,8 @@ int FGGenOutput::write( FGConstruct &c ) {
string dir = base + "/Scenery/" + b.gen_base_path();
#ifdef _MSCVER
fg_mkdir( dir.c_str );
#ifdef _MSC_VER
fg_mkdir( dir.c_str() );
#else
string command = "mkdir -p " + dir;
system(command.c_str());

View file

@ -133,6 +133,42 @@ static int actual_load_polys( const string& dir,
string base = c.get_bucket().gen_base_path();
string tile_str = c.get_bucket().gen_index_str();
string ext;
string file, f_index, full_path;
int pos;
#ifdef _MSC_VER
long hfile;
struct _finddata_t de;
string path;
path = dir + "/*.*";
if ( ( hfile = _findfirst( path.c_str(), &de ) ) == -1 ) {
cout << "cannot open directory " << dir << "\n";
return 0;
}
// load all matching polygon files
do {
file = de.name;
pos = file.find(".");
f_index = file.substr(0, pos);
if ( tile_str == f_index ) {
ext = file.substr(pos + 1);
cout << file << " " << f_index << " '" << ext << "'" << endl;
full_path = dir + "/" + file;
if ( (ext == "dem") || (ext == "dem.gz") ) {
// skip
} else {
cout << "ext = '" << ext << "'" << endl;
clipper.load_polys( full_path );
++counter;
}
}
} while ( _findnext( hfile, &de ) == 0 );
#else
DIR *d;
struct dirent *de;
@ -143,8 +179,6 @@ static int actual_load_polys( const string& dir,
}
// load all matching polygon files
string file, f_index, full_path;
int pos;
while ( (de = readdir(d)) != NULL ) {
file = de->d_name;
pos = file.find(".");
@ -165,6 +199,7 @@ static int actual_load_polys( const string& dir,
}
closedir(d);
#endif
return counter;
}
@ -265,6 +300,7 @@ static int actual_load_landcover ( LandCover &cover, FGConstruct & c,
// clip against each other to resolve any overlaps
static int load_polys( FGConstruct& c ) {
FGClipper clipper;
int i;
string base = c.get_bucket().gen_base_path();
string poly_path;
@ -274,7 +310,7 @@ static int load_polys( FGConstruct& c ) {
clipper.init();
// load 2D polygons from all directories provided
for ( int i = 0; i < (int)load_dirs.size(); ++i ) {
for ( i = 0; i < (int)load_dirs.size(); ++i ) {
poly_path = load_dirs[i] + '/' + base;
cout << "poly_path = " << poly_path << endl;
count += actual_load_polys( poly_path, c, clipper );
@ -309,8 +345,9 @@ static int load_polys( FGConstruct& c ) {
static int load_dem( FGConstruct& c, FGArray& array) {
point_list result;
string base = c.get_bucket().gen_base_path();
int i;
for ( int i = 0; i < (int)load_dirs.size(); ++i ) {
for ( i = 0; i < (int)load_dirs.size(); ++i ) {
string dem_path = load_dirs[i] + "/" + base
+ "/" + c.get_bucket().gen_index_str() + ".dem";
cout << "dem_path = " << dem_path << endl;
@ -491,13 +528,14 @@ static void fix_point_heights( FGConstruct& c, const FGArray& array ) {
static void build_wgs_84_point_list( FGConstruct& c, const FGArray& array ) {
point_list geod_nodes;
point_list wgs84_nodes;
int i;
cout << "generating wgs84 list" << endl;
Point3D geod, radians, cart;
point_list raw_nodes = c.get_tri_nodes().get_node_list();
for ( int i = 0; i < (int)raw_nodes.size(); ++i ) {
for ( i = 0; i < (int)raw_nodes.size(); ++i ) {
geod = raw_nodes[i];
// convert to radians
@ -727,8 +765,13 @@ static void do_custom_objects( const FGConstruct& c ) {
in >> skipws;
cout << "token = " << token << " name = " << name << endl;
#ifdef _MSC_VER
string command = "copy " + base_dir + "/" + name + ".gz "
+ dest_dir;
#else
string command = "cp " + base_dir + "/" + name + ".gz "
+ dest_dir;
#endif
cout << "running " << command << endl;
system( command.c_str() );
@ -967,8 +1010,9 @@ int main(int argc, char **argv) {
cout << "Load directory: " << argv[i] << endl;
}
#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ )
#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ ) || defined( _MSC_VER )
// the next bit crashes Cygwin for me - DCL
// MSVC does not have the function or variable type defined - BRF
#else
// set mem allocation limit. Reason: occasionally the triangle()
// routine can blow up and allocate memory forever. We'd like

View file

@ -460,17 +460,17 @@ void FGMatch::write_shared( FGConstruct& c ) {
FGBucket b = c.get_bucket();
string dir = base + "/Shared/" + b.gen_base_path();
string file = dir + "/" + b.gen_index_str();
#ifdef _MSC_VER
fg_mkdir( dir.c_str() );
#else
string command = "mkdir -p " + dir;
string file = dir + "/" + b.gen_index_str();
system(command.c_str());
#endif
cout << "shared data will be written to " << file << endl;
system(command.c_str());
#if 0
cout << "FLAGS" << endl;

View file

@ -71,7 +71,7 @@ public:
inline FGContourNode *get_kid( int n ) const { return kids[n]; }
inline void add_kid( FGContourNode *kid ) { kids.push_back( kid ); }
inline void remove_kid( int n ) {
cout << "kids[" << n << "] = " << kids[n] << endl;
// cout << "kids[" << n << "] = " << kids[n] << endl;
delete kids[n];
kids[n] = NULL;
}

View file

@ -22,6 +22,7 @@
// $Id$
#include <float.h>
#include <stdio.h>
#include <simgear/compiler.h>
@ -50,7 +51,8 @@ static double slope( const Point3D& p0, const Point3D& p1 ) {
if ( fabs(p0.x() - p1.x()) > FG_EPSILON ) {
return (p0.y() - p1.y()) / (p0.x() - p1.x());
} else {
return 1.0e+999; // really big number
// return 1.0e+999; // really big number
return DBL_MAX;
}
}
@ -110,6 +112,7 @@ Point3D calc_point_inside_old( const FGPolygon& p, const int contour,
int p1_index = 0;
int p2_index = 0;
int ln_index = 0;
int i;
// 1. find a point on the specified contour, min, with smallest y
@ -121,7 +124,7 @@ Point3D calc_point_inside_old( const FGPolygon& p, const int contour,
current = c.begin();
last = c.end();
for ( int i = 0; i < p.contour_size( contour ); ++i ) {
for ( i = 0; i < p.contour_size( contour ); ++i ) {
tmp = p.get_pt( contour, i );
if ( tmp.y() < min.y() ) {
min = tmp;
@ -178,7 +181,7 @@ Point3D calc_point_inside_old( const FGPolygon& p, const int contour,
p3.sety(100);
for ( int i = 0; i < (int)p.contours(); ++i ) {
for ( i = 0; i < (int)p.contours(); ++i ) {
cout << "contour = " << i << " size = " << p.contour_size( i ) << endl;
for ( int j = 0; j < (int)(p.contour_size( i ) - 1); ++j ) {
// cout << " p1 = " << poly[i][j] << " p2 = "
@ -192,7 +195,7 @@ Point3D calc_point_inside_old( const FGPolygon& p, const int contour,
cout << "intersection = " << result << endl;
if ( ( result.y() < p3.y() ) &&
( result.y() > m.y() ) &&
( base_leg != FGTriSeg(p1_index, p2_index, 0) ) ) {
!( base_leg == FGTriSeg(p1_index, p2_index, 0) ) ) {
p3 = result;
}
}
@ -207,7 +210,7 @@ Point3D calc_point_inside_old( const FGPolygon& p, const int contour,
cout << "intersection = " << result << endl;
if ( ( result.y() < p3.y() ) &&
( result.y() > m.y() ) &&
( base_leg != FGTriSeg(p1_index, p2_index, 0) ) ) {
!( base_leg == FGTriSeg(p1_index, p2_index, 0) ) ) {
p3 = result;
}
}
@ -237,6 +240,7 @@ void polygon_tesselate( const FGPolygon &p,
point_list &out_pts )
{
struct triangulateio in, out, vorout;
int i;
// make sure all elements of these structs point to "NULL"
zero_triangulateio( &in );
@ -249,7 +253,7 @@ void polygon_tesselate( const FGPolygon &p,
double max_x = p.get_pt(0,0).x();
int total_pts = 0;
for ( int i = 0; i < p.contours(); ++i ) {
for ( i = 0; i < p.contours(); ++i ) {
total_pts += p.contour_size( i );
}
@ -257,7 +261,7 @@ void polygon_tesselate( const FGPolygon &p,
in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
counter = 0;
for ( int i = 0; i < p.contours(); ++i ) {
for ( i = 0; i < p.contours(); ++i ) {
point_list contour = p.get_contour( i );
for ( int j = 0; j < (int)contour.size(); ++j ) {
in.pointlist[2*counter] = contour[j].x();
@ -274,7 +278,7 @@ void polygon_tesselate( const FGPolygon &p,
in.numberofpointattributes *
sizeof(REAL));
counter = 0;
for ( int i = 0; i < p.contours(); ++i ) {
for ( i = 0; i < p.contours(); ++i ) {
point_list contour = p.get_contour( i );
for ( int j = 0; j < (int)contour.size(); ++j ) {
in.pointattributelist[counter] = contour[j].z();
@ -283,7 +287,7 @@ void polygon_tesselate( const FGPolygon &p,
}
// in.pointmarkerlist = (int *) malloc(in.numberofpoints * sizeof(int));
// for ( int i = 0; i < in.numberofpoints; ++i) {
// for ( i = 0; i < in.numberofpoints; ++i) {
// in.pointmarkerlist[i] = 0;
// }
in.pointmarkerlist = NULL;
@ -295,7 +299,7 @@ void polygon_tesselate( const FGPolygon &p,
start = 0;
end = -1;
for ( int i = 0; i < p.contours(); ++i ) {
for ( i = 0; i < p.contours(); ++i ) {
point_list contour = p.get_contour( i );
start = end + 1;
end = start + contour.size() - 1;
@ -308,13 +312,13 @@ void polygon_tesselate( const FGPolygon &p,
}
in.segmentmarkerlist = (int *) malloc(in.numberofsegments * sizeof(int));
for ( int i = 0; i < in.numberofsegments; ++i ) {
for ( i = 0; i < in.numberofsegments; ++i ) {
in.segmentmarkerlist[i] = 0;
}
// hole list
in.numberofholes = 1;
for ( int i = 0; i < p.contours(); ++i ) {
for ( i = 0; i < p.contours(); ++i ) {
if ( p.get_hole_flag( i ) ) {
++in.numberofholes;
}
@ -325,7 +329,7 @@ void polygon_tesselate( const FGPolygon &p,
in.holelist[counter++] = max_x + 1.0;
in.holelist[counter++] = 0.0;
for ( int i = 0; i < (int)p.contours(); ++i ) {
for ( i = 0; i < (int)p.contours(); ++i ) {
if ( p.get_hole_flag( i ) ) {
in.holelist[counter++] = p.get_point_inside(i).x();
in.holelist[counter++] = p.get_point_inside(i).y();
@ -380,7 +384,7 @@ void polygon_tesselate( const FGPolygon &p,
elelist.clear();
int n1, n2, n3;
double attribute;
for ( int i = 0; i < out.numberoftriangles; ++i ) {
for ( i = 0; i < out.numberoftriangles; ++i ) {
n1 = out.trianglelist[i * 3];
n2 = out.trianglelist[i * 3 + 1];
n3 = out.trianglelist[i * 3 + 2];
@ -397,7 +401,7 @@ void polygon_tesselate( const FGPolygon &p,
// output points
out_pts.clear();
double x, y, z;
for ( int i = 0; i < out.numberofpoints; ++i ) {
for ( i = 0; i < out.numberofpoints; ++i ) {
x = out.pointlist[i * 2 ];
y = out.pointlist[i * 2 + 1];
z = out.pointattributelist[i];
@ -436,6 +440,7 @@ void polygon_tesselate( const FGPolygon &p,
FGPolygon polygon_tesselate_alt( FGPolygon &p ) {
FGPolygon result;
result.erase();
int i;
// Bail right away if polygon is empty
if ( p.contours() == 0 ) {
@ -445,7 +450,7 @@ FGPolygon polygon_tesselate_alt( FGPolygon &p ) {
// 1. Robustly find a point inside each contour that is not
// inside any other contour
calc_points_inside( p );
for ( int i = 0; i < p.contours(); ++i ) {
for ( i = 0; i < p.contours(); ++i ) {
cout << "final point inside =" << p.get_point_inside( i )
<< endl;
}
@ -457,7 +462,7 @@ FGPolygon polygon_tesselate_alt( FGPolygon &p ) {
// 3. Convert the tesselated output to a list of tringles.
// basically a polygon with a contour for every triangle
for ( int i = 0; i < (int)trieles.size(); ++i ) {
for ( i = 0; i < (int)trieles.size(); ++i ) {
FGTriEle t = trieles[i];
Point3D p1 = nodes[ t.get_n1() ];
Point3D p2 = nodes[ t.get_n2() ];
@ -480,6 +485,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
point_list &out_pts )
{
struct triangulateio in, out, vorout;
int i;
// make sure all elements of these structs point to "NULL"
zero_triangulateio( &in );
@ -509,7 +515,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
}
#endif
for ( int i = 0; i < hole_polys.contours(); ++i ) {
for ( i = 0; i < hole_polys.contours(); ++i ) {
total_pts += hole_polys.contour_size( i );
}
@ -517,7 +523,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
counter = 0;
for ( int i = 0; i < (int)contour.size(); ++i ) {
for ( i = 0; i < (int)contour.size(); ++i ) {
in.pointlist[2*counter] = contour[i].x();
in.pointlist[2*counter + 1] = contour[i].y();
if ( contour[i].x() > max_x ) {
@ -526,7 +532,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
++counter;
}
for ( int i = 0; i < hole_polys.contours(); ++i ) {
for ( i = 0; i < hole_polys.contours(); ++i ) {
point_list hole_contour = hole_polys.get_contour( i );
for ( int j = 0; j < (int)hole_contour.size(); ++j ) {
in.pointlist[2*counter] = hole_contour[j].x();
@ -543,12 +549,12 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
in.numberofpointattributes *
sizeof(REAL));
counter = 0;
for ( int i = 0; i < (int)contour.size(); ++i ) {
for ( i = 0; i < (int)contour.size(); ++i ) {
in.pointattributelist[counter] = contour[i].z();
++counter;
}
for ( int i = 0; i < hole_polys.contours(); ++i ) {
for ( i = 0; i < hole_polys.contours(); ++i ) {
point_list hole_contour = hole_polys.get_contour( i );
for ( int j = 0; j < (int)hole_contour.size(); ++j ) {
in.pointattributelist[counter] = hole_contour[j].z();
@ -557,7 +563,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
}
// in.pointmarkerlist = (int *) malloc(in.numberofpoints * sizeof(int));
// for ( int i = 0; i < in.numberofpoints; ++i) {
// for ( i = 0; i < in.numberofpoints; ++i) {
// in.pointmarkerlist[i] = 0;
// }
in.pointmarkerlist = NULL;
@ -569,7 +575,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
counter = 0;
start = 0;
end = contour.size() - 1;
for ( int i = 0; i < end; ++i ) {
for ( i = 0; i < end; ++i ) {
in.segmentlist[counter++] = i;
in.segmentlist[counter++] = i + 1;
in.segmentmarkerlist[i] = 0;
@ -578,7 +584,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
in.segmentlist[counter++] = start;
in.segmentmarkerlist[contour.size() - 1] = 0;
for ( int i = 0; i < hole_polys.contours(); ++i ) {
for ( i = 0; i < hole_polys.contours(); ++i ) {
point_list hole_contour = hole_polys.get_contour( i );
start = end + 1;
end = start + hole_contour.size() - 1;
@ -590,7 +596,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
in.segmentlist[counter++] = start;
}
for ( int i = 0; i < in.numberofsegments; ++i ) {
for ( i = 0; i < in.numberofsegments; ++i ) {
in.segmentmarkerlist[i] = 0;
}
@ -602,7 +608,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
in.holelist[counter++] = max_x + 1.0;
in.holelist[counter++] = 0.0;
for ( int i = 0; i < (int)hole_pts.size(); ++i ) {
for ( i = 0; i < (int)hole_pts.size(); ++i ) {
in.holelist[counter++] = hole_pts[i].x();
in.holelist[counter++] = hole_pts[i].y();
}
@ -654,7 +660,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
elelist.clear();
int n1, n2, n3;
double attribute;
for ( int i = 0; i < out.numberoftriangles; ++i ) {
for ( i = 0; i < out.numberoftriangles; ++i ) {
n1 = out.trianglelist[i * 3];
n2 = out.trianglelist[i * 3 + 1];
n3 = out.trianglelist[i * 3 + 2];
@ -671,7 +677,7 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p,
// output points
out_pts.clear();
double x, y, z;
for ( int i = 0; i < out.numberofpoints; ++i ) {
for ( i = 0; i < out.numberofpoints; ++i ) {
x = out.pointlist[i * 2 ];
y = out.pointlist[i * 2 + 1];
z = out.pointattributelist[i];
@ -827,11 +833,12 @@ static void build_contour_tree( FGContourNode *node,
cout << "working on contour = " << node->get_contour_num() << endl;
cout << " total contours = " << p.contours() << endl;
FGContourNode *tmp;
int i;
// see if we are building on a hole or note
// see if we are building on a hole or not
bool flag;
if ( node->get_contour_num() >= 0 ) {
flag = p.get_hole_flag( node->get_contour_num() );
flag = (bool)p.get_hole_flag( node->get_contour_num() );
} else {
flag = true;
}
@ -839,7 +846,7 @@ static void build_contour_tree( FGContourNode *node,
// add all remaining hole/non-hole contours as children of the
// current node if they are inside of it.
for ( int i = 0; i < p.contours(); ++i ) {
for ( i = 0; i < p.contours(); ++i ) {
cout << " testing contour = " << i << endl;
if ( p.get_hole_flag( i ) != flag ) {
// only holes can be children of non-holes and visa versa
@ -868,7 +875,7 @@ static void build_contour_tree( FGContourNode *node,
// inside one
cout << "node now has num kids = " << node->get_num_kids() << endl;
for ( int i = 0; i < node->get_num_kids(); ++i ) {
for ( i = 0; i < node->get_num_kids(); ++i ) {
for ( int j = 0; j < node->get_num_kids(); ++j ) {
if ( i != j ) {
if ( (node->get_kid(i) != NULL)&&(node->get_kid(j) != NULL) ) {
@ -894,7 +901,7 @@ static void build_contour_tree( FGContourNode *node,
}
// for each child, extend the contour tree
for ( int i = 0; i < node->get_num_kids(); ++i ) {
for ( i = 0; i < node->get_num_kids(); ++i ) {
tmp = node->get_kid( i );
if ( tmp != NULL ) {
build_contour_tree( tmp, p, avail );

View file

@ -21,8 +21,15 @@
// $Id$
#include <simgear/compiler.h>
#include STL_IOSTREAM
#include "genfans.hxx"
FG_USING_STD( cout );
FG_USING_STD( endl );
// make sure the list is expanded at least to hold "n" and then push
// "i" onto the back of the "n" list.
@ -59,6 +66,10 @@ static FGTriEle canonify( const FGTriEle& t, int center ) {
cout << "ERROR, index doesn't refer to this triangle!!!" << endl;
exit(-1);
}
// MSVC kludge (code should never reach this point, but it makes
// the MSVC compiler happy)
return t;
}
// returns a list of triangle indices

View file

@ -54,16 +54,17 @@ static void add_and_expand( opt_list& by_node, int n, int i ) {
opt_list tgGenStrips( const triele_list tris ) {
triele_list remaining = tris;
opt_list by_node;
int i;
while ( remaining.size() ) {
// traverse the triangle list and for each node, build a list of
// triangles that attach to it.
// cout << "building by_node list" << endl;
opt_list by_node;
by_node.clear();
for ( int i = 0; i < (int)remaining.size(); ++i ) {
for ( i = 0; i < (int)remaining.size(); ++i ) {
int n1 = remaining[i].get_n1();
int n2 = remaining[i].get_n2();
int n3 = remaining[i].get_n3();
@ -79,7 +80,7 @@ opt_list tgGenStrips( const triele_list tris ) {
int min_size = 32768;
int min_tri = -1;
for ( int i = 0; i < (int)remaining.size(); ++i ) {
for ( i = 0; i < (int)remaining.size(); ++i ) {
int n1 = remaining[i].get_n1();
int n2 = remaining[i].get_n2();
int n3 = remaining[i].get_n3();
@ -95,6 +96,8 @@ opt_list tgGenStrips( const triele_list tris ) {
}
}
}
return by_node;
}

View file

@ -44,7 +44,7 @@ bool poly_index_init( string path ) {
FILE *fp = fopen( poly_path.c_str(), "r" );
if ( fp == NULL ) {
cout << "Error cannot open " << poly_path << endl;
cout << "Warning: cannot open " << poly_path << endl;
poly_index = 0;
return false;
}

View file

@ -397,6 +397,7 @@ FGPolygon polygon_canonify( const FGPolygon& in_poly ) {
}
#if 0
// Wrapper for the fast Polygon Triangulation based on Seidel's
// Algorithm by Atul Narkhede and Dinesh Manocha
// http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html
@ -482,6 +483,7 @@ FGPolygon polygon_to_tristrip( const FGPolygon& in_poly ) {
// return result;
}
#endif
#if 0
@ -549,4 +551,6 @@ operator<< (ostream &output, const FGPolygon &poly)
output << poly.get_pt(i, j) << endl;
}
}
return output; // MSVC
}

View file

@ -21,7 +21,7 @@
// $Id$
#include <superpoly.hxx>
#include "superpoly.hxx"
// Constructor

View file

@ -36,6 +36,9 @@
#include <string>
#include <vector>
#ifdef _MSC_VER
# include <windows.h>
#endif
#include <GL/gl.h>
#include "polygon.hxx"

View file

@ -1,8 +1,32 @@
/*
* file: mkdir.cpp
*/
#include "simgear/config.h"
#include "simgear/compiler.h"
//
// file: mkdir.cpp
//
// A window mkdir function. Windows 9x system mkdir command will only
// create a single directory at a time. This function will parse the
// path and create each individual directory.
// Written by Bruce Finney
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h>
#include <direct.h>
#include <io.h>
@ -11,36 +35,34 @@
using namespace std;
// NOTE: the system mkdir will accept either a "/" or a "\"
// command.com ( the shell ) only accepts "\" in the path.
static char SEP[] = "/\\";
void fg_mkdir( const char *path )
{
char *r, *token, tmp_path[256];
string dir;
struct _finddata_t de;
char *r, *token, tmp_path[256];
string dir;
struct _finddata_t de;
//struct stat stat_buf;
strcpy( tmp_path, path );
r = strchr( SEP, path[0] ); // is first char a seperator?
token = strtok( tmp_path, SEP );
if ( r != NULL ) {
dir = --token; // include first char
} else {
dir = token;
}
strcpy( tmp_path, path );
r = strchr( SEP, path[0] ); // is first char a seperator?
token = strtok( tmp_path, SEP );
if ( r != NULL )
dir = --token; // include first char
else
dir = token;
while ( token != NULL )
{
//if ( stat( dir.c_str, &stat_buf) != 0 && errno == ENOENT )
if ( _findfirst( dir.c_str(), &de ) == -1 && token[1] != ':' )
{ // does not exist - create it
mkdir( dir.c_str() );
//printf( "mkdir %s\n", dir.c_str() );
} // end if
token = strtok( NULL, SEP );
if ( token != NULL )
//dir = dir + DIR_SEP + token;
dir = dir + "/" + token;
} // end while
while ( token != NULL ) {
if ( _findfirst( dir.c_str(), &de ) == -1 && token[1] != ':' ) {
// does not exist - create it
mkdir( dir.c_str() );
} // end if
token = strtok( NULL, SEP );
if ( token != NULL ) {
dir = dir + "/" + token;
}
} // end while
} // end fg_mkdir

View file

@ -156,6 +156,8 @@ writeVertex (ostream &output, double x, double y)
void
E00::write (ostream &output) const
{
int i, j, k;
output << "<?xml version=\"1.0\"?>" << endl << endl;
output << "<GIS>" << endl << endl;
@ -167,11 +169,11 @@ E00::write (ostream &output) const
}
}
for (int i = 0; i < (int)arc_section.size(); i++) {
for ( i = 0; i < (int)arc_section.size(); i++) {
const e00ARC &arc = arc_section[i];
if (!arc.inPolygon) {
output << "<line>" << endl;
for (int j = 0; j < (int)arc.coordinates.size(); j++) {
for ( j = 0; j < (int)arc.coordinates.size(); j++) {
writeVertex(output, arc.coordinates[j].x, arc.coordinates[j].y);
}
output << "</line>" << endl << endl;;
@ -179,10 +181,10 @@ E00::write (ostream &output) const
}
// NB: skip enclosing poly
for (int i = 1; i < (int)pal_section.size(); i++) {
for ( i = 1; i < (int)pal_section.size(); i++) {
const e00PAL &pal = pal_section[i];
output << "<polygon>" << endl;
for (int j = 0; j < pal.numArcs; j++) {
for ( j = 0; j < pal.numArcs; j++) {
bool isReversed = false;
int arcNum = pal.arcs[j].arcNum;
if (arcNum < 0) {
@ -192,11 +194,11 @@ E00::write (ostream &output) const
const e00ARC &arc = arc_section[arcNum];
output << "<arc coverage=\"" << arc.coverageId << "\">" << endl;
if (isReversed) {
for (int k = arc.numberOfCoordinates - 1; k >= 0; k--) {
for ( k = arc.numberOfCoordinates - 1; k >= 0; k--) {
writeVertex(output, arc.coordinates[k].x, arc.coordinates[k].y);
}
} else {
for (int k = 0; k < arc.numberOfCoordinates; k++) {
for ( k = 0; k < arc.numberOfCoordinates; k++) {
writeVertex(output, arc.coordinates[k].x, arc.coordinates[k].y);
}
}

View file

@ -1,12 +1,15 @@
#include <simgear/compiler.h>
#include <vector>
#include <map>
#include <string>
#include STL_STRING
#include <iostream>
using std::vector;
using std::map;
using std::string;
using std::istream;
FG_USING_STD(vector);
FG_USING_STD(map);
FG_USING_STD(string);
FG_USING_STD(istream);
FG_USING_STD(ostream);
struct E00Exception
{

View file

@ -4,19 +4,33 @@
// This program is in the Public Domain and comes with NO WARRANTY.
// Use at your own risk.
#include <fstream>
#include <string>
#include <simgear/compiler.h>
#include STL_STRING
#include "landcover.hxx"
using std::ifstream;
using std::string;
FG_USING_STD(ifstream);
FG_USING_STD(string);
LandCover::LandCover (const string &filename)
LandCover::LandCover( const string &filename )
{
_input = new ifstream(filename.c_str());
if (!_input->good())
throw (string("Failed to open ") + filename);
// MSVC chokes when these are defined and initialized as "static
// const long" in the class declaration.u
WIDTH = 43200;
HEIGHT = 21600;
_input = new ifstream(filename.c_str());
if (!_input->good()) {
#ifdef _MSC_VER
// there are no try or catch statements to support
// the throw-expression except in test-landcover.cxx
printf( "Failed to open %s\n", filename.c_str() );
exit( 1 );
#else
throw (string("Failed to open ") + filename);
#endif
}
}
LandCover::~LandCover ()

View file

@ -7,9 +7,13 @@
#ifndef __LANDCOVER_HXX
#define __LANDCOVER_HXX 1
#include <simgear/compiler.h>
#include STL_STRING
#include <fstream>
using std::ifstream;
FG_USING_STD(ifstream);
FG_USING_STD(string);
/**
@ -56,10 +60,12 @@ using std::ifstream;
* @author David Megginson, david@megginson.com
* @version 0.1
*/
class LandCover
{
class LandCover {
public:
LandCover (const string &filename);
LandCover( const string &filename );
virtual ~LandCover ();
virtual int getValue (long x, long y) const;
@ -68,8 +74,8 @@ public:
private:
mutable ifstream * _input;
static const long WIDTH = 43200;
static const long HEIGHT = 21600;
long WIDTH;
long HEIGHT;
};
#endif __LANDCOVER_HXX

View file

@ -1,6 +1,9 @@
#include <triangulate.h>
#include "triangulate.h"
#include <math.h>
#ifdef _MSC_VER
# include <memory.h>
#endif
node_t qs[QSIZE]; /* Query structure */
trap_t tr[TRSIZE]; /* Trapezoid structure */
@ -432,9 +435,9 @@ static int add_segment(segnum)
{
segment_t s;
segment_t *so = &seg[segnum];
int tu, tl, sk, tfirst, tlast, tnext;
int tu, tl, sk, tfirst, tlast;
int tfirstr, tlastr, tfirstl, tlastl;
int i1, i2, t, t1, t2, tn;
int i1, i2, t, tn;
point_t tpt;
int tritop = 0, tribot = 0, is_swapped = 0;
int tmptriseg;

View file

@ -1,5 +1,14 @@
#include <triangulate.h>
#include <sys/time.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "triangulate.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#else
# include <time.h>
#endif
#include <math.h>
#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ )
@ -15,14 +24,21 @@ static int permute[SEGSIZE];
int generate_random_ordering(n)
int n;
{
struct timeval tval;
struct timezone tzone;
register int i;
int m, st[SEGSIZE], *p;
#ifdef _MSC_VER
time_t ltime;
time( &ltime );
srand( ltime );
#else
struct timeval tval;
struct timezone tzone;
choose_idx = 1;
gettimeofday(&tval, &tzone);
srand48(tval.tv_sec);
#endif
for (i = 0; i <= n; i++)
st[i] = i;
@ -30,7 +46,11 @@ int generate_random_ordering(n)
p = st;
for (i = 1; i <= n; i++, p++)
{
m = lrand48() % (n + 1 - i) + 1;
#ifdef _MSC_VER
m = rand() % ( n + 1 - i ) + 1;
#else
m = lrand48() % ( n + 1 - i ) + 1;
#endif
permute[i] = p[m];
if (m != 1)
p[m] = p[1];
@ -43,8 +63,6 @@ int generate_random_ordering(n)
/* segments in S */
int choose_segment()
{
int i;
#ifdef DEBUG
fprintf(stderr, "choose_segment: %d\n", permute[choose_idx]);
#endif

View file

@ -1,5 +1,8 @@
#include <triangulate.h>
#include "triangulate.h"
#include <math.h>
#ifdef _MSC_VER
# include <memory.h>
#endif
#define CROSS_SINE(v0, v1) ((v0).x * (v1).y - (v1).x * (v0).y)
#define LENGTH(v0) (sqrt((v0).x * (v0).x + (v0).y * (v0).y))
@ -283,9 +286,9 @@ static int traverse_polygon(mcur, trnum, from, dir)
int dir;
{
trap_t *t = &tr[trnum];
int howsplit, mnew;
int v0, v1, v0next, v1next;
int retval, tmp;
int mnew;
int v0, v1;
int retval;
int do_switch = FALSE;
if ((trnum <= 0) || visited[trnum])

View file

@ -1,6 +1,8 @@
#include <triangulate.h>
#include <sys/time.h>
#include "triangulate.h"
/* #include <sys/time.h> */
#ifdef _MSC_VER
# include <memory.h>
#endif
static int initialise(n)
int n;

View file

@ -21,7 +21,130 @@
******************************************************************************
*
* $Log$
* Revision 1.1 2000/02/09 19:51:46 curt
* Revision 1.2 2000/11/25 19:39:49 curt
* Contributed by Bruce Finney:
*
* The following files have been changed to enable the latest Terragear CVS
* to compile with MSVC++ 5.0
*
* .\construct\clipper\clipper.cxx
* for( int i - lots of places
*
* .\construct\genoutput\genobj.cxx
* fix directory logic for windows, line 320 and following
*
* .\construct\main\main.cxx
* windows does not have an opendir function
* added code for windows directory functions
* disabled the mem allocation limit code - windows does not
* have similar functions
* for ( int i - several places
*
* .\construct\match\match.cxx
* moved the definition of file and command outside of the ifdef line 420
*
* .\lib\e00\e00.cxx
* for( int i - several places
*
* .\lib\e00\e00.cxx
* use simgear/compiler.h constructs
*
* .\lib\geometry\contour_tree.hxx
* removed a cout statement
*
* .\lib\geometry\poly_support.cxx
* added float.h changed 1.0e+999 to DBL_MAX, windows doesn't go that big
* lots of for ( int i changes
* lines 193 and 208 no != operator defined - changed logic
* line 801 flag should be int, not bool, get_hole_flag returns int
*
* .\lib\landcover\landcover.cxx
* .\lib\landcover\landcover.hxx
* add include simgear/compiler.h
* see comments
*
* .\lib\optimize\genfans.cxx
* function canonify added return at end, windows complains
* added using std for cout and endl
*
* .\lib\optimize\genstrips.cxx
* function tgGenStrips no return value, moved by_node into outer scope
* fix for ( int i ...
*
* .\lib\poly2tri\construct.c
* added include <memory.h> for windows
* remove unused variables lines 435 & 437
*
* .\lib\poly2tri\misc.c
* added HAVE_SYS_TIME_H logic for sys/time.h include file
* added logic to uses windows functions for time and rand
*
* .\lib\poly2tri\monotone.c
* added include <memory.h> for windows
* lines 286-288 remove unused variables
*
* .\lib\poly2tri\tri.c
* remove sys/time.h - no time functions called
* added include <memory.h> for windows
*
* .\lib\polygon\polygon.cxx
* function polygon_to_tristrip will not compile I don't think the
* logic is complete, no returned data added if else endif around
* function and polygon_to_tristrip_old, renamed _old function.
* Search of code reveals that function is not called by anyone.
*
* .\lib\polygon\superpoly.cxx
* changed include <superpoly.hxx> to "superpoly.hxx"
*
* .\lib\polygon\superpoly.hxx
* add include <windows.h> for windows before include <gl.h>
* needed for definitions used in Microsoft version of opengl
*
* .\lib\shapelib\dbfopen.c
* added include files for windows
* lines 195-197 271-272 515-517 removed unused variables
*
* .\lib\shapelib\shpopen.c
* added #include <stdlib.h> for malloc() and friends
* added include files for windows
* line 279 527 813 1127 removed unused variables
* line 827 cast result to int
*
* .\lib\win32\mkdir.cpp
* documented function, remove debug lines
*
* .\prep\demraw2ascii\main.c
* lines 46-50 remove unused variables
*
* .\prep\demraw2ascii\rawdem.c
* line 47 changed logic to compile with MSVC
* line 244-256 set real constants to float, windows complains with
* double constants
*
* .\prep\genairports\build.cxx
* lots of for ( int i changes
*
* .\prep\genairports\main.cxx
* fix mkdir logic for windows
*
* .\prep\genairports\output.cxx
* added using std cout endl
* lots of for ( int i changes
* fix mkdir logic for windows
*
* .\prep\genairports\runway.cxx
* for ( int i changes
* lines 117-118 161-162 remove default values for function parameters
*
* .\prep\gshhs\main.cxx
* added using std cout
*
* .\prep\shapefile\noaa_decode.cxx
* .\prep\shapefile\shape_decode.cxx
* added using std for cout
* lines 45-49 moved unused variables inside #if 0 block
*
* Revision 1.1.1.1 2000/02/09 19:51:46 curt
* Initial revision
*
* Revision 1.1 1999/08/24 21:13:00 curt
@ -78,6 +201,11 @@ static char rcsid[] =
#include "shapefil.h"
#include <math.h>
#ifdef _MSC_VER
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#endif
typedef unsigned char uchar;
@ -192,9 +320,8 @@ DBFHandle DBFOpen( const char * pszFilename, const char * pszAccess )
{
DBFHandle psDBF;
uchar *pabyBuf;
int nFields, nRecords, nHeadLen, nRecLen, iField, i;
int nFields, nRecords, nHeadLen, nRecLen, iField;
char *pszDBFFilename;
FILE *fp;
/* -------------------------------------------------------------------- */
/* We only allow the access strings "rb" and "r+". */
@ -268,8 +395,6 @@ DBFHandle DBFOpen( const char * pszFilename, const char * pszAccess )
for( iField = 0; iField < nFields; iField++ )
{
char *pszTitle;
int nType;
uchar *pabyFInfo;
pabyFInfo = pabyBuf+iField*32;
@ -512,9 +637,8 @@ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField,
char chReqType )
{
int nRecordOffset, i, j;
int nRecordOffset;
uchar *pabyRec;
char *pszSField;
void *pReturnField = NULL;
static double dDoubleField;

View file

@ -21,7 +21,130 @@
******************************************************************************
*
* $Log$
* Revision 1.1 2000/02/09 19:51:46 curt
* Revision 1.2 2000/11/25 19:39:49 curt
* Contributed by Bruce Finney:
*
* The following files have been changed to enable the latest Terragear CVS
* to compile with MSVC++ 5.0
*
* .\construct\clipper\clipper.cxx
* for( int i - lots of places
*
* .\construct\genoutput\genobj.cxx
* fix directory logic for windows, line 320 and following
*
* .\construct\main\main.cxx
* windows does not have an opendir function
* added code for windows directory functions
* disabled the mem allocation limit code - windows does not
* have similar functions
* for ( int i - several places
*
* .\construct\match\match.cxx
* moved the definition of file and command outside of the ifdef line 420
*
* .\lib\e00\e00.cxx
* for( int i - several places
*
* .\lib\e00\e00.cxx
* use simgear/compiler.h constructs
*
* .\lib\geometry\contour_tree.hxx
* removed a cout statement
*
* .\lib\geometry\poly_support.cxx
* added float.h changed 1.0e+999 to DBL_MAX, windows doesn't go that big
* lots of for ( int i changes
* lines 193 and 208 no != operator defined - changed logic
* line 801 flag should be int, not bool, get_hole_flag returns int
*
* .\lib\landcover\landcover.cxx
* .\lib\landcover\landcover.hxx
* add include simgear/compiler.h
* see comments
*
* .\lib\optimize\genfans.cxx
* function canonify added return at end, windows complains
* added using std for cout and endl
*
* .\lib\optimize\genstrips.cxx
* function tgGenStrips no return value, moved by_node into outer scope
* fix for ( int i ...
*
* .\lib\poly2tri\construct.c
* added include <memory.h> for windows
* remove unused variables lines 435 & 437
*
* .\lib\poly2tri\misc.c
* added HAVE_SYS_TIME_H logic for sys/time.h include file
* added logic to uses windows functions for time and rand
*
* .\lib\poly2tri\monotone.c
* added include <memory.h> for windows
* lines 286-288 remove unused variables
*
* .\lib\poly2tri\tri.c
* remove sys/time.h - no time functions called
* added include <memory.h> for windows
*
* .\lib\polygon\polygon.cxx
* function polygon_to_tristrip will not compile I don't think the
* logic is complete, no returned data added if else endif around
* function and polygon_to_tristrip_old, renamed _old function.
* Search of code reveals that function is not called by anyone.
*
* .\lib\polygon\superpoly.cxx
* changed include <superpoly.hxx> to "superpoly.hxx"
*
* .\lib\polygon\superpoly.hxx
* add include <windows.h> for windows before include <gl.h>
* needed for definitions used in Microsoft version of opengl
*
* .\lib\shapelib\dbfopen.c
* added include files for windows
* lines 195-197 271-272 515-517 removed unused variables
*
* .\lib\shapelib\shpopen.c
* added #include <stdlib.h> for malloc() and friends
* added include files for windows
* line 279 527 813 1127 removed unused variables
* line 827 cast result to int
*
* .\lib\win32\mkdir.cpp
* documented function, remove debug lines
*
* .\prep\demraw2ascii\main.c
* lines 46-50 remove unused variables
*
* .\prep\demraw2ascii\rawdem.c
* line 47 changed logic to compile with MSVC
* line 244-256 set real constants to float, windows complains with
* double constants
*
* .\prep\genairports\build.cxx
* lots of for ( int i changes
*
* .\prep\genairports\main.cxx
* fix mkdir logic for windows
*
* .\prep\genairports\output.cxx
* added using std cout endl
* lots of for ( int i changes
* fix mkdir logic for windows
*
* .\prep\genairports\runway.cxx
* for ( int i changes
* lines 117-118 161-162 remove default values for function parameters
*
* .\prep\gshhs\main.cxx
* added using std cout
*
* .\prep\shapefile\noaa_decode.cxx
* .\prep\shapefile\shape_decode.cxx
* added using std for cout
* lines 45-49 moved unused variables inside #if 0 block
*
* Revision 1.1.1.1 2000/02/09 19:51:46 curt
* Initial revision
*
* Revision 1.1 1999/08/24 21:13:01 curt
@ -101,6 +224,12 @@ static char rcsid[] =
#include <math.h>
#include <limits.h>
#include <assert.h>
#include <stdlib.h> /* malloc() && friends */
#ifdef _MSC_VER
# include <stdlib.h>
# include <memory.h>
# include <string.h>
#endif
typedef unsigned char uchar;
@ -276,7 +405,7 @@ SHPHandle SHPOpen( const char * pszLayer, const char * pszAccess )
SHPHandle psSHP;
uchar *pabyBuf;
int iField, i;
int i;
double dValue;
/* -------------------------------------------------------------------- */
@ -524,7 +653,6 @@ SHPHandle SHPCreate( const char * pszLayer, int nShapeType )
uchar abyHeader[100];
int32 i32;
double dValue;
int32 *panSHX;
/* -------------------------------------------------------------------- */
/* Establish the byte order on this system. */
@ -810,7 +938,7 @@ SHPObject *SHPCreateSimpleObject( int nSHPType, int nVertices,
int SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject )
{
int nRecordOffset, i, j, nRecordSize;
int nRecordOffset, i, nRecordSize;
uchar *pabyRec;
int32 i32;
@ -824,7 +952,7 @@ int SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject )
psSHP->nRecords++;
if( psSHP->nRecords > psSHP->nMaxRecords )
{
psSHP->nMaxRecords = psSHP->nMaxRecords * 1.3 + 100;
psSHP->nMaxRecords = (int)( psSHP->nMaxRecords * 1.3 ) + 100;
psSHP->panRecOffset = (int *)
SfRealloc(psSHP->panRecOffset,sizeof(int) * psSHP->nMaxRecords );
@ -1124,7 +1252,6 @@ int SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject )
SHPObject *SHPReadObject( SHPHandle psSHP, int hEntity )
{
int nRecordOffset, i, j;
SHPObject *psShape;
static uchar *pabyRec = NULL;

View file

@ -43,11 +43,10 @@ int main(int argc, char **argv) {
fgRAWDEM raw;
char basename[256], output_dir[256], hdr_file[256], dem_file[256];
int start_lat, end_lat;
int i, j;
int min, max;
double total;
unsigned char buf[2];
short int value;
int i;
// double total;
// unsigned char buf[2];
// short int value;
if ( argc != 3 ) {
printf("Usage: %s <input_file_basename> <output_dir>\n", argv[0]);
@ -81,6 +80,7 @@ int main(int argc, char **argv) {
printf(" short int size = %d\n", sizeof(short int) );
/*
int min, max;
min = max = 0;
total = 0;
for ( j = 0; j < raw.nrows; ++j ) {

View file

@ -44,7 +44,7 @@
#include "rawdem.h"
#if defined( HAVE_UNISTD_H ) && !defined( HAVE_RINT )
#if !defined( HAVE_RINT )
double round( double a ) {
long i;
@ -245,10 +245,10 @@ void rawConvertCenter2Edge( fgRAWDEM *raw ) {
/* derive edge nodes */
for ( i = 1; i < 120; i++ ) {
raw->edge[i][0] = (raw->center[i-1][0] + raw->center[i][0]) / 2.0;
raw->edge[i][120] = (raw->center[i-1][119] + raw->center[i][119]) / 2.0;
raw->edge[0][i] = (raw->center[0][i-1] + raw->center[0][i]) / 2.0;
raw->edge[120][i] = (raw->center[119][i-1] + raw->center[119][i]) / 2.0;
raw->edge[i][0] = (raw->center[i-1][0] + raw->center[i][0]) / 2.0f;
raw->edge[i][120] = (raw->center[i-1][119] + raw->center[i][119]) / 2.0f;
raw->edge[0][i] = (raw->center[0][i-1] + raw->center[0][i]) / 2.0f;
raw->edge[120][i] = (raw->center[119][i-1] + raw->center[119][i]) / 2.0f;
}
/* derive internal nodes */
@ -257,7 +257,7 @@ void rawConvertCenter2Edge( fgRAWDEM *raw ) {
raw->edge[i][j] = ( raw->center[i-1][j-1] +
raw->center[i] [j-1] +
raw->center[i] [j] +
raw->center[i-1][j] ) / 4;
raw->center[i-1][j] ) / 4.0f;
}
}
}

View file

@ -42,6 +42,8 @@
#include "gshhs.h"
#include "gshhs_split.hxx"
FG_USING_STD( string );
FG_USING_STD( cout );
// hackity, hackity, hack ... cough cough
#ifdef i386

View file

@ -39,16 +39,19 @@
# include <Win32/mkdir.hpp>
#endif
FG_USING_STD( cout );
FG_USING_STD( string );
// return the type of the shapefile record
AreaType get_shapefile_type(DBFHandle& hDBF, int rec) {
#if 0
int *panWidth, i, iRecord;
char szFormat[32];
int nWidth, nDecimals;
int bMultiLine = 0;
char szTitle[12];
int bMultiLine = 0;
#if 0
// grab the meta-information for all the fields
// this applies to all the records in the DBF file.
for ( i = 0; i < DBFGetFieldCount(hDBF); i++ ) {

View file

@ -39,16 +39,18 @@
# include <Win32/mkdir.hpp>
#endif
FG_USING_STD( cout );
FG_USING_STD( string );
// return the type of the shapefile record
AreaType get_shapefile_type(DBFHandle& hDBF, int rec) {
#if 0
int *panWidth, i, iRecord;
char szFormat[32];
int nWidth, nDecimals;
int bMultiLine = 0;
char szTitle[12];
#if 0
// grab the meta-information for all the fields
// this applies to all the records in the DBF file.
for ( i = 0; i < DBFGetFieldCount(hDBF); i++ ) {