root/OpenSceneGraph/trunk/src/osgPlugins/dot/ReaderWriterDOT.cpp @ 13041

Revision 13041, 1.9 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13#include <osgDB/ReaderWriter>
14#include <osgDB/FileUtils>
15#include <osgDB/FileNameUtils>
16#include "SimpleDotVisitor.h"
17
18class ReaderWriterDOT : public osgDB::ReaderWriter {
19  public:
20    virtual const char* className() const { return "DOT Writer"; }
21    virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"dot"); }
22
23    virtual WriteResult writeNode(const osg::Node& node,const std::string& fileName,const Options* options = NULL) const {
24      std::string ext = osgDB::getFileExtension(fileName);
25      if (!acceptsExtension(ext)) {
26        return WriteResult::FILE_NOT_HANDLED;
27      }
28
29      osgDB::ofstream o( fileName.c_str(), std::ios_base::out );
30      if ( o ) {
31        return writeNode( node, o, options );
32      }
33
34      return WriteResult(WriteResult::ERROR_IN_WRITING_FILE);
35    }
36
37    virtual WriteResult writeNode(const osg::Node& node,std::ostream& fout,const Options* options = NULL) const
38    {
39      osgDot::SimpleDotVisitor sdv;
40      sdv.setOptions(options);
41      sdv.run( *const_cast<osg::Node*>( &node ), &fout );
42      return WriteResult(WriteResult::FILE_SAVED);
43    }
44};
45
46// now register with Registry to instantiate the above
47// reader/writer.
48REGISTER_OSGPLUGIN(dot, ReaderWriterDOT)
Note: See TracBrowser for help on using the browser.