Stellarium 0.12.2
Star.hpp
1 /*
2  * The big star catalogue extension to Stellarium:
3  * Author and Copyright: Johannes Gajdosik, 2006, 2007
4  *
5  * Thanks go to Nigel Kerr for ideas and testing of BE/LE star repacking
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
20  */
21 
22 #ifndef _STAR_HPP_
23 #define _STAR_HPP_ 1
24 
25 #include "ZoneData.hpp"
26 #include "StelObjectType.hpp"
27 #include <QString>
28 
29 class StelObject;
30 
31 namespace BigStarCatalogExtension {
32 
33 typedef int Int32;
34 typedef unsigned int Uint32;
35 typedef short int Int16;
36 typedef unsigned short int Uint16;
37 
38 
39 template <class Star> class SpecialZoneArray;
40 template <class Star> struct SpecialZoneData;
41 
42 
43 // structs for storing the stars in binary form. The idea is
44 // to store much data for bright stars (Star1), but only little or even
45 // very little data for faints stars (Star3). Using only 6 bytes for Star3
46 // makes it feasable to store hundreds of millions of them in main memory.
47 
48 
49 
50 static inline float IndexToBV(unsigned char bV) {
51  return (float)bV*(4.f/127.f)-0.5f;
52 }
53 
54 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
55 #pragma pack(1)
56 #endif
57 struct Star1 { // 28 byte
58  int hip:24; // 17 bits needed
59  unsigned char componentIds; // 5 bits needed
60  Int32 x0; // 32 bits needed
61  Int32 x1; // 32 bits needed
62  unsigned char bV; // 7 bits needed
63  unsigned char mag; // 8 bits needed
64  Uint16 spInt; // 14 bits needed
65  Int32 dx0,dx1,plx;
66  enum {MaxPosVal=0x7FFFFFFF};
67  StelObjectP createStelObject(const SpecialZoneArray<Star1> *a,
68  const SpecialZoneData<Star1> *z) const;
69  void getJ2000Pos(const ZoneData *z,float movementFactor, Vec3f& pos) const {
70  pos = z->axis0;
71  pos*=((float)(x0)+movementFactor*dx0);
72  pos+=((float)(x1)+movementFactor*dx1)*z->axis1;
73  pos+=z->center;
74  }
75  float getBV(void) const {return IndexToBV(bV);}
76  bool hasName() const {return hip;}
77  QString getNameI18n(void) const;
78  int hasComponentID(void) const;
79  void repack(bool fromBe);
80  void print(void);
81 }
82 #if defined(__GNUC__)
83  __attribute__ ((__packed__))
84 #endif
85 ;
86 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
87 #pragma pack(0)
88 #endif
89 
90 
91 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
92 #pragma pack(1)
93 #endif
94 struct Star2 { // 10 byte
95  int x0:20;
96  int x1:20;
97  int dx0:14;
98  int dx1:14;
99  unsigned int bV:7;
100  unsigned int mag:5;
101  enum {MaxPosVal=((1<<19)-1)};
102  StelObjectP createStelObject(const SpecialZoneArray<Star2> *a,
103  const SpecialZoneData<Star2> *z) const;
104  void getJ2000Pos(const ZoneData *z,float movementFactor, Vec3f& pos) const {
105  pos = z->axis0;
106  pos*=((float)(x0)+movementFactor*dx0);
107  pos+=((float)(x1)+movementFactor*dx1)*z->axis1;
108  pos+=z->center;
109  }
110  float getBV(void) const {return IndexToBV(bV);}
111  QString getNameI18n(void) const {return QString();}
112  int hasComponentID(void) const {return 0;}
113  bool hasName() const {return false;}
114  void repack(bool fromBe);
115  void print(void);
116 }
117 #if defined(__GNUC__)
118  __attribute__ ((__packed__))
119 #endif
120 ;
121 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
122 #pragma pack(0)
123 #endif
124 
125 
126 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
127 #pragma pack(1)
128 #endif
129 struct Star3 { // 6 byte
130  int x0:18;
131  int x1:18;
132  unsigned int bV:7;
133  unsigned int mag:5;
134  enum {MaxPosVal=((1<<17)-1)};
135  StelObjectP createStelObject(const SpecialZoneArray<Star3> *a,
136  const SpecialZoneData<Star3> *z) const;
137  void getJ2000Pos(const ZoneData *z,float, Vec3f& pos) const {
138  pos = z->axis0;
139  pos*=(float)(x0);
140  pos+=z->center;
141  pos+=(float)(x1)*z->axis1;
142  }
143  float getBV(void) const {return IndexToBV(bV);}
144  QString getNameI18n(void) const {return QString();}
145  int hasComponentID(void) const {return 0;}
146  bool hasName() const {return false;}
147  void repack(bool fromBe);
148  void print(void);
149 }
150 #if defined(__GNUC__)
151  __attribute__ ((__packed__))
152 #endif
153 ;
154 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
155 #pragma pack(0)
156 #endif
157 
158 } // namespace BigStarCatalogExtension
159 
160 #endif // _STAR_HPP_