本文整理汇总了C++中Star::setCatalogNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ Star::setCatalogNumber方法的具体用法?C++ Star::setCatalogNumber怎么用?C++ Star::setCatalogNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Star
的用法示例。
在下文中一共展示了Star::setCatalogNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findWhileLoading
/*! While loading the star catalogs, this function must be called instead of
* find(). The final catalog number index for stars cannot be built until
* after all stars have been loaded. During catalog loading, there are two
* separate indexes: one for the binary catalog and another index for stars
* loaded from stc files. They binary catalog index is a sorted array, while
* the stc catalog index is an STL map. Since the binary file can be quite
* large, we want to avoid creating a map with as many nodes as there are
* stars. Stc files should collectively contain many fewer stars, and stars
* in an stc file may reference each other (barycenters). Thus, a dynamic
* structure like a map is both practical and essential.
*/
Star* StarDatabase::findWhileLoading(uint32 catalogNumber) const
{
// First check for stars loaded from the binary database
if (binFileCatalogNumberIndex != NULL)
{
Star refStar;
refStar.setCatalogNumber(catalogNumber);
Star** star = lower_bound(binFileCatalogNumberIndex,
binFileCatalogNumberIndex + binFileStarCount,
&refStar,
PtrCatalogNumberOrderingPredicate());
if (star != binFileCatalogNumberIndex + binFileStarCount && (*star)->getCatalogNumber() == catalogNumber)
return *star;
}
// Next check for stars loaded from an stc file
map<uint32, Star*>::const_iterator iter = stcFileCatalogNumberIndex.find(catalogNumber);
if (iter != stcFileCatalogNumberIndex.end())
{
return iter->second;
}
// Star not found
return NULL;
}
示例2: find
Star* StarDatabase::find(uint32 catalogNumber) const
{
Star refStar;
refStar.setCatalogNumber(catalogNumber);
Star** star = lower_bound(catalogNumberIndex,
catalogNumberIndex + nStars,
&refStar,
PtrCatalogNumberOrderingPredicate());
if (star != catalogNumberIndex + nStars && (*star)->getCatalogNumber() == catalogNumber)
return *star;
else
return NULL;
}
示例3: 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;
}