bool Graph::insertNode(int v) { if (find(v) != NULL) { cerr << "\nNode with value " << v << " already present in the graph" << endl; return false; } else { Node *toBeInserted = new Node(v); Node *temp = getRootNode(); while (temp != NULL) { if (temp->getValue() < v ) { temp = temp->getRightNode(); } else if (temp->getValue() > v ) { temp = temp->getLeftNode(); } else { temp = temp->getMidNode(); } } if (v < temp->val) temp->setLeftNode(toBeInserted); if (v > temp->val) temp->setRightNode(toBeinserted); if (v == temp->val) temp->setMidNode(toBeInserted); //FIXME: ++depth; return true; } }
void OffscreenCanvas::dump() const { cerr << "Canvas: " << getRootNode()->getID() << endl; for (unsigned i = 0; i < m_pDependentCanvases.size(); ++i) { cerr << " " << m_pDependentCanvases[i]->getRootNode()->getID() << endl; } }
Action * AnimationManager::createActionForCallbackChannel(const Sequence::Property &channel){ float lastKeyframeTime = 0; Vector<FiniteTimeAction *> actions; for (auto &keyframe : channel.keyframes){ float timeSinceLastKeyframe = keyframe.time - lastKeyframeTime; lastKeyframeTime = keyframe.time; if (timeSinceLastKeyframe > 0){ actions.pushBack(DelayTime::create(timeSinceLastKeyframe)); } auto &selectorName = keyframe.value.string; int selectorTarget = keyframe.value.number(1); // Callback through obj-c Ref *target = NULL; if (selectorTarget == TargetType::DOCUMENT_ROOT){ target = getRootNode(); }else if (selectorTarget == TargetType::OWNER){ target = _owner; } if (target) { if (selectorName.empty()) { log("AnimationManager::createActionForCallbackChannel() Unexpected empty selector."); }else{ ActionInstant *action = nullptr; auto resolver = dynamic_cast<SelectorResolver *>(target); if (resolver) { action = resolver->onResolveCallFunc(selectorName); } if (action) { actions.pushBack(action); } } } } return actions.empty()? nullptr : cocos2d::Sequence::create(actions); }
KGpgRefNode::KGpgRefNode(KGpgExpandableNode *parent, const QString &keyid) : KGpgNode(parent), m_id(keyid) { Q_ASSERT(!keyid.isEmpty()); KGpgRootNode *root = getRootNode(); KGpgExpandableNode *pnd = parent; do { m_selfsig = (pnd->getId().right(keyid.length()) == keyid); if (m_selfsig) m_keynode = pnd->toKeyNode(); else pnd = pnd->getParentKeyNode(); } while (!m_selfsig && (pnd != root)); // Self signatures do net need to get notified by their key: if the key is changed // the key node is deleted, then those refnode would be deleted anyway. This avoids // crashes when they would try to find the root node by iterating over their parent // when the parents destructor is already called (see bug 208659). if (!m_selfsig) { m_keynode = root->findKey(keyid); if (m_keynode != NULL) { m_keynode->addRef(this); } else { connect(root, SIGNAL(newKeyNode(KGpgKeyNode*)), this, SLOT(keyUpdated(KGpgKeyNode*))); } }
void Scene::draw(sf::RenderTarget& target,sf::RenderStates states) const { std::multimap<int,SceneNode const*> _renderQueue; getRenderQueue(getRootNode(), _renderQueue); for (auto& it : _renderQueue) target.draw(*it.second, states); }
void OffscreenCanvas::setRoot(NodePtr pRootNode) { Canvas::setRoot(pRootNode); if (!getRootNode()) { throw (Exception(AVG_ERR_XML_PARSE, "Root node of a canvas tree needs to be a <canvas> node.")); } }
void OffscreenCanvas::render() { if (!isRunning()) { throw(Exception(AVG_ERR_UNSUPPORTED, "OffscreenCanvas::render(): Player.play() needs to be called before rendering offscreen canvases.")); } Canvas::render(IntPoint(getRootNode()->getSize()), true, m_pFBO, OffscreenRenderProfilingZone); m_pFBO->copyToDestTexture(); m_bIsRendered = true; }
void SceneGraphTreeModel::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); if(whichField & InternalRootFieldMask) { produceTreeStructureChanged(createPath(getRootNode()),std::vector<UInt32>(1, 0),std::vector<boost::any>(1, boost::any(getRootNode()))); } }
wxDataViewItem TreeModelFilter::FindInteger(long needle, int column) { return FindRecursiveUsingRows(getRootNode(), [&] (Row& row)->bool { if (!ItemIsVisible(row)) { return false; // skip filtered items } return row[GetColumns()[column]].getInteger() == needle; }); }
wxDataViewItem TreeModelFilter::FindString(const std::string& needle, int column) { return FindRecursiveUsingRows(getRootNode(), [&] (Row& row)->bool { if (!ItemIsVisible(row)) { return false; // skip filtered items } return static_cast<std::string>(row[GetColumns()[column]]) == needle; }); }
TiXmlNode* openSection(const char* xmlFile) { char pathbuf[255]; kbe_snprintf(pathbuf, 255, "%s", xmlFile); txdoc_ = new TiXmlDocument((char*)&pathbuf); if(!txdoc_->LoadFile()) { ERROR_MSG(boost::format("load xml from %1% is error!\n") % pathbuf); return NULL; } rootElement_ = txdoc_->RootElement(); return getRootNode(); }
UXML2Document::UXML2Document(const UString& _data) : data(_data) { U_TRACE_REGISTER_OBJECT(0, UXML2Document, "%V", _data.rep) if (binit == false) init(); // impl_ = (xmlDocPtr) U_SYSCALL(xmlParseMemory, "%p,%d", U_STRING_TO_PARAM(_data)); /* Enum xmlParserOption { XML_PARSE_RECOVER = 1 : recover on errors XML_PARSE_NOENT = 2 : substitute entities XML_PARSE_DTDLOAD = 4 : load the external subset XML_PARSE_DTDATTR = 8 : default DTD attributes XML_PARSE_DTDVALID = 16 : validate with the DTD XML_PARSE_NOERROR = 32 : suppress error reports XML_PARSE_NOWARNING = 64 : suppress warning reports XML_PARSE_PEDANTIC = 128 : pedantic error reporting XML_PARSE_NOBLANKS = 256 : remove blank nodes XML_PARSE_SAX1 = 512 : use the SAX1 interface internally XML_PARSE_XINCLUDE = 1024 : Implement XInclude substitition XML_PARSE_NONET = 2048 : Forbid network access XML_PARSE_NODICT = 4096 : Do not reuse the context dictionnary XML_PARSE_NSCLEAN = 8192 : remove redundant namespaces declarations XML_PARSE_NOCDATA = 16384 : merge CDATA as text nodes XML_PARSE_NOXINCNODE = 32768 : do not generate XINCLUDE START/END nodes XML_PARSE_COMPACT = 65536 : compact small text nodes; no modification of the tree allowed afterwards (will possibly crash if you try to modify tree) XML_PARSE_OLD10 = 131072 : parse using XML-1.0 before update 5 XML_PARSE_NOBASEFIX = 262144 : do not fixup XINCLUDE xml:base uris XML_PARSE_HUGE = 524288 : relax any hardcoded limit from the parser XML_PARSE_OLDSAX = 1048576 : parse using SAX2 interface from before 2.7.0 } */ impl_ = (xmlDocPtr) U_SYSCALL(xmlReadMemory, "%p,%d,%S,%S,%d", U_STRING_TO_PARAM(_data), 0, 0, XML_PARSE_COMPACT); if (impl_ == NULL) { U_ERROR("unable to parse xml document"); } /* * Check the document is of the right kind */ if (getRootNode() == NULL) U_ERROR("empty xml document"); }
Node* Graph::find(int v) { Node *temp = getRootNode(); while (temp != NULL) { if (v < temp->getValue() == v) { return temp; } else if ( v < temp->getValue() ) { temp = temp->getLeftNode(); } else { temp = temp->getRightNode(); } } return NULL; }
void SceneManager::updateQueues( const Frustum &frustum1, const Frustum *frustum2, RenderingOrder::List order, bool lightQueue, bool renderableQueue ) { // Clear without affecting capacity if( lightQueue ) _lightQueue.resize( 0 ); if( renderableQueue ) _renderableQueue.resize( 0 ); updateNodes(); updateQueuesRec( frustum1, frustum2, order == RenderingOrder::FrontToBack || order == RenderingOrder::BackToFront, getRootNode(), lightQueue, renderableQueue ); // Sort if( order == RenderingOrder::FrontToBack ) std::sort( _renderableQueue.begin(), _renderableQueue.end(), SceneNode::frontToBackOrder ); else if( order == RenderingOrder::BackToFront ) std::sort( _renderableQueue.begin(), _renderableQueue.end(), SceneNode::backToFrontOrder ); }
void TestSceneManager3::populate() { // Build the vertex array using the lowest toplevel voxel per corner. Note, we're // leaving in vertex duplication so each voxel can have its own normals and tex-coords. // This will increase our sene complexity, but give us more control, as well. std::vector<Vector3> vertsArray; std::vector<Vector2> coordsArray; for (int x = 0; x < _world->getWidth(); x++) { for (int y = 0; y < _world->getHeight(); y++) { #define ADD_VECTOR(xOff, yOff) do { \ vertsArray.push_back(getVectorForCorner(x + xOff, y + yOff)); \ coordsArray.push_back(Vector2(xOff, yOff)); \ } while (0) // Bottom left triangle. ADD_VECTOR(0, 0); ADD_VECTOR(1, 0); ADD_VECTOR(0, 1); // Top right triangle. ADD_VECTOR(0, 1); ADD_VECTOR(1, 0); ADD_VECTOR(1, 1); #undef ADD_VECTOR } } // Calculate normals for each of the vertices. Vector3 *verts = new Vector3[vertsArray.size()]; Vector3 *norms = new Vector3[vertsArray.size()]; for (int i = 0; i < vertsArray.size(); i+=3) { Vector3 one = vertsArray[i+1] - vertsArray[i+0]; Vector3 two = vertsArray[i+2] - vertsArray[i+1]; Vector3 normal = one.crossProduct(two); normal.normalize(); for (int j = 0; j < 3; j++) { verts[i+j] = vertsArray[i+j]; norms[i+j] = normal; } } Entity *entity = createEntity(new WorldEntity(verts, norms, vector_to_array(coordsArray), vertsArray.size()), "world"); entity->setMaterial(_materialManager->getOrLoadResource("grass")); getRootNode()->attach(entity); }
TreePath SceneGraphTreeModel::getPathForNode(NodeUnrecPtr theNode) const { std::deque<boost::any> ResultPath; if(theNode != NULL && getInternalRoot() != NULL && theNode != getInternalRoot()) { NodeUnrecPtr parentNode(theNode); while(parentNode != NULL && parentNode != getInternalRoot()) { ResultPath.push_front(boost::any(parentNode)); parentNode = parentNode->getParent(); } ResultPath.push_front(boost::any(getRootNode())); } return TreePath(ResultPath, TreeModelUnrecPtr(const_cast<SceneGraphTreeModel*>(this))); }
void Iso::exploreIso() { stopTreeWidget = true; mTreeWidget.lock(); //Wait till other thread is done exiting there request stopTreeWidget = false; QTreeWidgetItem *parent = new QTreeWidgetItem(NULL); parent->setText(0, getShortIso()); uint64 totalSize = addTreeToWidget(parent, getRootNode()); if(!stopTreeWidget) { parent->setText(2, getHumenSize(totalSize)); emit doSetTree(parent); //Send the data to Main outside this thread } else { //Delete everything we created so far when we had to quit! as else we have major a major memory leak! qDeleteAll(parent->takeChildren()); delete parent; } mTreeWidget.unlock(); }
TiXmlNode* openSection(const char* xmlFile) { char pathbuf[255]; kbe_snprintf(pathbuf, 255, "%s", xmlFile); txdoc_ = new TiXmlDocument((char*)&pathbuf); if(!txdoc_->LoadFile()) { #if KBE_PLATFORM == PLATFORM_WIN32 printf("%s", (boost::format("TiXmlNode::openXML: %1%, is error!\n") % pathbuf).str().c_str()); #endif if(DebugHelper::isInit()) { ERROR_MSG(boost::format("TiXmlNode::openXML: %1%, is error!\n") % pathbuf); } return NULL; } rootElement_ = txdoc_->RootElement(); return getRootNode(); }
static int LUALoadObjScene(lua_State *L) { const char *filename=lua_tostring(L, 1); glm::vec3 t, r, z; t.x=lua_tonumber(L, 2); t.y=lua_tonumber(L, 3); t.z=lua_tonumber(L, 4); r.x=lua_tonumber(L, 5); r.y=lua_tonumber(L, 6); r.z=lua_tonumber(L, 7); z.x=z.y=z.z=lua_tonumber(L, 8); auto cw=engine->getCurrentContext(); auto sMgr=cw->getSceneManager(); auto node=sMgr->loadObjScene(sMgr->getRootNode(), filename); node->getTransformation()->setTranslation(t); node->getTransformation()->setRotation(r); node->getTransformation()->setScale(z); return 0; }
TreePath SceneGraphTreeModel::createPath(NodeUnrecPtr node) const { std::deque<boost::any> PathVec; NodeUnrecPtr recNode(node); if(recNode != NULL) { while(recNode != NULL && recNode != getRootNode()) { PathVec.push_front(boost::any(recNode)); recNode = recNode->getParent(); } if(recNode != NULL) { PathVec.push_front(boost::any(recNode)); } else { return TreePath(); } } return TreePath(PathVec, const_cast<SceneGraphTreeModel*>(this)); }
boost::any SceneGraphTreeModel::getRoot(void) const { return boost::any(getRootNode()); }
bool OffscreenCanvas::getHandleEvents() const { return dynamic_pointer_cast<OffscreenCanvasNode>(getRootNode())->getHandleEvents(); }
void CPinyinTrie::print(FILE *fp) const { std::string prefix; print(getRootNode(), prefix, fp); }
std::string OffscreenCanvas::getID() const { return getRootNode()->getID(); }
void OffscreenCanvas::setAutoRender(bool bAutoRender) { dynamic_pointer_cast<OffscreenCanvasNode>(getRootNode())->setAutoRender(bAutoRender); }
bool OffscreenCanvas::getAutoRender() const { return dynamic_pointer_cast<OffscreenCanvasNode>(getRootNode())->getAutoRender(); }
int OffscreenCanvas::getMultiSampleSamples() const { return dynamic_pointer_cast<OffscreenCanvasNode>( getRootNode())->getMultiSampleSamples(); }
pugi::xml_node MapConfigReader::getQuartiersNode() const { return getRootNode().child("Quartiers"); }
/** Returns the node onto which the whole scene should be attached * * It defaults to getRootNode() */ virtual osg::ref_ptr<osg::Group> getRefNode() { return getRootNode(); }
Scenegraph::Scenegraph(std::string scenegraphName) { m_scenegraphName = scenegraphName; setRootNode(new Node("Root")); getRootNode()->setIdentityMatrix_ModelMatrix(); }