// When the object is closed, add each of the child objects to the hierarchy. // Waiting until we have all the objects allows us to (otionally) radomize the // order of insertion, which can greatly affect the quality of the resulting // bounding volume hierarchy. void abvh::Close() { // Should "randomize" here... for( unsigned i = 0; i < NumChildren(); i++ ) { const Object *obj = GetChild(i); // Take into account the estimated cost of intersecting a ray with // this object as we insert it into the existing bvh. Insert( obj, obj->Cost() ); } }
// Recursively set so we don't have to recursively check. void plMaxNodeBase::SetItinerant(hsBool b) { const char* dbgNodeName = GetName(); if( !CanConvert() ) return; GetMD; pMD->SetItinerant(b); int i; for( i = 0; i < NumChildren(); i++ ) { ((plMaxNodeBase*)GetChildNode(i))->SetItinerant(b); } }
CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::CoverTree( const CoverTree& other) : dataset((other.parent == NULL && other.localDataset) ? new MatType(*other.dataset) : other.dataset), point(other.point), scale(other.scale), base(other.base), stat(other.stat), numDescendants(other.numDescendants), parent(other.parent), parentDistance(other.parentDistance), furthestDescendantDistance(other.furthestDescendantDistance), localMetric(false), localDataset(other.parent == NULL && other.localDataset), metric(other.metric), distanceComps(0) { // Copy each child by hand. for (size_t i = 0; i < other.NumChildren(); ++i) { children.push_back(new CoverTree(other.Child(i))); children[i]->Parent() = this; } // Propagate matrix, but only if we are the root. if (parent == NULL && localDataset) { std::queue<CoverTree*> queue; for (size_t i = 0; i < NumChildren(); ++i) queue.push(children[i]); while (!queue.empty()) { CoverTree* node = queue.front(); queue.pop(); node->dataset = dataset; for (size_t i = 0; i < node->NumChildren(); ++i) queue.push(node->children[i]); } } }
//another search thing CMySuperGrid::CTreeItem* CMySuperGrid::SearchEx(CTreeItem *pStartPosition, CString strItem) { CItemInfo* lp = GetData(pStartPosition); //if(lp->GetCheck()) another condition here maybe CString strData = lp->GetItemText(); if(strData==strItem) { return pStartPosition; } const int nChildren = NumChildren(pStartPosition); if (nChildren > 0) { POSITION pos = GetHeadPosition(pStartPosition); while (pos) { CTreeItem *pChild = GetNextChild(pStartPosition, pos); CItemInfo* lp = GetData(pChild); CString strData = lp->GetItemText(); if(strData==strItem) { return pChild; } } } POSITION pos = GetHeadPosition(pStartPosition); while (pos) { CTreeItem *pChild = GetNextChild(pStartPosition, pos); CItemInfo* lp = GetData(pChild); CString strData = lp->GetItemText(); if(strData==strItem) { return pChild; } pChild = SearchEx(pChild, strItem); if(pChild!=NULL) return pChild; } return NULL; }