本文整理汇总了C++中SoInput类的典型用法代码示例。如果您正苦于以下问题:C++ SoInput类的具体用法?C++ SoInput怎么用?C++ SoInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SoInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ivFileNameStr
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;
}
示例3:
void SoVtkImageVariance3D::inputChanged(SoField * f)
{
// Get the KernelSize value
if ( f == &KernelSize )
{
SbVariant *vKernelSize = (SbVariant *)KernelSize.getValues(0);
SoInput input;
int nb_fields = KernelSize.getNum();
int val0;
int val1;
int val2;
for (int i=0; i < nb_fields; i++)
{
input.setBuffer((void *)vKernelSize[i].getField().getString(),256);
input.read(val0);
input.read(val1);
input.read(val2);
mObject->SetKernelSize(
(int) val0,
(int) val1,
(int) val2
);
}
}
// Get the NumberOfThreads value
if ( f == &NumberOfThreads )
SO_VTK_SET_FIELD_VALUE( mObject, NumberOfThreads);
mObject->Update();
}
示例4: 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 ;
}
}
示例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() ;
}
示例6: 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();
}
示例7: 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;
}
示例8: inputChanged
void SoVtkOutlineFilter::inputChanged(SoField * f)
{
// Get the InputArrayToProcess value
if ( f == &InputArrayToProcess )
{
SbVariant vInputArrayToProcess = (SbVariant)InputArrayToProcess.getValue();
SoInput input;
int val0;
int val1;
int val2;
int val3;
SbString val4;
input.setBuffer((void *)vInputArrayToProcess.getField().getString(),256);
input.read(val0);
input.read(val1);
input.read(val2);
input.read(val3);
input.read(val4);
mObject->SetInputArrayToProcess(
(int) val0,
(int) val1,
(int) val2,
(int) val3,
val4.getString()
);
}
//mObject->Update();
}
示例9: 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;
}
示例10: SO_VTK_SET_FIELD_DATA
void SoVtkGenericProbeFilter::inputChanged(SoField * f)
{
// Get the Source value
if ( f == &Source )
SO_VTK_SET_FIELD_DATA( mObject, Source, vtkGenericDataSet);
// Get the NumberOfInputConnections value
if ( f == &NumberOfInputConnections )
{
SbVariant *vNumberOfInputConnections = (SbVariant *)NumberOfInputConnections.getValues(0);
SoInput input;
int nb_fields = NumberOfInputConnections.getNum();
int val0;
int val1;
for (int i=0; i < nb_fields; i++)
{
input.setBuffer((void *)vNumberOfInputConnections[i].getField().getString(),256);
input.read(val0);
input.read(val1);
//mObject->SetNumberOfInputConnections( (int) val0, (int) val1 );
}
}
mObject->Update();
}
示例11: 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;
}
示例12: 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 ;
}
示例13: LightManip
void LightManip(SoSeparator * root)
{
SoInput in;
in.setBuffer((void *)scenegraph, std::strlen(scenegraph));
SoSeparator * _root = SoDB::readAll( &in );
if ( _root == NULL ) return; // Shouldn't happen.
root->addChild(_root);
root->ref();
const char * pointlightnames[3] = { "RedLight", "GreenLight", "BlueLight" };
SoSearchAction sa;
for (int i = 0; i < 3; i++) {
sa.setName( pointlightnames[i] );
sa.setInterest( SoSearchAction::FIRST );
sa.setSearchingAll( false );
sa.apply( root );
SoPath * path = sa.getPath();
if ( path == NULL) return; // Shouldn't happen.
SoPointLightManip * manip = new SoPointLightManip;
manip->replaceNode( path );
}
}
示例14: inputChanged
void SoVtkFieldData::inputChanged(SoField * f)
{
// Get the Component value
if ( f == &Component )
{
SbVariant *vComponent = (SbVariant *)Component.getValues(0);
SoInput input;
int nb_fields = Component.getNum();
vtkIdType val0;
int val1;
double val2;
for (int i=0; i < nb_fields; i++)
{
input.setBuffer((void *)vComponent[i].getField().getString(),256);
input.read(val0);
input.read(val1);
input.read(val2);
mObject->SetComponent(
(const vtkIdType) val0,
(const int) val1,
(const double) val2
);
}
}
}
示例15: reset
void SoVtkFieldData::reset()
{
mObject->UnRegister(0);
mObject->Delete();
mObject = 0;
mObject = vtkFieldData::New();
mObject->Register(0);
mObject->SetGlobalWarningDisplay(0);
// Get the input type(s)
// Get the Component value
if (addCalled == 1)
{
SbVariant *vComponent = (SbVariant *)Component.getValues(0);
SoInput input;
int nb_fields = Component.getNum();
vtkIdType val0;
int val1;
double val2;
for (int i=0; i < nb_fields; i++)
{
input.setBuffer((void *)vComponent[i].getField().getString(),256);
input.read(val0);
input.read(val1);
input.read(val2);
mObject->SetComponent(
(const vtkIdType) val0,
(const int) val1,
(const double) val2
);
}
}
}