Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

modules/Star.hpp

00001 /*
00002  * The big star catalogue extension to Stellarium:
00003  * Author and Copyright: Johannes Gajdosik, 2006, 2007
00004  *
00005  * Thanks go to Nigel Kerr for ideas and testing of BE/LE star repacking
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020  */
00021 
00022 #ifndef _STAR_HPP_
00023 #define _STAR_HPP_ 1
00024 
00025 #include "ZoneData.hpp"
00026 #include "StelObjectType.hpp"
00027 #include <QString>
00028 
00029 class StelObject;
00030 
00031 namespace BigStarCatalogExtension {
00032 
00033 typedef int Int32;
00034 typedef unsigned int Uint32;
00035 typedef short int Int16;
00036 typedef unsigned short int Uint16;
00037 
00038 
00039 template <class Star> struct SpecialZoneArray;
00040 template <class Star> struct SpecialZoneData;
00041 
00042 
00043 // structs for storing the stars in binary form. The idea is
00044 // to store much data for bright stars (Star1), but only little or even
00045 // very little data for faints stars (Star3). Using only 6 bytes for Star3
00046 // makes it feasable to store hundreds of millions of them in main memory.
00047 
00048 
00049 
00050 static inline float IndexToBV(unsigned char bV) {
00051   return (float)bV*(4.f/127.f)-0.5f;
00052 }
00053 
00054 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00055 #pragma pack(1)
00056 #endif
00057 struct Star1 { // 28 byte
00058   int hip:24;                  // 17 bits needed
00059   unsigned char componentIds;  //  5 bits needed
00060   Int32 x0;                    // 32 bits needed
00061   Int32 x1;                    // 32 bits needed
00062   unsigned char bV;            //  7 bits needed
00063   unsigned char mag;           //  8 bits needed
00064   Uint16 spInt;                // 14 bits needed
00065   Int32 dx0,dx1,plx;
00066   enum {MaxPosVal=0x7FFFFFFF};
00067   StelObjectP createStelObject(const SpecialZoneArray<Star1> *a,
00068                      const SpecialZoneData<Star1> *z) const;
00069   void getJ2000Pos(const ZoneData *z,double movementFactor, Vec3d& pos) const {
00070       pos = z->axis0;
00071       pos*=((double)(x0)+movementFactor*dx0);
00072       pos+=((double)(x1)+movementFactor*dx1)*z->axis1;
00073       pos+=z->center;
00074   }
00075   float getBV(void) const {return IndexToBV(bV);}
00076   bool hasName() const {return hip;}
00077   QString getNameI18n(void) const;
00078   void repack(bool fromBe);
00079   void print(void);
00080 }
00081 #if defined(__GNUC__)
00082    __attribute__ ((__packed__))
00083 #endif
00084 ;
00085 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00086 #pragma pack(0)
00087 #endif
00088 
00089 
00090 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00091 #pragma pack(1)
00092 #endif
00093 struct Star2 {  // 10 byte
00094   int x0:20;
00095   int x1:20;
00096   int dx0:14;
00097   int dx1:14;
00098   unsigned int bV:7;
00099   unsigned int mag:5;
00100   enum {MaxPosVal=((1<<19)-1)};
00101   StelObjectP createStelObject(const SpecialZoneArray<Star2> *a,
00102                      const SpecialZoneData<Star2> *z) const;
00103   void getJ2000Pos(const ZoneData *z,double movementFactor, Vec3d& pos) const {
00104       pos = z->axis0;
00105       pos*=((double)(x0)+movementFactor*dx0);
00106       pos+=((double)(x1)+movementFactor*dx1)*z->axis1;
00107       pos+=z->center;
00108   }
00109   float getBV(void) const {return IndexToBV(bV);}
00110   QString getNameI18n(void) const {return QString();}
00111   bool hasName() const {return false;}
00112   void repack(bool fromBe);
00113   void print(void);
00114 }
00115 #if defined(__GNUC__)
00116    __attribute__ ((__packed__))
00117 #endif
00118 ;
00119 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00120 #pragma pack(0)
00121 #endif
00122 
00123 
00124 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00125 #pragma pack(1)
00126 #endif
00127 struct Star3 {  // 6 byte
00128   int x0:18;
00129   int x1:18;
00130   unsigned int bV:7;
00131   unsigned int mag:5;
00132   enum {MaxPosVal=((1<<17)-1)};
00133   StelObjectP createStelObject(const SpecialZoneArray<Star3> *a,
00134                      const SpecialZoneData<Star3> *z) const;
00135   void getJ2000Pos(const ZoneData *z,double, Vec3d& pos) const {
00136       pos = z->axis0;
00137       pos*=(double)(x0);
00138       pos+=z->center;
00139       pos+=(double)(x1)*z->axis1;
00140   }
00141   float getBV(void) const {return IndexToBV(bV);}
00142   QString getNameI18n(void) const {return QString();}
00143   bool hasName() const {return false;}
00144   void repack(bool fromBe);
00145   void print(void);
00146 }
00147 #if defined(__GNUC__)
00148    __attribute__ ((__packed__))
00149 #endif
00150 ;
00151 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00152 #pragma pack(0)
00153 #endif
00154 
00155 } // namespace BigStarCatalogExtension
00156 
00157 #endif // _STAR_HPP_

Generated on Mon Mar 22 09:55:38 2010 for Stellarium by  doxygen 1.5.5