diff --git a/src/BuildTiles/Clipper/clipper.cxx b/src/BuildTiles/Clipper/clipper.cxx index e105f2a1..2d13f80a 100644 --- a/src/BuildTiles/Clipper/clipper.cxx +++ b/src/BuildTiles/Clipper/clipper.cxx @@ -44,27 +44,28 @@ SG_USING_STD(cout); // Constructor. -FGClipper::FGClipper() { +TGClipper::TGClipper() { } // Destructor. -FGClipper::~FGClipper() { +TGClipper::~TGClipper() { } // Initialize the clipper (empty all the polygon buckets.) -bool FGClipper::init() { - for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) { +bool TGClipper::init() { + for ( int i = 0; i < TG_MAX_AREA_TYPES; ++i ) { polys_in.polys[i].clear(); } + fixed_elevations.clear(); return true; } // Load a polygon definition file. -bool FGClipper::load_polys(const string& path) { +bool TGClipper::load_polys(const string& path) { bool poly3d = false; string first_line; string poly_name; @@ -127,9 +128,8 @@ bool FGClipper::load_polys(const string& path) { startz = -9999.0; } p = Point3D(startx, starty, startz); - // cout << "load poly's: poly pt = " << p << endl; poly.add_node( i, p ); - SG_LOG( SG_CLIPPER, SG_BULK, "0 = " << p ); + fixed_elevations.unique_add( p ); for ( j = 1; j < count - 1; ++j ) { in >> x; @@ -140,8 +140,8 @@ bool FGClipper::load_polys(const string& path) { z = -9999.0; } p = Point3D( x, y, z ); - // cout << "load poly's: poly pt = " << p << endl; poly.add_node( i, p ); + fixed_elevations.unique_add( p ); } in >> lastx; @@ -158,8 +158,8 @@ bool FGClipper::load_polys(const string& path) { // last point same as first, discard } else { p = Point3D( lastx, lasty, lastz ); - // cout << "load poly's: poly pt = " << p << endl; poly.add_node( i, p ); + fixed_elevations.unique_add( p ); } } @@ -179,7 +179,7 @@ bool FGClipper::load_polys(const string& path) { // Load a polygon definition file containing osgb36 Eastings and Northings // and convert them to WGS84 Latitude and Longitude -bool FGClipper::load_osgb36_polys(const string& path) { +bool TGClipper::load_osgb36_polys(const string& path) { // cout << "Loading osgb36 poly\n"; string poly_name; AreaType poly_type = DefaultArea; @@ -288,7 +288,7 @@ bool FGClipper::load_osgb36_polys(const string& path) { // TEST - Ignore // } else - if ( area < FG_MAX_AREA_TYPES ) { + if ( area < TG_MAX_AREA_TYPES ) { polys_in.polys[area].push_back(poly); } else { SG_LOG( SG_CLIPPER, SG_ALERT, "Polygon type out of range = " @@ -303,9 +303,9 @@ bool FGClipper::load_osgb36_polys(const string& path) { } // Add a polygon to the clipper. -void FGClipper::add_poly( int area, const TGPolygon &poly ) +void TGClipper::add_poly( int area, const TGPolygon &poly ) { - if ( area < FG_MAX_AREA_TYPES ) { + if ( area < TG_MAX_AREA_TYPES ) { polys_in.polys[area].push_back(poly); } else { SG_LOG( SG_CLIPPER, SG_ALERT, "Polygon type out of range = " @@ -316,7 +316,7 @@ void FGClipper::add_poly( int area, const TGPolygon &poly ) // Move slivers from in polygon to out polygon. -void FGClipper::move_slivers( TGPolygon& in, TGPolygon& out ) { +void TGClipper::move_slivers( TGPolygon& in, TGPolygon& out ) { // traverse each contour of the polygon and attempt to identify // likely slivers @@ -377,7 +377,7 @@ void FGClipper::move_slivers( TGPolygon& in, TGPolygon& out ) { // a polygon with no increased contours (i.e. the sliver is adjacent // and can be merged.) If so, replace the clipped polygon with the // new polygon that has the sliver merged in. -void FGClipper::merge_slivers( FGPolyList& clipped, TGPolygon& slivers ) { +void TGClipper::merge_slivers( TGPolyList& clipped, TGPolygon& slivers ) { TGPolygon poly, result, sliver; point_list contour; int original_contours, result_contours; @@ -393,7 +393,7 @@ void FGClipper::merge_slivers( FGPolyList& clipped, TGPolygon& slivers ) { sliver.add_contour( contour, 0 ); done = false; - for ( area = 0; area < FG_MAX_AREA_TYPES && !done; ++area ) { + for ( area = 0; area < TG_MAX_AREA_TYPES && !done; ++area ) { if ( area == HoleArea ) { // don't merge a non-hole sliver in with a hole @@ -468,7 +468,7 @@ is_water_area (AreaType type) // Clip all the polygons against each other in a priority scheme based // on order of the polygon type in the polygon type enum. -bool FGClipper::clip_all(const point2d& min, const point2d& max) { +bool TGClipper::clip_all(const point2d& min, const point2d& max) { TGPolygon accum, tmp; TGPolygon slivers, remains; int i, j; @@ -503,7 +503,7 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) { // set up a mask for all water. TGPolygon water_mask; water_mask.erase(); - for ( i = 0; i < FG_MAX_AREA_TYPES; i++ ) { + for ( i = 0; i < TG_MAX_AREA_TYPES; i++ ) { if (is_water_area(AreaType(i))) { for (unsigned int j = 0; j < polys_in.polys[i].size(); j++) { water_mask = @@ -521,7 +521,7 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) { } // process polygons in priority order - for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + for ( i = 0; i < TG_MAX_AREA_TYPES; ++i ) { cout << "num polys of type (" << i << ") = " << polys_in.polys[i].size() << endl; // current = polys_in.polys[i].begin(); diff --git a/src/BuildTiles/Clipper/clipper.hxx b/src/BuildTiles/Clipper/clipper.hxx index 63ddc804..2989e601 100644 --- a/src/BuildTiles/Clipper/clipper.hxx +++ b/src/BuildTiles/Clipper/clipper.hxx @@ -36,6 +36,7 @@ #include #include +#include #include #include STL_STRING @@ -45,33 +46,34 @@ SG_USING_STD(string); SG_USING_STD(vector); -#define FG_MAX_AREA_TYPES 128 // FIXME also defined in +#define TG_MAX_AREA_TYPES 128 // FIXME also defined in // MergerClipper/clipper.hxx #define EXTRA_SAFETY_CLIP -class FGPolyList +class TGPolyList { public: - poly_list polys[FG_MAX_AREA_TYPES]; + poly_list polys[TG_MAX_AREA_TYPES]; TGPolygon safety_base; }; -class FGClipper +class TGClipper { private: - FGPolyList polys_in, polys_clipped; + TGPolyList polys_in, polys_clipped; + TGTriNodes fixed_elevations; public: // Constructor. - FGClipper (void); + TGClipper (void); // Destructor. - ~FGClipper (void); + ~TGClipper (void); // Initialize Clipper (allocate and/or connect structures.) bool init(); @@ -93,13 +95,16 @@ public: // yields a polygon with no increased contours (i.e. the sliver is // adjacent and can be merged.) If so, replace the clipped // polygon with the new polygon that has the sliver merged in. - void merge_slivers( FGPolyList& clipped, TGPolygon& slivers ); + void merge_slivers( TGPolyList& clipped, TGPolygon& slivers ); // Do actual clipping work. bool clip_all(const point2d& min, const point2d& max); // Return output poly list - inline FGPolyList get_polys_clipped() const { return polys_clipped; } + inline TGPolyList get_polys_clipped() const { return polys_clipped; } + + // Return the fixed elevation points list + inline TGTriNodes get_fixed_elevations() const { return fixed_elevations; } }; diff --git a/src/BuildTiles/Clipper/testclipper.cxx b/src/BuildTiles/Clipper/testclipper.cxx index 41790033..f736384d 100644 --- a/src/BuildTiles/Clipper/testclipper.cxx +++ b/src/BuildTiles/Clipper/testclipper.cxx @@ -39,7 +39,7 @@ int main( int argc, char **argv ) { global_min.x = global_min.y = 200; global_max.y = global_max.x = -200; - FGClipper clipper; + TGClipper clipper; clipper.init(); if ( argc < 2 ) { diff --git a/src/BuildTiles/GenOutput/genobj.cxx b/src/BuildTiles/GenOutput/genobj.cxx index 3d2288f6..faba0f59 100644 --- a/src/BuildTiles/GenOutput/genobj.cxx +++ b/src/BuildTiles/GenOutput/genobj.cxx @@ -46,7 +46,7 @@ SG_USING_STD(endl); // calculate the global bounding sphere. Center is the center of the // tile and zero elevation -void FGGenOutput::calc_gbs( FGConstruct& c ) { +void TGGenOutput::calc_gbs( TGConstruct& c ) { double dist_squared; double radius_squared = 0; @@ -77,7 +77,7 @@ void FGGenOutput::calc_gbs( FGConstruct& c ) { // traverse the specified fan and attempt to calculate "none // stretching" texture coordinates -int_list FGGenOutput::calc_tex_coords( FGConstruct& c, point_list geod_nodes, +int_list TGGenOutput::calc_tex_coords( TGConstruct& c, point_list geod_nodes, int_list fan ) { // cout << "calculating texture coordinates for a specific fan of size = " @@ -162,7 +162,7 @@ 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 TGGenOutput::build( TGConstruct& c ) { int i, j; TGTriNodes trinodes = c.get_tri_nodes(); @@ -176,7 +176,7 @@ int FGGenOutput::build( FGConstruct& c ) { // build the trifan list cout << "total triangles = " << tri_elements.size() << endl; TGGenFans f; - for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + for ( i = 0; i < TG_MAX_AREA_TYPES; ++i ) { triele_list area_tris; area_tris.erase( area_tris.begin(), area_tris.end() ); @@ -199,7 +199,7 @@ int FGGenOutput::build( FGConstruct& c ) { cout << "calculating texture coordinates" << endl; tex_coords.clear(); - for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + for ( i = 0; i < TG_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() << " === " @@ -238,7 +238,7 @@ int FGGenOutput::build( FGConstruct& c ) { // caclulate the bounding sphere for a list of triangle faces -void FGGenOutput::calc_group_bounding_sphere( FGConstruct& c, +void TGGenOutput::calc_group_bounding_sphere( TGConstruct& c, const opt_list& fans, Point3D *center, double *radius ) { @@ -290,7 +290,7 @@ void FGGenOutput::calc_group_bounding_sphere( FGConstruct& c, // caclulate the bounding sphere for the specified triangle face -void FGGenOutput::calc_bounding_sphere( FGConstruct& c, const FGTriEle& t, +void TGGenOutput::calc_bounding_sphere( TGConstruct& c, const TGTriEle& t, Point3D *center, double *radius ) { point_list wgs84_nodes = c.get_wgs84_nodes(); @@ -328,7 +328,7 @@ void FGGenOutput::calc_bounding_sphere( FGConstruct& c, const FGTriEle& t, #if 0 // write out the fgfs scenery file -int FGGenOutput::write_orig( FGConstruct &c ) { +int TGGenOutput::write_orig( TGConstruct &c ) { Point3D p; int i; @@ -410,7 +410,7 @@ int FGGenOutput::write_orig( FGConstruct &c ) { fprintf(fp, "\n"); int total_tris = 0; - for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + for ( i = 0; i < TG_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], ¢er, &radius ); @@ -446,7 +446,7 @@ int FGGenOutput::write_orig( FGConstruct &c ) { // write out the fgfs scenery file -int FGGenOutput::write( FGConstruct &c ) { +int TGGenOutput::write( TGConstruct &c ) { int i; // Assemble all the data into the final format @@ -475,7 +475,7 @@ int FGGenOutput::write( FGConstruct &c ) { group_list fans_v; group_list fans_tc; string_list fan_materials; fans_v.clear(); fans_tc.clear(); fan_materials.clear(); - for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + for ( i = 0; i < TG_MAX_AREA_TYPES; ++i ) { if ( (int)fans[i].size() > 0 ) { cout << "creating " << fans[i].size() << " fans of type " << i << endl; diff --git a/src/BuildTiles/GenOutput/genobj.hxx b/src/BuildTiles/GenOutput/genobj.hxx index 1a29a92e..ed7d487e 100644 --- a/src/BuildTiles/GenOutput/genobj.hxx +++ b/src/BuildTiles/GenOutput/genobj.hxx @@ -52,7 +52,7 @@ typedef vector < int_list > tex_list; typedef tex_list::iterator tex_list_iterator; typedef tex_list::const_iterator const_tex_list_iterator; -class FGGenOutput { +class TGGenOutput { private: @@ -66,10 +66,10 @@ private: TGTriNodes tex_coords; // fan list - opt_list fans[FG_MAX_AREA_TYPES]; + opt_list fans[TG_MAX_AREA_TYPES]; // textures pointer list - tex_list textures[FG_MAX_AREA_TYPES]; + tex_list textures[TG_MAX_AREA_TYPES]; // global bounding sphere Point3D gbs_center; @@ -77,32 +77,32 @@ private: // calculate the global bounding sphere. Center is the average of // the points. - void calc_gbs( FGConstruct& c ); + void calc_gbs( TGConstruct& c ); // caclulate the bounding sphere for a list of triangle faces - void calc_group_bounding_sphere( FGConstruct& c, const opt_list& fans, + void calc_group_bounding_sphere( TGConstruct& c, const opt_list& fans, Point3D *center, double *radius ); // caclulate the bounding sphere for the specified triangle face - void calc_bounding_sphere( FGConstruct& c, const FGTriEle& t, + void calc_bounding_sphere( TGConstruct& c, const TGTriEle& t, Point3D *center, double *radius ); // traverse the specified fan and attempt to calculate "none // stretching" texture coordinates - // int_list calc_tex_coords( FGConstruct& c, point_list geod_nodes, int_list fan ); + // int_list calc_tex_coords( TGConstruct& c, point_list geod_nodes, int_list fan ); public: // Constructor && Destructor - inline FGGenOutput() { } - inline ~FGGenOutput() { } + inline TGGenOutput() { } + inline ~TGGenOutput() { } // build the necessary output structures based on the // triangulation data - int build( FGConstruct& c ); + int build( TGConstruct& c ); // write out the fgfs scenery file - int write( FGConstruct &c ); + int write( TGConstruct &c ); }; diff --git a/src/BuildTiles/Main/construct.cxx b/src/BuildTiles/Main/construct.cxx index 04ced791..b43843e9 100644 --- a/src/BuildTiles/Main/construct.cxx +++ b/src/BuildTiles/Main/construct.cxx @@ -26,8 +26,8 @@ // Constructor -FGConstruct::FGConstruct() { } +TGConstruct::TGConstruct() { } // Destructor -FGConstruct::~FGConstruct() { } +TGConstruct::~TGConstruct() { } diff --git a/src/BuildTiles/Main/construct.hxx b/src/BuildTiles/Main/construct.hxx index 194081c0..61c6cb5c 100644 --- a/src/BuildTiles/Main/construct.hxx +++ b/src/BuildTiles/Main/construct.hxx @@ -32,7 +32,7 @@ // Maximum nodes per tile -#define FG_MAX_NODES 4000 +#define TG_MAX_NODES 4000 #include @@ -55,7 +55,7 @@ typedef belongs_to_list::iterator belongs_to_list_iterator; typedef belongs_to_list::const_iterator belongs_to_list_tripoly_iterator; -class FGConstruct { +class TGConstruct { private: @@ -81,7 +81,7 @@ private: SGBucket bucket; // clipped polygons (gpc format) - FGPolyList clipped_polys; + TGPolyList clipped_polys; // raw node list (after triangulation) TGTriNodes tri_nodes; @@ -111,10 +111,10 @@ private: public: // Constructor - FGConstruct(); + TGConstruct(); // Destructor - ~FGConstruct(); + ~TGConstruct(); // minimum interior angle for triangulation inline string get_angle() const { return angle; } @@ -145,8 +145,8 @@ public: inline void set_bucket( const SGBucket b ) { bucket = b; } // clipped polygons - inline FGPolyList get_clipped_polys() const { return clipped_polys; } - inline void set_clipped_polys( FGPolyList p ) { clipped_polys = p; } + inline TGPolyList get_clipped_polys() const { return clipped_polys; } + inline void set_clipped_polys( TGPolyList p ) { clipped_polys = p; } // node list (after triangulation) inline TGTriNodes get_tri_nodes() const { return tri_nodes; } diff --git a/src/BuildTiles/Main/main.cxx b/src/BuildTiles/Main/main.cxx index a9273bc1..77054b7e 100644 --- a/src/BuildTiles/Main/main.cxx +++ b/src/BuildTiles/Main/main.cxx @@ -133,8 +133,8 @@ static AreaType translateUSGSCover (int usgs_value) // Scan a directory and load polygon files. static int actual_load_polys( const string& dir, - FGConstruct& c, - FGClipper& clipper ) { + TGConstruct& c, + TGClipper& clipper ) { int counter = 0; string base = c.get_bucket().gen_base_path(); string tile_str = c.get_bucket().gen_index_str(); @@ -288,15 +288,15 @@ static void make_area( const LandCover &cover, TGPolygon *polys, // Generate polygons from la and-cover raster. Horizontally- or // vertically-adjacent polygons will be merged automatically. -static int actual_load_landcover ( FGConstruct & c, - FGClipper &clipper ) { +static int actual_load_landcover ( TGConstruct & c, + TGClipper &clipper ) { int count = 0; try { LandCover cover(c.get_cover()); - TGPolygon polys[FG_MAX_AREA_TYPES]; + TGPolygon polys[TG_MAX_AREA_TYPES]; TGPolygon poly; // working polygon double dx = 1.0 / 120.0; @@ -350,7 +350,7 @@ static int actual_load_landcover ( FGConstruct & c, // Now that we're finished looking up land cover, we have a list // of lists of polygons, one (possibly-empty) list for each area // type. Add the remaining polygons to the clipper. - for ( int i = 0; i < FG_MAX_AREA_TYPES; i++ ) { + for ( int i = 0; i < TG_MAX_AREA_TYPES; i++ ) { if ( polys[i].contours() ) { clipper.add_poly( i, polys[i] ); count++; @@ -368,8 +368,8 @@ static int actual_load_landcover ( FGConstruct & c, // load all 2d polygons from the specified load disk directories and // clip against each other to resolve any overlaps -static int load_polys( FGConstruct& c ) { - FGClipper clipper; +static int load_polys( TGConstruct& c ) { + TGClipper clipper; int i; string base = c.get_bucket().gen_base_path(); @@ -411,7 +411,7 @@ static int load_polys( FGConstruct& c ) { // Load elevation data from an Array file, a regular grid of elevation // data) and return list of fitted nodes. -static bool load_array( FGConstruct& c, TGArray& array) { +static bool load_array( TGConstruct& c, TGArray& array) { point_list result; string base = c.get_bucket().gen_base_path(); int i; @@ -436,21 +436,15 @@ static bool load_array( FGConstruct& c, TGArray& array) { } -// fit array nodes, return number of fitted nodes -static int fit_array(TGArray& array, int error) { - return array.fit( error ); -} - - // triangulate the data for each polygon ( first time before splitting ) -static void first_triangulate( FGConstruct& c, const TGArray& array, - FGTriangle& t ) { +static void first_triangulate( TGConstruct& c, const TGArray& array, + TGTriangle& t ) { // first we need to consolidate the points of the Array fit list and // all the polygons into a more "Triangle" friendly format point_list corner_list = array.get_corner_node_list(); point_list fit_list = array.get_fit_node_list(); - FGPolyList gpc_polys = c.get_clipped_polys(); + TGPolyList gpc_polys = c.get_clipped_polys(); cout << "ready to build node list and polygons" << endl; t.build( corner_list, fit_list, gpc_polys ); @@ -464,7 +458,7 @@ static void first_triangulate( FGConstruct& c, const TGArray& array, // triangulate the data for each polygon ( second time after splitting // and reassembling ) -static void second_triangulate( FGConstruct& c, FGTriangle& t ) { +static void second_triangulate( TGConstruct& c, TGTriangle& t ) { t.rebuild( c ); cout << "done re building node list and polygons" << endl; @@ -490,7 +484,8 @@ static double distance2D( const Point3D p1, const Point3D p2 ) { // fix the elevations of the geodetic nodes -static void fix_point_heights( FGConstruct& c, const TGArray& array ) { +static void fix_point_heights( TGConstruct& c, const TGArray& array ) +{ int i; double z; @@ -509,7 +504,7 @@ static void fix_point_heights( FGConstruct& c, const TGArray& array ) { cout << "flattening ocean connected nodes" << endl; triele_list tris = c.get_tri_elements(); - FGTriEle t; + TGTriEle t; Point3D p; AreaType a; int n1, n2, n3; @@ -591,7 +586,7 @@ static void fix_point_heights( FGConstruct& c, const TGArray& array ) { // build the wgs-84 point list -static void build_wgs_84_point_list( FGConstruct& c, const TGArray& array ) { +static void build_wgs_84_point_list( TGConstruct& c, const TGArray& array ) { point_list geod_nodes; point_list wgs84_nodes; int i; @@ -624,7 +619,7 @@ static void build_wgs_84_point_list( FGConstruct& c, const TGArray& array ) { // build the node -> element (triangle) reverse lookup table. there // is an entry for each point containing a list of all the triangles // that share that point. -static belongs_to_list gen_node_ele_lookup_table( FGConstruct& c ) { +static belongs_to_list gen_node_ele_lookup_table( TGConstruct& c ) { belongs_to_list reverse_ele_lookup; reverse_ele_lookup.clear(); @@ -657,7 +652,7 @@ static belongs_to_list gen_node_ele_lookup_table( FGConstruct& c ) { // caclulate the area for the specified triangle face -static double tri_ele_area( const FGConstruct& c, const FGTriEle tri ) { +static double tri_ele_area( const TGConstruct& c, const TGTriEle tri ) { point_list nodes = c.get_geod_nodes(); Point3D p1 = nodes[ tri.get_n1() ]; @@ -669,7 +664,7 @@ static double tri_ele_area( const FGConstruct& c, const FGTriEle tri ) { // caclulate the normal for the specified triangle face -static Point3D calc_normal( FGConstruct& c, int i ) { +static Point3D calc_normal( TGConstruct& c, int i ) { sgVec3 v1, v2, normal; point_list wgs84_nodes = c.get_wgs84_nodes(); @@ -731,7 +726,7 @@ static Point3D calc_normal( FGConstruct& c, int i ) { // build the face normal list -static point_list gen_face_normals( FGConstruct& c ) { +static point_list gen_face_normals( TGConstruct& c ) { point_list face_normals; // traverse triangle structure building the face normal table @@ -750,7 +745,7 @@ static point_list gen_face_normals( FGConstruct& c ) { // calculate the normals for each point in wgs84_nodes -static point_list gen_point_normals( FGConstruct& c ) { +static point_list gen_point_normals( TGConstruct& c ) { point_list point_normals; Point3D normal; @@ -793,14 +788,14 @@ static point_list gen_point_normals( FGConstruct& c ) { // generate the flight gear scenery file -static void do_output( FGConstruct& c, FGGenOutput& output ) { +static void do_output( TGConstruct& c, TGGenOutput& output ) { output.build( c ); output.write( c ); } // collect custom objects and move to scenery area -static void do_custom_objects( const FGConstruct& c ) { +static void do_custom_objects( const TGConstruct& c ) { SGBucket b = c.get_bucket(); // Create/open the output .stg file for writing @@ -854,7 +849,7 @@ static void do_custom_objects( const FGConstruct& c ) { } // master construction routine -static void construct_tile( FGConstruct& c ) { +static void construct_tile( TGConstruct& c ) { cout << "Construct tile, bucket = " << c.get_bucket() << endl; // fit with ever increasing error tolerance until we produce <= @@ -879,7 +874,7 @@ static void construct_tile( FGConstruct& c ) { TGArray array; load_array( c, array ); - FGTriangle t; + TGTriangle t; while ( ! acceptable ) { // do a least squares fit of the (array) data with the given @@ -965,7 +960,7 @@ static void construct_tile( FGConstruct& c ) { // match tile edges with any neighbor tiles that have already been // generated - FGMatch m; + TGMatch m; m.load_neighbor_shared( c ); m.split_tile( c ); m.write_shared( c ); @@ -999,7 +994,7 @@ static void construct_tile( FGConstruct& c ) { build_wgs_84_point_list( c, array ); // generate the output - FGGenOutput output; + TGGenOutput output; do_output( c, output ); array.close(); @@ -1124,7 +1119,7 @@ int main(int argc, char **argv) { #endif // end of stuff that crashes Cygwin // main construction data management class - FGConstruct c; + TGConstruct c; c.set_angle( min_angle ); c.set_cover( cover ); @@ -1133,7 +1128,7 @@ int main(int argc, char **argv) { c.set_useUKGrid( useUKgrid ); c.set_min_nodes( 50 ); - c.set_max_nodes( (int)(FG_MAX_NODES * 0.8) ); + c.set_max_nodes( (int)(TG_MAX_NODES * 0.8) ); if (tile_id == -1) { if (xdist == -1 || ydist == -1) { diff --git a/src/BuildTiles/Match/match.cxx b/src/BuildTiles/Match/match.cxx index d5a623e4..76d6dee0 100644 --- a/src/BuildTiles/Match/match.cxx +++ b/src/BuildTiles/Match/match.cxx @@ -40,16 +40,16 @@ SG_USING_STD(cout); SG_USING_STD(endl); -FGMatch::FGMatch( void ) { +TGMatch::TGMatch( void ) { } -FGMatch::~FGMatch( void ) { +TGMatch::~TGMatch( void ) { } // scan the specified share file for the specified information -void FGMatch::scan_share_file( const string& dir, const SGBucket& b, +void TGMatch::scan_share_file( const string& dir, const SGBucket& b, neighbor_type search, neighbor_type dest ) { string file = dir + "/" + b.gen_base_path() + "/" + b.gen_index_str(); @@ -140,7 +140,7 @@ void FGMatch::scan_share_file( const string& dir, const SGBucket& b, // try to find info for the specified shared component -void FGMatch::load_shared( const FGConstruct& c, neighbor_type n ) { +void TGMatch::load_shared( const TGConstruct& c, neighbor_type n ) { SGBucket b = c.get_bucket(); double clon = b.get_center_lon(); @@ -204,7 +204,7 @@ void FGMatch::load_shared( const FGConstruct& c, neighbor_type n ) { // load any previously existing shared data from all neighbors (if // shared data for a component exists set that components flag to true -void FGMatch::load_neighbor_shared( FGConstruct& c ) { +void TGMatch::load_neighbor_shared( TGConstruct& c ) { cout << "Loading existing shared data from neighbor tiles" << endl; // start with all flags false @@ -289,7 +289,7 @@ Point3D tgFakeNormal( const Point3D& p ) { // segments and the body. This must be done after calling // 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 ) { +void TGMatch::split_tile( TGConstruct& c ) { int i; cout << "Spliting tile" << endl; @@ -456,7 +456,7 @@ void FGMatch::split_tile( FGConstruct& c ) { // write the new shared edge points, normals, and segments for this // tile -void FGMatch::write_shared( FGConstruct& c ) { +void TGMatch::write_shared( TGConstruct& c ) { string base = c.get_work_base(); SGBucket b = c.get_bucket(); @@ -635,7 +635,7 @@ void insert_normal( point_list& normals, Point3D n, int i ) { // reassemble the tile pieces (combining the shared data and our own // data) -void FGMatch::assemble_tile( FGConstruct& c ) { +void TGMatch::assemble_tile( TGConstruct& c ) { int i; TGTriNodes new_nodes; new_nodes.clear(); diff --git a/src/BuildTiles/Match/match.hxx b/src/BuildTiles/Match/match.hxx index 8cc5aa5f..700f6333 100644 --- a/src/BuildTiles/Match/match.hxx +++ b/src/BuildTiles/Match/match.hxx @@ -37,7 +37,7 @@ #include
-class FGMatch { +class TGMatch { private: @@ -73,36 +73,36 @@ public: }; // Constructor - FGMatch( void ); + TGMatch( void ); // Destructor - ~FGMatch( void ); + ~TGMatch( void ); // load any previously existing shared data from all neighbors (if // shared data for a component exists set that components flag to // true - void load_neighbor_shared( FGConstruct& c ); + void load_neighbor_shared( TGConstruct& c ); // scan the specified share file for the specified information void scan_share_file( const string& dir, const SGBucket& b, neighbor_type search, neighbor_type dest ); // try to find info for the specified shared component - void load_shared( const FGConstruct& c, neighbor_type n ); + void load_shared( const TGConstruct& c, neighbor_type n ); // split up the tile between the shared edge points, normals, and // segments and the body. This must be done after calling // load_neighbor_data() and will ignore any shared data from the // current tile that already exists from a neighbor. - void split_tile( FGConstruct& c ); + void split_tile( TGConstruct& c ); // write the new shared edge points, normals, and segments for // this tile - void write_shared( FGConstruct& c ); + void write_shared( TGConstruct& c ); // reassemble the tile pieces (combining the shared data and our // own data) - void assemble_tile( FGConstruct& c ); + void assemble_tile( TGConstruct& c ); }; diff --git a/src/BuildTiles/Triangulate/triangle.cxx b/src/BuildTiles/Triangulate/triangle.cxx index 245a0f21..1b42a01e 100644 --- a/src/BuildTiles/Triangulate/triangle.cxx +++ b/src/BuildTiles/Triangulate/triangle.cxx @@ -33,20 +33,20 @@ SG_USING_STD(endl); // Constructor -FGTriangle::FGTriangle( void ) { +TGTriangle::TGTriangle( void ) { } // Destructor -FGTriangle::~FGTriangle( void ) { +TGTriangle::~TGTriangle( void ) { } // populate this class based on the specified gpc_polys list int -FGTriangle::build( const point_list& corner_list, +TGTriangle::build( const point_list& corner_list, const point_list& fit_list, - const FGPolyList& gpc_polys ) + const TGPolyList& gpc_polys ) { int debug_counter = 0; int index; @@ -78,7 +78,7 @@ FGTriangle::build( const point_list& corner_list, // process polygons in priority order cout << "prepairing node list and polygons" << endl; - for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + for ( i = 0; i < TG_MAX_AREA_TYPES; ++i ) { polylist[i].clear(); cout << "area type = " << i << " polys = " << gpc_polys.polys[i].size() @@ -198,7 +198,7 @@ FGTriangle::build( const point_list& corner_list, index = in_nodes.course_add( fit_list[i] ); } - for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + for ( i = 0; i < TG_MAX_AREA_TYPES; ++i ) { if ( polylist[i].size() ) { cout << get_area_name((AreaType)i) << " = " << polylist[i].size() << endl; @@ -214,7 +214,7 @@ FGTriangle::build( const point_list& corner_list, point_list node_list = in_nodes.get_node_list(); TGPolygon poly; - for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + for ( i = 0; i < TG_MAX_AREA_TYPES; ++i ) { cout << "area type = " << i << endl; poly_list_iterator tp_current, tp_last; tp_current = polylist[i].begin(); @@ -265,7 +265,7 @@ FGTriangle::build( const point_list& corner_list, // populate this class based on the specified gpc_polys list -int FGTriangle::rebuild( FGConstruct& c ) { +int TGTriangle::rebuild( TGConstruct& c ) { in_nodes.clear(); in_segs.clear(); @@ -338,7 +338,7 @@ static void write_out_data(struct triangulateio *out) { // generates extra nodes for a better triangulation. 2 = second pass // after split/reassem where we don't want any extra nodes generated. -int FGTriangle::run_triangulate( const string& angle, const int pass ) { +int TGTriangle::run_triangulate( const string& angle, const int pass ) { TGPolygon poly; Point3D p; struct triangulateio in, out, vorout; @@ -420,7 +420,7 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) { // region list in.numberofregions = 0; - for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + for ( i = 0; i < TG_MAX_AREA_TYPES; ++i ) { poly_list_iterator h_current, h_last; h_current = polylist[i].begin(); h_last = polylist[i].end(); @@ -436,7 +436,7 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) { in.regionlist = (REAL *) malloc(in.numberofregions * 4 * sizeof(REAL)); counter = 0; - for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + for ( i = 0; i < TG_MAX_AREA_TYPES; ++i ) { poly_list_iterator h_current, h_last; h_current = polylist[(int)i].begin(); h_last = polylist[(int)i].end(); @@ -504,7 +504,7 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) { tri_options = "pczYYAen"; } else { cout << "unknown pass number = " << pass - << " in FGTriangle::run_triangulate()" << endl; + << " in TGTriangle::run_triangulate()" << endl; exit(-1); } cout << "Triangulation with options = " << tri_options << endl; @@ -514,7 +514,7 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) { // TEMPORARY // write_tri_data(&out); - // now copy the results back into the corresponding FGTriangle + // now copy the results back into the corresponding TGTriangle // structures // nodes @@ -548,7 +548,7 @@ int FGTriangle::run_triangulate( const string& angle, const int pass ) { } // cout << "triangle = " << n1 << " " << n2 << " " << n3 << endl; - elelist.push_back( FGTriEle( n1, n2, n3, attribute ) ); + elelist.push_back( TGTriEle( n1, n2, n3, attribute ) ); } // free mem allocated to the "Triangle" structures diff --git a/src/BuildTiles/Triangulate/triangle.hxx b/src/BuildTiles/Triangulate/triangle.hxx index 398ff625..88ccdb47 100644 --- a/src/BuildTiles/Triangulate/triangle.hxx +++ b/src/BuildTiles/Triangulate/triangle.hxx @@ -34,7 +34,6 @@ #include #include -#include #include
#include @@ -50,7 +49,7 @@ extern "C" { #include "trieles.hxx" -class FGTriangle { +class TGTriangle { private: @@ -63,7 +62,7 @@ private: TGTriSegments out_segs; // polygon list - poly_list polylist[FG_MAX_AREA_TYPES]; + poly_list polylist[TG_MAX_AREA_TYPES]; // triangle list triele_list elelist; @@ -71,8 +70,8 @@ private: public: // Constructor and destructor - FGTriangle( void ); - ~FGTriangle( void ); + TGTriangle( void ); + ~TGTriangle( void ); // add nodes from the dem fit int add_nodes(); @@ -80,10 +79,10 @@ public: // populate this class based on the specified gpc_polys list int build( const point_list& corner_list, const point_list& fit_list, - const FGPolyList& gpc_polys ); + const TGPolyList& gpc_polys ); // populate this class based on the specified gpc_polys list - int rebuild( FGConstruct& c ); + int rebuild( TGConstruct& c ); // Front end triangulator for polygon list. Allocates and builds // up all the needed structures for the triangulator, runs it, diff --git a/src/BuildTiles/Triangulate/trieles.hxx b/src/BuildTiles/Triangulate/trieles.hxx index 7ac2d6f3..602bcc02 100644 --- a/src/BuildTiles/Triangulate/trieles.hxx +++ b/src/BuildTiles/Triangulate/trieles.hxx @@ -38,7 +38,7 @@ SG_USING_STD(vector); // a segment is two integer pointers into the node list -class FGTriEle { +class TGTriEle { int n1, n2, n3; double attribute; @@ -46,12 +46,12 @@ class FGTriEle { public: // Constructor and destructor - inline FGTriEle( void ) { }; - inline FGTriEle( int i1, int i2, int i3, double a ) { + inline TGTriEle( void ) { }; + inline TGTriEle( int i1, int i2, int i3, double a ) { n1 = i1; n2 = i2; n3 = i3; attribute = a; } - inline ~FGTriEle( void ) { }; + inline ~TGTriEle( void ) { }; inline int get_n1() const { return n1; } inline void set_n1( int i ) { n1 = i; } @@ -65,7 +65,7 @@ public: }; -typedef vector < FGTriEle > triele_list; +typedef vector < TGTriEle > triele_list; typedef triele_list::iterator triele_list_iterator; typedef triele_list::const_iterator const_triele_list_iterator; diff --git a/src/Lib/Geometry/poly_support.cxx b/src/Lib/Geometry/poly_support.cxx index 9f62955b..f5e42960 100644 --- a/src/Lib/Geometry/poly_support.cxx +++ b/src/Lib/Geometry/poly_support.cxx @@ -382,7 +382,7 @@ void polygon_tesselate( const TGPolygon &p, // TEMPORARY // write_tri_data(&out); - // now copy the results back into the corresponding FGTriangle + // now copy the results back into the corresponding TGTriangle // structures // triangles @@ -400,7 +400,7 @@ void polygon_tesselate( const TGPolygon &p, } // cout << "triangle = " << n1 << " " << n2 << " " << n3 << endl; - elelist.push_back( FGTriEle( n1, n2, n3, attribute ) ); + elelist.push_back( TGTriEle( n1, n2, n3, attribute ) ); } // output points @@ -468,7 +468,7 @@ TGPolygon polygon_tesselate_alt( TGPolygon &p ) { // 3. Convert the tesselated output to a list of tringles. // basically a polygon with a contour for every triangle for ( i = 0; i < (int)trieles.size(); ++i ) { - FGTriEle t = trieles[i]; + TGTriEle t = trieles[i]; Point3D p1 = nodes[ t.get_n1() ]; Point3D p2 = nodes[ t.get_n2() ]; Point3D p3 = nodes[ t.get_n3() ]; @@ -515,7 +515,7 @@ static void contour_tesselate( TGContourNode *node, const TGPolygon &p, out_pts.push_back( Point3D(0, 0, 0) ); out_pts.push_back( Point3D(0, 1, 0) ); out_pts.push_back( Point3D(1, 1, 0) ); - elelist.push_back( FGTriEle( 0, 1, 2, 0.0 ) ); + elelist.push_back( TGTriEle( 0, 1, 2, 0.0 ) ); return; } #endif @@ -661,7 +661,7 @@ static void contour_tesselate( TGContourNode *node, const TGPolygon &p, // TEMPORARY // write_tri_data(&out); - // now copy the results back into the corresponding FGTriangle + // now copy the results back into the corresponding TGTriangle // structures // triangles @@ -679,7 +679,7 @@ static void contour_tesselate( TGContourNode *node, const TGPolygon &p, } // cout << "triangle = " << n1 << " " << n2 << " " << n3 << endl; - elelist.push_back( FGTriEle( n1, n2, n3, attribute ) ); + elelist.push_back( TGTriEle( n1, n2, n3, attribute ) ); } // output points @@ -728,7 +728,7 @@ static Point3D point_inside_hole( point_list contour ) { exit(-1); } - FGTriEle t = elelist[0]; + TGTriEle t = elelist[0]; Point3D p1 = contour[ t.get_n1() ]; Point3D p2 = contour[ t.get_n2() ]; Point3D p3 = contour[ t.get_n3() ]; @@ -778,7 +778,7 @@ static Point3D point_inside_contour( TGContourNode *node, const TGPolygon &p ) { double max_area = 0.0; int biggest = 0; for ( i = 0; i < (int)elelist.size(); ++i ) { - FGTriEle t = elelist[i]; + TGTriEle t = elelist[i]; Point3D p1 = out_pts[ t.get_n1() ]; Point3D p2 = out_pts[ t.get_n2() ]; Point3D p3 = out_pts[ t.get_n3() ]; @@ -791,7 +791,7 @@ static Point3D point_inside_contour( TGContourNode *node, const TGPolygon &p ) { // find center point of largest triangle cout << "biggest = " << biggest + 1 << " out of " << elelist.size() << endl; - FGTriEle t = elelist[biggest]; + TGTriEle t = elelist[biggest]; contour_num = node->get_contour_num(); Point3D p1 = out_pts[ t.get_n1() ]; Point3D p2 = out_pts[ t.get_n2() ]; diff --git a/src/Lib/Geometry/trinodes.cxx b/src/Lib/Geometry/trinodes.cxx index b5a7b1af..0d0ea450 100644 --- a/src/Lib/Geometry/trinodes.cxx +++ b/src/Lib/Geometry/trinodes.cxx @@ -40,7 +40,7 @@ int TGTriNodes::unique_add( const Point3D& p ) { point_list_iterator current, last; int counter = 0; - // cout << p.x() << "," << p.y() << endl; + cout << "unique add = " << p << endl; // see if point already exists current = node_list.begin(); @@ -48,6 +48,12 @@ int TGTriNodes::unique_add( const Point3D& p ) { for ( ; current != last; ++current ) { if ( close_enough_2d(p, *current) ) { // cout << "found an existing match!" << endl; + + // update elevation if new point has better info + if ( p.z() > current->z() ) { + current->setz( p.z() ); + } + return counter; } @@ -112,6 +118,12 @@ int TGTriNodes::course_add( const Point3D& p ) { for ( ; current != last; ++current ) { if ( course_close_enough(p, *current) ) { // cout << "found an existing match!" << endl; + + // update elevation if new point has better info + if ( p.z() > current->z() ) { + current->setz( p.z() ); + } + return counter; } diff --git a/src/Lib/Optimize/genfans.cxx b/src/Lib/Optimize/genfans.cxx index 51eb7fc3..39892e31 100644 --- a/src/Lib/Optimize/genfans.cxx +++ b/src/Lib/Optimize/genfans.cxx @@ -54,14 +54,14 @@ static void add_and_expand( opt_list& by_node, int n, int i ) { // given an input triangle, shuffle nodes so that "center" is the // first node, but maintain winding order. -static FGTriEle canonify( const FGTriEle& t, int center ) { +static TGTriEle canonify( const TGTriEle& t, int center ) { if ( t.get_n1() == center ) { // already ok return t; } else if ( t.get_n2() == center ) { - return FGTriEle( t.get_n2(), t.get_n3(), t.get_n1(), 0.0 ); + return TGTriEle( t.get_n2(), t.get_n3(), t.get_n1(), 0.0 ); } else if ( t.get_n3() == center ) { - return FGTriEle( t.get_n3(), t.get_n1(), t.get_n2(), 0.0 ); + return TGTriEle( t.get_n3(), t.get_n1(), t.get_n2(), 0.0 ); } else { cout << "ERROR, index doesn't refer to this triangle!!!" << endl; exit(-1); @@ -86,8 +86,8 @@ static int_list make_best_fan( const triele_list& master_tris, int_list tmp_result; tmp_result.clear(); - FGTriEle current_tri; - FGTriEle test; + TGTriEle current_tri; + TGTriEle test; current_tri = canonify( master_tris[local_tris[start]], center ); tmp_result.push_back( local_tris[start] ); @@ -200,7 +200,7 @@ opt_list TGGenFans::greedy_build( triele_list tris ) { int_list_iterator i_current = i_start; int_list_iterator i_last = best_fan.end(); for ( ; i_current != i_last; ++i_current ) { - FGTriEle t = canonify( tris[*i_current], index ); + TGTriEle t = canonify( tris[*i_current], index ); if ( i_start == i_current ) { node_list.push_back( t.get_n1() ); node_list.push_back( t.get_n2() );