From b13900402d7dddf41456fd424ae07c67bfebe7d1 Mon Sep 17 00:00:00 2001 From: frohlich Date: Fri, 2 Feb 2007 18:09:27 +0000 Subject: [PATCH] Modified Files: ephemeris.cxx ephemeris.hxx stardata.cxx stardata.hxx: Throw out sg.h --- simgear/ephemeris/ephemeris.cxx | 5 ++-- simgear/ephemeris/ephemeris.hxx | 4 ++-- simgear/ephemeris/stardata.cxx | 41 +++++++++++---------------------- simgear/ephemeris/stardata.hxx | 29 ++++++++--------------- 4 files changed, 28 insertions(+), 51 deletions(-) diff --git a/simgear/ephemeris/ephemeris.cxx b/simgear/ephemeris/ephemeris.cxx index 7f14dd6f..3c4c54f9 100644 --- a/simgear/ephemeris/ephemeris.cxx +++ b/simgear/ephemeris/ephemeris.cxx @@ -42,9 +42,8 @@ SGEphemeris::SGEphemeris( const string &path ) { uranus = new Uranus; neptune = new Neptune; nplanets = 7; - for ( int i = 0; i < nplanets; ++i ) { - sgdSetVec3( planets[i].sg(), 0.0, 0.0, 0.0 ); - } + for ( int i = 0; i < nplanets; ++i ) + planets[i] = SGVec3d::zeros(); stars = new SGStarData( SGPath(path) ); } diff --git a/simgear/ephemeris/ephemeris.hxx b/simgear/ephemeris/ephemeris.hxx index 7554391f..d46650fb 100644 --- a/simgear/ephemeris/ephemeris.hxx +++ b/simgear/ephemeris/ephemeris.hxx @@ -30,8 +30,6 @@ #define _EPHEMERIS_HXX -#include - #include #include #include @@ -43,6 +41,8 @@ #include #include +#include + /** Ephemeris class * diff --git a/simgear/ephemeris/stardata.cxx b/simgear/ephemeris/stardata.cxx index 7f04b8b2..0be37865 100644 --- a/simgear/ephemeris/stardata.cxx +++ b/simgear/ephemeris/stardata.cxx @@ -25,6 +25,7 @@ #endif #include +#include #include #include "stardata.hxx" @@ -34,16 +35,9 @@ #endif // Constructor -SGStarData::SGStarData() : - nstars(0) +SGStarData::SGStarData( const SGPath& path ) { -} - -SGStarData::SGStarData( SGPath path ) : - nstars(0) -{ - data_path = SGPath( path ); - load(); + load(path); } @@ -52,31 +46,27 @@ SGStarData::~SGStarData() { } -bool SGStarData::load() { +bool SGStarData::load( const SGPath& path ) { - // -dw- avoid local data > 32k error by dynamic allocation of the - // array, problem for some compilers - stars = new SGVec3d[SG_MAX_STARS]; + _stars.clear(); - // build the full path name to the stars data base file - data_path.append( "stars" ); - SG_LOG( SG_ASTRO, SG_INFO, " Loading stars from " << data_path.str() ); + // build the full path name to the stars data base file + path.append( "stars" ); + SG_LOG( SG_ASTRO, SG_INFO, " Loading stars from " << path.str() ); - sg_gzifstream in( data_path.str() ); + sg_gzifstream in( path.str() ); if ( ! in.is_open() ) { SG_LOG( SG_ASTRO, SG_ALERT, "Cannot open star file: " - << data_path.str() ); - exit(-1); + << path.str() ); + return false; } double ra, dec, mag; char c; string name; - nstars = 0; - // read in each line of the file - while ( ! in.eof() && nstars < SG_MAX_STARS ) { + while ( ! in.eof() ) { in >> skipcomment; getline( in, name, ',' ); @@ -116,13 +106,10 @@ bool SGStarData::load() { in >> mag; // cout << " star data = " << ra << " " << dec << " " << mag << endl; - - sgdSetVec3( stars[nstars].sg(), ra, dec, mag ); - - ++nstars; + _stars.push_back(SGVec3d(ra, dec, mag)); } - SG_LOG( SG_ASTRO, SG_INFO, " Loaded " << nstars << " stars" ); + SG_LOG( SG_ASTRO, SG_INFO, " Loaded " << _stars.size() << " stars" ); return true; } diff --git a/simgear/ephemeris/stardata.hxx b/simgear/ephemeris/stardata.hxx index 5ac685b3..40513e65 100644 --- a/simgear/ephemeris/stardata.hxx +++ b/simgear/ephemeris/stardata.hxx @@ -24,37 +24,28 @@ #ifndef _SG_STARDATA_HXX #define _SG_STARDATA_HXX +#include +#include -#include - -#include - - -#define SG_MAX_STARS 850 - +class SGPath; class SGStarData { - - int nstars; - SGVec3d *stars; - - SGPath data_path; - public: - // Constructor - SGStarData(); - SGStarData( SGPath path ); + SGStarData( const SGPath& path ); // Destructor ~SGStarData(); // load the stars database - bool load(); + bool load( const SGPath& path ); // stars - inline int getNumStars() const { return nstars; } - inline SGVec3d *getStars() { return stars; } + inline int getNumStars() const { return _stars.size(); } + inline SGVec3d *getStars() { return &(_stars[0]); } + +private: + std::vector _stars; }; -- 2.39.5