当前位置: 首页>>代码示例>>C++>>正文


C++ SoInput::openFile方法代码示例

本文整理汇总了C++中SoInput::openFile方法的典型用法代码示例。如果您正苦于以下问题:C++ SoInput::openFile方法的具体用法?C++ SoInput::openFile怎么用?C++ SoInput::openFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SoInput的用法示例。


在下文中一共展示了SoInput::openFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;

}
开发者ID:hcu5555,项目名称:tonatiuh,代码行数:30,代码来源:ComponentHeliostatField.cpp

示例2: catch

/*!
  \brief Add a new object in the scene graph
  \param iv_filename : name of.iv file to load
  \param fMo       : position of the object wrt the reference frame
*/
void
vpSimulator::load(const char * iv_filename,const vpHomogeneousMatrix &fMo)
{

  SoInput in;
  SoSeparator * newObject;

  if (! in.openFile (iv_filename))
  {
    vpERROR_TRACE ("Erreur lors de la lecture du fichier %s.", iv_filename);
  }

  newObject = SoDB::readAll (&in);
  if (NULL == newObject)
  {
    vpERROR_TRACE ("Problem reading data for file <%s>.", iv_filename);
  }

  try
  {
    this->addObject (newObject, fMo) ;
  }
  catch(...)
  {
    vpERROR_TRACE("Error adding object from file <%s> ",iv_filename) ;
    throw ;
  }

}
开发者ID:tswang,项目名称:visp,代码行数:34,代码来源:vpSimulator.cpp

示例3: 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;
}
开发者ID:tarunrs,项目名称:homework-fall-2011,代码行数:26,代码来源:OSUInventor.C

示例4: readNodeFromSoInput

// Read file and convert to OSG
osgDB::ReaderWriter::ReadResult
ReaderWriterIV::readNode(const std::string& file,
                         const osgDB::ReaderWriter::Options* options) const
{
    // Accept extension
    std::string ext = osgDB::getLowerCaseFileExtension(file);
    if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;

    // Find file
    std::string fileName = osgDB::findDataFile( file, options );
    if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;

    // Notify
    OSG_NOTICE << "osgDB::ReaderWriterIV::readNode() Reading file "
                             << fileName.data() << std::endl;
    OSG_INFO << "osgDB::ReaderWriterIV::readNode() Inventor version: "
                           << SoDB::getVersion() << std::endl;

    // Open the file
    SoInput input;
    if (!input.openFile(fileName.data()))
    {
        OSG_WARN << "osgDB::ReaderWriterIV::readIVFile() "
                               << "Cannot open file " << fileName << std::endl;
        return ReadResult::ERROR_IN_READING_FILE;
    }

    // Perform reading from SoInput
    return readNodeFromSoInput(input, fileName, options);
}
开发者ID:LaurensVoerman,项目名称:OpenSceneGraph,代码行数:31,代码来源:ReaderWriterIV.cpp

示例5:

//!loading the virtual scene
void
vpSimulator::load(const char *file_name)
{

  SoInput input;
  if (!input.openFile(file_name))
  {
    vpERROR_TRACE("Erreur cannot open file %s",file_name);
  }

  SoSeparator *newscene=SoDB::readAll(&input);
  newscene->ref() ;
  if (newscene==NULL)
  {
    vpERROR_TRACE("Error while reading %s",file_name);
  }
  
  SoScale *taille = new SoScale;
  taille->scaleFactor.setValue (zoomFactor, zoomFactor, zoomFactor);

//  newscene->addChild(taille);

//  std::cout << "this->scene->getNumChildren() = " << this->scene->getNumChildren() << std::endl;

  this->scene->addChild(taille);
  this->scene->addChild(newscene);
  newscene->unref() ;

}
开发者ID:tswang,项目名称:visp,代码行数:30,代码来源:vpSimulator.cpp

示例6: 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;
}
开发者ID:Aconex,项目名称:pcp,代码行数:35,代码来源:scenefileobj.cpp

示例7: if

