void operator()(NodePtrType node) { DefaultNodePtrType nodePtr(node); // assert is fine here, since this is implementation internal. assert( nodePtr->isLeaf() ); addHosts( source_, nodePtr->getAlert()->getSourceHosts() ); addHosts( target_, nodePtr->getAlert()->getTargetHosts() ); }
void remove(const Position& p)// remove a given node { sz--; NodePtr v = nodePtr(p); v->prev->next = v->next; // unlink from the list v->next->prev = v->prev; delete v; }
Position insertAfter(const Position& p, const Object& element) { // insert after p NodePtr v = nodePtr(p); sz++; NodePtr newNode = new Node(element, v, v->next); v->next->prev = newNode; // link node into list v->next = newNode; return Position(newNode); }
void BVH4i::clearBarrier(NodeRef& node) { if (node.isBarrier()) node.clearBarrier(); else if (!node.isLeaf()) { Node* n = node.node(nodePtr()); for (size_t c=0; c<4; c++) clearBarrier(n->child(c)); } }
virtual void apply(osg::Node& node) { int index; osg::ref_ptr<osg::Node> nodePtr(&node); if (node.getUserValue("overrideFx", index)) { if (index == 1) overrideTexture(mTexture, mResourcesystem, nodePtr); } traverse(node); }
float BVH4i::sah (NodeRef& node, const BBox3f& bounds) { float f = bounds.empty() ? 0.0f : area(bounds); if (node.isNode()) { Node* n = node.node(nodePtr()); for (size_t c=0; c<4; c++) f += sah(n->child(c),n->bounds(c)); return f; } else { size_t num; node.leaf(triPtr(),num); return f*num; } }
void Graph::addNode(const string& name, const float data1, const float data2) { // before adding the node, try to find it nodePtr nodeExists = findNode(name); // if the node already exists, throw an error message // if the node does not exist, add it to the list of nodes if ( nodeList.size() > 0 && nodeExists ) { string errorString = "File format error : Duplicate node '" + nodeExists->getNodeID() + "'"; throw runtime_error(errorString.c_str()); } else { nodeList.push_back( nodePtr(new Node(name, data1, data2) ) ); } }
float BVH4i::sah (NodeRef& node, BBox3fa bounds) { float f = bounds.empty() ? 0.0f : area(bounds); if (node.isNode()) { Node* n = node.node(nodePtr()); for (size_t c=0; c<BVH4i::N; c++) if (n->child(c) != BVH4i::invalidNode) f += sah(n->child(c),n->bounds(c)); return f; } else { unsigned int num; node.leaf(triPtr(),num); return f*num; } }
void replaceElement(const Position& p, const Object& element) { // replace element NodePtr v = nodePtr(p); v->element = element; }
Position before(const Position& p) const // return item before p { NodePtr v = nodePtr(p); NodePtr prev = v->prev; return Position(prev); }
bool isLast(const Position& p) const { NodePtr v = nodePtr(p); return v->next == trailer; }
bool isFirst(const Position& p) const { NodePtr v = nodePtr(p); return v->prev == header; }
void operator()(NodePtrType node) { PointerWrapper<DefaultNodePtrType> nodePtr(node); if( nodePtr->isLeaf() ) fo_( nodePtr.get() ); }
/** Method for getting a bound graph from the one stored into the object. * \param boundGraph: resulting graph, it must be empty when the method * is called. * \param nodesToBound: a map containing as key the id of a node, and * as value the class/state to be bound. */ void getBoundGraph( CGraph &boundGraph, std::map<size_t,size_t> nodesToBound ) { // Check that the graph is empty assert( boundGraph.getNodes().size() == 0 ); // Copy the graph into boundGraph // Copy nodes for ( size_t node = 0; node < m_nodes.size(); node++ ) { CNodePtr nodePtr(new CNode(*m_nodes[node])); boundGraph.addNode( nodePtr ); } // Copy edges for ( size_t edge = 0; edge < m_edges.size(); edge++ ) { CEdgePtr edgePtr( new CEdge(*m_edges[edge])); boundGraph.addEdge( edgePtr ); } // Okey, now iterate over the nodes to be bound, removing then from // the resulting graph by expanding the potential associated with // their bound state for ( std::map<size_t,size_t>::iterator it = nodesToBound.begin(); it != nodesToBound.end(); it++ ) { size_t nodeID = it->first; size_t nodeState = it->second; // Potential of the state to be bounded double nodePotential = boundGraph.getNodeWithID( nodeID )->getPotentials()( nodeState ); // Iterate over the neighbours, updating their node potentials // according to the state of the node to be bound and its potential pair<multimap<size_t,CEdgePtr>::iterator,multimap<size_t,CEdgePtr>::iterator > neighbors; neighbors = boundGraph.getEdgesF().equal_range(nodeID); for ( multimap<size_t,CEdgePtr>::iterator it = neighbors.first; it != neighbors.second; it++ ) { CEdgePtr edgePtr( (*it).second ); Eigen::MatrixXd edgePotentials = edgePtr->getPotentials(); size_t ID1, ID2; edgePtr->getNodesID(ID1,ID2); // If the node to be bound is the first one appearing in the // edge. if ( ID1 == nodeID ) { CNodePtr nodePtr = boundGraph.getNodeWithID( ID2 ); Eigen::VectorXd boundPotentials = edgePotentials.row(nodeState).transpose()*nodePotential; Eigen::VectorXd newPotentials = nodePtr->getPotentials().cwiseProduct(boundPotentials); nodePtr->setPotentials( newPotentials ); } else // If it is the second one in the edge { CNodePtr nodePtr = boundGraph.getNodeWithID( ID1 ); Eigen::VectorXd boundPotentials = edgePotentials.col( nodeState )*nodePotential; Eigen::VectorXd newPotentials = nodePtr->getPotentials().cwiseProduct(boundPotentials); nodePtr->setPotentials( newPotentials ); } } // Now that the potential of the state of the node to bound // has been expanded, delete the node from the graph. boundGraph.deleteNode( nodeID ); } }