00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include <stdlib.h>
00040 #include <stdio.h>
00041
00042 #include <fstream>
00043
00044 #include "OSGConfig.h"
00045
00046 #include "OSGVRMLSceneFileType.h"
00047 #include "OSGVRMLWriteAction.h"
00048
00049 OSG_USING_NAMESPACE
00050
00055 const Char8 *VRMLSceneFileType::_suffixA[] = { "wrl" };
00056
00057 VRMLSceneFileType VRMLSceneFileType::_the(_suffixA,
00058 sizeof(_suffixA),
00059 false,
00060 10,
00061 OSG_READ_SUPPORTED |
00062 OSG_WRITE_SUPPORTED);
00063
00064
00065
00066
00067 VRMLSceneFileType &VRMLSceneFileType::the(void)
00068 {
00069 return _the;
00070 }
00071
00072
00073
00074
00075
00076 VRMLSceneFileType::~VRMLSceneFileType(void)
00077 {
00078 }
00079
00080
00081
00082
00083 const Char8 *VRMLSceneFileType::getName(void) const
00084 {
00085 return "VRML Geometry";
00086 }
00087
00088
00089
00090
00091 NodePtr VRMLSceneFileType::read(std::istream &is, const Char8 *) const
00092 {
00093 NodePtr root = NullFC;
00094
00095 VRMLFile *loader = new VRMLFile();
00096 loader->createStandardPrototypes();
00097 loader->scanStream(is);
00098 root = loader->getRoot();
00099 delete loader;
00100
00101 return root;
00102 }
00103
00104
00105
00106
00107 bool VRMLSceneFileType::write(const NodePtr &node, std::ostream &os,
00108 const Char8 *fileNameOrExtension) const
00109 {
00110
00111 std::ofstream *osf = dynamic_cast<std::ofstream *>(&os);
00112 if(osf != NULL)
00113 osf->close();
00114
00115 VRMLWriteAction *pWriter = VRMLWriteAction::create();
00116
00117
00118 if(_options.find("inlineTextures=true") != std::string::npos)
00119 pWriter->addOptions(VRMLWriteAction::OSGPixelTextures);
00120 else if(_options.find("inlineTextures=false") != std::string::npos)
00121 pWriter->subOptions(VRMLWriteAction::OSGPixelTextures);
00122
00123 pWriter->open(fileNameOrExtension);
00124
00125 pWriter->write(node);
00126
00127 pWriter->close();
00128
00129 delete pWriter;
00130
00131 return true;
00132 }
00133
00134
00135
00136
00137 VRMLSceneFileType::VRMLSceneFileType(const Char8 *suffixArray[],
00138 UInt16 suffixByteCount,
00139 bool override,
00140 UInt32 overridePriority,
00141 UInt32 flags) :
00142 Inherited(suffixArray,
00143 suffixByteCount,
00144 override,
00145 overridePriority,
00146 flags)
00147 {
00148 }
00149
00150
00151
00152
00153
00154 #ifdef __sgi
00155 #pragma set woff 1174
00156 #endif
00157
00158 #ifdef OSG_LINUX_ICC
00159 #pragma warning( disable : 177 )
00160 #endif
00161
00162 namespace
00163 {
00164 static Char8 cvsid_cpp[] = "@(#)$Id: $";
00165 static Char8 cvsid_hpp[] = OSGVRMLSCENEFILETYPE_HEADER_CVSID;
00166 }
00167