osg::OSGLoader Class Reference

native osg loader (vrml syntax)

#include <OSGLoader.h>

Inheritance diagram for osg::OSGLoader:

osg::ScanParseFieldTypeMapper< BaseT >

List of all members.

Member



FieldContainerPtr _pCurrentFC
NodePtr _pRootNode
Field_pCurrentField
const FieldDescription_pCurrentFieldDesc
NamedFCMap _defMap
std::stack< FieldContainerPtr_fcStack
std::stack< Field * > _fStack
std::stack< const
FieldDescription * > 
_fdStack
void initFieldTypeMapper (void)
void setFieldContainerValue (FieldContainerPtr pNewNode)

Public Member Functions

Constructors


 OSGLoader (void)
 Constructor.
Destructor


virtual ~OSGLoader (void)
 Destructor.
Skel replacements


virtual void scanStream (std::istream &is)
virtual void beginNode (const Char8 *szNodeTypename, const Char8 *szNodename)
virtual void endNode (void)
virtual void use (const Char8 *szName)
virtual void beginField (const Char8 *szFieldname, const UInt32 uiFieldTypeId)
virtual void endField (void)
virtual void addFieldValue (const Char8 *szFieldVal)
virtual Int32 mapExtIntFieldType (const Char8 *szFieldname, const Int32 iFieldTypeId)
virtual UInt32 getFieldType (const Char8 *szFieldname)
Get


virtual NodePtr getRootNode (void)
virtual std::vector
< FieldContainerPtr
getRootNodes (void)
virtual FieldContainerPtr getReference (const Char8 *szName)
Set


void setExtIntMapping (BuildInFieldTypes eBuildInType, UInt32 uiMappedType)
void setIntExtMapping (UInt32 uiMappedType, BuildInFieldTypes eBuildInType)
Map


virtual Int32 mapIntExtFieldType (const Char8 *szFieldname, const Int32 iFieldTypeId)

Protected Types

typedef Inherited::BuildInFieldType BuildInFieldTypes
typedef std::map
< BuildInFieldTypes, UInt32
IntExtMap
typedef std::map< UInt32,
BuildInFieldTypes
ExtIntMap

Protected Attributes

Member


IntExtMap _mIntExt
ExtIntMap _mExtInt

Private Types

typedef
ScanParseFieldTypeMapper
< ScanParseSkel
Inherited
typedef std::map< std::string,
FieldContainerPtr
NamedFCMap
typedef OSGLoader Self

Private Member Functions

 OSGLoader (const OSGLoader &source)
 prohibit default function (move to 'public' if needed)
void operator= (const OSGLoader &source)
 prohibit default function (move to 'public' if needed)


Detailed Description

Definition at line 64 of file OSGLoader.h.


Member Typedef Documentation

Reimplemented from osg::ScanParseFieldTypeMapper< BaseT >.

Definition at line 70 of file OSGLoader.h.

typedef std::map<std::string, FieldContainerPtr> osg::OSGLoader::NamedFCMap [private]

Definition at line 72 of file OSGLoader.h.

typedef OSGLoader osg::OSGLoader::Self [private]

Definition at line 73 of file OSGLoader.h.

template<class BaseT>
typedef Inherited::BuildInFieldType osg::ScanParseFieldTypeMapper< BaseT >::BuildInFieldTypes [protected, inherited]

Definition at line 61 of file OSGScanParseFieldTypeMapper.h.

template<class BaseT>
typedef std::map<BuildInFieldTypes, UInt32 > osg::ScanParseFieldTypeMapper< BaseT >::IntExtMap [protected, inherited]

Definition at line 64 of file OSGScanParseFieldTypeMapper.h.

template<class BaseT>
typedef std::map<UInt32, BuildInFieldTypes> osg::ScanParseFieldTypeMapper< BaseT >::ExtIntMap [protected, inherited]

Definition at line 66 of file OSGScanParseFieldTypeMapper.h.


Constructor & Destructor Documentation

OSGLoader::OSGLoader ( void   ) 

Definition at line 364 of file OSGLoader.cpp.

References initFieldTypeMapper().

