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  return (float)bV*(4.f/127.f)-0.5f;
48 }
49 
50 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
51 #pragma pack(1)
52 #endif
53 struct Star1 { // 28 byte
54 #ifdef _MSC_BUILD
55  unsigned int hip:24; // 17 bits needed
56  unsigned int componentIds:8; // 5 bits needed
57 #else
58  int hip:24; // 17 bits needed
59  unsigned char componentIds; // 5 bits needed
60 #endif
61  Int32 x0; // 32 bits needed
62  Int32 x1; // 32 bits needed
63  unsigned char bV; // 7 bits needed
64  unsigned char mag; // 8 bits needed
65  Uint16 spInt; // 14 bits needed
66  Int32 dx0,dx1,plx;
67  enum {MaxPosVal=0x7FFFFFFF};
68  StelObjectP createStelObject(const SpecialZoneArray<Star1> *a,
69  const SpecialZoneData<Star1> *z) const;
70  void getJ2000Pos(const ZoneData *z,float movementFactor, Vec3f& pos) const {
71  pos = z->axis0;
72  pos*=((float)(x0)+movementFactor*dx0);
73  pos+=((float)(x1)+movementFactor*dx1)*z->axis1;
74  pos+=z->center;
75  }
76  float getBV(void) const {return IndexToBV(bV);}
77  bool hasName() const {return hip;}
78  QString getNameI18n(void) const;
79  int hasComponentID(void) const;
80  void repack(bool fromBe);
81  void print(void);
82 }
83 #if defined(__GNUC__)
84  __attribute__ ((__packed__))
85 #endif
86 ;
87 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
88 #pragma pack(0)
89 #endif
90 
91 
92 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
93 #pragma pack(1)
94 #endif
95 struct Star2 { // 10 byte
96  int x0:20;
97  int x1:20;
98  int dx0:14;
99  int dx1:14;
100  unsigned int bV:7;
101  unsigned int mag:5;
102  enum {MaxPosVal=((1<<19)-1)};
103  StelObjectP createStelObject(const SpecialZoneArray<Star2> *a,
104  const SpecialZoneData<Star2> *z) const;
105  void getJ2000Pos(const ZoneData *z,float movementFactor, Vec3f& pos) const {
106  pos = z->axis0;
107  pos*=((float)(x0)+movementFactor*dx0);
108  pos+=((float)(x1)+movementFactor*dx1)*z->axis1;
109  pos+=z->center;
110  }
111  float getBV(void) const {return IndexToBV(bV);}
112  QString getNameI18n(void) const {return QString();}
113  int hasComponentID(void) const {return 0;}
114  bool hasName() const {return false;}
115  void repack(bool fromBe);
116  void print(void);
117 }
118 #if defined(__GNUC__)
119  __attribute__ ((__packed__))
120 #endif
121 ;
122 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
123 #pragma pack(0)
124 #endif
125 
126 
127 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
128 #pragma pack(1)
129 #endif
130 struct Star3 { // 6 byte
131  int x0:18;
132  int x1:18;
133  unsigned int bV:7;
134  unsigned int mag:5;
135  enum {MaxPosVal=((1<<17)-1)};
136  StelObjectP createStelObject(const SpecialZoneArray<Star3> *a, const SpecialZoneData<Star3> *z) const;
137  void getJ2000Pos(const ZoneData *z,float, Vec3f& pos) const
138  {
139  pos = z->axis0;
140  pos*=(float)(x0);
141  pos+=z->center;
142  pos+=(float)(x1)*z->axis1;
143  }
144  float getBV() const {return IndexToBV(bV);}
145  QString getNameI18n() const {return QString();}
146  int hasComponentID() const {return 0;}
147  bool hasName() const {return false;}
148  void repack(bool fromBe);
149  void print();
150 }
151 #if defined(__GNUC__)
152  __attribute__ ((__packed__))
153 #endif
154 ;
155 #if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
156 #pragma pack(0)
157 #endif
158 
159 #endif // _STAR_HPP_
Wrapper struct around ZoneData.
Definition: Star.hpp:37
Definition: Star.hpp:95
The base abstract class for sky objects used in Stellarium like Stars, Planets, Constellations etc...
Definition: StelObject.hpp:36
Definition: Star.hpp:53
A single triangle.
Definition: ZoneData.hpp:37
Definition: Star.hpp:130
Define the StelObjectP type.
Implements all the virtual methods in ZoneArray.
Definition: Star.hpp:36