From 4ef15f03daef3ed99b67a4b9c249ea206a21d5e1 Mon Sep 17 00:00:00 2001 From: Ralf Gerlich Date: Fri, 5 Jun 2009 21:49:59 +0200 Subject: [PATCH] Added flag to fg-construct to use the shared data of the constructed tile in addition to its neighbours'. Useful for rebuilding part of the scenery to fit the neighbours. --- src/BuildTiles/Main/construct.hxx | 8 ++++++ src/BuildTiles/Main/main.cxx | 11 ++++++++ src/BuildTiles/Match/match.cxx | 42 +++++++++++++++++++++++++++++++ src/BuildTiles/Match/match.hxx | 3 +++ 4 files changed, 64 insertions(+) diff --git a/src/BuildTiles/Main/construct.hxx b/src/BuildTiles/Main/construct.hxx index 2c9ce99b..1565cd62 100644 --- a/src/BuildTiles/Main/construct.hxx +++ b/src/BuildTiles/Main/construct.hxx @@ -72,6 +72,10 @@ private: // flag indicating whether this is a rebuild and Shared edge // data should only be used for fitting, but not rewritten bool writeSharedEdges; + + // flag indicating whether the shared edge data of the + // tile to be built should be used in addition to neighbour data + bool useOwnSharedEdges; // detail level constraints int min_nodes; @@ -137,6 +141,10 @@ public: // shared edge write flag inline bool get_write_shared_edges() const { return writeSharedEdges; } inline void set_write_shared_edges( const bool b ) { writeSharedEdges = b; } + + // own shared edge use flag + inline bool get_use_own_shared_edges() const { return useOwnSharedEdges; } + inline void set_use_own_shared_edges( const bool b ) { useOwnSharedEdges = b; } // detail level constraints inline int get_min_nodes() const { return min_nodes; } diff --git a/src/BuildTiles/Main/main.cxx b/src/BuildTiles/Main/main.cxx index d235bfbe..880ffef8 100644 --- a/src/BuildTiles/Main/main.cxx +++ b/src/BuildTiles/Main/main.cxx @@ -1037,6 +1037,9 @@ static void construct_tile( TGConstruct& c ) { // generated TGMatch m; m.load_neighbor_shared( c ); + if ( c.get_use_own_shared_edges() ) { + m.load_missing_shared( c ); + } m.split_tile( c ); if ( c.get_write_shared_edges() ) { m.write_shared( c ); @@ -1102,6 +1105,7 @@ static void usage( const string name ) { cout << " --nudge=" << endl; cout << " --useUKgrid" << endl; cout << " --no-write-shared-edges" << endl; + cout << " --use-own-shared-edges" << endl; cout << " ] " << endl; exit(-1); } @@ -1125,6 +1129,10 @@ int main(int argc, char **argv) { // data should only be used for fitting, but not rewritten bool writeSharedEdges = true; + // flag indicating whether the shared edge data of the + // tile to be built should be used in addition to neighbour data + bool useOwnSharedEdges = false; + sglog().setLogLevels( SG_ALL, SG_DEBUG ); // @@ -1156,6 +1164,8 @@ int main(int argc, char **argv) { useUKgrid = true; } else if (arg.find("--no-write-shared-edges") == 0) { writeSharedEdges = false; + } else if (arg.find("--use-own-shared-edges") == 0) { + useOwnSharedEdges = true; } else if (arg.find("--") == 0) { usage(argv[0]); } else { @@ -1219,6 +1229,7 @@ int main(int argc, char **argv) { c.set_output_base( output_dir ); c.set_useUKGrid( useUKgrid ); c.set_write_shared_edges( writeSharedEdges ); + c.set_use_own_shared_edges( useOwnSharedEdges ); c.set_min_nodes( 50 ); c.set_max_nodes( (int)(TG_MAX_NODES * 0.8) ); diff --git a/src/BuildTiles/Match/match.cxx b/src/BuildTiles/Match/match.cxx index b4caa7c2..2bbc7a28 100644 --- a/src/BuildTiles/Match/match.cxx +++ b/src/BuildTiles/Match/match.cxx @@ -266,6 +266,48 @@ void TGMatch::load_neighbor_shared( TGConstruct& c ) { } } +// try to load any missing shared data from our own shared data file +void TGMatch::load_missing_shared( TGConstruct& c ) { + SGBucket b = c.get_bucket(); + + double clon = b.get_center_lon(); + double clat = b.get_center_lat(); + + string base = c.get_work_base() + "/Shared/"; + + if ( !nw_flag ) { + scan_share_file( base, b, NW_Corner, NW_Corner ); + } + + if ( !ne_flag ) { + scan_share_file( base, b, NE_Corner, NE_Corner ); + } + + if ( !se_flag ) { + scan_share_file( base, b, SE_Corner, SE_Corner ); + } + + if ( !sw_flag ) { + scan_share_file( base, b, SW_Corner, SW_Corner ); + } + + if ( !north_flag ) { + scan_share_file( base, b, NORTH, NORTH ); + } + + if ( !east_flag ) { + scan_share_file( base, b, EAST, EAST ); + } + + if ( !south_flag ) { + scan_share_file( base, b, SOUTH, SOUTH ); + } + + if ( !west_flag ) { + scan_share_file( base, b, WEST, WEST ); + } +} + // fake a normal for a point which is basically straight up Point3D tgFakeNormal( const Point3D& p ) { diff --git a/src/BuildTiles/Match/match.hxx b/src/BuildTiles/Match/match.hxx index f76431c8..6a9c65c6 100644 --- a/src/BuildTiles/Match/match.hxx +++ b/src/BuildTiles/Match/match.hxx @@ -84,6 +84,9 @@ public: // shared data for a component exists set that components flag to // true void load_neighbor_shared( TGConstruct& c ); + + // try to load any missing shared data from our own shared data file + void load_missing_shared( TGConstruct& c ); // scan the specified share file for the specified information void scan_share_file( const string& dir, const SGBucket& b,