当前位置: 首页>>代码示例>>C++>>正文


C++ BaseNode类代码示例

本文整理汇总了C++中BaseNode的典型用法代码示例。如果您正苦于以下问题:C++ BaseNode类的具体用法?C++ BaseNode怎么用?C++ BaseNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BaseNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

std::string BaseLink::CreateStringPath(Base* dest, Base* from)
{
    if (!dest || dest == from) return std::string("[]");
    BaseObject* o = dest->toBaseObject();
    BaseObject* f = from->toBaseObject();
    BaseContext* ctx = from->toBaseContext();
    if (!ctx && f) ctx = f->getContext();
    if (o)
    {
        std::string objectPath = o->getName();
        BaseObject* master = o->getMaster();
        while (master)
        {
            objectPath = master->getName() + std::string("/") + objectPath;
            master = master->getMaster();
        }
        BaseNode* n = o->getContext()->toBaseNode();
        if (f && o->getContext() == ctx)
            return objectPath;
        else if (n)
            return n->getPathName() + std::string("/") + objectPath; // TODO: compute relative path
        else
            return objectPath; // we could not determine destination path, specifying simply its name might be enough to find it back
    }
    else // dest is a context
    {
        if (f && ctx == dest)
            return std::string("./");
        BaseNode* n = dest->toBaseNode();
        if (n) return n->getPathName(); // TODO: compute relative path
        else return dest->getName(); // we could not determine destination path, specifying simply its name might be enough to find it back
    }
}
开发者ID:151706061,项目名称:sofa,代码行数:33,代码来源:BaseLink.cpp

示例2: getExpandedNodes

/// Traverse the item tree and retrive the item that are expanded. The path of the node
/// that are expanded are stored in the the pathes std::vector::std::string>.
void QSofaListView::getExpandedNodes(QTreeWidgetItem* item, std::vector<std::string>& pathes)
{
    if(!item)
        return;

    /// We have reached a leaf of the hierarchy or it is closed...so we save the path
    if( !item->isExpanded() && graphListener_->findObject(item)->toBaseNode() != nullptr )
        return;

    BaseNode* parentNode = graphListener_->findObject(item)->toBaseNode() ;
    if(parentNode == nullptr)
        return;

    std::string path = parentNode->getPathName();
    pathes.push_back(path);

    for(int i=0 ; i<item->childCount() ; i++)
    {
        QTreeWidgetItem* child = item->child(i);
        BaseNode* childNode = graphListener_->findObject(child)->toBaseNode() ;

        if(childNode==nullptr)
            continue;

        if( childNode->getParents()[0] == parentNode )
            getExpandedNodes(child, pathes) ;
    }

    return ;
}
开发者ID:david-cazier,项目名称:sofa,代码行数:32,代码来源:QSofaListView.cpp

示例3: initNode

bool BaseMultiMappingElement::initNode()
{
    using namespace core::objectmodel;
    using namespace core;
    bool result = ObjectElement::initNode();


    if( result )
    {

        BaseMapping* multimapping = this->getTypedObject()->toBaseMapping();
        NodeElement* currentNodeElement = dynamic_cast<NodeElement *>(getParent());
        simulation::Node* currentNode =  dynamic_cast<simulation::Node* >( currentNodeElement->getTypedObject() );
        helper::vector<core::BaseState*> inputStates  = multimapping->getFrom();
        helper::vector<core::BaseState*> outputStates = multimapping->getTo();


        helper::vector<core::BaseState*>::iterator iterState;
        helper::vector<simulation::Node*> inputNodes, outputNodes;

        /* get the Nodes corresponding to each input BaseState context */
        for( iterState = inputStates.begin();  iterState != inputStates.end(); ++iterState)
        {
            simulation::Node* node = dynamic_cast< simulation::Node* >((*iterState)->getContext());
            inputNodes.push_back(node);
        }
        /* */
        /* get the Nodes corresponding to each output BaseState context */
        for( iterState = outputStates.begin(); iterState != outputStates.end(); ++iterState)
        {
            simulation::Node* node = dynamic_cast< simulation::Node* >((*iterState)->getContext());
            outputNodes.push_back(node);
        }

        helper::vector<simulation::Node*>::iterator iterNode;
        BaseNode* currentBaseNode;

        /* filter out inputNodes which already belong to the currentNode ancestors */
        helper::vector<simulation::Node*> otherInputNodes;
        helper::vector<simulation::Node*> ancestorInputNodes;
        iterNode = inputNodes.begin();
        currentBaseNode = currentNode;
        for( iterNode = inputNodes.begin(); iterNode != inputNodes.end(); ++iterNode)
        {
            if( !currentBaseNode->hasAncestor(*iterNode) )
            {
                otherInputNodes.push_back(*iterNode);
            }
            else
            {
                ancestorInputNodes.push_back(*iterNode);
            }
        }

        updateSceneGraph(multimapping, ancestorInputNodes, otherInputNodes, outputNodes );

    }

    return result;
}
开发者ID:david-cazier,项目名称:sofa,代码行数:60,代码来源:BaseMultiMappingElement.cpp

示例4: getStop

