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 handleError (const Char8 *szErrorText);
00135
00136 virtual void beginFieldDecl(const Char8 *szFieldType,
00137 const UInt32 uiFieldTypeId,
00138 const Char8 *szFieldName);
00139
00140
00141 virtual void beginNode (const Char8 *szNodeTypename,
00142 const Char8 *szNodename);
00143
00144 virtual void endNode (void);
00145
00146 virtual void beginScript (const Char8 *szNodename);
00147
00148 virtual void endScript (void);
00149
00150
00151 virtual void beginField (const Char8 *szFieldname,
00152 const UInt32 uiFieldTypeId);
00153
00154 virtual void endField (void);
00155
00156
00157 virtual void addFieldValue(const Char8 *szFieldVal);
00158
00159
00160 virtual UInt32 getFieldType (const Char8 *szFieldname);
00161
00162
00163 virtual void use (const Char8 *szName);
00164
00166
00170 void scanStandardPrototypes (const Char8 *szFilename);
00171
00172 void createStandardPrototypes(void);
00173
00174 NodePtr getRoot (void);
00175
00177
00178 protected:
00179
00180 typedef std::pair<BitVector,
00181 BitVector> MaskPair;
00182
00183 typedef std::map<IDString, FieldContainerPtr> NameContainerMap;
00184 typedef std::map<IDString, VRMLNodeDesc *> NameDescriptionMap;
00185 typedef std::stack< MaskPair > MaskStack;
00186
00187
00191
00192 NodePtr _pSceneRootNode;
00193
00194 NodePtr _pLightRoot;
00195 NodePtr _pCurrentGlobalLight;
00196
00197 VRMLNodeDesc * _pCurrNodeDesc;
00198 std::stack<VRMLNodeDesc *> _sNodeDescs;
00199
00200 FieldContainerPtr _pCurrentFC;
00201 Field *_pCurrentField;
00202 const FieldDescription *_pCurrentFieldDesc;
00203
00204 std::stack< FieldContainerPtr > _fcStack;
00205 std::stack< Field *> _fStack;
00206 std::stack<const FieldDescription *> _fdStack;
00207
00208 MaskPair _bvChanged;
00209 MaskStack _sChangedStack;
00210
00211 NameContainerMap _nameFCMap;
00212 NameDescriptionMap _nameDescMap;
00213
00214 void initIntExtFieldTypeMapper(void);
00215 void initExtIntFieldTypeMapper(void);
00216
00217 FieldContainerPtr findFCByName (const Char8 *szName,
00218 NodePtr pNode);
00219
00220 void setContainerFieldValue (const FieldContainerPtr &pFC);
00221
00222 FieldContainerPtr findReference (const Char8 *szName);
00223
00225
00226 private:
00227
00229 VRMLFile(const VRMLFile &source);
00231 void operator =(const VRMLFile &source);
00232 };
00233
00234 OSG_END_NAMESPACE
00235
00236 #define OSGVRMLFILE_HEADER_CVSID "@(#)$Id: $"
00237
00238 #endif