Stellarium 0.13.0
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_
24 
25 #include "ZoneData.hpp"
26 #include "StelObjectType.hpp"
27 #include <QString>
28 
29 class StelObject;
30 
31 typedef int Int32;
32 typedef unsigned int Uint32;
33 typedef short int Int16;
34 typedef unsigned short int Uint16;
35 
36 template <class Star> class SpecialZoneArray;
37 template <class Star> struct SpecialZoneData;
38 
39 
40 // structs for storing the stars in binary form. The idea is
41 // to store much data for bright stars (Star1), but only little or even
42 // very little data for faints stars (Star3). Using only 6 bytes for Star3
43 // makes it feasable to store hundreds of millions of them in main memory.
44 
45 
46 static inline float IndexToBV(unsigned char bV)
47 {
48  return (float)bV*(4.f/127.f)-0.5f;
49 }
50 
51 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
52 #pragma pack(1)
53 #elif defined(_MSC_VER)
54 #pragma pack(push, 1)
55 #endif
56 struct Star1 { // 28 byte
57 #ifdef _MSC_VER
58  unsigned int hip:24; // 24 bits needed
59  unsigned int componentIds:8; // 8 bits needed
60 #else
61  int hip:24; // 24 bits needed
62  unsigned char componentIds; // 8 bits needed
63 #endif
64  Int32 x0; // 32 bits needed
65  Int32 x1; // 32 bits needed
66  unsigned char bV; // 8 bits needed
67  unsigned char mag; // 8 bits needed
68  Uint16 spInt; // 16 bits needed
69  Int32 dx0,dx1,plx; // 32 bits needed (x3)
70  enum {MaxPosVal=0x7FFFFFFF};
71  StelObjectP createStelObject(const SpecialZoneArray<Star1> *a, const SpecialZoneData<Star1> *z) const;
72  void getJ2000Pos(const ZoneData *z,float movementFactor, Vec3f& pos) const
73  {
74  pos = z->axis0;
75  pos*=((float)(x0)+movementFactor*dx0);
76  pos+=((float)(x1)+movementFactor*dx1)*z->axis1;
77  pos+=z->center;
78  }
79  float getBV(void) const {return IndexToBV(bV);}
80  bool hasName() const {return hip;}
81  QString getNameI18n(void) const;
82  int hasComponentID(void) const;
83  void repack(bool fromBe);
84  void print(void);
85 }
86 #if defined(__GNUC__)
87  __attribute__ ((__packed__))
88 #endif
89 ;
90 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
91 #pragma pack(0)
92 #elif defined(_MSC_VER)
93 #pragma pack(pop)
94 #endif
95 
96 
97 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
98 #pragma pack(1)
99 #elif defined(_MSC_VER)
100 #pragma pack(push, 1)
101 #endif
102 struct Star2 { // 10 byte
103  int x0:20; // 20 bits needed
104  int x1:20; // 20 bits needed
105  int dx0:14; // 14 bits needed
106  int dx1:14; // 14 bits needed
107  unsigned int bV:7; // 7 bits needed
108  unsigned int mag:5; // 5 bits needed
109  enum {MaxPosVal=((1<<19)-1)};
110  StelObjectP createStelObject(const SpecialZoneArray<Star2> *a, const SpecialZoneData<Star2> *z) const;
111  void getJ2000Pos(const ZoneData *z,float movementFactor, Vec3f& pos) const
112  {
113  pos = z->axis0;
114  pos*=((float)(x0)+movementFactor*dx0);
115  pos+=((float)(x1)+movementFactor*dx1)*z->axis1;
116  pos+=z->center;
117  }
118  float getBV(void) const {return IndexToBV(bV);}
119  QString getNameI18n(void) const {return QString();}
120  int hasComponentID(void) const {return 0;}
121  bool hasName() const {return false;}
122  void repack(bool fromBe);
123  void print(void);
124 }
125 #if defined(__GNUC__)
126  __attribute__ ((__packed__))
127 #endif
128 ;
129 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
130 #pragma pack(0)
131 #elif defined(_MSC_VER)
132 #pragma pack(pop)
133 #endif
134 
135 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
136 #pragma pack(1)
137 #elif defined(_MSC_VER)
138 #pragma pack(push, 1)
139 #endif
140 struct Star3 { // 6 byte
141  int x0:18; // 18 bits needed
142  int x1:18; // 18 bits needed
143  unsigned int bV:7; // 7 bits needed
144  unsigned int mag:5; // 5 bits needed
145  enum {MaxPosVal=((1<<17)-1)};
146  StelObjectP createStelObject(const SpecialZoneArray<Star3> *a, const SpecialZoneData<Star3> *z) const;
147  void getJ2000Pos(const ZoneData *z,float, Vec3f& pos) const
148  {
149  pos = z->axis0;
150  pos*=(float)(x0);
151  pos+=z->center;
152  pos+=(float)(x1)*z->axis1;
153  }
154  float getBV() const {return IndexToBV(bV);}
155  QString getNameI18n() const {return QString();}
156  int hasComponentID() const {return 0;}
157  bool hasName() const {return false;}
158  void repack(bool fromBe);
159  void print();
160 }
161 #if defined(__GNUC__)
162  __attribute__ ((__packed__))
163 #endif
164 ;
165 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
166 #pragma pack(0)
167 #elif defined(_MSC_VER)
168 #pragma pack(pop)
169 #endif
170 
171 #endif // _STAR_HPP_
Wrapper struct around ZoneData.
Definition: Star.hpp:37
Definition: Star.hpp:102
The base abstract class for sky objects used in Stellarium like Stars, Planets, Constellations etc...
Definition: StelObject.hpp:36
Definition: Star.hpp:56
A single triangle.
Definition: ZoneData.hpp:37
Definition: Star.hpp:140
Define the StelObjectP type.
Implements all the virtual methods in ZoneArray.
Definition: Star.hpp:36