本文整理汇总了C++中TreeNode::SetParent方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::SetParent方法的具体用法?C++ TreeNode::SetParent怎么用?C++ TreeNode::SetParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::SetParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitRoots
bool NodeHPChecker::InitRoots()
{
for (int j = 0; j < NUM_TREES;j++)
{
pRoot[j] = new TreeNode();
GeneratingName(pRoot[j]);
// new root pointers
domNode_Array& aNodes = pVisualScene[j]->getNode_array();
// add each node to root
for ( size_t i = 0; i < aNodes.getCount(); i++ )
{
TreeNode * pChild = new TreeNode();
// Load current dom node
// Append child
pRoot[j]->AppendChildren( LoadNode(aNodes.get(i), pRoot[j]) );
pChild->SetParent(pRoot[j]);
}
// reset index:
giIndexNoName = 0;
}
// sort each tree
SortChildren();
return true;
}
示例2: TreeNode
// copy id node tree in visual scene or generate the names
NodeHPChecker::TreeNode * NodeHPChecker::LoadNode(domNode *pDomNode, NodeHPChecker::TreeNode *pParentNode)
{
TreeNode * pNode = new TreeNode();
pNode->SetParent(pParentNode);
// check id of node
if ( pDomNode->getID() == NULL ) // no ID in this node
{
GeneratingName(pNode);
}
else
{
// put id of node to it
pNode->SetID( std::string( pDomNode->getID() ) );
}
// transverse children of current node
domNode_Array& aNodes = pDomNode->getNode_array();
for ( size_t i = 0; i < aNodes.getCount(); i++ )
{
pNode->AppendChildren( LoadNode(aNodes.get(i), pNode) );
}
return pNode;
}
示例3: HandElem
TreeNode<HandElem>* Hand::ParseFile(string strFileName)
{
m_strFileName = strFileName;
TreeNode<HandElem> *root = NULL;
stack<TreeNode<HandElem> *> stkNodes;
stack<char> stkBraces;
char c;
m_tkSFP.Open(strFileName.c_str());
if (m_tkSFP.IsEOF() == true)
{
m_tkSFP.Abort("Null Hand File!");
return root;
}
// read the tree structure
do
{
string strToken = m_tkSFP.GetToken();
if (strToken != HandElem::s_strElem)
{
m_tkSFP.Abort("Wrong Hand File Format!");
return root;
}
else
{
// read the joint name
string strName = m_tkSFP.GetToken();
m_tkSFP.SkipWhitespace();
// get to the '{'
c = m_tkSFP.GetChar();
if (c != '{')
{
m_tkSFP.Abort("Wrong Hand File Format!");
return root;
}
// parse the joint info, and push it into stack
HandElem *elem = new HandElem(strName);
elem->ReadInfo(m_tkSFP);
m_pHandElems[elem->GetLabel()] = elem;
// copy the pointers to quadarics to the vector of the hand
for (vector<Quadric *>::const_iterator it = elem->GetQuadrics().begin();
it != elem->GetQuadrics().end(); it++)
{
m_vecQuadrics.push_back(*it);
}
// insert the hand element to the tree
TreeNode<HandElem> *pNode = new TreeNode<HandElem>(elem);
if (stkNodes.empty())
{
pNode->SetParent(NULL);
root = pNode;
}
else
{
pNode->SetParent(stkNodes.top());
stkNodes.top()->InsertChildren(pNode);
}
stkBraces.push('{');
stkNodes.push(pNode);
// check whether these are some '}'
// for every '}', pop the stack
do
{
if (m_tkSFP.IsEOF() == true)
{
break;
}
m_tkSFP.SkipWhitespace();
c = m_tkSFP.CheckChar();
if (c == '}')
{
stkBraces.pop();
stkNodes.pop();
// igonore the '}'
c = m_tkSFP.GetChar();
}
} while (c == '}');
}
} while (!(stkNodes.empty()));
m_tkSFP.Close();
m_pRoot = root;
m_trHand.BuildTree(m_pRoot);
TraverseTree(m_pRoot);
Update();
m_bIsInit = true;
// Normalize();
return root;
}