本文整理汇总了C++中FileName::str方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::str方法的具体用法?C++ FileName::str怎么用?C++ FileName::str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromFile
bool PropertyBag::loadFromFile(const FileName &filename, bool merge) {
if (!isFileOnDisk(filename)) {
ERR("File not found: " + filename.str());
return false;
}
FileText file;
if (!file.openStream(filename, File::FILE_MODE_READ)) {
ERR("File failed to load: " + filename.str());
return false;
}
const string fileContents = file.getFullText();
// Load / Merge the data
if (!merge) {
data.clear();
}
if (!loadMergeFromString(fileContents)) {
FAIL("Failed to merge file contents on load: " + filename.str());
return false;
}
return true;
}
示例2: loadHairBin
int loadHairBin(const FileName& fileName, OBJScene::HairSet* hairset, Vec3fa& offset)
{
FILE* fin = fopen(fileName.c_str(),"rb");
if (!fin) throw std::runtime_error("could not open " + fileName.str());
int magick;
fread(&magick,sizeof(int),1,fin);
if (magick != hair_bin_magick)
throw std::runtime_error("invalid binary hair file " + fileName.str());
int numHairs;
fread(&numHairs,sizeof(int),1,fin);
int numPoints;
fread(&numPoints,sizeof(int),1,fin);
int numSegments;
fread(&numSegments,sizeof(int),1,fin);
hairset->v.resize(numPoints);
hairset->hairs.resize(numSegments);
if (numPoints) fread(&hairset->v[0],sizeof(Vec3fa),numPoints,fin);
if (numSegments) fread(&hairset->hairs[0],sizeof(OBJScene::Hair),numSegments,fin);
fclose(fin);
for (size_t i=0; i<numPoints; i++) {
hairset->v[i].x-=offset.x;
hairset->v[i].y-=offset.y;
hairset->v[i].z-=offset.z;
}
return numHairs;
}
示例3: importDefaultExtensions
void Importer::importDefaultExtensions(const std::shared_ptr<Node> &world,
const FileName &fileNamen)
{
std::cout << "importDefaultExtensions \"" << fileNamen.str() << "\"" << std::endl;
std::vector<FileName> files;
//check for multiple files
if (fileNamen.str().find(",") != std::string::npos) {
std::cout << "parsing import file series" << std::endl;
// file series
std::string filestr = fileNamen.str();
std::replace(filestr.begin(),filestr.end(),',',' ');
std::stringstream ss(filestr);
std::string file;
while (ss >> file)
files.push_back(FileName(file));
if (files.size() > 0) {
auto ext = files[0].ext(); //TODO: check that they are all homogeneous
#ifdef OSPRAY_APPS_SG_VTK
auto& selector = createChild("selector", "Selector");
if (ext == "vti") {
sg::importVTIs(selector.shared_from_this(), files);
return;
}
#endif
}
} else {
示例4: tex
/*! read png texture from disk */
std::shared_ptr<Texture> Texture::load(const FileName& fileName)
{
if (texture_cache.find(fileName.str()) != texture_cache.end())
return texture_cache[fileName.str()];
std::shared_ptr<Texture> tex(new Texture(loadImage(fileName),fileName));
return texture_cache[fileName.str()] = tex;
}
示例5: loadPFM
/*! read PFM file from disk */
Ref<Image> loadPFM(const FileName& fileName)
{
/* open PPM file */
FILE* file = fopen(fileName.c_str(), "rb");
if (!file) THROW_RUNTIME_ERROR("cannot open " + fileName.str());
/* read file type */
char type[8];
if (fscanf(file, "%7s", type) != 1)
THROW_RUNTIME_ERROR("Error reading " + fileName.str());
/* skip comment lines */
while (readCommentLine(file)) {};
/* read width, height, and maximal color value */
int width, height;
float maxColor;
if (fscanf(file, "%i %i %f", &width, &height, &maxColor) != 3)
THROW_RUNTIME_ERROR("Error reading " + fileName.str());
/* Check for big endian PFM file */
if (maxColor > 0.0f) {
fclose(file);
THROW_RUNTIME_ERROR("Big endian PFM files not supported");
}
float rcpMaxColor = -1.0f/float(maxColor);
/* get return or space */
fgetc(file);
/* create image and fill with data */
Ref<Image> img = new Image3f(width,height,fileName);
/* image in binary format 32 bit */
if (!strcmp(type, "PF"))
{
float rgb[3];
for (ssize_t y=0; y<height; y++) {
for (ssize_t x=0; x<width; x++) {
if (fread(rgb,sizeof(rgb),1,file) != 1)
THROW_RUNTIME_ERROR("Error reading " + fileName.str());
img->set(x,y,Color4(float(rgb[0])*rcpMaxColor,float(rgb[1])*rcpMaxColor,float(rgb[2])*rcpMaxColor,1.0f));
}
}
}
/* invalid magic value */
else {
fclose(file);
THROW_RUNTIME_ERROR("Invalid magic value in PFM file");
}
fclose(file);
return img;
}
示例6: loadTexture
Ref<Device::RTTexture> loadTexture(const FileName fileName)
{
static std::map<std::string,Ref<Device::RTTexture> > texture_map;
if (texture_map.find(fileName.str()) != texture_map.end())
return texture_map[fileName.str()];
Ref<Device::RTTexture> texture = g_device->rtNewTexture("nearest");
texture->rtSetImage("image",loadRTImage(fileName));
texture->rtCommit();
return texture_map[fileName.str()] = texture;
}
示例7: main
/* main function in embree namespace */
int main(int argc, char** argv)
{
/* for best performance set FTZ and DAZ flags in MXCSR control and status register */
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
/* create stream for parsing */
Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv));
/* parse command line */
parseCommandLine(stream, FileName());
/* load default scene if none specified */
if (filename.ext() == "") {
FileName file = FileName::executableFolder() + FileName("models/cornell_box.ecs");
parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
}
/* configure number of threads */
if (g_numThreads)
g_rtcore += ",threads=" + std::to_string((long long)g_numThreads);
if (g_numBenchmarkFrames)
g_rtcore += ",benchmark=1";
g_rtcore += g_subdiv_mode;
/* load scene */
if (strlwr(filename.ext()) == std::string("obj")) {
g_scene->add(loadOBJ(filename,g_subdiv_mode != ""));
}
else if (strlwr(filename.ext()) == std::string("xml")) {
g_scene->add(loadXML(filename,one));
}
else if (filename.ext() != "")
THROW_RUNTIME_ERROR("invalid scene type: "+strlwr(filename.ext()));
/* initialize ray tracing core */
init(g_rtcore.c_str());
/* send model */
g_obj_scene.add(g_scene.dynamicCast<SceneGraph::Node>(),g_instancing_mode);
g_scene = nullptr;
set_scene(&g_obj_scene);
/* benchmark mode */
if (g_numBenchmarkFrames)
renderBenchmark(outFilename);
/* render to disk */
if (outFilename.str() != "")
renderToFile(outFilename);
/* interactive mode */
if (g_interactive) {
initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen);
enterWindowRunLoop(g_anim_mode);
}
return 0;
}
示例8: main
/* main function in embree namespace */
int main(int argc, char** argv)
{
/* create stream for parsing */
Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv));
/* parse command line */
parseCommandLine(stream, FileName());
if (filename.str() == "") {
printf("Error: No input OBJ file specified, use -i option.\n");
exit(1);
}
/* load scene */
loadOBJ(filename,g_mesh);
/* initialize ISPC */
init(g_verbose);
/* set scene */
setScene(g_mesh,g_pointLightPosition,g_pointLightIntensity,g_ambientLightIntensity);
/* initialize GLUT */
initGlut("tutorial03",g_width,g_height,g_fullscreen,false);
return 0;
}
示例9: main
void main(int argc, char **argv)
{
std::cout << " === Possible cmd line options: -lazy, -pregenerate, -cache === " << std::endl;
/* set default camera */
g_camera.from = Vec3fa(1.5f,1.5f,-1.5f);
g_camera.to = Vec3fa(0.0f,0.0f,0.0f);
/*! Parse command line options. */
parseCommandLine(new ParseStream(new CommandLineStream(argc, argv)), FileName());
/*! Set the thread count in the Embree configuration string. */
if (g_numThreads) g_rtcore += ",threads=" + std::stringOf(g_numThreads);
g_rtcore += g_subdiv_mode;
/*! Initialize the task scheduler. */
#if !defined(RTCORE_EXPORT_ALL_SYMBOLS)
TaskScheduler::create(g_numThreads);
#endif
/*! Initialize Embree state. */
init(g_rtcore.c_str());
/* render to disk */
if (outFilename.str() != "")
renderToFile(outFilename);
/* interactive mode */
if (g_interactive) {
initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen);
enterWindowRunLoop();
}
}
示例10: main
/* main function in embree namespace */
int main(int argc, char** argv)
{
/* set default camera */
g_camera.from = Vec3fa(2.5f,2.5f,2.5f);
g_camera.to = Vec3fa(0.0f,0.0f,0.0f);
/* create stream for parsing */
Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv));
/* parse command line */
parseCommandLine(stream, FileName());
if (g_numThreads)
g_rtcore += ",threads=" + std::stringOf(g_numThreads);
/* initialize ray tracing core */
init(g_rtcore.c_str());
/* render to disk */
if (outFilename.str() != "") {
renderToFile(outFilename);
return 0;
}
/* initialize GLUT */
initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen);
/* enter the GLUT run loop */
enterWindowRunLoop();
return 0;
}
示例11: storeTga
void storeTga(const Ref<Image>& img, const FileName& fileName)
{
FILE* file = fopen(fileName.c_str(), "wb");
if (!file) THROW_RUNTIME_ERROR("error opening file " + fileName.str());
fwrite_uchar(0x00, file);
fwrite_uchar(0x00, file);
fwrite_uchar(0x02, file);
fwrite_ushort(0x0000, file);
fwrite_ushort(0x0000, file);
fwrite_ushort(0x0000, file);
fwrite_ushort(0x0000, file);
fwrite_uchar(0x00, file);
fwrite_ushort((unsigned short)img->width , file);
fwrite_ushort((unsigned short)img->height, file);
fwrite_uchar(0x18, file);
fwrite_uchar(0x20, file);
for (size_t y=0; y<img->height; y++) {
for (size_t x=0; x<img->width; x++) {
Color c = img->get(x,y);
fwrite_uchar((unsigned char)(clamp(c.b)*255.0f), file);
fwrite_uchar((unsigned char)(clamp(c.g)*255.0f), file);
fwrite_uchar((unsigned char)(clamp(c.r)*255.0f), file);
}
}
fclose(file);
}
示例12: loadHairASCII
int loadHairASCII(const FileName& fileName, OBJScene::HairSet* hairset, Vec3fa& offset)
{
/* open hair file */
FILE* f = fopen(fileName.c_str(),"r");
if (!f) throw std::runtime_error("could not open " + fileName.str());
char line[10000];
fgets(line,10000,f);
int numCurves = 0;
while (fgets(line,10000,f) && !feof(f))
{
/* comment */
if (line[0] == '#')
continue;
if (!strncmp(line,"Curve:",strlen("Curve:")))
{
char name[1000];
unsigned int tracks, points;
sscanf(line,"Curve: %s %d Tracks %d Points",name,&tracks,&points);
/* skip Tracks line */
fgets(line,10000,f);
const int vertex_start_id = hairset->v.size();
double x,y,z,w;
unsigned int id = 0;
for (int i=0; i<points; i++)
{
fgets(line,10000,f);
/* comment */
if (line[0] == '#' || !strncmp(line," Tracks:",strlen(" Tracks:")))
continue;
Vec3fa v;
if (i == 0) sscanf(line,"%d : Bezier %f %f %f %f",&id,&v.x,&v.y,&v.z,&v.w);
else sscanf(line,"%d : %f %f %f %f",&id,&v.x,&v.y,&v.z,&v.w);
//printf("%d %d : %f %f %f %f \n",id,vertex_start_id+id,v.x,v.y,v.z,v.w);
v.x-=offset.x;
v.y-=offset.y;
v.z-=offset.z;
hairset->v.push_back(v);
}
/* add indices to hair starts */
for (int i=0; i<points-1; i+=3)
hairset->hairs.push_back(OBJScene::Hair(vertex_start_id + i,numCurves));
if (id != points-1)
throw std::runtime_error("hair parsing error");
numCurves++;
}
}
fclose(f);
return numCurves;
}
示例13: main
/* main function in embree namespace */
int main(int argc, char** argv)
{
/* for best performance set FTZ and DAZ flags in MXCSR control and status register */
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
/* set default camera */
g_camera.from = Vec3fa(2.5f,2.5f,2.5f);
g_camera.to = Vec3fa(0.0f,0.0f,0.0f);
/* create stream for parsing */
Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv));
/* parse command line */
parseCommandLine(stream, FileName());
if (g_numThreads)
g_rtcore += ",threads=" + toString(g_numThreads);
/* initialize ray tracing core */
init(g_rtcore.c_str());
/* render to disk */
if (outFilename.str() != "") {
renderToFile(outFilename);
return 0;
}
/* initialize GLUT */
initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen);
/* enter the GLUT run loop */
enterWindowRunLoop();
return 0;
}
示例14: main
int main(int argc, char **argv)
{
/* for best performance set FTZ and DAZ flags in MXCSR control and status register */
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
std::cout << " === Possible cmd line options: -pregenerate, -cache === " << std::endl;
/* set default camera */
g_camera.from = Vec3fa(1.5f,1.5f,-1.5f);
g_camera.to = Vec3fa(0.0f,0.0f,0.0f);
/*! Parse command line options. */
parseCommandLine(new ParseStream(new CommandLineStream(argc, argv)), FileName());
/*! Set the thread count in the Embree configuration string. */
if (g_numThreads) g_rtcore += ",threads=" + std::to_string((long long)g_numThreads);
g_rtcore += g_subdiv_mode;
/*! Initialize Embree state. */
init(g_rtcore.c_str());
/* render to disk */
if (outFilename.str() != "")
renderToFile(outFilename);
/* interactive mode */
if (g_interactive) {
initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen);
enterWindowRunLoop();
}
return 0;
}
示例15: fopen
vector<KeyFrame>
ModelLoaderMD3::loadKeyFrames(const FileName &fileName,
const FileName &skinName,
TextureFactory &textureFactory) const {
FILE * stream = fopen(fileName.c_str(), "rb");
VERIFY(stream && !ferror(stream), "MD3 failed to open: "+fileName.str());
Header header = readHeader(stream);
Frame *frames = readFrames(stream, header);
Tag *tags = readTags(stream, header);
Surface *surfaces = readSurfaces(stream, header);
fclose(stream);
vector<KeyFrame> keyFrames = buildKeyFrame(surfaces,
fileName,
skinName,
header,
textureFactory);
delete [] frames;
delete [] tags;
delete [] surfaces;
return keyFrames;
}