Exemple #1
0
void CGroupEditTree::OnLButtonUp(UINT nFlags, CPoint point) 
{
	CTreeCtrl::OnLButtonUp(nFlags, point);

	if (m_bDragging)
	{
		m_bDragging = FALSE;
		CImageList::DragLeave(this);
		CImageList::EndDrag();
		ReleaseCapture();

		delete m_pDragImage;

		// Remove drop target highlighting
		SelectDropTarget(NULL);

		if (m_hitemDrag == m_hitemDrop || m_hitemDrop == NULL)
			return;

		// If Drag item is an ancestor of Drop item then return
		HTREEITEM htiParent = m_hitemDrop;
		while ((htiParent = GetParentItem(htiParent)) != NULL)
			if (htiParent == m_hitemDrag)
				return;
		
		Expand(m_hitemDrop, TVE_EXPAND);

		DWORD source = GetItemData(m_hitemDrag);
		DWORD dest = GetItemData(m_hitemDrop) - 0xFFFF;
		TV_INSERTSTRUCT tvstruct;
		tvstruct.hParent = m_hitemDrop;
		tvstruct.hInsertAfter = TVI_SORT;
		tvstruct.item.lParam = source;
		tvstruct.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
		DeleteItem(m_hitemDrag);

		if (source < 0xFFFF)
		{
			opts->piecesgroups[source] = opts->groups[dest];

			tvstruct.item.iImage = 2;
			tvstruct.item.iSelectedImage = 2;
			tvstruct.item.pszText = (char*)opts->pieces[source]->GetName();
			InsertItem(&tvstruct);
		}
		else
		{
			opts->groupsgroups[source - 0xFFFF] = opts->groups[dest];

			tvstruct.item.iImage = 0;
			tvstruct.item.iSelectedImage = 1;
			tvstruct.item.pszText = opts->groups[source - 0xFFFF]->m_strName;

			HTREEITEM hti = InsertItem(&tvstruct);
			AddChildren(hti, opts->groups[source - 0xFFFF]);
		}

//		AddChildren(m_hitemDrop, opts->groups[dest]);
	}
}
Exemple #2
0
Fichier : dir.c Projet : taysom/tau
void SeekTest (void)
{
	int num_children = 10;
	dir_s dir = NilDir;
	DIR *d;
	struct dirent *entry;
	int i;

	dir.name = RndName();
	mkdir(dir.name, 0777);
	AddChildren(&dir, num_children);

	d = opendir(dir.name);
	while ((entry = readdir(d)) != NULL) {
		SaveTell(d, entry, &dir);
	}
	for (i = 0; i < 27; i++) {
		int k = urand(num_children);
		file_s *file = &dir.file[k];
		seekdir(d, file->tell);
		entry = readdir(d);
		if (strcmp(entry->d_name, file->name) != 0) {
			PrError("Seekdir failed. Looking for %s found %s",
				entry->d_name, file->name);
		}
	}
	closedir(d);
	DeleteChildren(&dir);
	rmdir(dir.name);
	free(dir.name);
}
Exemple #3
0
void CGroupEditTree::AddChildren(HTREEITEM hParent, Group* pGroup)
{
	int i;
	TV_INSERTSTRUCT tvstruct;
	tvstruct.hParent = hParent;
	tvstruct.hInsertAfter = TVI_SORT;

	for (i = 0; i < opts->groupcount; i++)
		if (opts->groupsgroups[i] == pGroup)
		{
			tvstruct.item.lParam = i + 0xFFFF;
			tvstruct.item.iImage = 0;
			tvstruct.item.iSelectedImage = 1;
			tvstruct.item.pszText = opts->groups[i]->m_strName;
			tvstruct.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;

			HTREEITEM hti = InsertItem(&tvstruct);
			AddChildren(hti, opts->groups[i]);
		}

	for (i = 0; i < opts->piececount; i++)
		if (opts->piecesgroups[i] == pGroup)
		{
			tvstruct.item.lParam = i;
			tvstruct.item.iImage = 2;
			tvstruct.item.iSelectedImage = 2;
			tvstruct.item.pszText = (char*)opts->pieces[i]->GetName();
			tvstruct.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
			InsertItem(&tvstruct);
		}
}
Exemple #4
0
void AssetsWindow::AddAsset(AssetPtr asset)
{
    ///\todo Check that the asset doesn't already exists
    AssetItem *item = new AssetItem(asset);
    AddChildren(asset, item);

    connect(asset.get(), SIGNAL(Loaded(AssetPtr)), SLOT(HandleAssetLoaded(AssetPtr)));
    connect(asset.get(), SIGNAL(Unloaded(IAsset *)), SLOT(HandleAssetUnloaded(IAsset *)));

    bool storageFound = false;
    AssetStoragePtr storage = asset->GetAssetStorage();
    if (storage)
        for(int i = 0; i < treeWidget->topLevelItemCount(); ++i)
        {
            QTreeWidgetItem *storageItem = treeWidget->topLevelItem(i);
            if (storageItem->text(0) == storage->ToString())
            {
                storageItem->addChild(item);
                storageFound = true;
                break;
            }
        }

    if (!storageFound)
        noProviderItem->addChild(item);

    noProviderItem->setHidden(noProviderItem->childCount() == 0);
}
Exemple #5
0
void DirectoryTree::OnItemExpanded(wxTreeEvent& evt)
  {
  wxTreeItemId tid = evt.GetItem();
	if(!tid.IsOk())
		{
    wxLogDebug(wxT("OnItemExpanded(): invalid event wxTreeItemId %u"), (int) tid);
		return;
		}

  wxString sPath;
  bool bGotPath = GetItemPath(tid, sPath);
	if(!bGotPath)
		{
    wxLogDebug(wxT("OnItemExpanded(): Can't get path from tree item %u"), (int) tid);
		return;
		}

  wxLogTrace(DIRECTORYTREE_EVENTS, wxT("OnItemExpanded(): '%s'"), sPath.c_str());

	AddChildren(tid);

	// TBI: Improve this by using GetBoundingRect
  // Scroll the view so that we can see as much of the newly expanded branch as possible
	// Get the last 'nChildId', so we can call 'EnsureVisible'
	wxTreeItemId tidLastChild = GetLastChild(tid);
 	if(tidLastChild.IsOk())
 		EnsureVisible(tidLastChild);
	EnsureVisible(tid);
  }