Error BaseContext::removeUnreachableCode() {
  PodList<BaseNode*>::Link* link = _unreachableList.getFirst();
  BaseNode* stop = getStop();

  while (link != NULL) {
    BaseNode* node = link->getValue();
    if (node != NULL && node->getPrev() != NULL) {
      // Locate all unreachable nodes.
      BaseNode* first = node;
      do {
        if (node->isFetched())
          break;
        node = node->getNext();
      } while (node != stop);

      // Remove.
      if (node != first) {
        BaseNode* last = (node != NULL) ? node->getPrev() : getCompiler()->getLastNode();
        getCompiler()->removeNodes(first, last);
      }
    }

    link = link->getNext();
  }

  return kErrorOk;
}
开发者ID:bnoordhuis,项目名称:asmjit,代码行数:27,代码来源:context.cpp

示例5: tick

State BehaviorTree::tick(Value* target, Blackboard* blackBoard, float deltaTime) {
//    m_tick->reset();
    m_tick->setTarget(target);
    m_tick->setBlackBoard(blackBoard);
    m_tick->setTree(this);
    m_tick->setDeltaTime(deltaTime);

    State ret = this->m_root->_execute(m_tick);

    std::vector<Value>& lastOpenNodes = blackBoard->get("openNodes", this->getId()).asVector();
    std::vector<Value>& curOpenNodes = m_tick->getOpenNodes();

    int start = 0;
    int length = lastOpenNodes.size() < curOpenNodes.size() ? (int)lastOpenNodes.size() : (int)curOpenNodes.size();

    for(int i = 0; i < length; i++) {
        start = i + 1;
        if(lastOpenNodes[i] != curOpenNodes[i])
            break;
    }

    for(int i = (int)lastOpenNodes.size() - 1; i >= start; i--) {
        BaseNode* baseNode = (BaseNode*)lastOpenNodes[i].asObject();
        baseNode->_close(m_tick);
    }

    blackBoard->set("openNodes", Value(curOpenNodes), this->getId());

    return ret;
}
开发者ID:cleverpo,项目名称:behavior3cpp,代码行数:30,代码来源:BehaviorTree.cpp

示例6: assert

/*! Returns a new copy of the prototype specified by prototype_id.
  The id must be valid. Functions should use the id
  returned by registerPrototype.
*/
BaseNode *NodeFactory::produce(int prototype_id) {
  assert(prototype_id >= 0);
  assert(prototype_id < static_cast<int>(prototypes.size()));
  BaseNode* clone = prototypes.at(prototype_id)->clone();
  // qDebug(qPrintable(id.toString()));
  clone->setId(QUuid::createUuid());
  return clone;
}
开发者ID:hexfaker,项目名称:puml,代码行数:12,代码来源:nodefactory.cpp

示例7: assert

/*! Slot. Removes the currently selected node. If the node is
    an object, it also removes all connections connected to that
    node.
*/
void Document::removeObject() {
  assert(indexOfSelectedObject >= -1);
  assert(indexOfSelectedObject < static_cast<int>(nodes.size()));

  if (indexOfSelectedObject != -1) {
    BaseNode* obj = nodes.at(indexOfSelectedObject);
    if (obj->isConnector() == false) {
      // erase all the connected connectionnodes
      // get the list of connected nodes, which are all connections
      std::list<BaseNode*> objs;
      objs = obj->getConnectedNodes();

      // iterator through that list and delete the connection nodes
      // as well as remove the pointers to this node from all objects
      // that are connected to the connection node
      std::list<BaseNode*>::iterator it;
      for (it = objs.begin(); it != objs.end(); ++it) {
        // for each of the objects that are connected to this connection,
        std::list<BaseNode*> secondaryObject;
        std::list<BaseNode*>::iterator it2;
        for (it2 = secondaryObject.begin(); it2 != secondaryObject.end(); ++it) {  // NOLINT
          // remove the connection back to the connectionode we are deleting
          (*it2)->removeConnectedNode(*it);
        }

        // delete this connection node
        for (int i = 0; i < static_cast<int>(nodes.size()); i++) {
          if (nodes.at(i) == (*it)) {
            removeFromOrdering(i);
            nodes.erase(nodes.begin()+i);
          }
        }
      }
      // now actually erase the object
      removeFromOrdering(indexOfSelectedObject);
      nodes.erase(nodes.begin()+indexOfSelectedObject);
    } else {
      // get the list of connected objects (should only be two objects)
      std::list<BaseNode*> secondaryObjects;
      secondaryObjects = obj->getConnectedNodes();

      // iterate through the list and disconnect the connectionnode we
      // are deleting from the objects.
      std::list<BaseNode*>::iterator it;  // NOLINT
      for (it = secondaryObjects.begin(); it != secondaryObjects.end(); ++it) {
        (*it)->removeConnectedNode(obj);
      }

      // now delete the actual nodecount
      removeFromOrdering(indexOfSelectedObject);
      nodes.erase(nodes.begin()+indexOfSelectedObject);
    }
  }
  setModified(true);
  indexOfSelectedObject = -1;
  emit modelChanged();
}
开发者ID:hexfaker,项目名称:puml,代码行数:61,代码来源:document.cpp

