本文整理汇总了C++中FileName::setExt方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::setExt方法的具体用法?C++ FileName::setExt怎么用?C++ FileName::setExt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::setExt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadHair
void loadHair(const FileName& fileName, OBJScene& scene, Vec3fa& offset)
{
/* add new hair set to scene */
OBJScene::HairSet* hairset = new OBJScene::HairSet;
#if CONVERT_TO_BINARY
offset = Vec3fa(zero);
#endif
int numHairs = 0;
if (fileName.ext() == "txt")
numHairs = loadHairASCII(fileName,hairset,offset);
else
numHairs = loadHairBin(fileName,hairset,offset);
/* reduce number of hairs */
if (g_reduce_hair_segment_error != 0.0f)
{
std::ios_base :: fmtflags flag = std::cout.flags();
std :: streamsize prec = std::cout.precision();
std::cout << "reducing number of hair segments ... " << std::flush;
std::cout.precision(3);
std::cout << 1E-6*float(hairset->hairs.size()) << "M" << std::flush;
for (size_t i=0; i<10; i++) {
hairset = reduce_hairs(hairset,g_reduce_hair_segment_error);
std::cout << " " << 1E-6*float(hairset->hairs.size()) << "M" << std::flush;
}
std::cout << " [DONE]" << std::endl;
std::cout.flags (flag);
std::cout.precision(prec);
}
/* add hairset to scene */
scene.hairsets.push_back(hairset);
int numPoints = hairset->v.size();
int numSegments = hairset->hairs.size();
#if CONVERT_TO_BINARY
FILE* fout = fopen(fileName.setExt(".bin").c_str(),"wb");
if (!fout) THROW_RUNTIME_ERROR("could not open " + fileName.str());
fwrite(&hair_bin_magick,sizeof(int),1,fout);
fwrite(&numHairs,sizeof(int),1,fout);
fwrite(&numPoints,sizeof(int),1,fout);
fwrite(&numSegments,sizeof(int),1,fout);
if (numPoints) fwrite(&hairset->v[0],sizeof(Vec3fa),numPoints,fout);
if (numSegments) fwrite(&hairset->hairs[0],sizeof(OBJScene::Hair),numSegments,fout);
fclose(fout);
#endif
}
示例2: loadHair
void loadHair(const FileName& fileName, OBJScene& scene, Vec3fa& offset)
{
/* add new hair set to scene */
OBJScene::HairSet* hairset = new OBJScene::HairSet;
#if CONVERT_TO_BINARY
offset = Vec3fa(zero);
#endif
int numHairs = 0;
if (fileName.ext() == "txt")
numHairs = loadHairASCII(fileName,hairset,offset);
else
numHairs = loadHairBin(fileName,hairset,offset);
/* reduce number of hairs */
#if 0
PRINT(hairset->hairs.size());
hairset = reduce_hairs(hairset);
PRINT(hairset->hairs.size());
hairset = reduce_hairs(hairset);
PRINT(hairset->hairs.size());
hairset = reduce_hairs(hairset);
PRINT(hairset->hairs.size());
hairset = reduce_hairs(hairset);
PRINT(hairset->hairs.size());
#endif
/* add hairset to scene */
scene.hairsets.push_back(hairset);
int numPoints = hairset->v.size();
int numSegments = hairset->hairs.size();
PRINT(numHairs);
PRINT(numSegments);
PRINT(numPoints);
#if CONVERT_TO_BINARY
FILE* fout = fopen(fileName.setExt(".bin").c_str(),"wb");
if (!fout) throw std::runtime_error("could not open " + fileName.str());
fwrite(&hair_bin_magick,sizeof(int),1,fout);
fwrite(&numHairs,sizeof(int),1,fout);
fwrite(&numPoints,sizeof(int),1,fout);
fwrite(&numSegments,sizeof(int),1,fout);
if (numPoints) fwrite(&hairset->v[0],sizeof(Vec3fa),numPoints,fout);
if (numSegments) fwrite(&hairset->hairs[0],sizeof(OBJScene::Hair),numSegments,fout);
fclose(fout);
#endif
}