Star.hpp   Star.hpp 
skipping to change at line 28 skipping to change at line 28
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _STAR_HPP_ #ifndef _STAR_HPP_
#define _STAR_HPP_ #define _STAR_HPP_
#include "ZoneData.hpp" #include "ZoneData.hpp"
#include "StelObjectType.hpp" #include "StelObjectType.hpp"
#include <QString> #include <QString>
#include <QtEndian>
class StelObject; class StelObject;
typedef unsigned char Uint8;
typedef int Int32; typedef int Int32;
typedef unsigned int Uint32; typedef unsigned int Uint32;
typedef short int Int16; typedef short int Int16;
typedef unsigned short int Uint16; typedef unsigned short int Uint16;
template <class Star> class SpecialZoneArray; template <class Star> class SpecialZoneArray;
template <class Star> struct SpecialZoneData; template <class Star> struct SpecialZoneData;
// structs for storing the stars in binary form. The idea is // structs for storing the stars in binary form. The idea is
// to store much data for bright stars (Star1), but only little or even // to store much data for bright stars (Star1), but only little or even
// very little data for faints stars (Star3). Using only 6 bytes for Star3 // very little data for faints stars (Star3). Using only 6 bytes for Star3
// makes it feasable to store hundreds of millions of them in main memory. // makes it feasable to store hundreds of millions of them in main memory.
static inline float IndexToBV(unsigned char bV) static inline float IndexToBV(unsigned char bV)
{ {
return (float)bV*(4.f/127.f)-0.5f; return (float)bV*(4.f/127.f)-0.5f;
} }
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
#pragma pack(1)
#elif defined(_MSC_VER)
#pragma pack(push, 1)
#endif
struct Star1 { // 28 byte struct Star1 { // 28 byte
#ifdef _MSC_VER
unsigned int hip:24; // 24 bits needed /*
unsigned int componentIds:8; // 8 bits needed _______________
#else 0 hip | |
int hip:24; // 24 bits needed 1 | |
unsigned char componentIds; // 8 bits needed 2 |_______________|
#endif 3 cIds |_______________|
Int32 x0; // 32 bits needed 4 x0 | |
Int32 x1; // 32 bits needed 5 | |
unsigned char bV; // 8 bits needed 6 | |
unsigned char mag; // 8 bits needed 7 |_______________|
Uint16 spInt; // 16 bits needed 8 x1 | |
Int32 dx0,dx1,plx; // 32 bits needed (x3) 9 | |
10 | |
11 |_______________|
12 bV |_______________|
13 mag |_______________|
14 spInt | |
15 |_______________|
16 dx0 | |
17 | |
18 | |
19 |_______________|
20 dx1 | |
21 | |
22 | |
23 |_______________|
24 plx | |
25 | |
26 | |
27 |_______________|
*/
// componentIds 8
// hip 24
//
// Int32 x0 32
// Int32 x1 32
//
// unsigned char bV 8
// unsigned char mag 8
// Uint16 spInt 16
//
// Int32 dx0,dx1,plx 32
private:
Uint8 d[28];
public:
enum {MaxPosVal=0x7FFFFFFF}; enum {MaxPosVal=0x7FFFFFFF};
StelObjectP createStelObject(const SpecialZoneArray<Star1> *a, const SpecialZoneData<Star1> *z) const; StelObjectP createStelObject(const SpecialZoneArray<Star1> *a, const SpecialZoneData<Star1> *z) const;
void getJ2000Pos(const ZoneData *z,float movementFactor, Vec3f& pos) const void getJ2000Pos(const ZoneData *z,float movementFactor, Vec3f& pos) const
{ {
pos = z->axis0; pos = z->axis0;
pos*=((float)(x0)+movementFactor*dx0); pos*=((float)(getX0())+movementFactor*getDx0());
pos+=((float)(x1)+movementFactor*dx1)*z->axis1; pos+=((float)(getX1())+movementFactor*getDx1())*z->axis1;
pos+=z->center; pos+=z->center;
} }
float getBV(void) const {return IndexToBV(bV);} inline int getBVIndex() const {return d[12];}
bool hasName() const {return hip;} inline int getMag() const {return d[13];}
inline int getSpInt() const {return ((Uint16*)d)[7];}
inline int getX0() const { return qFromLittleEndian(((Int32*)d)[1]);
}
inline int getX1() const { return qFromLittleEndian(((Int32*)d)[2]);
}
inline int getDx0() const {return qFromLittleEndian(((Int32*)d)[4]);
}
inline int getDx1() const {return qFromLittleEndian(((Int32*)d)[5]);
}
inline int getPlx() const {return qFromLittleEndian(((Int32*)d)[6]);
}
inline int getHip() const
{
Uint32 v = d[0] | d[1] << 8 | d[2] << 16;
return ((Int32)v) << 8 >> 8;
}
inline int getComponentIds() const
{
return (Int32)d[3];
}
float getBV(void) const {return IndexToBV(getBVIndex());}
bool hasName() const {return getHip();}
QString getNameI18n(void) const; QString getNameI18n(void) const;
int hasComponentID(void) const; int hasComponentID(void) const;
void repack(bool fromBe);
void print(void); void print(void);
} };
#if defined(__GNUC__)
__attribute__ ((__packed__))
#endif
;
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
#pragma pack(0)
#elif defined(_MSC_VER)
#pragma pack(pop)
#endif
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
#pragma pack(1)
#elif defined(_MSC_VER)
#pragma pack(push, 1)
#endif
struct Star2 { // 10 byte struct Star2 { // 10 byte
int x0:20; // 20 bits needed
int x1:20; // 20 bits needed /*
int dx0:14; // 14 bits needed _______________
int dx1:14; // 14 bits needed 0 x0 | |
unsigned int bV:7; // 7 bits needed 1 |_______ |
unsigned int mag:5; // 5 bits needed 2 x1 | |_______|
3 | |
4 |_______________|
5 dx0 |___ |
6 dx1 | |___________|
7 |_______ |
8 bV |_______|_______|
9 mag |_________|_____| bV
int x0 :20;
int x1 :20;
int dx0 :14;
int dx1 :14;
unsigned int bV :7;
unsigned int mag:5;
*/
private:
Uint8 d[10];
public:
inline int getX0() const
{
Uint32 v = d[0] | d[1] << 8 | (d[2] & 0xF) << 16;
return ((Int32)v) << 12 >> 12;
}
inline int getX1() const
{
Uint32 v = d[2] >> 4 | d[3] << 4 | d[4] << 12;
return ((Int32)v) << 12 >> 12;
}
inline int getDx0() const
{
Uint16 v = d[5] | (d[6] & 0x3F) << 8;
return (Int16)v;
}
inline int getDx1() const
{
Uint16 v = d[6] >> 6 | d[7] << 2 | (d[8] & 0xF) << 10;
return (Int16)v;
}
inline int getBVIndex() const
{
return d[8] >> 4 | (d[9] & 0x7) << 4;
}
inline int getMag() const
{
return d[9] >> 3;
}
enum {MaxPosVal=((1<<19)-1)}; enum {MaxPosVal=((1<<19)-1)};
StelObjectP createStelObject(const SpecialZoneArray<Star2> *a, const SpecialZoneData<Star2> *z) const; StelObjectP createStelObject(const SpecialZoneArray<Star2> *a, const SpecialZoneData<Star2> *z) const;
void getJ2000Pos(const ZoneData *z,float movementFactor, Vec3f& pos) const void getJ2000Pos(const ZoneData *z,float movementFactor, Vec3f& pos) const
{ {
pos = z->axis0; pos = z->axis0;
pos*=((float)(x0)+movementFactor*dx0); pos*=((float)(getX0())+movementFactor*getDx0());
pos+=((float)(x1)+movementFactor*dx1)*z->axis1; pos+=((float)(getX1())+movementFactor*getDx1())*z->axis1;
pos+=z->center; pos+=z->center;
} }
float getBV(void) const {return IndexToBV(bV);} float getBV(void) const {return IndexToBV(getBVIndex());}
QString getNameI18n(void) const {return QString();} QString getNameI18n(void) const {return QString();}
int hasComponentID(void) const {return 0;} int hasComponentID(void) const {return 0;}
bool hasName() const {return false;} bool hasName() const {return false;}
void repack(bool fromBe);
void print(void); void print(void);
} };
#if defined(__GNUC__)
__attribute__ ((__packed__))
#endif
;
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
#pragma pack(0)
#elif defined(_MSC_VER)
#pragma pack(pop)
#endif
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
#pragma pack(1)
#elif defined(_MSC_VER)
#pragma pack(push, 1)
#endif
struct Star3 { // 6 byte struct Star3 { // 6 byte
int x0:18; // 18 bits needed
int x1:18; // 18 bits needed /*
unsigned int bV:7; // 7 bits needed _______________
unsigned int mag:5; // 5 bits needed 0 x0 | |
1 |___________ |
2 x1 | |___|
3 |_______ |
4 bV |_______|_______|
5 mag |_________|_____| bV
int x0 :18
int x1 :18
unsigned int bV :7
unsigned int mag :5
*/
private:
Uint8 d[6];
public:
inline int getX0() const
{
Uint32 v = d[0] | d[1] << 8 | (d[2] & 0x3) << 16;
return ((Int32)v) << 14 >> 14;
}
inline int getX1() const
{
Uint32 v = d[2] >> 2 | d[3] << 6 | (d[4] & 0xF) << 14;
return ((Int32)v) << 14 >> 14;
}
inline int getBVIndex() const
{
return d[4] >> 4 | (d[5] & 0x7) << 4;
}
inline int getMag() const
{
return d[5] >> 3;
}
enum {MaxPosVal=((1<<17)-1)}; enum {MaxPosVal=((1<<17)-1)};
StelObjectP createStelObject(const SpecialZoneArray<Star3> *a, const SpecialZoneData<Star3> *z) const; StelObjectP createStelObject(const SpecialZoneArray<Star3> *a, const SpecialZoneData<Star3> *z) const;
void getJ2000Pos(const ZoneData *z,float, Vec3f& pos) const void getJ2000Pos(const ZoneData *z,float, Vec3f& pos) const
{ {
pos = z->axis0; pos = z->axis0;
pos*=(float)(x0); pos*=(float)(getX0());
pos+=z->center; pos+=z->center;
pos+=(float)(x1)*z->axis1; pos+=(float)(getX1())*z->axis1;
} }
float getBV() const {return IndexToBV(bV);} float getBV() const {return IndexToBV(getBVIndex());}
QString getNameI18n() const {return QString();} QString getNameI18n() const {return QString();}
int hasComponentID() const {return 0;} int hasComponentID() const {return 0;}
bool hasName() const {return false;} bool hasName() const {return false;}
void repack(bool fromBe);
void print(); void print();
} };
#if defined(__GNUC__)
__attribute__ ((__packed__))
#endif
;
#if (defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__))
#pragma pack(0)
#elif defined(_MSC_VER)
#pragma pack(pop)
#endif
#endif // _STAR_HPP_ #endif // _STAR_HPP_
 End of changes. 19 change blocks. 
83 lines changed or deleted 192 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/