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 #ifndef _OSGVRMLFILE_H_
00040 #define _OSGVRMLFILE_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045 #include <OSGSystemDef.h>
00046
00047 #include <map>
00048 #include <stack>
00049 #include <vector>
00050
00051 #include <OSGBaseTypes.h>
00052 #include <OSGScanParseSkel.h>
00053 #include <OSGScanParseFieldTypeMapper.h>
00054
00055 #include <OSGFieldContainerPtr.h>
00056 #include <OSGField.h>
00057 #include <OSGFieldContainer.h>
00058
00059 #include <OSGVRMLNodeFactory.h>
00060
00061 OSG_BEGIN_NAMESPACE
00062
00063 typedef VRMLNodeFactory<ScanParseFieldTypeMapper<ScanParseSkel> > Parent;
00064
00065 #if __GNUC__ >= 3
00066 # if __GNUC_MINOR__ >=4
00067 # define OSG_GCC_34 1
00068 # endif
00069 #endif
00070 # if __GNUC__ >= 4
00071 # define OSG_GCC_34 1
00072 #endif
00073
00074 #if __GNUC__ >= 4
00075 # define OSG_GCC_4 1
00076 #endif
00077
00078 #ifndef OSG_COMPILEVRMLLOADERINST
00079 #if !defined(__sgi) && !defined(__hpux) && !defined(OSG_LINUX_ICC) && \
00080 !defined(__sun) && !defined(OSG_GCC_34) && !defined(OSG_GCC_4)
00081 extern template OSG_SYSTEMLIB_DLLMAPPING
00082 ScanParseFieldTypeMapper<ScanParseSkel>;
00083 extern template OSG_SYSTEMLIB_DLLMAPPING
00084 VRMLNodeFactory<ScanParseFieldTypeMapper<ScanParseSkel> >;
00085 #endif
00086 #endif
00087
00090
00091 class OSG_SYSTEMLIB_DLLMAPPING VRMLFile : public Parent
00092 {
00093
00094 protected:
00095
00096 typedef Parent Inherited;
00097 typedef VRMLFile Self;
00098
00099
00100 public:
00101
00102 enum
00103 {
00104 CreateNormals = Inherited::LastOption << 1,
00105 StripeGeometry = CreateNormals << 1,
00106 LogProtoGeneration = StripeGeometry << 1,
00107 LogObjectGeneration = LogProtoGeneration << 1,
00108
00109 LastOption = LogObjectGeneration
00110 };
00111
00112
00116 VRMLFile(void);
00117
00119
00123 virtual ~VRMLFile(void);
00124
00126
00130 virtual void scanStream (std::istream &is);
00131
00132 virtual void scanFile (const Char8 *szFilename);
00133
00134 virtual void beginFieldDecl(const Char8 *szFieldType,
00135 const UInt32 uiFieldTypeId,
00136 const Char8 *szFieldName);
00137
00138
00139 virtual void beginNode (const Char8 *szNodeTypename,
00140 const Char8 *szNodename);
00141
00142 virtual void endNode (void);
00143
00144 virtual void beginScript (const Char8 *szNodename);
00145
00146 virtual void endScript (void);
00147
00148
00149 virtual void beginField (const Char8 *szFieldname,
00150 const UInt32 uiFieldTypeId);
00151
00152 virtual void endField (void);
00153
00154
00155 virtual void addFieldValue(const Char8 *szFieldVal);
00156
00157
00158 virtual UInt32 getFieldType (const Char8 *szFieldname);
00159
00160
00161 virtual void use (const Char8 *szName);
00162
00164
00168 void scanStandardPrototypes (const Char8 *szFilename);
00169
00170 void createStandardPrototypes(void);
00171
00172 NodePtr getRoot (void);
00173
00175
00176 protected:
00177
00178 typedef std::map<IDString, FieldContainerPtr> NameContainerMap;
00179 typedef std::map<IDString, VRMLNodeDesc *> NameDescriptionMap;
00180
00181
00185
00186 NodePtr _pSceneRootNode;
00187
00188 NodePtr _pLightRoot;
00189 NodePtr _pCurrentGlobalLight;
00190
00191 VRMLNodeDesc * _pCurrNodeDesc;
00192 std::stack<VRMLNodeDesc *> _sNodeDescs;
00193
00194 FieldContainerPtr _pCurrentFC;
00195 Field *_pCurrentField;
00196 const FieldDescription *_pCurrentFieldDesc;
00197
00198 std::stack< FieldContainerPtr > _fcStack;
00199 std::stack< Field *> _fStack;
00200 std::stack<const FieldDescription *> _fdStack;
00201
00202 NameContainerMap _nameFCMap;
00203 NameDescriptionMap _nameDescMap;
00204
00205 void initIntExtFieldTypeMapper(void);
00206 void initExtIntFieldTypeMapper(void);
00207
00208 FieldContainerPtr findFCByName (const Char8 *szName,
00209 NodePtr pNode);
00210
00211 void setContainerFieldValue (const FieldContainerPtr &pFC);
00212
00213 FieldContainerPtr findReference (const Char8 *szName);
00214
00216
00217 private:
00218
00220 VRMLFile(const VRMLFile &source);
00222 void operator =(const VRMLFile &source);
00223 };
00224
00225 OSG_END_NAMESPACE
00226
00227 #define OSGVRMLFILE_HEADER_CVSID "@(#)$Id: $"
00228
00229 #endif