]> git.mxchange.org Git - flightgear.git/commitdiff
cleanup of atmosphere patch
authorTim Moore <timoore@redhat.com>
Thu, 10 Sep 2009 09:42:42 +0000 (11:42 +0200)
committerTim Moore <timoore@redhat.com>
Thu, 10 Sep 2009 09:42:42 +0000 (11:42 +0200)
Remove some dead code and space changes. Replace boost::tuple with std::pair,
but do use boost::tie.

src/Environment/atmosphere.cxx
src/Environment/atmosphere.hxx
src/Environment/environment.cxx
src/Main/main.cxx

index 427a055d8146f3323ab1ed731a3dc59d3c551e41..a15c943ed47aba514bddb6212459f38f9a85c3fc 100644 (file)
@@ -1,3 +1,5 @@
+#include <boost/tuple/tuple.hpp>
+
 #include <simgear/math/SGMath.hxx>
 #include <simgear/debug/logstream.hxx>
 
@@ -21,54 +23,6 @@ ISA_layer(7,  80000,  262467,  0.88628, 0.000261718, 196.65, -76.50),
 
 const int ISA_def_size(sizeof(ISA_def) / sizeof(ISA_layer));
 
-#if 0
-// Pressure within a layer, as a function of height
-// and of layer parameters.
-// Physics model:  standard or nonstandard atmosphere,
-//  depending on what parameters you pass in.
-// Heights in meters, pressures in Pa.
-// As always, $lambda is positive in the troposphere,
-//  and zero in the first part of the stratosphere.
-// 
-double Ph_layer(
-  const double hh, 
-  const double hb, 
-  const double Pb, 
-  const double Tb, 
-  const double lambda) {
-using namespace atmodel;  
-  if (lambda) {
-//  (1/N) &:=& {g\,m_M \over \lambda\,R}
-    double N = lambda * Rgas / mm / g;
-    return Pb * pow((Tb - lambda*(hh - hb)) / Tb, 1/N);
-  } else {
-    return Pb * exp(-g * mm / Rgas / Tb * (hh - hb));
-  }
-}
-
-// Pressure as a function of height.
-// Valid below 32000 meters,
-//   i.e. troposphere and first two layers of stratosphere.
-// Does not depend on any caching; can be used to
-// *construct* caches and interpolation tables.
-//
-// Height in meters, pressure in pascals.
-
-double old_p_vs_a(const double height) {
-    using namespace atmodel;
-    if (height <= 11000.) {
-        return P_layer(height, 0.0, ISA::P0, ISA::T0, ISA::lam0);
-    } else if (height <= 20000.) {
-        return P_layer(height, 11000., 22632.06, 216.65, 0.0);
-    } else if (height <= 32000.) {
-        return P_layer(height, 20000.,  5474.89, 216.65, -0.001);
-    }
-    return 0;
-}
-
-
-#endif
-
 // Pressure within a layer, as a function of height.
 // Physics model:  standard or nonstandard atmosphere,
 //    depending on what parameters you pass in.
