~ubuntu-branches/debian/squeeze/stellarium/squeeze

« back to all changes in this revision

Viewing changes to src/Star.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Cédric Delfosse
  • Date: 2008-05-19 21:28:23 UTC
  • mfrom: (3.1.5 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080519212823-m5nfiuntxstxzxj7
Tags: 0.9.1-4
Add libxcursor-dev, libxfixes-dev, libxinerama-dev, libqt4-opengl-dev to
build-deps (Closes: #479906)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
20
 */
 
21
 
 
22
#ifndef _STAR_HPP_
 
23
#define _STAR_HPP_
 
24
 
 
25
#include "ZoneData.hpp"
 
26
 
 
27
#include <boost/intrusive_ptr.hpp>
 
28
 
 
29
#include <string>
 
30
 
 
31
 
 
32
class StelObject;
 
33
 
 
34
namespace BigStarCatalogExtension {
 
35
 
 
36
typedef int Int32;
 
37
typedef unsigned int Uint32;
 
38
typedef short int Int16;
 
39
typedef unsigned short int Uint16;
 
40
 
 
41
 
 
42
template <class Star> struct SpecialZoneArray;
 
43
template <class Star> struct SpecialZoneData;
 
44
 
 
45
 
 
46
// structs for storing the stars in binary form. The idea is
 
47
// to store much data for bright stars (Star1), but only little or even
 
48
// very little data for faints stars (Star3). Using only 6 bytes for Star3
 
49
// makes it feasable to store hundreds of millions of them in main memory.
 
50
 
 
51
 
 
52
 
 
53
static inline float IndexToBV(unsigned char b_v) {
 
54
  return (float)b_v*(4.f/127.f)-0.5f;
 
55
}
 
56
 
 
57
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
 
58
#pragma pack(1)
 
59
#endif
 
60
struct Star1 { // 28 byte
 
61
  int hip:24;                  // 17 bits needed
 
62
  unsigned char component_ids; //  5 bits needed
 
63
  Int32 x0;                    // 32 bits needed
 
64
  Int32 x1;                    // 32 bits needed
 
65
  unsigned char b_v;           //  7 bits needed
 
66
  unsigned char mag;           //  8 bits needed
 
67
  Uint16 sp_int;               // 14 bits needed
 
68
  Int32 dx0,dx1,plx;
 
69
  enum {max_pos_val=0x7FFFFFFF};
 
70
  boost::intrusive_ptr<StelObject>
 
71
    createStelObject(const SpecialZoneArray<Star1> *a,
 
72
                     const SpecialZoneData<Star1> *z) const;
 
73
  Vec3d getJ2000Pos(const ZoneData *z,double movement_factor) const {
 
74
    Vec3d pos = z->center
 
75
              + (x0+movement_factor*dx0)*z->axis0
 
76
              + (x1+movement_factor*dx1)*z->axis1;
 
77
    pos.normalize();
 
78
    return pos;
 
79
  }
 
80
  float getBV(void) const {return IndexToBV(b_v);}
 
81
  std::wstring getNameI18n(void) const;
 
82
  void repack(bool from_be);
 
83
  void print(void);
 
84
}
 
85
#if defined(__GNUC__)
 
86
   __attribute__ ((__packed__))
 
87
#endif
 
88
;
 
89
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
 
90
#pragma pack(0)
 
91
#endif
 
92
 
 
93
 
 
94
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
 
95
#pragma pack(1)
 
96
#endif
 
97
struct Star2 {  // 10 byte
 
98
  int x0:20;
 
99
  int x1:20;
 
100
  int dx0:14;
 
101
  int dx1:14;
 
102
  unsigned int b_v:7;
 
103
  unsigned int mag:5;
 
104
  enum {max_pos_val=((1<<19)-1)};
 
105
  boost::intrusive_ptr<StelObject>
 
106
    createStelObject(const SpecialZoneArray<Star2> *a,
 
107
                     const SpecialZoneData<Star2> *z) const;
 
108
  Vec3d getJ2000Pos(const ZoneData *z,double movement_factor) const {
 
109
    Vec3d pos = z->center
 
110
              + (x0+movement_factor*dx0)*z->axis0
 
111
              + (x1+movement_factor*dx1)*z->axis1;
 
112
    pos.normalize();
 
113
    return pos;
 
114
  }
 
115
  float getBV(void) const {return IndexToBV(b_v);}
 
116
  std::wstring getNameI18n(void) const {return L"";}
 
117
  void repack(bool from_be);
 
118
  void print(void);
 
119
}
 
120
#if defined(__GNUC__)
 
121
   __attribute__ ((__packed__))
 
122
#endif
 
123
;
 
124
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
 
125
#pragma pack(0)
 
126
#endif
 
127
 
 
128
 
 
129
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
 
130
#pragma pack(1)
 
131
#endif
 
132
struct Star3 {  // 6 byte
 
133
  int x0:18;
 
134
  int x1:18;
 
135
  unsigned int b_v:7;
 
136
  unsigned int mag:5;
 
137
  enum {max_pos_val=((1<<17)-1)};
 
138
  boost::intrusive_ptr<StelObject>
 
139
    createStelObject(const SpecialZoneArray<Star3> *a,
 
140
                     const SpecialZoneData<Star3> *z) const;
 
141
  Vec3d getJ2000Pos(const ZoneData *z,double) const {
 
142
    Vec3d pos = z->center + (double)(x0)*z->axis0 + (double)(x1)*z->axis1;
 
143
    pos.normalize();
 
144
    return pos;
 
145
  }
 
146
  float getBV(void) const {return IndexToBV(b_v);}
 
147
  std::wstring getNameI18n(void) const {return L"";}
 
148
  void repack(bool from_be);
 
149
  void print(void);
 
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
} // namespace BigStarCatalogExtension
 
160
 
 
161
#endif