本文整理汇总了C++中Star::setDetails方法的典型用法代码示例。如果您正苦于以下问题:C++ Star::setDetails方法的具体用法?C++ Star::setDetails怎么用?C++ Star::setDetails使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Star
的用法示例。
在下文中一共展示了Star::setDetails方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadBinary
bool StarDatabase::loadBinary(istream& in)
{
uint32 nStarsInFile = 0;
// Verify that the star database file has a correct header
{
int headerLength = strlen(FILE_HEADER);
char* header = new char[headerLength];
in.read(header, headerLength);
if (strncmp(header, FILE_HEADER, headerLength))
return false;
delete[] header;
}
// Verify the version
{
uint16 version;
in.read((char*) &version, sizeof version);
LE_TO_CPU_INT16(version, version);
if (version != 0x0100)
return false;
}
// Read the star count
in.read((char *) &nStarsInFile, sizeof nStarsInFile);
LE_TO_CPU_INT32(nStarsInFile, nStarsInFile);
if (!in.good())
return false;
unsigned int totalStars = nStars + nStarsInFile;
while (((unsigned int) nStars) < totalStars)
{
uint32 catNo = 0;
float x = 0.0f, y = 0.0f, z = 0.0f;
int16 absMag;
uint16 spectralType;
in.read((char *) &catNo, sizeof catNo);
LE_TO_CPU_INT32(catNo, catNo);
in.read((char *) &x, sizeof x);
LE_TO_CPU_FLOAT(x, x);
in.read((char *) &y, sizeof y);
LE_TO_CPU_FLOAT(y, y);
in.read((char *) &z, sizeof z);
LE_TO_CPU_FLOAT(z, z);
in.read((char *) &absMag, sizeof absMag);
LE_TO_CPU_INT16(absMag, absMag);
in.read((char *) &spectralType, sizeof spectralType);
LE_TO_CPU_INT16(spectralType, spectralType);
if (in.bad())
break;
Star star;
star.setPosition(x, y, z);
star.setAbsoluteMagnitude((float) absMag / 256.0f);
StarDetails* details = NULL;
StellarClass sc;
if (sc.unpack(spectralType))
details = StarDetails::GetStarDetails(sc);
if (details == NULL)
{
cerr << _("Bad spectral type in star database, star #") << nStars << "\n";
return false;
}
star.setDetails(details);
star.setCatalogNumber(catNo);
unsortedStars.add(star);
nStars++;
}
if (in.bad())
return false;
DPRINTF(0, "StarDatabase::read: nStars = %d\n", nStarsInFile);
clog << nStars << _(" stars in binary database\n");
// Create the temporary list of stars sorted by catalog number; this
// will be used to lookup stars during file loading. After loading is
// complete, the stars are sorted into an octree and this list gets
// replaced.
if (unsortedStars.size() > 0)
{
binFileStarCount = unsortedStars.size();
binFileCatalogNumberIndex = new Star*[binFileStarCount];
for (unsigned int i = 0; i < binFileStarCount; i++)
{
binFileCatalogNumberIndex[i] = &unsortedStars[i];
}
sort(binFileCatalogNumberIndex, binFileCatalogNumberIndex + binFileStarCount,
PtrCatalogNumberOrderingPredicate());
}
return true;
}