@@ -112,7 +66,7 @@ double T_layer (
 //  from the table: the reference height in that layer, 
 //  the lapse in that layer, and the cap (if any) for that layer 
 // (which we take from the /next/ row of the table, if any).
-tuple<double,double> PT_vs_hpt(
+pair<double,double> PT_vs_hpt(
       const double hh, 
       const double _p0,
       const double _t0
@@ -145,7 +99,7 @@ tuple<double,double> PT_vs_hpt(
       xhgt = (pp+1)->height;      
     }
     if (hh <= xhgt) {
-      return make_tuple(P_layer(hh, hgt, p0, t0, lapse),
+      return make_pair(P_layer(hh, hgt, p0, t0, lapse),
                  T_layer(hh, hgt, p0, t0, lapse));
     }
     p0 = P_layer(xhgt, hgt, p0, t0, lapse);
@@ -155,7 +109,7 @@ tuple<double,double> PT_vs_hpt(
   
 // Should never get here.
   SG_LOG(SG_GENERAL, SG_ALERT, "PT_vs_hpt: ran out of layers");
-  return make_tuple(d0,d0);
+  return make_pair(d0, d0);
 }
 
 
@@ -206,7 +160,7 @@ void FGAtmoCache::tabulate() {
 
     for (double hgt = -1000; hgt <= 32000;) {
         double press,temp;
-        make_tuple(ref(press), ref(temp)) = PT_vs_hpt(hgt);
+        boost::tie(press, temp) = PT_vs_hpt(hgt);
         a_tvs_p->addEntry(press / inHg, hgt / foot);
 
 #ifdef DEBUG_EXPORT_P_H
@@ -258,7 +212,7 @@ void FGAtmoCache::check_model() {
         using namespace atmodel;
         cache();
         double press,temp;
-        make_tuple(ref(press), ref(temp)) = PT_vs_hpt(height);
+        boost::tie(press, temp) = PT_vs_hpt(height);
         cout << "Height: " << height
              << " \tpressure: " << press << endl;
         cout << "Check:  "
index 73fa494771fcf202bbe377ed5ba0c22e582c0af5..55ccfb3f9e580a76d6d08c4ee1006fcb714bef02 100644 (file)
 
 #include <simgear/compiler.h>
 #include <simgear/math/interpolater.hxx>
-#include "boost/tuple/tuple.hpp"
-using namespace boost;
 
 #include <cmath>
+#include <utility>
 
 using namespace std;
 
@@ -84,7 +83,7 @@ public:
 
 extern const ISA_layer ISA_def[];
 
-tuple<double,double> PT_vs_hpt(
+std::pair<double,double> PT_vs_hpt(
           const double hh, 
           const double _p0 = atmodel::ISA::P0,
           const double _t0 = atmodel::ISA::T0);
index 5eeca7f757da9db7eca8dddee7e9b571a3891e06..eed66fa17cd28c5ece0da1d192b53254cc7e79c9 100644 (file)
@@ -18,7 +18,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
-// $Id: environment.cxx,v 1.1 2009/01/30 15:07:04 jsd Exp $
+// $Id$
 
 
 #ifdef HAVE_CONFIG_H
@@ -27,6 +27,8 @@
 
 #include <math.h>
 
+#include <boost/tuple/tuple.hpp>
+
 #include <plib/sg.h>
 
 #include <simgear/constants.h>
@@ -205,12 +207,12 @@ FGEnvironment::read (const SGPropertyNode * node)
                      &FGEnvironment::set_visibility_m);
 
     if (!maybe_copy_value(this, node, "temperature-sea-level-degc",
-             &FGEnvironment::set_temperature_sea_level_degc))
+                          &FGEnvironment::set_temperature_sea_level_degc))
         maybe_copy_value(this, node, "temperature-degc",
                          &FGEnvironment::set_temperature_degc);
 
     if (!maybe_copy_value(this, node, "dewpoint-sea-level-degc",
-             &FGEnvironment::set_dewpoint_sea_level_degc))
+                          &FGEnvironment::set_dewpoint_sea_level_degc))
         maybe_copy_value(this, node, "dewpoint-degc",
                          &FGEnvironment::set_dewpoint_degc);
 
@@ -634,7 +636,7 @@ FGEnvironment::_recalc_alt_pt ()
   }
 #endif
   double press, temp;
-  make_tuple(ref(press), ref(temp)) = PT_vs_hpt(elevation_ft * foot, 
+  boost::tie(press, temp) = PT_vs_hpt(elevation_ft * foot, 
         pressure_sea_level_inhg * inHg, temperature_sea_level_degc + freezing);
   temperature_degc = temp - freezing;
   pressure_inhg = press / inHg;
index 830a102146432b88b062147a9200e76bd074b04f..a6d28297c474489f8852c767ac4168412b1ee5d8 100644 (file)
@@ -718,7 +718,6 @@ struct GeneralInitOperation : public GraphicsContextOperation
 
 static void fgIdleFunction ( void ) {
     static osg::ref_ptr<GeneralInitOperation> genOp;
-    ////////cerr << "Idle state: " << idle_state << endl;
     if ( idle_state == 0 ) {
         idle_state++;
         // Pick some window on which to do queries.