1
0
Fork 0

MSVC5 combatibility tweaks contributed by Bruce Finney.

This commit is contained in:
curt 2000-05-30 21:11:15 +00:00
parent 66dbea0aaa
commit c54e5e8adc
25 changed files with 245 additions and 93 deletions

View file

@ -423,7 +423,9 @@ static FGPolygon add_nodes_to_poly( const FGPolygon& poly,
add_intermediate_nodes( i, p0, p1, tmp_nodes, &result );
// end of segment is beginning of next segment
result.add_node( i, p1 );
// 5/9/2000 CLO - this results in duplicating the last point
// of a contour so I have removed this line.
// result.add_node( i, p1 );
// maintain original hole flag setting
result.set_hole_flag( i, poly.get_hole_flag( i ) );

View file

@ -101,6 +101,8 @@ bool test_point(Point3D Pa, Point3D Pb, Point3D Pc) {
// point2d. The algorithm description can be found at:
// http://riot.ieor.berkeley.edu/riot/Applications/ConvexHull/CHDetails.html
FGPolygon convex_hull( const point_list& input_list ) {
int i;
map_iterator map_current, map_next, map_next_next, map_last;
// list of translated points
@ -120,7 +122,7 @@ FGPolygon convex_hull( const point_list& input_list ) {
in_count = input_list.size();
sum_x = sum_y = 0.0;
for ( int i = 0; i < in_count; ++i ) {
for ( i = 0; i < in_count; ++i ) {
sum_x += input_list[i].x();
sum_y += input_list[i].y();
}
@ -132,7 +134,7 @@ FGPolygon convex_hull( const point_list& input_list ) {
// STEP TWO: Translate input points so average is at origin
trans_list.clear();
for ( int i = 0; i < in_count; ++i ) {
for ( i = 0; i < in_count; ++i ) {
p = Point3D( input_list[i].x() - average.x(),
input_list[i].y() - average.y(), 0 );
// printf("%.6f %.6f\n", p.x, p.y);
@ -142,7 +144,7 @@ FGPolygon convex_hull( const point_list& input_list ) {
// STEP THREE: convert to radians and sort by theta
radians_map.clear();
for ( int i = 0; i < in_count; ++i ) {
for ( i = 0; i < in_count; ++i ) {
p = cart_to_polar_2d( trans_list[i] );
if ( p.x() > radians_map[p.y()] ) {
radians_map[p.y()] = p.x();
@ -243,5 +245,3 @@ FGPolygon convex_hull( const point_list& input_list ) {
return con_hull;
}

View file

@ -32,6 +32,8 @@
#include "clipper.hxx"
FG_USING_STD(cout);
#define MASK_CLIP 1

View file

@ -29,8 +29,15 @@
#include <Polygon/names.hxx>
#include "scenery_version.hxx"
#ifdef _MSC_VER
# include <win32/mkdir.hpp>
#endif
#include "genobj.hxx"
FG_USING_STD(cout);
FG_USING_STD(endl);
// calculate the global bounding sphere. Center is the center of the
// tile and zero elevation
@ -151,6 +158,8 @@ int_list FGGenOutput::calc_tex_coords( FGConstruct& c, point_list geod_nodes,
// build the necessary output structures based on the triangulation
// data
int FGGenOutput::build( FGConstruct& c ) {
int i, j;
FGTriNodes trinodes = c.get_tri_nodes();
// copy the geodetic node list into this class
@ -162,7 +171,7 @@ int FGGenOutput::build( FGConstruct& c ) {
// build the trifan list
cout << "total triangles = " << tri_elements.size() << endl;
FGGenFans f;
for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
triele_list area_tris;
area_tris.erase( area_tris.begin(), area_tris.end() );
@ -185,8 +194,8 @@ int FGGenOutput::build( FGConstruct& c ) {
cout << "calculating texture coordinates" << endl;
tex_coords.clear();
for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
for ( int j = 0; j < (int)fans[i].size(); ++j ) {
for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
for ( j = 0; j < (int)fans[i].size(); ++j ) {
// int_list t_list = calc_tex_coords( c, geod_nodes, fans[i][j] );
// cout << fans[i][j].size() << " === "
// << t_list.size() << endl;
@ -302,13 +311,19 @@ void FGGenOutput::calc_bounding_sphere( FGConstruct& c, const FGTriEle& t,
// write out the fgfs scenery file
int FGGenOutput::write( FGConstruct &c ) {
Point3D p;
int i;
string base = c.get_output_base();
FGBucket b = c.get_bucket();
string dir = base + "/Scenery/" + b.gen_base_path();
#ifdef _MSCVER
fg_mkdir( dir.c_str );
#else
string command = "mkdir -p " + dir;
system(command.c_str());
#endif
string file = dir + "/" + b.gen_index_str();
cout << "Output file = " << file << endl;
@ -361,7 +376,7 @@ int FGGenOutput::write( FGConstruct &c ) {
// write texture coordinates
point_list tex_coord_list = tex_coords.get_node_list();
fprintf(fp, "# texture coordinate list\n");
for ( int i = 0; i < (int)tex_coord_list.size(); ++i ) {
for ( i = 0; i < (int)tex_coord_list.size(); ++i ) {
p = tex_coord_list[i];
fprintf(fp, "vt %.5f %.5f\n", p.x(), p.y());
}
@ -374,7 +389,7 @@ int FGGenOutput::write( FGConstruct &c ) {
fprintf(fp, "\n");
int total_tris = 0;
for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
if ( (int)fans[i].size() > 0 ) {
string attr_name = get_area_name( (AreaType)i );
calc_group_bounding_sphere( c, fans[i], &center, &radius );

View file

@ -21,12 +21,20 @@
// $Id$
#include <sys/types.h> // for directory reading
#include <dirent.h> // for directory reading
#ifdef _MSC_VER
# include <io.h>
#else
# include <sys/types.h> // for directory reading
# include <dirent.h> // for directory reading
#endif
#include <sys/time.h> // set mem allocation limit
#include <sys/resource.h> // set mem allocation limit
#include <unistd.h> // set mem allocation limit
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> // set mem allocation limit
#endif
#ifndef _MSC_VER
# include <sys/resource.h> // set mem allocation limit
# include <unistd.h> // set mem allocation limit
#endif
#include <plib/sg.h>
@ -42,6 +50,9 @@
#include "construct.hxx"
FG_USING_STD(cout);
FG_USING_STD(endl);
// do actual scan of directory and loading of files
int actual_load_polys( const string& dir, FGConstruct& c, FGClipper& clipper ) {
@ -236,13 +247,14 @@ static double distance2D( const Point3D p1, const Point3D p2 ) {
// fix the elevations of the geodetic nodes
static void fix_point_heights( FGConstruct& c, const FGArray& array ) {
int i;
double z;
cout << "fixing node heights" << endl;
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 ) {
z = array.interpolate_altitude( raw_nodes[i].x() * 3600.0,
raw_nodes[i].y() * 3600.0 );
cout << " old z = " << raw_nodes[i].z() << " new z = " << z << endl;
@ -261,7 +273,7 @@ static void fix_point_heights( FGConstruct& c, const FGArray& array ) {
int n1, n2, n3;
for ( int count = 0; count < 3; ++count ) {
for ( int i = 0; i < (int)tris.size(); ++i ) {
for ( i = 0; i < (int)tris.size(); ++i ) {
double e1, e2, e3, ave, min;
t = tris[i];
@ -314,7 +326,7 @@ static void fix_point_heights( FGConstruct& c, const FGArray& array ) {
}
}
for ( int i = 0; i < (int)tris.size(); ++i ) {
for ( i = 0; i < (int)tris.size(); ++i ) {
// set all ocean nodes to 0.0
t = tris[i];
n1 = t.get_n1();

View file

@ -1,4 +1,4 @@
// array.cxx -- Array management class
// match.cxx -- Handle details of matching up tile edges
//
// Written by Curtis Olson, started March 1998.
//
@ -29,8 +29,14 @@
#include <simgear/math/point3d.hxx>
#include <simgear/misc/fgstream.hxx>
#ifdef _MSC_VER
# include <Win32/mkdir.hpp>
#endif
#include "match.hxx"
FG_USING_STD(cout);
FG_USING_STD(endl);
FGMatch::FGMatch( void ) {
@ -254,6 +260,8 @@ void FGMatch::load_neighbor_shared( FGConstruct& c ) {
// load_neighbor_data() and will ignore any shared data from the
// current tile that already exists from a neighbor.
void FGMatch::split_tile( FGConstruct& c ) {
int i;
cout << "Spliting tile" << endl;
cout << " extracting (shared) edge nodes and normals" << endl;
@ -272,7 +280,7 @@ void FGMatch::split_tile( FGConstruct& c ) {
point_list nodes = c.get_geod_nodes();
point_list point_normals = c.get_point_normals();
for ( int i = 0; i < (int)nodes.size(); ++i ) {
for ( i = 0; i < (int)nodes.size(); ++i ) {
Point3D node = nodes[i];
Point3D normal = point_normals[i];
@ -369,30 +377,30 @@ void FGMatch::split_tile( FGConstruct& c ) {
if ( !nw_flag ) { cout << " nw corner = " << nw_node << endl; }
if ( !north_flag ) {
cout << " north nodes = " << north_nodes.size() << endl;
for ( int i = 0; i < (int)north_nodes.size(); ++i ) {
for ( i = 0; i < (int)north_nodes.size(); ++i ) {
cout << " " << north_nodes[i] << endl;
}
}
if ( !south_flag ) {
cout << " south nodes = " << south_nodes.size() << endl;
for ( int i = 0; i < (int)south_nodes.size(); ++i ) {
for ( i = 0; i < (int)south_nodes.size(); ++i ) {
cout << " " << south_nodes[i] << endl;
}
}
if ( !east_flag ) {
cout << " east nodes = " << east_nodes.size() << endl;
for ( int i = 0; i < (int)east_nodes.size(); ++i ) {
for ( i = 0; i < (int)east_nodes.size(); ++i ) {
cout << " " << east_nodes[i] << endl;
}
}
if ( !west_flag ) {
cout << " west nodes = " << west_nodes.size() << endl;
for ( int i = 0; i < (int)west_nodes.size(); ++i ) {
for ( i = 0; i < (int)west_nodes.size(); ++i ) {
cout << " " << west_nodes[i] << endl;
}
}
cout << " body nodes = " << body_nodes.size() << endl;
for ( int i = 0; i < (int)body_nodes.size(); ++i ) {
for ( i = 0; i < (int)body_nodes.size(); ++i ) {
cout << " " << body_nodes[i] << endl;
}
}
@ -405,8 +413,14 @@ void FGMatch::write_shared( FGConstruct& c ) {
FGBucket b = c.get_bucket();
string dir = base + "/Shared/" + b.gen_base_path();
#ifdef _MSC_VER
fg_mkdir( dir.c_str() );
#else
string command = "mkdir -p " + dir;
string file = dir + "/" + b.gen_index_str();
#endif
cout << "shared data will be written to " << file << endl;
system(command.c_str());
@ -589,6 +603,7 @@ static Point3D fake_normal( const Point3D& p ) {
// reassemble the tile pieces (combining the shared data and our own
// data)
void FGMatch::assemble_tile( FGConstruct& c ) {
int i;
FGTriNodes new_nodes;
new_nodes.clear();
@ -619,23 +634,23 @@ void FGMatch::assemble_tile( FGConstruct& c ) {
int index;
for ( int i = 0; i < (int)north_nodes.size(); ++i ) {
for ( i = 0; i < (int)north_nodes.size(); ++i ) {
index = new_nodes.unique_add( north_nodes[i] );
insert_normal( new_normals, north_normals[i], index );
}
for ( int i = 0; i < (int)south_nodes.size(); ++i ) {
for ( i = 0; i < (int)south_nodes.size(); ++i ) {
index = new_nodes.unique_add( south_nodes[i] );
insert_normal( new_normals, south_normals[i], index );
}
for ( int i = 0; i < (int)east_nodes.size(); ++i ) {
for ( i = 0; i < (int)east_nodes.size(); ++i ) {
index = new_nodes.unique_add( east_nodes[i] );
insert_normal( new_normals, east_normals[i], index );
}
// cout << "Total west nodes = " << west_nodes.size() << endl;
for ( int i = 0; i < (int)west_nodes.size(); ++i ) {
for ( i = 0; i < (int)west_nodes.size(); ++i ) {
// cout << "adding west node " << west_nodes[i] << endl;
index = new_nodes.unique_add( west_nodes[i] );
insert_normal( new_normals, west_normals[i], index );
@ -646,7 +661,7 @@ void FGMatch::assemble_tile( FGConstruct& c ) {
cout << " new normals = " << new_normals.size() << endl;
// add the body points
for ( int i = 0; i < (int)body_nodes.size(); ++i ) {
for ( i = 0; i < (int)body_nodes.size(); ++i ) {
index = new_nodes.unique_add( body_nodes[i] );
insert_normal( new_normals, body_normals[i], index );
}

View file

@ -27,6 +27,9 @@
#include "triangle.hxx"
FG_USING_STD(cout);
FG_USING_STD(endl);
// Constructor
FGTriangle::FGTriangle( void ) {
@ -46,6 +49,7 @@ FGTriangle::build( const point_list& corner_list,
{
int debug_counter = 0;
int index;
int i;
in_nodes.clear();
in_segs.clear();
@ -75,7 +79,7 @@ FGTriangle::build( const point_list& corner_list,
// process polygons in priority order
cout << "prepairing node list and polygons" << endl;
for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
polylist[i].clear();
cout << "area type = " << i << endl;
@ -163,7 +167,7 @@ FGTriangle::build( const point_list& corner_list,
index = in_nodes.course_add( *f_current );
}
for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
if ( polylist[i].size() ) {
cout << get_area_name((AreaType)i) << " = "
<< polylist[i].size() << endl;
@ -179,7 +183,7 @@ FGTriangle::build( const point_list& corner_list,
point_list node_list = in_nodes.get_node_list();
FGPolygon poly;
for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
cout << "area type = " << i << endl;
poly_list_iterator tp_current, tp_last;
tp_current = polylist[i].begin();
@ -243,10 +247,12 @@ int FGTriangle::rebuild( FGConstruct& c ) {
#if 0
static void write_out_data(struct triangulateio *out) {
int i, j;
FILE *node = fopen("tile.node", "w");
fprintf(node, "%d 2 %d 0\n",
out->numberofpoints, out->numberofpointattributes);
for (int i = 0; i < out->numberofpoints; ++i) {
for ( i = 0; i < out->numberofpoints; ++i) {
fprintf(node, "%d %.6f %.6f %.2f\n",
i, out->pointlist[2*i], out->pointlist[2*i + 1], 0.0);
}
@ -254,12 +260,12 @@ static void write_out_data(struct triangulateio *out) {
FILE *ele = fopen("tile.ele", "w");
fprintf(ele, "%d 3 0\n", out->numberoftriangles);
for (int i = 0; i < out->numberoftriangles; ++i) {
for ( i = 0; i < out->numberoftriangles; ++i) {
fprintf(ele, "%d ", i);
for (int j = 0; j < out->numberofcorners; ++j) {
for ( j = 0; j < out->numberofcorners; ++j) {
fprintf(ele, "%d ", out->trianglelist[i * out->numberofcorners + j]);
}
for (int j = 0; j < out->numberoftriangleattributes; ++j) {
for ( j = 0; j < out->numberoftriangleattributes; ++j) {
fprintf(ele, "%.6f ",
out->triangleattributelist[i
* out->numberoftriangleattributes
@ -273,18 +279,18 @@ static void write_out_data(struct triangulateio *out) {
FILE *fp = fopen("tile.poly", "w");
fprintf(fp, "0 2 1 0\n");
fprintf(fp, "%d 1\n", out->numberofsegments);
for (int i = 0; i < out->numberofsegments; ++i) {
for ( i = 0; i < out->numberofsegments; ++i) {
fprintf(fp, "%d %d %d %d\n",
i, out->segmentlist[2*i], out->segmentlist[2*i + 1],
out->segmentmarkerlist[i] );
}
fprintf(fp, "%d\n", out->numberofholes);
for (int i = 0; i < out->numberofholes; ++i) {
for ( i = 0; i < out->numberofholes; ++i) {
fprintf(fp, "%d %.6f %.6f\n",
i, out->holelist[2*i], out->holelist[2*i + 1]);
}
fprintf(fp, "%d\n", out->numberofregions);
for (int i = 0; i < out->numberofregions; ++i) {
for ( i = 0; i < out->numberofregions; ++i) {
fprintf(fp, "%d %.6f %.6f %.6f\n",
i, out->regionlist[4*i], out->regionlist[4*i + 1],
out->regionlist[4*i + 2]);
@ -306,13 +312,14 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) {
Point3D p;
struct triangulateio in, out, vorout;
int counter;
int i, j;
// point list
point_list node_list = in_nodes.get_node_list();
in.numberofpoints = node_list.size();
in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
for ( int i = 0; i < in.numberofpoints; ++i ) {
for ( i = 0; i < in.numberofpoints; ++i ) {
in.pointlist[2*i] = node_list[i].x();
in.pointlist[2*i + 1] = node_list[i].y();
}
@ -321,12 +328,12 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) {
in.pointattributelist = (REAL *) malloc(in.numberofpoints *
in.numberofpointattributes *
sizeof(REAL));
for ( int i = 0; i < in.numberofpoints * in.numberofpointattributes; ++i) {
for ( i = 0; i < in.numberofpoints * in.numberofpointattributes; ++i) {
in.pointattributelist[i] = node_list[i].z();
}
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;
}
@ -364,7 +371,7 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) {
counter = 0;
for ( ; h_current != h_last; ++h_current ) {
poly = *h_current;
for ( int j = 0; j < poly.contours(); ++j ) {
for ( j = 0; j < poly.contours(); ++j ) {
p = poly.get_point_inside( j );
in.holelist[counter++] = p.x();
in.holelist[counter++] = p.y();
@ -373,13 +380,13 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) {
// region list
in.numberofregions = 0;
for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
poly_list_iterator h_current, h_last;
h_current = polylist[i].begin();
h_last = polylist[i].end();
for ( ; h_current != h_last; ++h_current ) {
poly = *h_current;
for ( int j = 0; j < poly.contours(); ++j ) {
for ( j = 0; j < poly.contours(); ++j ) {
if ( ! poly.get_hole_flag( j ) ) {
++in.numberofregions;
}
@ -389,13 +396,13 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) {
in.regionlist = (REAL *) malloc(in.numberofregions * 4 * sizeof(REAL));
counter = 0;
for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
poly_list_iterator h_current, h_last;
h_current = polylist[(int)i].begin();
h_last = polylist[(int)i].end();
for ( ; h_current != h_last; ++h_current ) {
poly = *h_current;
for ( int j = 0; j < poly.contours(); ++j ) {
for ( j = 0; j < poly.contours(); ++j ) {
if ( ! poly.get_hole_flag( j ) ) {
p = poly.get_point_inside( j );
cout << "Region point = " << p << endl;
@ -472,7 +479,7 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) {
// nodes
out_nodes.clear();
for ( int i = 0; i < out.numberofpoints; ++i ) {
for ( i = 0; i < out.numberofpoints; ++i ) {
Point3D p( out.pointlist[2*i], out.pointlist[2*i + 1],
out.pointattributelist[i] );
// cout << "point = " << p << endl;
@ -481,7 +488,7 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) {
// segments
out_segs.clear();
for ( int i = 0; i < out.numberofsegments; ++i ) {
for ( i = 0; i < out.numberofsegments; ++i ) {
out_segs.unique_add( FGTriSeg( out.segmentlist[2*i],
out.segmentlist[2*i+1],
out.segmentmarkerlist[i] ) );
@ -491,7 +498,7 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) {
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];

View file

@ -51,9 +51,15 @@
#include <simgear/misc/strutils.hxx>
#include <simgear/math/leastsqs.hxx>
#ifdef _MSC_VER
# include <win32/mkdir.hpp>
#endif
#include "array.hxx"
FG_USING_STD(string);
FG_USING_STD(cout);
FG_USING_STD(endl);
FGArray::FGArray( void ) {
@ -492,8 +498,12 @@ void FGArray::outputmesh_output_nodes( const string& fg_root, FGBucket& p )
if ( result != 0 && errno == ENOENT ) {
cout << " Creating directory\n";
#ifdef _MSC_VER
fg_mkdir( dir.cstr() );
#else
command = "mkdir -p " + dir + "\n";
system( command.c_str() );
#endif
} else {
// assume directory exists
}

View file

@ -51,8 +51,15 @@
#include <simgear/misc/fgstream.hxx>
#include <simgear/misc/strutils.hxx>
#ifdef _MSC_VER
# include <win32/mkdir.hpp>
#endif
#include "dem.hxx"
FG_USING_STD(cout);
FG_USING_STD(endl);
#define MAX_EX_NODES 10000
@ -415,8 +422,12 @@ FGDem::write_area( const string& root, FGBucket& b, bool compress ) {
// generate output file name
string base = b.gen_base_path();
string path = root + "/" + base;
#ifdef _MSC_VER
fg_mkdir( path.c_str() );
#else
string command = "mkdir -p " + path;
system( command.c_str() );
#endif
string demfile = path + "/" + b.gen_index_str() + ".dem";
cout << "demfile = " << demfile << endl;
@ -764,27 +775,12 @@ void FGDem::outputmesh_output_nodes( const string& fg_root, FGBucket& p )
if ( result != 0 && errno == ENOENT ) {
cout << "Creating directory\n";
// #ifndef WIN32
#ifdef _MSC_VER
fg_mkdir( dir.c_str() );
#else
command = "mkdir -p " + dir + "\n";
system( command.c_str() );
#if 0
// #else // WIN32
// Cygwin crashes when trying to output to node file
// explicitly making directory structure seems OK on Win95
extract_path (base_path, tmp_path);
dir = fg_root + "/" + tmp_path;
if (my_mkdir ( dir.c_str() )) { exit (-1); }
dir = fg_root + "/" + base_path;
if (my_mkdir ( dir.c_str() )) { exit (-1); }
// #endif // WIN32
#endif //0
#endif
} else {
// assume directory exists

View file

@ -504,7 +504,7 @@ static triele_list contour_tesselate( const point_list contour ) {
vorout.normlist = (REAL *) NULL; // Needed only if -v switch used.
// TEMPORARY
write_tri_data(&in);
// write_tri_data(&in);
// Triangulate the points. Switches are chosen to read and write
// a PSLG (p), number everything from zero (z), and produce an
@ -513,14 +513,13 @@ static triele_list contour_tesselate( const point_list contour ) {
// splitting (YY), no quality refinement (q)
string tri_options;
// tri_options = "pzYYen";
tri_options = "zYYen";
tri_options = "pzYYen";
cout << "Triangulation with options = " << tri_options << endl;
triangulate( (char *)tri_options.c_str(), &in, &out, &vorout );
// TEMPORARY
// write_out_data(&out);
write_tri_data(&out);
// now copy the results back into the corresponding FGTriangle
// structures
@ -647,6 +646,8 @@ void calc_points_inside( FGPolygon& p ) {
}
}
exit(0);
// next calculate an inside point for all non-hole contours taking
// into consideration the holes
for ( int i = 0; i < p.contours(); ++i ) {

View file

@ -48,7 +48,7 @@ private:
// return true of the two points are "close enough" as defined by
// FG_PROXIMITY_EPSILON
bool close_enough( const Point3D& p, const Point3D& p ) const;
bool close_enough( const Point3D& p1, const Point3D& p2 ) const;
// return true of the two points are "close enough" as defined by
// FG_COURSE_EPSILON

View file

@ -28,6 +28,9 @@
#include "trisegs.hxx"
FG_USING_STD(cout);
FG_USING_STD(endl);
// Constructor
FGTriSegments::FGTriSegments( void ) {

View file

@ -22,12 +22,16 @@
#include <simgear/compiler.h>
#include STL_IOSTREAM
#include STL_STRING
#include <stdio.h>
#include "index.hxx"
FG_USING_STD(cout);
FG_USING_STD(endl);
static long int poly_index;
static string poly_path;
@ -48,6 +52,8 @@ bool poly_index_init( string path ) {
fscanf( fp, "%ld", &poly_index );
fclose( fp );
return true;
}

View file

@ -29,6 +29,8 @@
#include STL_STRING
FG_USING_STD(string);
// initialize the unique polygon index counter stored in path
bool poly_index_init( string path );

View file

@ -22,10 +22,14 @@
#include <simgear/compiler.h>
#include STL_IOSTREAM
#include STL_STRING
#include "names.hxx"
FG_USING_STD(cout);
FG_USING_STD(endl);
// return area type from text name
AreaType get_area_type( string area ) {

View file

@ -36,6 +36,9 @@ extern "C" {
#include "polygon.hxx"
FG_USING_STD(cout);
FG_USING_STD(endl);
// Constructor
FGPolygon::FGPolygon( void ) {
@ -367,6 +370,7 @@ FGPolygon polygon_canonify( const FGPolygon& in_poly ) {
#define FG_MAX_TRIANGLES 100000
FGPolygon polygon_to_tristrip( const FGPolygon& in_poly ) {
int i, j;
// canonify the polygon winding, outer contour must be
// anti-clockwise, all inner contours must be clockwise.
@ -376,15 +380,15 @@ FGPolygon polygon_to_tristrip( const FGPolygon& in_poly ) {
int ncontours = canon_poly.contours();
int cntr[ncontours];
int vsize = 1;
for ( int i = 0; i < canon_poly.contours(); ++i ) {
for ( i = 0; i < canon_poly.contours(); ++i ) {
cntr[i] = canon_poly.contour_size( i );
vsize += cntr[i];
}
double vertices[vsize][2];
int counter = 1;
Point3D p;
for ( int i = 0; i < canon_poly.contours(); ++i ) {
for ( int j = 0; j < canon_poly.contour_size( i ); ++j ) {
for ( i = 0; i < canon_poly.contours(); ++i ) {
for ( j = 0; j < canon_poly.contour_size( i ); ++j ) {
p = canon_poly.get_pt( i, j );
vertices[counter][0] = p.x();
vertices[counter][1] = p.y();

View file

@ -28,10 +28,16 @@
#include <simgear/bucket/newbucket.hxx>
#include <simgear/debug/logstream.hxx>
#ifdef _MSC_VER
# include <win32/mkdir.hpp>
#endif
#include "index.hxx"
#include "names.hxx"
#include "split.hxx"
FG_USING_STD(cout);
static void clip_and_write_poly( string root, long int p_index, AreaType area,
FGBucket b, const FGPolygon& shape ) {
@ -83,8 +89,13 @@ static void clip_and_write_poly( string root, long int p_index, AreaType area,
if ( result.contours() > 0 ) {
long int t_index = b.gen_index();
string path = root + "/" + b.gen_base_path();
#ifdef _MSC_VER
fg_mkdir( path.c_str() );
#else
string command = "mkdir -p " + path;
system( command.c_str() );
#endif
sprintf( tile_name, "%ld", t_index );
string polyfile = path + "/" + tile_name;

View file

@ -31,8 +31,13 @@
#include <DEM/dem.hxx>
#ifdef _MSC_VER
# include <Win32/mkdir.hpp>
#endif
#include "point2d.hxx"
FG_USING_STD(cout);
FG_USING_STD(string);
@ -56,8 +61,13 @@ int main(int argc, char **argv) {
string dem_name = argv[1];
string work_dir = argv[2];
#ifdef _MSC_VER
fg_mkdir( work_dir.c_str() );
#else
string command = "mkdir -p " + work_dir;
system( command.c_str() );
#endif
FGDem dem(dem_name);
dem.parse();

View file

@ -29,6 +29,8 @@
#include <DEM/dem.hxx>
FG_USING_STD(cout);
// static float dem_data[DEM_SIZE_1][DEM_SIZE_1];
// static float output_data[DEM_SIZE_1][DEM_SIZE_1];
@ -38,8 +40,6 @@ int main(int argc, char **argv) {
// DEM data
FGDem dem;
string filename;
double error;
int i, j;
if ( argc != 2 ) {
printf("Usage: %s <file.dem>\n", argv[0]);

View file

@ -22,10 +22,19 @@
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <unistd.h> /* tmp for read() */
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* tmp for read() */
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include "rawdem.h"

View file

@ -26,19 +26,39 @@
# include <config.h>
#endif
#include <math.h> /* rint() */
#include <math.h> /* rint() */
#include <stdio.h>
#include <stdlib.h> /* atoi() atof() */
#include <string.h> /* swab() */
#include <stdlib.h> /* atoi() atof() */
#include <string.h> /* swab() */
#include <sys/types.h> /* open() */
#include <sys/types.h> /* open() */
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h> /* close() */
#ifdef _MSC_VER
# include <io.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* close() */
#endif
#include "rawdem.h"
#if defined( HAVE_UNISTD_H ) && !defined( HAVE_RINT )
double round( double a ) {
long i;
if ( a > 0.0 ) {
i = (long)( a + 0.5 );
} else {
i = (long)( a - 0.5 );
}
return (double)i;
}
#endif
/* Read the DEM header to determine various key parameters for this
* DEM file */
void rawReadDemHdr( fgRAWDEM *raw, char *hdr_file ) {
@ -88,28 +108,28 @@ void rawReadDemHdr( fgRAWDEM *raw, char *hdr_file ) {
#ifdef HAVE_RINT
raw->ulxmap = (int)rint(tmp * 3600.0); /* convert to arcsec */
#else
# error Port me rint()
raw->ulxmap = (int)round(tmp * 3600.0); /* convert to arcsec */
#endif
} else if ( strcmp(key, "ULYMAP") == 0 ) {
tmp = atof(value);
#ifdef HAVE_RINT
raw->ulymap = (int)rint(tmp * 3600.0); /* convert to arcsec */
#else
# error Port me rint()
raw->ulymap = (int)round(tmp * 3600.0); /* convert to arcsec */
#endif
} else if ( strcmp(key, "XDIM") == 0 ) {
tmp = atof(value);
#ifdef HAVE_RINT
raw->xdim = (int)rint(tmp * 3600.0); /* convert to arcsec */
#else
# error Port me rint()
raw->xdim = (int)round(tmp * 3600.0); /* convert to arcsec */
#endif
} else if ( strcmp(key, "YDIM") == 0 ) {
tmp = atof(value);
#ifdef HAVE_RINT
raw->ydim = (int)rint(tmp * 3600.0); /* convert to arcsec */
#else
# error Port me rint()
raw->ydim = (int)round(tmp * 3600.0); /* convert to arcsec */
#endif
} else {
/* ignore for now */
@ -475,5 +495,3 @@ void rawProcessStrip( fgRAWDEM *raw, int lat_degrees, char *path ) {
rawDumpAsciiDEM(raw, path, (raw->rootx / 3600) + i, lat_degrees - 1);
}
}

View file

@ -36,6 +36,9 @@
#include "gshhs_split.hxx"
#include "simple_clip.hxx"
FG_USING_STD(cout);
FG_USING_STD(string);
// process shape front end ... split shape into lon = -180 ... 180,
// -360 ... -180, and 180 ... 360 ... shift the offset sections and

View file

@ -35,6 +35,10 @@
#include <Polygon/polygon.hxx>
#include <Polygon/split.hxx>
#ifdef _MSC_VER
# include <Win32/mkdir.hpp>
#endif
#include "gshhs.h"
#include "gshhs_split.hxx"
@ -63,8 +67,13 @@ int main( int argc, char **argv ) {
// make work directory
string work_dir = argv[2];
#ifdef _MSC_VER
fg_mkdir( work_dir.c_str() );
#else
string command = "mkdir -p " + work_dir;
system( command.c_str() );
#endif
// get the specified data level
int target_level = atoi(argv[3]);

View file

@ -28,8 +28,12 @@
#include "simple_clip.hxx"
FG_USING_STD(cout);
FG_USING_STD(endl);
#define CLIP_EPSILON 0.000000000001
// Given a line segment specified by two endpoints p1 and p2, return
// the x value of a point on the line that intersects with the
// horizontal line through y. Return true if an intersection is found,

View file

@ -35,6 +35,10 @@
#include <Polygon/split.hxx>
#include <shapelib/shapefil.h>
#ifdef _MSC_VER
# include <Win32/mkdir.hpp>
#endif
// return the type of the shapefile record
AreaType get_shapefile_type(DBFHandle& hDBF, int rec) {
@ -155,8 +159,13 @@ int main( int argc, char **argv ) {
// make work directory
string work_dir = argv[2];
#ifdef _MSC_VER
fg_mkdir( work_dir.c_str() );
#else
string command = "mkdir -p " + work_dir;
system( command.c_str() );
#endif
// allow us to override the area type from the command line. All
// polygons in the processed shape file will be assigned this area