bool initialize(const CommandLineArgumentWrapper& args) { OpenSGSceneGraphInterface* sgIF = dynamic_cast<OpenSGSceneGraphInterface*>(sceneGraphInterface); // must exist because it is created by the OutputInterface if (!sgIF) { printd(ERROR, "GoingImmersive::initialize(): Unable to obtain SceneGraphInterface!\n"); return false; } // if // obtain the scene node from the SceneGraphInterface NodeRecPtr scene = sgIF->getNodePtr(); // set root node to the responsible SceneManager (managed by OpenSGApplicationBase) setRootNode(scene); // set our transformation to the start transformation TransformationData startTrans = WorldDatabase::getEnvironmentWithId(1)->getStartTransformation(0); localUser->setNavigatedTransformation(startTrans); //----------------------------------------------------------------------------// // Snippet-3-5 // //----------------------------------------------------------------------------// //----------------------------------------------------------------------------// // Snippet-4-2 // //----------------------------------------------------------------------------// //----------------------------------------------------------------------------// // Snippet-1-1 // //----------------------------------------------------------------------------// return true; } // initialize
void MeshSkin::setRootJoint(Joint* joint) { if (_rootJoint) { if (_rootJoint->getParent()) { _rootJoint->getParent()->removeListener(this); } } _rootJoint = joint; // If the root joint has a parent node, register for its transformChanged event if (_rootJoint && _rootJoint->getParent()) { _rootJoint->getParent()->addListener(this, 1); } Node* newRootNode = _rootJoint; if (newRootNode) { // Find the top level parent node of the root joint for (Node* node = newRootNode->getParent(); node != NULL; node = node->getParent()) { if (node->getParent() == NULL) { newRootNode = node; break; } } } setRootNode(newRootNode); }
void XbelTree::CreateHeaderFolder(QDomElement *fold, QString name, int type) { if( domDocument.isNull() ){ setRootNode(); } QDomElement root = domDocument.documentElement(); *fold = domDocument.createElement("folder"); QDomElement title = domDocument.createElement("title"); QDomText text = domDocument.createTextNode(name); title.appendChild(text); fold->appendChild(title); fold->setAttribute("folded", "yes"); fold->setAttribute("device", devices++); fold->setAttribute("type", type); root.appendChild(*fold); }
void Node::operator =(Node* node) { (*this) = (*node); prev = 0L; next = 0L; parent = 0L; child = 0L; listItem = 0L; groupElementLists.clear(); group = 0L; groupTag = 0L; #ifdef BUILD_KAFKAPART setRootNode(0L); setLeafNode(0L); #endif tag = new Tag(*(node->tag)); }
PhysXRigidBody::PhysXRigidBody( PxPhysics* PxDevice, PhysXMaterial* Material, const ERigidBodies Type, scene::SceneNode* RootNode, const SRigidBodyConstruction &Construct) : BaseObject ( ), PhysicsBaseObject ( ), RigidBody (Type, Construct), PhysXBaseObject (Material ), PxActor_ (0 ) { if (!PxDevice || !RootNode || !Material) throw io::stringc("Invalid arguments for rigid body"); /* Create dynamic rigid body */ PxBaseActor_ = PxActor_ = PxDevice->createRigidDynamic( PxTransform(PxMat44(RootNode->getTransformMatrix(true).getArray())) ); PxBaseActor_->userData = RootNode; if (!PxActor_) throw io::stringc("Could not create PhysX actor for rigid body"); /* Create base shape */ switch (Type) { case RIGIDBODY_BOX: createBox (Construct); break; case RIGIDBODY_SPHERE: createSphere (Construct); break; case RIGIDBODY_CAPSULE: createCapsule (Construct); break; default: throw io::stringc("Unsupported rigid body type"); } /* Initialize root node and actor */ setRootNode(RootNode); setMass(1.0f); }
QSGRenderer::~QSGRenderer() { setRootNode(0); delete m_node_updater; }
Scenegraph::Scenegraph(std::string scenegraphName) { m_scenegraphName = scenegraphName; setRootNode(new Node("Root")); getRootNode()->setIdentityMatrix_ModelMatrix(); }
CallstackProfiler::~CallstackProfiler() { setRootNode(nullptr); }
ImageModel::ImageModel(const QList<QList<QVariant> > &data, QObject *parent) : BasicModel(parent) { setRootNode(new ImageItem(data, true)); }
uSOAP::SOAPResponse::SOAPResponse() { setRootNode(uSOAP::SOAP::CreateEnvelopeBodyNode()); setContentType(uXML::XML::CONTENT_TYPE); }
void XmlOutputter::write() { setRootNode(); m_stream << m_xml->toString(); }
void BPlusTree::_remove(Block blk, AttrType k) { Node node(blk); int i; std::cout << "BPlusTree::_remove == k " << k.datai << std::endl; std::cout << "BPlusTree::_remove == blk.pos " << blk.pos << std::endl; // delete the corresponding p, k at first for( i = 0; i < node.getKSize(); i++ ) { if( node.getK(i) == k ) { node.remove(k, node.getP(i), i); break; } } // then check whether the size of the node is too small bool isRootWithSoleChild = node.isRoot() && !node.isLeaf() && node.getPSize() == 1; bool isNotRootAndTooSmall = ( node.isLeaf() && node.getKSize() < fanout / 2 ) || ( !node.isLeaf() && node.getKSize() < (fanout+1) / 2 ); isNotRootAndTooSmall = isNotRootAndTooSmall && node.isRoot(); if( isRootWithSoleChild ) { // If the root node has only one pointer after deletion, it is deleted and the sole child becomes the root. Block soleChildBlk; bufferManager->getBlock(filename, node.getP(0), soleChildBlk); Node soleChildNode(soleChildBlk); soleChildNode.setRoot(true); setRootNode(soleChildNode); setRootPos(soleChildBlk.getPos()); soleChildNode.write2Blk(soleChildBlk, typeId, strLen, bufferManager); bufferManager->deleteBlock(blk); return; } else if( isNotRootAndTooSmall ) { Block parentBlk; Block siblingBlk; Node siblingNode; AttrType nk; std::cout << "isNotRootAndTooSmall" << std::endl; std::cout << "stk.top() = " << stk.top() << std::endl; stk.pop(); std::cout << "parentBlk pos = " << stk.size() << std::endl; bufferManager->getBlock(filename, stk.top(), parentBlk); //stk.pop(); Node parentNode(parentBlk); std::cout << "f**k" << std::endl; // find sibling bool isLeftSibling = true; int siblingPos; for( i = 0; i < parentNode.getPSize(); i++ ) { if( parentNode.getP(i) == blk.getPos() ) { if( i > 0 ) { siblingPos = parentNode.getP(i-1); nk = parentNode.getK(i); } else { siblingPos = parentNode.getP(i+1); nk = parentNode.getK(i); isLeftSibling = false; } std::cout << "siblingPos " << siblingPos/BLOCK_SIZE << std::endl; bufferManager->getBlock(filename, siblingPos, siblingBlk); siblingNode.resetByBlock(siblingBlk); break; } } std::cout << "success up to now" << std::endl; // merge if( !isLeftSibling ) { std::swap(node, siblingNode); std::swap(blk, siblingBlk); } if( siblingNode.isLeaf() ) { siblingNode.popP(); } else { siblingNode.appendK(nk); } for( i = 0; i < node.getPSize(); i++ ) { siblingNode.appendP(node.getP(i)); if( i < node.getPSize() - 1 ) { siblingNode.appendK(node.getK(i)); } } for( i = 0; i < siblingNode.getPSize(); i++ ) { std::cout << "siblingNode.getP[" << i << "] = " << siblingNode.getP(i) << std::endl; } for( i = 0; i < siblingNode.getKSize(); i++ ) { std::cout << "siblingNode.getK[" << i << "] = " << siblingNode.getK(i).datai << std::endl; } if( siblingNode.getPSize() <= fanout ) { // can be merged std::cout << "siblingNode.write2Blk -- siblingBlk.pos[] " << siblingBlk.pos << std::endl; // siblingNode.write2Blk(siblingBlk, typeId, strLen, bufferManager); // bufferManager->deleteBlock(blk); siblingNode.write2Blk(blk, typeId, strLen, bufferManager); bufferManager->deleteBlock(siblingBlk); _remove(parentBlk, nk); } else { // split Node n1(false, false), n2(false, false); for( i = 0; i < (siblingNode.getPSize() + 1) / 2 - 1; i++ ) { n1.appendK(siblingNode.getK(i)); n1.appendP(siblingNode.getP(i)); } n1.appendP(siblingNode.getP(i)); for( i = (siblingNode.getPSize() + 1) / 2; i < (siblingNode.getPSize() + 1) / 2; i++ ) { n2.appendK(siblingNode.getK(i)); n2.appendP(siblingNode.getP(i)); } n2.appendP(siblingNode.getP(i)); n1.write2Blk(siblingBlk, typeId, strLen, bufferManager); n2.write2Blk(blk, typeId, strLen, bufferManager); if( !isLeftSibling ) { std::swap(blk, siblingBlk); } } } else { node.write2Blk(blk, typeId, strLen, bufferManager); } }
void BPlusTree::_insertNewBlk(Block &blk1, const AttrType &k, Block &blk2) { Node n1 = Node(blk1), n2 = Node(blk2); int i; if( n1.isRoot() ) { Node newNode(true, false); Block newBlk = bufferManager->newBlock(filename); newNode.appendP(blk1.getPos()); newNode.appendK(k); newNode.appendP(blk2.getPos()); // update the former root and write it to block n1.setRoot(false); n1.write2Blk(blk1, typeId, strLen, bufferManager); n2.setRoot(false); std::cout << "_insertNewBlk == n1.isLeaf() " << (int)n1.isLeaf() << std::endl; std::cout << "_insertNewBlk == n2.isLeaf() " << (int)n2.isLeaf() << std::endl; n2.write2Blk(blk2, typeId, strLen, bufferManager); // update the B+ tree and write new parent to block setRootNode(newNode); setRootPos(newBlk.getPos()); newNode.write2Blk(newBlk, typeId, strLen, bufferManager); } else { // retrieve the parent stk.pop(); Block opBlk; bufferManager->getBlock(filename, stk.top(), opBlk); Node opNode(opBlk); for( i = 0; i < opNode.getPSize(); i++ ) { if( opNode.getP(i) == blk1.getPos() ) { opNode.insert(k, blk2.getPos(), i+1); } } if( opNode.getKSize() < fanout ) { opNode.write2Blk(opBlk, typeId, strLen, bufferManager); } else { // this parent node still need to split Node npNode1(false, true), npNode2(false, true); Block npBlk = bufferManager->newBlock(filename); npNode1.setRoot(opNode.isRoot()); npNode2.setRoot(opNode.isRoot()); npNode1.setLeaf(opNode.isLeaf()); npNode2.setLeaf(opNode.isLeaf()); for( i = 0; i < (fanout + 1) / 2 - 1; i++ ) { npNode1.appendK(opNode.getK(i)); npNode1.appendP(opNode.getP(i)); } AttrType nk = opNode.getK(i); npNode1.appendP(opNode.getP(i)); for( i = (fanout + 1) / 2; i < fanout; i++ ) { npNode2.appendK(opNode.getK(i)); npNode2.appendP(opNode.getP(i)); } npNode2.appendP(opNode.getP(i)); npNode1.write2Blk(opBlk, typeId, strLen, bufferManager); npNode2.write2Blk(npBlk, typeId, strLen, bufferManager); _insertNewBlk(opBlk, nk, npBlk); } } }