1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
44 #include "OSGConfig.h"
46 #include "OSGVRMLSceneFileType.h"
47 #include "OSGVRMLWriteAction.h"
49 #include "OSGVRMLFile.h"
53 /*! \class OSG::VRMLSceneFileType
54 \ingroup GrpSystemFileIO
57 const Char8
*VRMLSceneFileType::_suffixA
[] = { "wrl", "wrz" };
59 VRMLSceneFileType
VRMLSceneFileType::_the(_suffixA
,
64 OSG_WRITE_SUPPORTED
));
66 /*-------------------------------------------------------------------------*/
69 VRMLSceneFileType
&VRMLSceneFileType::the(void)
75 /*-------------------------------------------------------------------------*/
78 VRMLSceneFileType::~VRMLSceneFileType(void)
82 /*-------------------------------------------------------------------------*/
85 const Char8
*VRMLSceneFileType::getName(void) const
87 return "VRML Geometry";
90 /*-------------------------------------------------------------------------*/
93 NodeTransitPtr
VRMLSceneFileType::read( std::istream
&is
,
97 NodeTransitPtr
root(NULL
);
99 VRMLFile
*loader
= new VRMLFile();
101 bool pushNames
= false;
103 if(this->getOptionAs("pushNames", pushNames
) == true)
105 if(pushNames
== true)
106 loader
->addOptions(VRMLFile::PushNames
);
109 loader
->createStandardPrototypes();
111 root
= loader
->scanStream(is
);
120 /*-------------------------------------------------------------------------*/
123 bool VRMLSceneFileType::write(Node
* const node
,
125 Char8
const *fileNameOrExtension
) const
127 // This is a hack but should be safer.
129 std::ofstream
*osf
= dynamic_cast<std::ofstream
*>(&os
);
134 VRMLWriteAction
*pWriter
= VRMLWriteAction::create();
137 bool inlineTex
= false;
138 if(getOptionAs
<bool>("inlineTextures", inlineTex
))
141 pWriter
->addOptions(VRMLWriteAction::OSGPixelTextures
);
143 pWriter
->subOptions(VRMLWriteAction::OSGPixelTextures
);
146 pWriter
->open(fileNameOrExtension
);
148 pWriter
->write(node
);
157 /*-------------------------------------------------------------------------*/
160 VRMLSceneFileType::VRMLSceneFileType(const Char8
*suffixArray
[],
161 UInt16 suffixByteCount
,
163 UInt32 overridePriority
,
165 Inherited(suffixArray
,