00364                          :
00365     Inherited(),
00366     _pCurrentFC   (NullFC),
00367     _pRootNode    (NullFC),
00368     _pCurrentField(NULL),
00369     _fcStack      (),
00370     _fStack       (),
00371     _fdStack      ()
00372 {
00373     Self::setReferenceHeader("#OSG V1.0 ");
00374     initFieldTypeMapper();
00375 }

OSGLoader::~OSGLoader ( void   )  [virtual]

Definition at line 380 of file OSGLoader.cpp.

00381 {
00382 }

osg::OSGLoader::OSGLoader ( const OSGLoader source  )  [private]


Member Function Documentation

void OSGLoader::scanStream ( std::istream &  is  )  [virtual]

Definition at line 386 of file OSGLoader.cpp.

References _defMap, _pCurrentFC, _pCurrentField, _pCurrentFieldDesc, _pRootNode, and osg::NullFC.

Referenced by osg::OSGSceneFileType::read().

00387 {
00388     if(is)
00389     {
00390         _pRootNode         = NullFC;
00391         _pCurrentFC        = NullFC;
00392         _pCurrentField     = NULL;
00393         _pCurrentFieldDesc = NULL;
00394         _defMap.clear();
00395 
00396         Inherited::scanStream(is);
00397     }
00398 }

void OSGLoader::beginNode ( const Char8 szNodeTypename,
const Char8 szNodename 
) [virtual]

Definition at line 404 of file OSGLoader.cpp.

References _defMap, _fcStack, _pCurrentFC, _pRootNode, osg::beginEditCP(), osg::Node::ChildrenFieldMask, osg::Node::CoreFieldMask, osg::GroupBase::create(), osg::Node::create(), osg::FieldContainerFactory::createFieldContainer(), osg::NodePtr::dcast(), osg::AttachmentContainerPtr::dcast(), osg::endEditCP(), osg::NullFC, PINFO, setFieldContainerValue(), osg::setName(), SLOG, and osg::FieldContainerFactory::the().

00406 {
00407     FieldContainerPtr pNewNode;
00408 
00409     if(szNodeTypename == NULL)
00410         return;
00411 
00412     PINFO << "Begin node : " << szNodeTypename << " | ";
00413 
00414     if(szNodename == NULL)
00415     {
00416         PINFO << "NULL";
00417     }
00418     else
00419     {
00420         PINFO << szNodename;
00421     }
00422 
00423     PINFO << std::endl;
00424 
00425     pNewNode =
00426         FieldContainerFactory::the()->createFieldContainer(szNodeTypename);
00427 
00428     if(szNodename != NULL && pNewNode != NullFC)
00429     {
00430         AttachmentContainerPtr pAttCon =
00431             AttachmentContainerPtr::dcast(pNewNode);
00432 
00433         if(pAttCon != NullFC)
00434         {
00435             setName(pAttCon, szNodename);
00436         }
00437 
00438         _defMap.insert(std::make_pair(std::string(szNodename), pNewNode));
00439     }
00440 
00441     // assign nodepointer to current sf|mf field
00442     setFieldContainerValue(pNewNode);
00443 
00444     _pCurrentFC = pNewNode;
00445 
00446     _fcStack.push(_pCurrentFC);
00447 
00448     if(_fcStack.size() == 1)
00449     {
00450         NodePtr pNode;
00451         if(_pCurrentFC->getType().isNode())
00452         {
00453             pNode = NodePtr::dcast(_pCurrentFC);
00454         }
00455         else if(_pCurrentFC->getType().isNodeCore())
00456         {
00457             pNode = Node::create();
00458             pNode->setCore(NodeCorePtr::dcast(_pCurrentFC));
00459         }
00460         else
00461         {
00462             SLOG << "Fieldcontainer " << szNodeTypename
00463                  << "is neither Node nor NodeCore " << std::endl;
00464         }
00465 
00466         if(_pRootNode == NullFC)
00467         {
00468             GroupPtr pGroup = Group::create();
00469 
00470             _pRootNode = Node::create();
00471 
00472             beginEditCP(_pRootNode, Node::CoreFieldMask);
00473             {
00474                 _pRootNode->setCore(pGroup);
00475             }
00476             endEditCP  (_pRootNode, Node::CoreFieldMask);
00477         }
00478 
00479         beginEditCP(_pRootNode, Node::ChildrenFieldMask);
00480         {
00481             _pRootNode->addChild(pNode);
00482         }
00483         endEditCP  (_pRootNode, Node::ChildrenFieldMask);
00484     }
00485 }

