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 VRMLFile *VRMLSceneFileType::_pVRMLLoader = NULL;
00065
00066
00067
00068
00069 VRMLSceneFileType &VRMLSceneFileType::the(void)
00070 {
00071 return _the;
00072 }
00073
00074
00075
00076
00077
00078 VRMLSceneFileType::~VRMLSceneFileType(void)
00079 {
00080 }
00081
00082
00083
00084
00085 const Char8 *VRMLSceneFileType::getName(void) const
00086 {
00087 return "VRML GEOMETRY";
00088 }
00089
00090
00091
00092
00093 NodePtr VRMLSceneFileType::read(std::istream &is, const Char8 *) const
00094 {
00095 if(_pVRMLLoader == NULL)
00096 {
00097 _pVRMLLoader = new VRMLFile();
00098
00099
00100 _pVRMLLoader->createStandardPrototypes();
00101 }
00102
00103 _pVRMLLoader->scanStream(is);
00104
00105 return _pVRMLLoader->getRoot();
00106 }
00107
00108
00109
00110
00111 bool VRMLSceneFileType::write(const NodePtr &node, std::ostream &os,
00112 const Char8 *fileNameOrExtension) const
00113 {
00114
00115 std::ofstream *osf = dynamic_cast<std::ofstream *>(&os);
00116 if(osf != NULL)
00117 osf->close();
00118
00119 VRMLWriteAction *pWriter = VRMLWriteAction::create();
00120
00121 pWriter->open(fileNameOrExtension);
00122
00123 pWriter->write(node);
00124
00125 pWriter->close();
00126
00127 return true;
00128 }
00129
00130
00131
00132
00133 VRMLSceneFileType::VRMLSceneFileType(const Char8 *suffixArray[],
00134 UInt16 suffixByteCount,
00135 bool override,
00136 UInt32 overridePriority,
00137 UInt32 flags) :
00138 Inherited(suffixArray,
00139 suffixByteCount,
00140 override,
00141 overridePriority,
00142 flags)
00143 {
00144 }
00145
00146
00147
00148
00149
00150 #ifdef __sgi
00151 #pragma set woff 1174
00152 #endif
00153
00154 #ifdef OSG_LINUX_ICC
00155 #pragma warning( disable : 177 )
00156 #endif
00157
00158 namespace
00159 {
00160 static Char8 cvsid_cpp[] = "@(#)$Id: $";
00161 static Char8 cvsid_hpp[] = OSGVRMLSCENEFILETYPE_HEADER_CVSID;
00162 }
00163