Exemple #6
0
TreeNode* MakeTree(std::istream& in)
{
	Tokens tok(in);
	tok.AddDelims("{}");
	TreeNode* root = new TreeNode(TreeNode::strdup(""));
	AddChildren(tok, root);
	return root;
}
Exemple #7
0
bool ScenePanel::SetScene(const aiScene* scene)
{
	mSceneTree->Hide();
	mSceneTree->DeleteAllItems();
	aiNode* root = scene->mRootNode;
	wxTreeItemId rootId = mSceneTree->AddRoot(wxString(&root->mName.data[0], wxConvUTF8), -1, -1, new SceneTreeItemData( root ));
	AddChildren(root, rootId, true);
	mSceneTree->Show();
	return true;	
}
Exemple #8
0
LRESULT CHierarchyView::OnTVItemExpanding (int idCtrl, LPNMHDR pnmh, BOOL &bHandled) 
{
	NM_TREEVIEW *pNMTreeView = (NM_TREEVIEW *) pnmh;
	TVITEM *pTVItem = &pNMTreeView ->itemNew;

	//
	// If the action is expanding
	//

	if (pNMTreeView ->action == TVE_EXPAND) 
	{

		//
		// If this item has never been expanded
		//

	    if ((pTVItem ->state & TVIS_EXPANDEDONCE) == 0) 
		{

			//
			// Show a wait cursor
			//

			CWaitCursor wait;

			//
			// Turn off redraw
			//

			m_tv .SendMessage (WM_SETREDRAW, FALSE, 0);

			//
			// Set the expand once flag
			//

			m_tv .SetItemState (pTVItem ->hItem, 
				TVIS_EXPANDEDONCE, TVIS_EXPANDEDONCE);

			//
			// Add the children
			//

			AddChildren ((int) m_tv .GetItemData (
				pTVItem ->hItem), pTVItem ->hItem);

			//
			// Turn on redraw
			//

			m_tv .SendMessage (WM_SETREDRAW, TRUE, 0);
		}
	}
	return FALSE;
}
Exemple #9
0
void DirectoryTree::DoSelection(wxTreeItemId& tid)
  {
  wxLogTrace(DIRECTORYTREE_EVENTS, wxT("DoSelection()"));
  if(!tid.IsOk())
    return;

  AddChildren(tid);
  EnsureVisible(tid);
	SetFocus();
	SelectItem(tid);
  }