void OSGLoader::endNode ( void   )  [virtual]

Definition at line 491 of file OSGLoader.cpp.

References _fcStack, _pCurrentFC, osg::GroupBase::create(), osg::NodePtr::dcast(), osg::NodePtr::getCore(), osg::NullFC, and PINFO.

00492 {
00493     PINFO << "End Node" << std::endl;
00494 
00495     if(_pCurrentFC != NullFC)
00496     {
00497         if(_pCurrentFC->getType().isNode() == true)
00498         {
00499             NodePtr pNode = NodePtr::dcast(_pCurrentFC);
00500 
00501             if(pNode->getCore() == NullFC)
00502             {
00503                 GroupPtr pGroup = Group::create();
00504 
00505                 pNode->setCore(pGroup);
00506             }
00507         }
00508     }
00509 
00510     _fcStack.pop();
00511 
00512     if(_fcStack.size() != 0)
00513     {
00514         _pCurrentFC = _fcStack.top();
00515     }
00516     else
00517     {
00518         _pCurrentFC = NullFC;
00519     }
00520 }

void OSGLoader::use ( const Char8 szName  )  [virtual]

Definition at line 522 of file OSGLoader.cpp.

References getReference(), osg::NullFC, setFieldContainerValue(), and SLOG.

00523 {
00524     FieldContainerPtr pUseNode;
00525 
00526     // try to find a container with the given name attachment
00527 
00528     pUseNode = getReference(szName);
00529 
00530     if(pUseNode == NullFC)
00531     {
00532         SLOG << "No FieldContainer found with name " << szName << std::endl;
00533     }
00534     else
00535     {
00536         // assign nodepointer to current sf|mf field
00537         setFieldContainerValue(pUseNode);
00538     }
00539 }

void OSGLoader::beginField ( const Char8 szFieldname,
const UInt32  uiFieldTypeId 
) [virtual]

Definition at line 641 of file OSGLoader.cpp.

References _fdStack, _fStack, _pCurrentFC, _pCurrentField, _pCurrentFieldDesc, osg::ChangedOrigin::Abstract, osg::ChangedOrigin::AbstrIgnoreChild, osg::ChangedOrigin::AbstrIgnoreCore, osg::beginEditCP(), osg::FieldDescription::getFieldMask(), osg::NullFC, and PINFO.

00643 {
00644     PINFO << "BeginField "
00645           << szFieldname
00646           << " "
00647           << _pCurrentField
00648           << std::endl;
00649 
00650     if(szFieldname == NULL)
00651         return;
00652 
00653     _pCurrentField = NULL;
00654 
00655     if(_pCurrentFC != NullFC)
00656     {
00657         _pCurrentField     = _pCurrentFC->getField(szFieldname);
00658 
00659         _pCurrentFieldDesc =
00660             _pCurrentFC->getType().findFieldDescription(szFieldname);
00661 
00662         PINFO << "BF : "
00663               <<  szFieldname       << " "
00664               << _pCurrentField     << " "
00665               << _pCurrentFieldDesc << std::endl;
00666 
00667         if(_pCurrentFieldDesc != NULL)
00668         {
00669             beginEditCP(_pCurrentFC,
00670                         _pCurrentFieldDesc->getFieldMask(),
00671                          ChangedOrigin::Abstract          |
00672                          ChangedOrigin::AbstrIgnoreCore   |
00673                          ChangedOrigin::AbstrIgnoreChild  );
00674         }
00675     }
00676 
00677     _fStack.push (_pCurrentField);
00678     _fdStack.push(_pCurrentFieldDesc);
00679 }

void OSGLoader::endField ( void   )  [virtual]

Definition at line 681 of file OSGLoader.cpp.

References _fdStack, _fStack, _pCurrentFC, _pCurrentField, _pCurrentFieldDesc, osg::ChangedOrigin::Abstract, osg::ChangedOrigin::AbstrIgnoreChild, osg::ChangedOrigin::AbstrIgnoreCore, osg::endEditCP(), osg::FieldDescription::getFieldMask(), osg::NullFC, and PINFO.