void
DragDropHandlerP::dropEvent(QDropEvent * event)
{
  const QMimeData * mimedata = event->mimeData();

  SoSeparator * root;
  SoInput in;
  QByteArray bytes;

  if (mimedata->hasUrls()) {
    QUrl url = mimedata->urls().takeFirst();
    if (url.scheme().isEmpty() || url.scheme().toLower() == QString("file") ) {
      // attempt to open file
      if (!in.openFile(url.toLocalFile().toLatin1().constData())) return;
    }
  } else if (mimedata->hasText()) {
    /* FIXME 2007-11-09 preng: dropping text buffer does not work on Windows Vista. */
    bytes = mimedata->text().toUtf8();
    in.setBuffer((void *) bytes.constData(), bytes.size());
    if (!in.isValidBuffer()) return;
  }

  // attempt to import it
  root = SoDB::readAll(&in);
  if (root == NULL) return;

  // set new scenegraph
  this->quarterwidget->setSceneGraph(root);
  this->quarterwidget->viewport()->update();
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:30,代码来源:DragDropHandler.cpp

示例8: 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 ;
}
开发者ID:pmitros,项目名称:ball,代码行数:31,代码来源:main.cpp

示例9: 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;
}
开发者ID:Lillian003,项目名称:tonatiuh,代码行数:38,代码来源:Document.cpp

示例10: loadIvFile

bool QCtkXipSGWidget::loadIvFile(const QString& ivFileName)
{
  if(!QFile::exists(ivFileName))
  {
    QString pwd = QDir::currentPath();
    return false;
  }

  std::string ivFileNameStr(ivFileName.toStdString());
  const char *ivStr = (const char*) ivFileNameStr.c_str();

  SoInput in;
  in.openFile(ivStr); // file
  SoSeparator *topNode = SoDB::readAll(&in);
  if (topNode)
  {
    if(mRoot)
    {
      mRoot->removeAllChildren();
      mRoot->addChild(topNode);

      return true;

    }
  }


  return false;

}
开发者ID:ivowolf,项目名称:vtkIvPropProject,代码行数:30,代码来源:qCtkXipSGWidget.cpp

示例11:

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;
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:41,代码来源:SoTexture2.cpp

示例12: assert

void
SoXtMaterialList::selectionCallback(// private
  int materialid)
{
  materialid--; // get index
  SoXtMaterialDirectory * data = common->getMaterialDirectory();

  assert(materialid >= 0 &&
          materialid < data->groups[data->current]->numMaterials);
  const char * materialdata =
    data->groups[data->current]->materials[materialid]->data;

  SoInput reader;
  if (data->flags & SOXT_BUILTIN_MATERIALS) {
    reader.setBuffer((void *) materialdata, strlen(materialdata));
  } else {
    if (! reader.openFile(materialdata, FALSE)) {
      SoDebugError::postWarning("SoXtMaterialList::selectionCallback",
        "could not open file: \"%s\"", materialdata);
      return;
    }
  }

  SoNode * material = NULL;
  if (! SoDB::read(&reader, material)) {
    SoDebugError::postWarning("SoXtMaterialList::selectionCallback",
      "failed to read material");
    return;
  }
  if (! material) {
    SoDebugError::postWarning("SoXtMaterialList::selectionCallback",
      "read returned no data");
    return;
  }
  material->ref();
  if (! material->isOfType(SoMaterial::getClassTypeId())) {
    SoDebugError::postWarning("SoXtMaterialList::selectionCallback",
      "not a material node!");
    material->unref();
    return;
  }
  common->invokeCallbacks((SoMaterial *) material);
  material->unref();
} // selectionCallback()
开发者ID:ALLPix,项目名称:SoXt,代码行数:44,代码来源:SoXtMaterialList.cpp

示例13: 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;
}
开发者ID:BackupTheBerlios,项目名称:qilex-svn,代码行数:20,代码来源:qilexdoc.cpp

示例14: 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;
}
开发者ID:JenniferBuehler,项目名称:urdf-tools-pkgs,代码行数:20,代码来源:InventorViewer.cpp

示例15:

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...
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:40,代码来源:SoFile.cpp


注:本文中的SoInput::openFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。