Exemple #10
0
Fichier : dir.c Projet : taysom/tau
static void Simple (void)
{
	int num_children = 20;
	dir_s dir = NilDir;

	dir.name = RndName();
	mkdir(dir.name, 0777);
	AddChildren(&dir, num_children);
	AuditDir(&dir);
	DeleteChildren(&dir);
	rmdir(dir.name);
	free(dir.name);
}
Exemple #11
0
void CBranchProcessor::AddChildren(MSXML2::IXMLDOMNodePtr pParent)
{
	//添加当前节点
	AddChild(pParent);

	//循环获得所有节点
	for (MSXML2::IXMLDOMNodePtr pChild = pParent->firstChild;
		NULL != pChild;
		pChild = pChild->nextSibling)
	{
	//递归
	AddChildren(pChild);
	}
}
Exemple #12
0
bool ScenePanel::AddChildren(aiNode* node, wxTreeItemId treeItem, bool root)
{
	wxTreeItemId item = treeItem;
	if (!root)
	{
		item = mSceneTree->AppendItem(treeItem, wxString(&node->mName.data[0],wxConvUTF8), -1, -1, new SceneTreeItemData(node));
	}
	for(int i = node->mNumChildren - 1; i >= 0; i--)
	{
		aiNode *child = node->mChildren[i];
		AddChildren(child, item);
	}
	return true;
}
// Removes all the child cells and fetches them again from the data source.
void ElementDataGridRow::RefreshRows()
{
	// Remove all our child rows from the table.
	RemoveChildren();

	// Load the children from the data source.
	if (data_source)
	{
		int num_rows = data_source->GetNumRows(data_table);
		if (num_rows > 0)
		{
			AddChildren(0, num_rows);
		}
	}
}
Exemple #14
0
wxTreeItemId DirectoryTree::PopulatePath(const wxString& sPath)
  {
  wxString sSeparator = wxFileName::GetPathSeparator();
  wxChar chSeparator = sSeparator.GetChar(0);

  // Ensure path finishes in path separator
	wxString sTerminatedPath = sPath;
  if(sTerminatedPath.Right(1) != sSeparator)
    sTerminatedPath += sSeparator;

  // Start from root path
  wxTreeItemId tid = GetRootItem(sPath);
	if(!tid.IsOk())
    {
    wxLogDebug(wxT("DirectoryTree::PopulatePath(): GetRootItem(sPath) failed;"), (int) tid);
    return wxTreeItemId(); 
    }

  sTerminatedPath = sTerminatedPath.AfterFirst(chSeparator);
  while(sTerminatedPath != wxT(""))
    {
		// Ensure all children exist
		AddChildren(tid);

		// Select the sub-directory
    wxString sDir = sTerminatedPath.BeforeFirst(chSeparator);
    wxLogTrace(DIRECTORYTREE_EVENTS, wxT("CreatePath(): Directory '%s'"), sDir.c_str());
    wxTreeItemId tidChild = GetChildByName(tid, sDir);
		// Fail if we can't find the sub-directory
    if(!tidChild.IsOk())
			{
			wxLogTrace(DIRECTORYTREE_EVENTS, wxT("CreatePath(): GetChildByName(%u, '%s') failed"), (int) tid, sDir.c_str());
			break;
			}

    sTerminatedPath = sTerminatedPath.AfterFirst(chSeparator);
    tid = tidChild;
    }
	
	// Return the item
  return tid;
  }