00682 {
00683     PINFO << "End Field" << std::endl;
00684 
00685     _fStack.pop();
00686 
00687     if(_fStack.size() != 0)
00688     {
00689         _pCurrentField = _fStack.top();
00690     }
00691     else
00692     {
00693         _pCurrentField = NULL;
00694     }
00695 
00696 
00697     if(_pCurrentFC != NullFC && _pCurrentFieldDesc != NULL)
00698     {
00699         endEditCP(_pCurrentFC,
00700                   _pCurrentFieldDesc->getFieldMask(),
00701                    ChangedOrigin::Abstract          |
00702                    ChangedOrigin::AbstrIgnoreCore   |
00703                    ChangedOrigin::AbstrIgnoreChild  );
00704     }
00705 
00706     _fdStack.pop();
00707 
00708     if(_fdStack.size() != 0)
00709     {
00710         _pCurrentFieldDesc = _fdStack.top();
00711     }
00712     else
00713     {
00714         _pCurrentFieldDesc = NULL;
00715     }
00716 }

void OSGLoader::addFieldValue ( const Char8 szFieldVal  )  [virtual]

Definition at line 557 of file OSGLoader.cpp.

References _pCurrentField, PINFO, and osg::Field::pushValueByStr().

00558 {
00559     PINFO << "\t\tFV : " << szFieldVal << std::endl;
00560 
00561     if(_pCurrentField != NULL)
00562     {
00563         _pCurrentField->pushValueByStr(szFieldVal);
00564     }
00565 }

Int32 OSGLoader::mapExtIntFieldType ( const Char8 szFieldname,
const Int32  iFieldTypeId 
) [virtual]

Reimplemented from osg::ScanParseFieldTypeMapper< BaseT >.

Definition at line 590 of file OSGLoader.cpp.

References _pCurrentFC, osg::FieldType::getCardinality(), osg::TypeBase::getCName(), osg::FieldType::getContentType(), osg::Field::getType(), osg::ScanParseFieldTypeMapper< BaseT >::mapExtIntFieldType(), osg::NullFC, osg::ScanParseSkel::OSGmfNode, osg::ScanParseSkel::OSGsfNode, PINFO, and osg::FieldType::SINGLE_FIELD.

00592 {
00593     Int32 returnValue = Inherited::mapExtIntFieldType(szFieldname,
00594                                                       iFieldTypeId);
00595 
00596     if(returnValue < 0 && szFieldname != NULL && _pCurrentFC != NullFC)
00597     {
00598         Field *pField = _pCurrentFC->getField(szFieldname);
00599 
00600         if(pField != NULL)
00601         {
00602             const FieldType &oFieldType = pField->getType();
00603 
00604             /* Should be this way
00605 
00606             if(oFieldType.getContentType().isDerivedFrom(
00607                 FieldDataTraits<FieldContainerPtr>::getType()) == true)
00608             {
00609             }
00610             */
00611 
00612             PINFO << "FieldTypeId invalid, trying to fix. " << std::endl;
00613             PINFO << oFieldType.getContentType().getCName()
00614                   << " comparing with "
00615                   << FieldDataTraits<FieldContainerPtr>::getType().getCName()
00616                   << std::endl;
00617 
00618 
00619             if(strstr(oFieldType.getContentType().getCName(),
00620                       "Ptr"                                 ) != NULL)
00621             {
00622                 PINFO << "FieldContainerPtr or derived class, "
00623                       << "parsing as Node"
00624                       << std::endl;
00625 
00626                 if(oFieldType.getCardinality() == FieldType::SINGLE_FIELD)
00627                 {
00628                     returnValue = ScanParseSkel::OSGsfNode;
00629                 }
00630                 else
00631                 {
00632                     returnValue = ScanParseSkel::OSGmfNode;
00633                 }
00634             }
00635         }
00636     }
00637 
00638     return returnValue;
00639 }

UInt32 OSGLoader::getFieldType ( const Char8 szFieldname  )  [virtual]

Definition at line 567 of file OSGLoader.cpp.

References _pCurrentFC, osg::FieldType::getScanTypeId(), osg::Field::getType(), osg::NullFC, and PINFO.

