//////////////////////////////////////////////////////////////////////////////
//
//  Description:
//    Convert the passed path list to a byte stream.
//    binaryFormat determines whether to copy the data in binary (TRUE) or
//    ascii (FALSE) format.
//
//  Use: public
//
void
SoByteStream::convert(SoPathList *pathList, SbBool binaryFormat)
//
//////////////////////////////////////////////////////////////////////////////
{
    // clear out any old data
    if (data != NULL) {
	free(data);
	data = NULL;
	numBytes = 0;
    }
	
    if ((pathList == NULL) || (pathList->getLength() == 0))
	return;

    // Write all the paths in the path list into an in-memory buffer
    SoWriteAction wa;
    SoOutput *out = wa.getOutput();
    out->setBinary(binaryFormat);
    out->setBuffer(malloc(128), 128, realloc);

    for (int i = 0; i < pathList->getLength(); i++) {
    	wa.apply((*pathList)[i]);
    }

    // Point to the byte stream data
    void *buf;
    size_t size;

    out->getBuffer(buf, size);
    data = buf;
    numBytes = (uint32_t) size;
    isRaw = FALSE;
}
Exemple #2
0
int main(int argc, char** argv)
{
    QWidget* mainwin = SoQt::init(argc, argv, argv[0]);

    SoSeparator* root = new SoSeparator;
    root->ref();
    InventorRobot robot(root);

    if (argc == 1){
        //robot.parse("../RobotEditorArmar4.dae");
        //robot.parse("/media/sf_host/manikin_creo_4.dae");
        std::cout << "Usage collada <collada file> [<inventor export>]" <<std::endl;
        return 1;
    }
    else {
        robot.parse(argv[1]);
        if (argc==3){
            SoWriteAction writeAction;
            writeAction.getOutput()->openFile(argv[2]);
            writeAction.apply(root);
        }
    }

    SoQtExaminerViewer* viewer = new SoQtExaminerViewer(mainwin);
    viewer->setSceneGraph(root);
    viewer->show();

    // Pop up the main window.
    SoQt::show(mainwin);
    // Loop until exit.
    SoQt::mainLoop();

    root->unref();
    return 1;
}
Exemple #3
0
void
SoDebug::write(SoNode *node)
//
////////////////////////////////////////////////////////////////////////
{
    node->ref();

    SoWriteAction	wa;
    wa.apply(node);

    node->unrefNoDelete();
}
Exemple #4
0
void
SoDebug::writeFile(SoNode *node, const char *filename)
//
////////////////////////////////////////////////////////////////////////
{
    node->ref();

    if (filename == NULL) filename = "/tmp/debug.iv";

    SoWriteAction	wa;
    wa.getOutput()->openFile(filename);
    wa.apply(node);

    node->unrefNoDelete();
}
void
main(int, char **argv)
{
    SoDB::init();

    root = new SoSeparator;
    root->ref();

    parse();

    SoWriteAction writeit;

    writeit.getOutput()->setFilePointer(stdout);
    writeit.getOutput()->setBinary(FALSE);
    writeit.apply(root);
}
Exemple #6
0
/*!
 * Writes the document scene to a file with the given \a fileName.
 *
 * Returns true if the scene was successfully written; otherwise returns false.
 */
bool Document::WriteFile( const QString& fileName )
{
    SoWriteAction SceneOuput;
    if ( !SceneOuput.getOutput()->openFile( fileName.toLatin1().constData() ) )
	{
		QString message = QString( "Cannot open file %1." ).arg( fileName );
		emit Warning( message );

   		return false;
   	}

    QApplication::setOverrideCursor( Qt::WaitCursor );
   	SceneOuput.getOutput()->setBinary( false );
   	SceneOuput.apply( m_scene );
   	SceneOuput.getOutput()->closeFile();
   	QApplication::restoreOverrideCursor();
   	m_isModified = false;
	return true;
}
Exemple #7
0
void
SoDebug::writeField(SoField *field)
//
////////////////////////////////////////////////////////////////////////
{
    SoFieldContainer *fc = field->getContainer();

    SbName fieldName;
    fc->getFieldName(field, fieldName);
    printf("Field name is: %s\n", fieldName.getString());
    if (fc->isOfType(SoNode::getClassTypeId())) {
	printf("Field is part of node:\n");

	SoNode *node = (SoNode *)fc;
	node->ref();

	SoWriteAction	wa;
	wa.apply(node);

	node->unrefNoDelete();
    }
}