本文整理汇总了C++中SoInput::closeFile方法的典型用法代码示例。如果您正苦于以下问题:C++ SoInput::closeFile方法的具体用法?C++ SoInput::closeFile怎么用?C++ SoInput::closeFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoInput
的用法示例。
在下文中一共展示了SoInput::closeFile方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadModel
SoSeparator* loadModel(const char* fileName)
{
SoSeparator *root = new SoSeparator;
SoInput myScene;
//try to open the file
if (!myScene.openFile(fileName)) {
printf("Could not open %s\n",fileName) ;
return NULL;
}
//check if the file is valid
if (!myScene.isValidFile()) {
printf("%s is not a valid Inventor file\n",fileName) ;
return NULL;
}
//try to read the file
root = SoDB::readAll(&myScene) ;
if (root == NULL) {
printf("Problem reading %s\n",fileName) ;
myScene.closeFile() ;
return NULL;
}
//close the file
myScene.closeFile() ;
return root ;
}
示例2: atoi
SoSeparator *
SceneFileObj::readSceneFile(void)
{
SoInput input;
SoSeparator *s;
FILE *f = NULL;
if (_sceneFileName[0] == '<') {
char *p = _sceneFileName+1;
while (*p) {
if (! isdigit(*p))
break;
p++;
}
if (*p == '\0') {
int fd = atoi(_sceneFileName+1);
if ((f = fdopen(fd, "r")) == NULL) {
return (NULL);
}
input.setFilePointer(f);
}
}
if (f == NULL) {
if (!input.openFile(_sceneFileName))
return NULL;
}
s = SoDB::readAll(&input);
input.closeFile();
return s;
}
示例3: OpenHeliostatComponent
TSeparatorKit* ComponentHeliostatField::OpenHeliostatComponent( QString fileName )
{
if ( fileName.isEmpty() ) return 0;
SoInput componentInput;
if ( !componentInput.openFile( fileName.toLatin1().constData() ) )
{
QMessageBox::warning( 0, QString( "Scene Graph Structure" ),
QString( "Cannot open file %1:\n." ).arg( fileName ) );
return 0;
}
SoSeparator* componentSeparator = SoDB::readAll( &componentInput );
componentInput.closeFile();
if ( !componentSeparator )
{
QMessageBox::warning( 0, QString( "Scene Graph Structure" ),
QString( "Error reading file %1:\n%2." )
.arg( fileName ) );
return 0;
}
TSeparatorKit* componentRoot = static_cast< TSeparatorKit* >( componentSeparator->getChild(0) );
componentRoot->ref();
return componentRoot;
}
示例4: GetSceneKitFromFile
/*!
* Reads the scene saved on the file with given \a filename and return a pointer to the scene.
*
* Returns null on any error.
*/
TSceneKit* Document::GetSceneKitFromFile( const QString& fileName )
{
SoInput sceneInput;
if ( !sceneInput.openFile( fileName.toLatin1().constData() ) )
{
QString message = QString( "Cannot open file %1." ).arg( fileName );
emit Warning( message );
return 0;
}
if( !sceneInput.isValidFile() )
{
QString message = QString( "Error reading file %1.\n" ).arg( fileName );
emit Warning( message );
return 0;
}
SoSeparator* graphSeparator = SoDB::readAll( &sceneInput );
sceneInput.closeFile();
if ( !graphSeparator )
{
QString message = QString( "Error reading file %1.\n" ).arg( fileName );
emit Warning( message );
return 0;
}
return static_cast< TSceneKit* >( graphSeparator->getChild(0) );
return 0;
}
示例5: exit
SoSeparator *ReadScene(const char *Dir, const char *filename) {
FILE *filePtr = NULL;
SoSeparator *root;
SoInput in;
in.addDirectoryLast(Dir);
if (!in.openFile(filename)) {
cerr << "Error opening file " << filename << " from Directory " << Dir
<< endl;
exit(1);
}
root = SoDB::readAll(&in);
if (root == NULL)
cerr << "Error reading file " << filename << " from Directory " << Dir
<< endl;
else {
#ifdef DEBUG
cerr << "Scene (" << filename << ") read!\n";
#endif
root->ref();
}
in.closeFile();
return root;
}
示例6: readFile
SoSeparator* QilexDoc::readFile(const char *filename, int &tipus)
{
// Open the input file
SoInput mySceneInput;
if (!mySceneInput.openFile(filename)) {
fprintf(stderr, "Cannot open file %s\n", filename);
return NULL;
}
// Read the whole file into the database
SoSeparator *myGraph = SoDB::readAll(&mySceneInput);
tipus = (int)mySceneInput.isFileVRML2();
if (myGraph == NULL) {
fprintf(stderr, "Problem reading file\n");
return NULL;
}
mySceneInput.closeFile();
return myGraph;
}
示例7: loadModel
bool InventorViewer::loadModel(const std::string& filename)
{
if (!initialized)
{
ROS_ERROR("InventorViewer not initialized.");
return false;
}
SoInput in;
SoNode *model = NULL;
if (!in.openFile(filename.c_str()))
return false;
if (!SoDB::read(&in, model) || model == NULL)
/*model = SoDB::readAll(&in);
if (!model)*/
return false;
root->addChild(model);
in.closeFile();
return true;
}
示例8:
SbBool
SoTexture2::readImage(const SbString& fname, int &w, int &h, int &nc,
unsigned char *&bytes)
//
////////////////////////////////////////////////////////////////////////
{
w = h = nc = 0;
bytes = NULL;
// Empty file means an empty image...
if (fname.getString()[0] == '\0')
return TRUE;
SoInput in;
if (!in.openFile(fname.getString(), TRUE)) {
return FALSE;
}
#ifdef DEBUG
SoDebugError::postInfo("SoTexture2::readImage",
"Reading texture image %s",
fname.getString());
#endif
if (ReadSGIImage(in, w, h, nc, bytes))
return TRUE;
// fiopen() closes the file even if it can't read the data, so
// reopen it
in.closeFile();
if (!in.openFile(fname.getString(), TRUE))
return FALSE;
if (ReadGIFImage(in, w, h, nc, bytes))
return TRUE;
if (ReadJPEGImage(in, w, h, nc, bytes))
return TRUE;
return FALSE;
}
示例9:
void
SoFile::nameChangedCB(void *data, SoSensor *)
//
////////////////////////////////////////////////////////////////////////
{
SoFile *f = (SoFile *)data;
f->children.truncate(0);
SoInput in;
const char *filename = f->name.getValue().getString();
// Open file
f->readOK = TRUE;
if (! in.openFile(filename, TRUE)) {
f->readOK = FALSE;
SoReadError::post(&in, "Can't open included file \"%s\" in File node",
filename);
}
if (f->readOK) {
SoNode *node;
// Read children from opened file.
while (TRUE) {
if (SoDB::read(&in, node)) {
if (node != NULL)
f->children.append(node);
else
break;
}
else
f->readOK = FALSE;
}
in.closeFile();
}
// Note: if there is an error reading one of the children, the
// other children will still be added properly...
}
示例10: readFile
void SoFileSubgraph::readFile(const char *fileName){
// open the input file
SoInput sceneInput;
if (!sceneInput.openFile(fileName)) {
SoDebugError::post("SoFileSubgraph::readFile()",
"Cannot open file '%s'",
fileName);
return;
}
if (!sceneInput.isValidFile()){
SoDebugError::post("SoFileSubgraph::readFile()",
"file '%s' is not a valid Inventor file",
fileName);
return;
}
else{
SoDebugError::postInfo("SoFileSubgraph::readFile()",
"file '%s' read successfully",
fileName);
}
// read the whole file into the database
SoSeparator *subgraph=SoDB::readAll(&sceneInput);
subgraph->ref();
if (subgraph ==NULL) {
SoDebugError::post("SoFileSubgraph::readFile()",
"problem reading contents of file '%s'",
fileName);
return;
}
SoSeparator *graphRoot=SO_GET_ANY_PART(this,"root",SoSeparator);
graphRoot->addChild(subgraph);
sceneInput.closeFile();
}
示例11: QString
/*!
Tries to load the shape primitives file for the grasped object. It uses
the same file name as the current object, but looks in the primitives folder
within the objects directory. If the primitives are not found, it uses
the original geometry of the object, the \a IVGeomRoot.
*/
void
grasp_manager::loadPrimitives()
{
SoInput myInput;
char prDir[256];
QString directory = QString(getenv("GRASPIT"))+
QString("/models/objects/primitives/");
QString filename = my_body->getFilename().section('/',-1);
//make sure the extension is iv, as this is how primitives
//are stored for now
filename = filename.section('.',-2,-2) + ".iv";
QString path = directory + filename;
printf("Loading primitive %s.\n",path.latin1());
if (!(myInput.openFile(path.latin1()))) {
pr_error("could not open primitives file!");
primitives = my_body->getIVGeomRoot();
printf ("%s\n",prDir);
printf("Setting primitive root node to original object.\n");
}
else {
primitives = SoDB::readAll(&myInput);
myInput.closeFile();
if (primitives == NULL) {
printf("Load Primitive didnt work, although file seems to exist.\n");
printf("Setting primitive root node to original object.\n");
primitives = my_body->getIVGeomRoot();
}
else {
primitives->ref();
}
}
}
示例12: addSearchPaths
/**
* Read from SoInput and convert to OSG.
* This is a method used by readNode(string,options) and readNode(istream,options).
*/
osgDB::ReaderWriter::ReadResult
ReaderWriterIV::readNodeFromSoInput(SoInput &input,
std::string &fileName, const osgDB::ReaderWriter::Options *options) const
{
// Parse options and add search paths to SoInput
const osgDB::FilePathList *searchPaths = options ? &options->getDatabasePathList() : NULL;
if (options)
addSearchPaths(searchPaths);
// Create the inventor scenegraph by reading from SoInput
SoSeparator* rootIVNode = SoDB::readAll(&input);
// Remove recently appened search paths
if (options)
removeSearchPaths(searchPaths);
// Close the file
input.closeFile();
// Perform conversion
ReadResult result;
if (rootIVNode)
{
rootIVNode->ref();
// Convert the inventor scenegraph to an osg scenegraph
ConvertFromInventor convertIV;
convertIV.preprocess(rootIVNode);
result = convertIV.convert(rootIVNode);
rootIVNode->unref();
} else
result = ReadResult::FILE_NOT_HANDLED;
// Notify
if (result.success()) {
if (fileName.length())
{
OSG_NOTICE << "osgDB::ReaderWriterIV::readNode() "
<< "File " << fileName
<< " loaded successfully." << std::endl;
}
else
{
OSG_NOTICE << "osgDB::ReaderWriterIV::readNode() "
<< "Stream loaded successfully." << std::endl;
}
} else {
if (fileName.length())
{
OSG_WARN << "osgDB::ReaderWriterIV::readNode() "
<< "Failed to load file " << fileName
<< "." << std::endl;
}
else
{
OSG_WARN << "osgDB::ReaderWriterIV::readNode() "
<< "Failed to load stream." << std::endl;
}
}
return result;
}