00568 {
00569     UInt32  returnValue = 0;
00570     Field     *pField      = NULL;
00571 
00572     if(szFieldname == NULL)
00573         return returnValue;
00574 
00575     if(_pCurrentFC != NullFC)
00576     {
00577         pField = _pCurrentFC->getField(szFieldname);
00578 
00579         PINFO << "GF : " << szFieldname << " " << pField << std::endl;
00580 
00581         if(pField != NULL)
00582         {
00583             returnValue = pField->getType().getScanTypeId();
00584         }
00585     }
00586 
00587     return returnValue;
00588 }

NodePtr OSGLoader::getRootNode ( void   )  [virtual]

Definition at line 541 of file OSGLoader.cpp.

References _pRootNode.

Referenced by osg::OSGSceneFileType::read().

00542 {
00543     return _pRootNode;
00544 }

std::vector< FieldContainerPtr > OSGLoader::getRootNodes ( void   )  [virtual]

Definition at line 546 of file OSGLoader.cpp.

References _pRootNode.

00547 {
00548     std::vector<FieldContainerPtr> fcVec;
00549 
00550     for( UInt32 i=0; i<_pRootNode->getNChildren(); ++i )
00551     {
00552         fcVec.push_back( _pRootNode->getChild(i) );
00553     }
00554     return fcVec;
00555 }

FieldContainerPtr OSGLoader::getReference ( const Char8 szName  )  [virtual]

Definition at line 718 of file OSGLoader.cpp.

References _defMap, and osg::NullFC.

Referenced by use().

00719 {
00720     // Find a previously DEF'ed FC by its name and return Ptr to it
00721 
00722     NamedFCMap::iterator entry = _defMap.find(std::string(szName));
00723 
00724     if(entry == _defMap.end())
00725         return NullFC;
00726 
00727     return entry->second; // return the stored FCPtr
00728 }

void OSGLoader::initFieldTypeMapper ( void   )  [protected]

Definition at line 129 of file OSGLoader.cpp.

References osg::MField< FieldTypeT, fieldNameSpace >::getClassType(), osg::SField< FieldTypeT, fieldNameSpace >::getClassType(), osg::ScanParseSkel::OSGmfColor3f, osg::ScanParseSkel::OSGmfColor4f, osg::ScanParseSkel::OSGmfColor4i, osg::ScanParseSkel::OSGmfFloat, osg::ScanParseSkel::OSGmfInt32, osg::ScanParseSkel::OSGmfNode, osg::ScanParseSkel::OSGmfPlane, osg::ScanParseSkel::OSGmfPnt3f, osg::ScanParseSkel::OSGmfRotation, osg::ScanParseSkel::OSGmfString, osg::ScanParseSkel::OSGmfTime, osg::ScanParseSkel::OSGmfVec2f, osg::ScanParseSkel::OSGmfVec3f, osg::ScanParseSkel::OSGmfVec4f, osg::ScanParseSkel::OSGsfBool, osg::ScanParseSkel::OSGsfColor3f, osg::ScanParseSkel::OSGsfColor4f, osg::ScanParseSkel::OSGsfColor4i, osg::ScanParseSkel::OSGsfFloat, osg::ScanParseSkel::OSGsfInt32, osg::ScanParseSkel::OSGsfMatrix, osg::ScanParseSkel::OSGsfNode, osg::ScanParseSkel::OSGsfPlane, osg::ScanParseSkel::OSGsfPnt3f, osg::ScanParseSkel::OSGsfRotation, osg::ScanParseSkel::OSGsfString, osg::ScanParseSkel::OSGsfTime, osg::ScanParseSkel::OSGsfVec2f, osg::ScanParseSkel::OSGsfVec3f, osg::ScanParseSkel::OSGsfVec4f, osg::ScanParseSkel::OSGsfVolume, and osg::ScanParseFieldTypeMapper< BaseT >::setIntExtMapping().

Referenced by OSGLoader().

