Home · All Namespaces · All Classes · Functions · Coding Style · 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 
00027 #include <boost/intrusive_ptr.hpp>
00028 
00029 #include <QString>
00030 
00031 class StelObject;
00032 
00033 namespace BigStarCatalogExtension {
00034 
00035 typedef int Int32;
00036 typedef unsigned int Uint32;
00037 typedef short int Int16;
00038 typedef unsigned short int Uint16;
00039 
00040 
00041 template <class Star> struct SpecialZoneArray;
00042 template <class Star> struct SpecialZoneData;
00043 
00044 
00045 // structs for storing the stars in binary form. The idea is
00046 // to store much data for bright stars (Star1), but only little or even
00047 // very little data for faints stars (Star3). Using only 6 bytes for Star3
00048 // makes it feasable to store hundreds of millions of them in main memory.
00049 
00050 
00051 
00052 static inline float IndexToBV(unsigned char bV) {
00053   return (float)bV*(4.f/127.f)-0.5f;
00054 }
00055 
00056 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00057 #pragma pack(1)
00058 #endif
00059 struct Star1 { // 28 byte
00060   int hip:24;                  // 17 bits needed
00061   unsigned char componentIds;  //  5 bits needed
00062   Int32 x0;                    // 32 bits needed
00063   Int32 x1;                    // 32 bits needed
00064   unsigned char bV;            //  7 bits needed
00065   unsigned char mag;           //  8 bits needed
00066   Uint16 spInt;                // 14 bits needed
00067   Int32 dx0,dx1,plx;
00068   enum {MaxPosVal=0x7FFFFFFF};
00069   boost::intrusive_ptr<StelObject>
00070     createStelObject(const SpecialZoneArray<Star1> *a,
00071                      const SpecialZoneData<Star1> *z) const;
00072   Vec3d getJ2000Pos(const ZoneData *z,double movementFactor) const {
00073     Vec3d pos = z->center
00074               + (x0+movementFactor*dx0)*z->axis0
00075               + (x1+movementFactor*dx1)*z->axis1;
00076     //pos.normalize();
00077     return pos;
00078   }
00079   float getBV(void) const {return IndexToBV(bV);}
00080   QString getNameI18n(void) const;
00081   void repack(bool fromBe);
00082   void print(void);
00083 }
00084 #if defined(__GNUC__)
00085    __attribute__ ((__packed__))
00086 #endif
00087 ;
00088 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00089 #pragma pack(0)
00090 #endif
00091 
00092 
00093 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00094 #pragma pack(1)
00095 #endif
00096 struct Star2 {  // 10 byte
00097   int x0:20;
00098   int x1:20;
00099   int dx0:14;
00100   int dx1:14;
00101   unsigned int bV:7;
00102   unsigned int mag:5;
00103   enum {MaxPosVal=((1<<19)-1)};
00104   boost::intrusive_ptr<StelObject>
00105     createStelObject(const SpecialZoneArray<Star2> *a,
00106                      const SpecialZoneData<Star2> *z) const;
00107   Vec3d getJ2000Pos(const ZoneData *z,double movementFactor) const {
00108     Vec3d pos = z->center
00109               + (x0+movementFactor*dx0)*z->axis0
00110               + (x1+movementFactor*dx1)*z->axis1;
00111     //pos.normalize();
00112     return pos;
00113   }
00114   float getBV(void) const {return IndexToBV(bV);}
00115   QString getNameI18n(void) const {return "";}
00116   void repack(bool fromBe);
00117   void print(void);
00118 }
00119 #if defined(__GNUC__)
00120    __attribute__ ((__packed__))
00121 #endif
00122 ;
00123 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00124 #pragma pack(0)
00125 #endif
00126 
00127 
00128 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00129 #pragma pack(1)
00130 #endif
00131 struct Star3 {  // 6 byte
00132   int x0:18;
00133   int x1:18;
00134   unsigned int bV:7;
00135   unsigned int mag:5;
00136   enum {MaxPosVal=((1<<17)-1)};
00137   boost::intrusive_ptr<StelObject>
00138     createStelObject(const SpecialZoneArray<Star3> *a,
00139                      const SpecialZoneData<Star3> *z) const;
00140   Vec3d getJ2000Pos(const ZoneData *z,double) const {
00141     Vec3d pos = z->center + (double)(x0)*z->axis0 + (double)(x1)*z->axis1;
00142     //pos.normalize();
00143     return pos;
00144   }
00145   float getBV(void) const {return IndexToBV(bV);}
00146   QString getNameI18n(void) const {return "";}
00147   void repack(bool fromBe);
00148   void print(void);
00149 }
00150 #if defined(__GNUC__)
00151    __attribute__ ((__packed__))
00152 #endif
00153 ;
00154 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
00155 #pragma pack(0)
00156 #endif
00157 
00158 } // namespace BigStarCatalogExtension
00159 
00160 #endif // _STAR_HPP_

Generated on Mon Feb 2 17:23:47 2009 for Stellarium by  doxygen 1.5.5