本文整理汇总了C++中SoInput::isValidFile方法的典型用法代码示例。如果您正苦于以下问题:C++ SoInput::isValidFile方法的具体用法?C++ SoInput::isValidFile怎么用?C++ SoInput::isValidFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoInput
的用法示例。
在下文中一共展示了SoInput::isValidFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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 ;
}
示例3: 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();
}