00130 {
00131     setIntExtMapping(SFBool::getClassType().getId(),
00132                      ScanParseSkel::OSGsfBool);
00133 
00134 /*
00135     setIntExtMapping(ScanParseSkel::OSGsfColor,
00136                ::getClassType().getId());
00137 */
00138 
00139     setIntExtMapping(SFReal32::getClassType().getId(),
00140                      ScanParseSkel::OSGsfFloat);
00141 /*
00142     setIntExtMapping(SFImagePtr::getClassType().getId(),
00143                      ScanParseSkel::OSGsfString);
00144 */
00145     setIntExtMapping(SFInt32::getClassType().getId(),
00146                      ScanParseSkel::OSGsfInt32);
00147 
00148 
00149     setIntExtMapping(SFQuaternion::getClassType().getId(),
00150                      ScanParseSkel::OSGsfRotation);
00151 
00152     setIntExtMapping(SFString::getClassType().getId(),
00153                      ScanParseSkel::OSGsfString);
00154 
00155     setIntExtMapping(SFTime::getClassType().getId(),
00156                      ScanParseSkel::OSGsfTime);
00157 
00158     setIntExtMapping(SFVec2f::getClassType().getId(),
00159                      ScanParseSkel::OSGsfVec2f);
00160 
00161     setIntExtMapping(SFVec3f::getClassType().getId(),
00162                      ScanParseSkel::OSGsfVec3f);
00163 
00164     setIntExtMapping(SFVec4f::getClassType().getId(),
00165                      ScanParseSkel::OSGsfVec4f);
00166 
00167     setIntExtMapping(SFColor4f::getClassType().getId(),
00168                      ScanParseSkel::OSGsfColor4f);
00169 
00170     setIntExtMapping(SFColor4ub::getClassType().getId(),
00171                      ScanParseSkel::OSGsfColor4i);
00172 
00173     setIntExtMapping(SFColor3f::getClassType().getId(),
00174                      ScanParseSkel::OSGsfColor3f);
00175 
00176 /*
00177     setIntExtMapping(ScanParseSkel::OSGmfColor,
00178                ::getClassType().getId());
00179 */
00180 
00181     setIntExtMapping(MFReal32::getClassType().getId(),
00182                      ScanParseSkel::OSGmfFloat);
00183 
00184     setIntExtMapping(MFInt32::getClassType().getId(),
00185                      ScanParseSkel::OSGmfInt32);
00186 
00187     setIntExtMapping(MFQuaternion::getClassType().getId(),
00188                      ScanParseSkel::OSGmfRotation);
00189 
00190     setIntExtMapping(MFString::getClassType().getId(),
00191                      ScanParseSkel::OSGmfString);
00192 
00193     setIntExtMapping(MFTime::getClassType().getId(),
00194                      ScanParseSkel::OSGmfTime);
00195 
00196 
00197     setIntExtMapping(MFVec2f::getClassType().getId(),
00198                      ScanParseSkel::OSGmfVec2f);
00199 
00200     setIntExtMapping(MFVec3f::getClassType().getId(),
00201                      ScanParseSkel::OSGmfVec3f);
00202 
00203     setIntExtMapping(MFVec4f::getClassType().getId(),
00204                      ScanParseSkel::OSGmfVec4f);
00205 
00206     setIntExtMapping(MFColor4f::getClassType().getId(),
00207                      ScanParseSkel::OSGmfColor4f);
00208 
00209     setIntExtMapping(MFColor4ub::getClassType().getId(),
00210                      ScanParseSkel::OSGmfColor4i);
00211 
00212     setIntExtMapping(MFColor3f::getClassType().getId(),
00213                      ScanParseSkel::OSGmfColor3f);
00214 
00215     setIntExtMapping(SFNodePtr::getClassType().getId(),
00216                      ScanParseSkel::OSGsfNode);
00217     setIntExtMapping(MFNodePtr::getClassType().getId(),
00218                      ScanParseSkel::OSGmfNode);
00219 
00220 
00221     /* To Base Type Mappings */
00222 
00223     setIntExtMapping(SFUInt8::getClassType().getId(),
00224                      ScanParseSkel::OSGsfInt32);
00225     setIntExtMapping(MFUInt8::getClassType().getId(),
00226                      ScanParseSkel::OSGmfInt32);
00227 
00228     setIntExtMapping(SFInt8::getClassType().getId(),
00229                      ScanParseSkel::OSGsfInt32);
00230     setIntExtMapping(MFInt8::getClassType().getId(),
00231                      ScanParseSkel::OSGmfInt32);
00232 
00233 
00234     setIntExtMapping(SFUInt16::getClassType().getId(),
00235                      ScanParseSkel::OSGsfInt32);
00236     setIntExtMapping(MFUInt16::getClassType().getId(),
00237                      ScanParseSkel::OSGmfInt32);
00238 
00239     setIntExtMapping(SFInt16::getClassType().getId(),
00240                      ScanParseSkel::OSGsfInt32);
00241     setIntExtMapping(MFInt16::getClassType().getId(),
00242                      ScanParseSkel::OSGmfInt32);
00243 
00244 
00245     setIntExtMapping(SFUInt32::getClassType().getId(),
00246                      ScanParseSkel::OSGsfInt32);
00247     setIntExtMapping(MFUInt32::getClassType().getId(),
00248                      ScanParseSkel::OSGmfInt32);
00249 
00250     setIntExtMapping(SFGLenum::getClassType().getId(),
00251                      ScanParseSkel::OSGsfInt32);
00252     setIntExtMapping(SFGLenum::getClassType().getId(),
00253                      ScanParseSkel::OSGmfInt32);
00254 
00255 
00256     /* To Node Mappings */
00257 
00258     setIntExtMapping(SFAttachmentMap::getClassType().getId(),
00259                      ScanParseSkel::OSGmfNode);
00260 
00261     /* extended types */
00262 
00263     setIntExtMapping(SFMatrix::getClassType().getId(),
00264                      ScanParseSkel::OSGsfMatrix);
00265 
00266     setIntExtMapping(SFPnt3f::getClassType().getId(),
00267                      ScanParseSkel::OSGsfPnt3f);
00268 
00269     setIntExtMapping(MFPnt3f::getClassType().getId(),
00270                      ScanParseSkel::OSGmfPnt3f);
00271     setIntExtMapping(SFDynamicVolume::getClassType().getId(),
00272                      ScanParseSkel::OSGmfFloat);
00273 
00274     setIntExtMapping(SFPlane::getClassType().getId(),
00275                      ScanParseSkel::OSGsfPlane);
00276     setIntExtMapping(MFPlane::getClassType().getId(),
00277                      ScanParseSkel::OSGmfPlane);
00278 
00279     setIntExtMapping(SFDynamicVolume::getClassType().getId(),
00280                      ScanParseSkel::OSGsfVolume);
00281 }

