本文整理汇总了C++中SoPath::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ SoPath::getLength方法的具体用法?C++ SoPath::getLength怎么用?C++ SoPath::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoPath
的用法示例。
在下文中一共展示了SoPath::getLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SoPath
SoPath *pickFilterCB(void *, const SoPickedPoint *pick)
{
SoPath *path = pick->getPath();
for (int i=0; i< path->getLength(); i++) {
LabObject *found = NULL;
if (LabObject::isLabObject(path->getNodeFromTail(i), &found)) {
//return path->copy(0, i+1);
return path->copy(0, path->getLength()-i);
}
}
return new SoPath();
}
示例2: while
//////////////////////////////////////////////////////////////////////////////
//
// beginTraversal - have the base class render the passed scene graph,
// then render highlights for our selection node.
//
void
SoLineHighlightRenderAction::apply(SoNode *node)
//
//////////////////////////////////////////////////////////////////////////////
{
// Render the scene
SoGLRenderAction::apply(node);
// Render the highlight?
if (! hlVisible) return;
// Add the rendering localRoot beneath our local scene graph localRoot
// so that we can find a path from localRoot to the selection node
// which is under the render root.
localRoot->addChild(node);
// Find the selection node under the local root
static SoSearchAction *sa = NULL;
if (sa == NULL)
sa = new SoSearchAction;
else
sa->reset();
sa->setFind(SoSearchAction::TYPE);
sa->setInterest(SoSearchAction::FIRST);
sa->setType(SoSelection::getClassTypeId());
sa->apply(localRoot);
SoPath *hlPath = sa->getPath();
if (hlPath != NULL) {
hlPath = hlPath->copy();
hlPath->ref();
// Make sure something is selected
SoSelection *sel = (SoSelection *) hlPath->getTail();
if (sel->getNumSelected() > 0) {
// Keep the length from the root to the selection
// as an optimization so we can reuse this data
int reusablePathLength = hlPath->getLength();
// For each selection path, create a new path rooted under our localRoot
for (int j = 0; j < sel->getNumSelected(); j++) {
// Continue the path down to the selected object.
// No need to deal with p[0] since that is the sel node.
SoFullPath *p = (SoFullPath *) sel->getPath(j);
SoNode *pathTail = p->getTail();
if ( pathTail->isOfType(SoBaseKit::getClassTypeId())) {
// Find the last nodekit on the path.
SoNode *kitTail = ((SoNodeKitPath *)p)->getTail();
// Extend the selectionPath until it reaches this last kit.
SoFullPath *fp = (SoFullPath *) p;
int k = 0;
do {
hlPath->append(fp->getIndex(++k));
}
while ( fp->getNode(k) != kitTail );
}
else {
for (int k = 1; k < p->getLength(); k++)
hlPath->append(p->getIndex(k));
}
// Render the shape with the local draw style to make the highlight
SoGLRenderAction::apply(hlPath);
// Restore hlPath for reuse
hlPath->truncate(reusablePathLength);
}
}
hlPath->unref();
}
// Remove the rendering localRoot from our local scene graph
localRoot->removeChild(node);
}