Exemple #15
0
static void AddChildren(Tokens& tok, TreeNode* parent)
{
	TreeNode* cur = 0;
	while (tok.Good())
	{
		std::string str;
		tok >> str;
		if (!tok.Good() || str.at(0) == '}')
			return;
		if (str.at(0) == '{')
		{
			if (!cur)
				cur = parent->AddChild(TreeNode::strdup(""));
			AddChildren(tok, cur);
			continue;
		}

		cur = parent->AddChild(TreeNode::strdup(str));
	}
}
Exemple #16
0
void DocHistory::AddChildren(int parent_pos, const doc_id& di, const doc_id& sel_doc, const Catalyst& catalyst) {
	wxASSERT(di.IsDocument());

	const int childCount = catalyst.GetChildCount(di);
	for (int i = 0; i < childCount; ++i) {
		const doc_id child = catalyst.GetChildID(di, i);
		item new_item;
		new_item.doc = child;
		new_item.date = catalyst.GetDocDate(child);
		new_item.parent = parent_pos;

		// Find the insert pos
		size_t n;
		for (n = parent_pos+1; n < m_items.size(); ++n) {
			if (new_item.date < m_items[n].date) {
				m_items.insert(m_items.begin()+n, new_item);

				// The indexes under the insertion has moved, so
				// we also have to update any references to this range
				if (m_selectedNode >= (int)n) ++m_selectedNode;
				for (size_t n2 = n+1; n2 < m_items.size(); ++n2) {
					int& parent = m_items[n2].parent;
					if (parent >= (int)n) ++parent;
				}
				break;
			}
		}
		if (n == m_items.size()) {
			m_items.push_back(new_item);
		}

		// Check if this is the selected node
		if (child.IsDocument()) {
			if (child == sel_doc) m_selectedNode = n;

			AddChildren(n, child, sel_doc, catalyst);
		}
		else if (child.SameDoc(sel_doc)) m_selectedNode = n;
	}
}
Exemple #17
0
bool CBranchProcessor::Process()
{
	//解析xml文件
	MSXML2::IXMLDOMDocumentPtr m_plDomDocument;     
	MSXML2::IXMLDOMElementPtr m_pDocRoot;
	HRESULT hr=m_plDomDocument.CreateInstance(__uuidof(MSXML2::DOMDocument30));
	if(FAILED(hr))
	{
		return false;
	}
	variant_t vResult=m_plDomDocument->load(CString(saveplace).AllocSysString());
	
	if (((bool)vResult) == TRUE)
	{
		m_pDocRoot = m_plDomDocument->documentElement;
		AddChildren(m_pDocRoot);
	}
	else
	{
		return false;
	}
	return true;
}
void uwTreeList::ExpandPlaceholder( const wxTreeItemId& parent )
{
	unDataTree& tree = GetDataTree( parent );

	if( tree.Expand() )
	{
		AddChildren( tree );	
		if( tree.ShouldSort() )				
			SortChildren( tree.GetTreeID() );	

        wxTreeItemIdValue cookie = 0;
        wxTreeItemId child = GetFirstChild(parent, cookie);
        while( child.IsOk() ) 
        {
            unDataTree& tree_child = GetDataTree( child );
            if( tree_child.GetAutoExpand() )
            {
                Expand(child);
            }
            child = GetNextChild(parent, cookie);
        }
	}
}
Exemple #19
0
void DocHistory::ReBuildTree() {
	if (m_document_id == -1) {
		wxASSERT(m_sourceDoc.IsDraft());
		// The draft has no parent (and can't have children)
		// So just add a single entry.
		m_items.clear();
		m_positions.clear();

		item new_item;
		new_item.doc = m_sourceDoc;
		cxLOCKDOC_READ(m_doc)
			new_item.date = doc.GetDate();
		cxENDLOCK
		new_item.parent = 0; // root is it's own parent
		new_item.ypos = 0;

		m_items.push_back(new_item);
		m_positions.push_back(0);
		m_selectedNode = 0;

		// Update timeline
		m_pTimeline->Clear();
		m_pTimeline->AddItem(new_item.date);

		// Update the VersionTree
		m_pTree->Clear();
		m_pTree->AddRoot();
	}
	else
	{
		m_items.clear();
		m_positions.clear();

		// Add the root
		const doc_id root(DOCUMENT, m_document_id, 0); // root is always zero
		item new_item;
		new_item.doc = root;
		cxLOCK_READ(m_catalyst)
			new_item.date = catalyst.GetDocDate(root);
			new_item.parent = 0; // root is it's own parent
			new_item.ypos = 0;
			m_items.push_back(new_item);
			if (m_sourceDoc == root) m_selectedNode = 0;
			else m_selectedNode = -1; // not yet set

			// Build the tree
			AddChildren(0, root, m_sourceDoc, catalyst);
		cxENDLOCK
		wxASSERT(m_selectedNode >= 0 && m_selectedNode < (int)m_items.size());

		// Update Timeline & VersionTree
		m_pTimeline->Clear();
		m_pTree->Clear();
		if (!m_items.empty()) {
			m_pTimeline->AddItem(new_item.date);
			m_pTree->AddRoot();
		}
		for(unsigned int i = 1; i < m_items.size(); ++i) {
			const int ypos = m_pTimeline->AddItem(m_items[i].date);
			m_pTree->AddNode(m_items[i].parent, ypos);
			m_items[i].ypos = ypos;
		}
	}

	m_pTree->CalculateLayout();

	m_treeHeight = m_items.empty() ? 0 : m_items.back().ypos + m_lineHeight;
}
void ElementDataGridRow::OnRowAdd(DataSource* _data_source, const Rocket::Core::String& _data_table, int first_row_added, int num_rows_added)
{
	if (_data_source == data_source && _data_table == data_table)
		AddChildren(first_row_added, num_rows_added);
}
Exemple #21
0
//----------------------------------------------------------------------------
//
// build kd tree (prototype)
//
// pts: point locations to be indexed in kd-tree (for now)
// loc_num_pats: local number of points
// glo_num_pats: global number of points
// num_levels: number of tree levels, counting root
// num_bins: number of histogram bins at all levels
//
void Blocking::BuildTree(float *pts, int loc_num_pts, int glo_num_pts,
			 int num_levels, int num_bins) {

  int num_hists; // number of historgrams in this level
  int median = glo_num_pts / 2; // desired median
  int parent = 0; // curent parent tree node
  int tot_num_bins; // total number of bins in all histograms for a block

  // headers for each block
  int **hdrs = new int*[nb];
  for (int i = 0; i < nb; i++)
    hdrs[i] = new int[1];

  // todo: only the right number of bins for global range
  // yet to implement local ranges, especially for later levels

  // allocate histograms, hists[i] allocated and freed during each level
  int **hists;
  hists = new int*[nb];

  // initialize kd-tree with level 0
  kd_node_t node;
  for (int i = 0; i < dim; i++) {
    node.bounds.min[i] = data_min[i];
    node.bounds.max[i] = data_max[i];
  }
  node.proc = 0; // default
  node.l_child = -1; // empty, to be filled in later
  node.r_child = -1; // ditto
  node.parent = -1; // will remain empty for root
  kd_tree.push_back(node);

  for (int level = 1; level < num_levels; level++) { // tree levels

    int dir = (level - 1) % dim;
    num_hists = ((level - 1) ? num_hists * 2 : 1);
    // toto: reduce histogram size with level (after one full cycle of all dirs)
    // turned off for now
//     if (level - 1)
//       num_bins = (num_bins >= 2 * min_num_bins ? num_bins / 2 : min_num_bins);
    tot_num_bins = num_hists * num_bins;

    for (int b = 0; b < nb; b++)
      hists[b] = new int[tot_num_bins];

    // init histograms
    for (int b = 0; b < nb; b++) {
      for (int i = 0; i < tot_num_bins; i++)
	hists[b][i] = 0;
    }

    for (int b = 0; b < nb; b++) { // local blocks

      // scan and bin objects
      // todo: is data_max and data_min set correctly? I doubt it for particles
      float bin_width = (data_max[dir] - data_min[dir]) / num_bins;
      for (int i = 0; i < loc_num_pts; i++) {

	// search for particle in tree
	// todo: don't have to start at root each time
	int pt_node = SearchTree(&pts[3 * i], 0);
	// pos of node in level
	int temp = (int)(pow(2, level - 1));
	int node_level_pos = pt_node + 1 - temp;

	// debug
// 	fprintf(stderr, "pt: %.1f %.1f %.1f in node %d: node_level_pos %d\n",
// 		pts[3 * i], pts[3 * i + 1], pts[3 * i + 2],
// 		pt_node, node_level_pos);

	int bin = pts[3 * i + dir] / bin_width;
	if (bin >= num_bins)
	  bin = num_bins - 1;
	bin += num_bins * node_level_pos; // move to correct histogram
	hists[b][bin]++;

      } // objects

      hdrs[b][0] = tot_num_bins;

    } // local blocks

    // debug: print the histograms
//     for (int b = 0; b < nb; b++) {
//       for (int i = 0; i < num_bins; i++)
// 	fprintf(stderr, "hists[%d][%d] = %d\n", b, i, hists[b][i]);
//     }

    // merge the histograms
    // todo: change merge and swap API to take a target k and figure out
    // rounds and kvalues itself
    int rounds = log2f((float)tot_b); // todo: assumes power of 2 blocks
    int kvalues[rounds];
    for (int i = 0; i < rounds; i++)
      kvalues[i] = 2;
    int nb_merged; // number of output merged blocks

    DIY_Merge_blocks(did, (char**)hists, hdrs, rounds, kvalues, 
		     &KdTree_MergeHistogram, &KdTree_CreateHistogram, 
		     &KdTree_DestroyHistogram, 
		     &KdTree_CreateHistogramType, &nb_merged);

    // find median split points in histograms
    int split_index[num_hists]; // split indices in cumulative mass function
    if (rank == groupsize - 1) {

      assert(nb_merged == 1); // sanity

      // debug: print the merged histogram
//       for (int i = 0; i < num_bins; i++)
// 	fprintf(stderr, "hist[%d] = %d\n", i, hists[0][i]);

      // convert histogram to cumulative mass function; prefix sum
      for (int i = 0; i < num_hists; i++) {
	int ofst = i * num_bins; // start of this histogram
	for (int j = 1; j < num_bins; j++)
	  hists[0][ofst + j] += hists[0][ofst + j - 1];
      }

      // debug: print the CMF
//       for (int i = 0; i < num_bins; i++)
// 	fprintf(stderr, "cmf[%d] = %d\n", i, hists[0][i]);

      // find split index of CMF
      for (int i = 0; i < num_hists; i++) {
	int ofst = i * num_bins; // start of this histogram
	split_index[i] = BinarySearch(ofst, num_bins, hists[0], median);
	// debug
	fprintf(stderr, "level = %d split_index[%d] = %d median = %d\n", 
		level, i, split_index[i], median);
      }

    }

    // broadcast the split points
    MPI_Bcast(split_index, num_hists, MPI_INT, groupsize - 1, comm);

    // add new level to kd-tree
    for (int i = 0; i < num_hists; i++) {
      int ofst = i * num_bins; // start of this histogram
      AddChildren(parent + i, dir, ((float)split_index[i] - ofst)/ num_bins);
    }

    parent += num_hists;
    median /= 2;

    // cleanup
    for (int b = 0; b < nb; b++)
      delete[] hists[b];

  // debug: print the kd tree
//   if (rank == 0) { // duplicated on all ranks, print only once
//     for (int i = 0; i < kd_tree.size(); i++)
//       fprintf(stderr, "kd tree node %d: proc %d min[%.1f %.1f %.1f] "
// 	      "max[%.1f %.1f %.1f] l_child %d r_child %d parent %d\n",
// 	      i, kd_tree[i].proc, kd_tree[i].bounds.min[0], 
// 	      kd_tree[i].bounds.min[1], kd_tree[i].bounds.min[2], 
// 	      kd_tree[i].bounds.max[0], kd_tree[i].bounds.max[1], 
// 	      kd_tree[i].bounds.max[2], kd_tree[i].l_child, kd_tree[i].r_child,
// 	      kd_tree[i].parent);
//   }

  } // tree levels

  // debug: print the kd tree
  if (rank == 0) { // duplicated on all ranks, print only once
    for (int i = 0; i < (int)kd_tree.size(); i++)
      fprintf(stderr, "kd tree node %d: proc %d min[%.1f %.1f %.1f] "
	      "max[%.1f %.1f %.1f] l_child %d r_child %d parent %d\n",
	      i, kd_tree[i].proc, kd_tree[i].bounds.min[0], 
	      kd_tree[i].bounds.min[1], kd_tree[i].bounds.min[2], 
	      kd_tree[i].bounds.max[0], kd_tree[i].bounds.max[1], 
	      kd_tree[i].bounds.max[2], kd_tree[i].l_child, kd_tree[i].r_child,
	      kd_tree[i].parent);
  }

  // cleanup
  delete[] hists;

}