void OSGLoader::setFieldContainerValue ( FieldContainerPtr  pNewNode  )  [protected]

Definition at line 283 of file OSGLoader.cpp.

References _pCurrentFC, _pCurrentField, osg::Node::create(), osg::AttachmentPtr::dcast(), osg::AttachmentContainerPtr::dcast(), osg::NodePtr::dcast(), osg::Field::getCardinality(), osg::FieldType::MULTI_FIELD, osg::NullFC, osg::FieldType::SINGLE_FIELD, and SLOG.

Referenced by beginNode(), and use().

00284 {
00285     /* Hack attack, the {S|M}FieldContainerPtr * cast is a hack until the
00286        type system is fixed to get it right */
00287 
00288     if(_pCurrentField != NULL && _pCurrentFC != NullFC && pNewNode != NullFC)
00289     {
00290         if(_pCurrentField == _pCurrentFC->getField("core"))
00291         {
00292             NodePtr     pNode = NodePtr    ::dcast(_pCurrentFC);
00293             NodeCorePtr pCore = NodeCorePtr::dcast( pNewNode);
00294 
00295             pNode->setCore(pCore);
00296         }
00297         else if(_pCurrentField == _pCurrentFC->getField("children"))
00298         {
00299             NodePtr pNode      = NodePtr::dcast(_pCurrentFC);
00300             NodePtr pChildNode;
00301             if(pNewNode->getType().isNode())
00302             {
00303                 pChildNode=NodePtr::dcast(pNewNode);
00304             }
00305             else if(pNewNode->getType().isNodeCore())
00306             {
00307                 pChildNode=Node::create();
00308                 pChildNode->setCore(NodeCorePtr::dcast(pNewNode));
00309             }
00310             else
00311             {
00312                 SLOG << "Fieldcontainer " << pNewNode->getType().getName()
00313                      << "is neither Node nor NodeCore " << std::endl;
00314             }
00315             pNode->addChild(pChildNode);
00316         }
00317         else if(_pCurrentField == _pCurrentFC->getField("attachments"))
00318         {
00319             if(pNewNode->getType().isAttachment() == true)
00320             {
00321                 AttachmentContainerPtr pAttContainer =
00322                     AttachmentContainerPtr::dcast(_pCurrentFC);
00323 
00324                 if(pAttContainer != NullFC)
00325                 {
00326                     AttachmentPtr pAtt  = AttachmentPtr::dcast(pNewNode);
00327 
00328                     pAttContainer->addAttachment(pAtt);
00329                 }
00330                 else
00331                 {
00332                     SLOG << "FieldContainer "
00333                          << _pCurrentFC->getType().getName()
00334                          << "is no attachment container"
00335                          << std::endl;
00336                 }
00337             }
00338             else
00339             {
00340                 SLOG << "FieldContainer : " << pNewNode->getType().getName()
00341                      << " is no attachment" << std::endl;
00342             }
00343         }
00344         else if(_pCurrentField->getCardinality() == FieldType::SINGLE_FIELD)
00345         {
00346             ((SFFieldContainerPtr *) _pCurrentField)->setValue(pNewNode);
00347         }
00348         else if(_pCurrentField->getCardinality() == FieldType::MULTI_FIELD)
00349         {
00350             ((MFFieldContainerPtr *) _pCurrentField)->push_back(pNewNode);
00351         }
00352     }
00353 }