示例8: if

 void BVHN<N>::clearBarrier(NodeRef& node)
 {
   if (node.isBarrier())
     node.clearBarrier();
   else if (!node.isLeaf()) {
     BaseNode* n = node.baseNode(BVH_FLAG_ALIGNED_NODE); // FIXME: flags should be stored in BVH
     for (size_t c=0; c<N; c++)
       clearBarrier(n->child(c));
   }
 }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例9: parent

void Noun::detachSelf()
{
	BaseNode * pParent = parent();
	if ( pParent != NULL )
	{
		pParent->detachNodeSwap( this );
	}
	else
	{
		TRACE( "Noun::detachSelf() - NULL parent!" );
	}
}
开发者ID:BlackYoup,项目名称:medusa,代码行数:12,代码来源:Noun.cpp

示例10: process

	Status MaxTime::process(Tick& tick)
	{
		float elapsedTime = tick.tree.getElapsedTime(actionId);

		BaseNode* node = tick.tree.actionManager.getActionById(child);
		// CCAssert(node != nullptr)
		Status status = node->execute(tick);
		if (elapsedTime > maxDelay)
		{
			return Status::Failure;
		}

		return status;
	}
开发者ID:shizhexu,项目名称:BehaviorTrees.v2.0,代码行数:14,代码来源:MaxTime.cpp

示例11: qDebug

/*! Returns a new copy of the prototype specified by name, or
  null if the name isn't valid.
*/
BaseNode *NodeFactory::produceFromClassName(QString name)
{
  std::vector<BaseNode*>::iterator it;
  BaseNode* clone;

  for (it=prototypes.begin(); it < prototypes.end(); it++) {
    if ((*it)->metaObject()->className() == name) {
      clone = (*it)->clone();
      clone->setId(QUuid::createUuid());
      return clone;
    }
  }
  qDebug("Error: couldn't produce class");
  return 0;
}
开发者ID:hexfaker,项目名称:puml,代码行数:18,代码来源:nodefactory.cpp

示例12: localFrame

void Noun::setWorldFrame( const Matrix33 & frame )
{
	m_WorldFrame = frame;
	Matrix33 localFrame( frame );

	BaseNode * pBaseNode = parent();
	while( pBaseNode != NULL )
	{
		NodeTransform * pNode = WidgetCast<NodeTransform>( pBaseNode );
		if ( pNode != NULL )
			localFrame = pNode->frame() * localFrame;

		pBaseNode = pBaseNode->parent();
	}

	setFrame( localFrame );
}
开发者ID:BlackYoup,项目名称:medusa,代码行数:17,代码来源:Noun.cpp

示例13: localPosition

void Noun::setWorldPosition( const Vector3 & position )
{
	// convert the world position into a local position by enumerating all parent nodes
	m_WorldPosition = position;
	Vector3 localPosition( position );

	BaseNode * pBaseNode = parent();
	while( pBaseNode != NULL )
	{
		NodeTransform * pNode = WidgetCast<NodeTransform>( pBaseNode );
		if ( pNode != NULL )
			localPosition = pNode->frame() * (localPosition - pNode->position());

		pBaseNode = pBaseNode->parent();
	}

	setPosition( localPosition );
}
开发者ID:BlackYoup,项目名称:medusa,代码行数:18,代码来源:Noun.cpp

示例14: new_node_from_tag

BaseNode* new_node_from_tag(SBinaryTag* tag, bool skipCopy) {

  const char* tagClass = get_string_from_dict(tag, "class");
  nodeFunctionPtr createFunction = NULL;
  for (int index = 0; index < g_createFunctionsLength; index += 1) {
    SFuncLookup* entry = &g_createFunctions[index];
    if (strcmp(entry->className, tagClass) == 0) {
      createFunction = entry->createFunction;
    }
  }
  if (createFunction == NULL) {
    fprintf(stderr, "new_node_from_tag(): Couldn't find a factory function for node class '%s'\n", tagClass);
    return NULL;
  }
  BaseNode* result = createFunction(tag, skipCopy);
  const char* name = get_string_from_dict(tag, "name");
  result->setName(name);
  return result;
}
开发者ID:anshulnsit,项目名称:MDig,代码行数:19,代码来源:nodefactory.cpp

示例15: decltype

unique_ptr<const BaseContainer> AdapterChain::doArchiverExtract(const BaseNode &from_node) const
{
    if (!archiver_)	throw MethodNotApplicableException("an archiver is needed but is not specified");

    InputLumpData inex = {
        from_node.ReadableData(),
        from_node.size()
        };

    typedef decltype(inex.palettes) PaletteMap;
    for (const auto dependency : archiver_->getPaletteDependencies())
    {
        inex.palettes.insert(PaletteMap::value_type(
                                                            dependency,
                                                            from_node.getDirectory()->getPalette(dependency)
                                                      )
                            );
    }

    return archiver_->extract(inex);
}
开发者ID:TarCV,项目名称:WarStudio,代码行数:21,代码来源:AdapterChain.cpp


注:本文中的BaseNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。