コード例 #1
0
/* remove this, if there is a general methode to find containers */
FieldContainer *VRMLFile::findFCByName(const Char8 *szName,
                                             Node  *pNode)
{
    MFUnrecNodePtr::const_iterator i;

    FieldContainer *pFC       = NULL;

#if 0
    Name           *pNodename = NULL;
    NodeCore       *pCore     = NULL;
    // check if name matches nodename

    pNodename =
        dynamic_cast<NamePtr>(
            pNode->findAttachment(Name::getClassType().getGroupId()));

    if(pNodename != NullFC)
    {
        if(strcmp(szName, pNodename->getFieldPtr()->getValue().c_str())==0)
            return pNode;
    }
    // check if name matches corename

    pCore = pNode->getCore();

    if(pCore != NullFC)
    {
        pNodename = dynamic_cast<NamePtr>(
            pCore->findAttachment(Name::getClassType().getGroupId()));

        if(pNodename != NullFC)
        {
            if(strcmp(szName, pNodename->getFieldPtr()->getValue().c_str())==0)
                return pCore;
        }
    }

    // matching for children
    for(i  = pNode->getMFChildren()->begin();
        i != pNode->getMFChildren()->end();
        i++)
    {
        pFC = findFCByName(szName, *i);

        if(pFC != NullFC)
        {
            return pFC;
        }
    }
#endif

    return pFC;
}
コード例 #2
0
const Char8 *getName(AttachmentContainer * const pContainer)
{
    if(pContainer == NULL)
        return NULL;
   
    // Get attachment pointer
    Attachment *att = 
        pContainer->findAttachment(Name::getClassType().getGroupId());

    if(att == NULL)
        return NULL;
   
    // Cast to name pointer                           

    Name *name = dynamic_cast<Name *>(att);

    if(name == NULL)
        return NULL;
   
    return name->getFieldPtr()->getValue().c_str();
}