void osg::OSGLoader::operator= ( const OSGLoader source  )  [private]

template<class BaseT>
void osg::ScanParseFieldTypeMapper< BaseT >::setExtIntMapping ( BuildInFieldTypes  eBuildInType,
UInt32  uiMappedType 
) [inline, inherited]

Definition at line 81 of file OSGScanParseFieldTypeMapper.inl.

References osg::ScanParseFieldTypeMapper< BaseT >::_mIntExt.

00084 {
00085     _mIntExt[eBuildInType] = uiMappedType;
00086 }

template<class BaseT>
void osg::ScanParseFieldTypeMapper< BaseT >::setIntExtMapping ( UInt32  uiMappedType,
BuildInFieldTypes  eBuildInType 
) [inline, inherited]

Definition at line 73 of file OSGScanParseFieldTypeMapper.inl.

References osg::ScanParseFieldTypeMapper< BaseT >::_mExtInt.

Referenced by initFieldTypeMapper().

00076 {
00077     _mExtInt[uiMappedType] = eBuildInType;
00078 }

template<class BaseT>
Int32 osg::ScanParseFieldTypeMapper< BaseT >::mapIntExtFieldType ( const Char8 szFieldname,
const Int32  iFieldTypeId 
) [inline, virtual, inherited]

Definition at line 109 of file OSGScanParseFieldTypeMapper.inl.

References osg::ScanParseFieldTypeMapper< BaseT >::_mIntExt.

00112 {
00113     typename IntExtMap::iterator gMIt = _mIntExt.find(
00114         (BuildInFieldTypes) iFieldTypeId);
00115 
00116     if(gMIt != _mIntExt.end())
00117     {
00118         return gMIt->second;
00119     }
00120     else
00121     {
00122         return -iFieldTypeId;
00123     }
00124 }


Member Data Documentation

Definition at line 135 of file OSGLoader.h.

Referenced by beginNode(), getRootNode(), getRootNodes(), and scanStream().

Definition at line 136 of file OSGLoader.h.

Referenced by addFieldValue(), beginField(), endField(), scanStream(), and setFieldContainerValue().

Definition at line 137 of file OSGLoader.h.

Referenced by beginField(), endField(), and scanStream().

Definition at line 138 of file OSGLoader.h.

Referenced by beginNode(), getReference(), and scanStream().

std::stack< FieldContainerPtr > osg::OSGLoader::_fcStack [protected]

Definition at line 140 of file OSGLoader.h.

Referenced by beginNode(), and endNode().

std::stack< Field *> osg::OSGLoader::_fStack [protected]

Definition at line 141 of file OSGLoader.h.

Referenced by beginField(), and endField().

std::stack<const FieldDescription *> osg::OSGLoader::_fdStack [protected]

Definition at line 142 of file OSGLoader.h.

Referenced by beginField(), and endField().

template<class BaseT>
IntExtMap osg::ScanParseFieldTypeMapper< BaseT >::_mIntExt [protected, inherited]

template<class BaseT>
ExtIntMap osg::ScanParseFieldTypeMapper< BaseT >::_mExtInt [protected, inherited]


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 12:05:10 2008 for OpenSG by  doxygen 1.5.5