Thread: Searching an octree

  1. #1
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273

    Searching an octree

    Hello,

    I'm trying to devise a method for searching an octree in a particular way. To elaborate, I'm using the struct:-
    Code:
    typedef struct TAGoctree {
    	unsigned long count;
    	int level;
    	struct TAGoctree *children[8];
    } node;
    Given generation of a tree of these structs 9 "levels" deep (0-8), and with only the structs at level 8 having a value for count, I want to find the struct that has the lowest of the counts, or the first one with the lowest. Could anyone give any clues?

  2. #2
    Registered User lobo's Avatar
    Join Date
    Oct 2001
    Posts
    71
    Use standard depth-first search approach:
    (pseudo)

    dummy_dfs(current)
    if (current->level == 8)
      if (min > count)
       min = count;
       minstruct_id = current_struct_id; //whatever ~ pointer..just your id of struct with lowest value

    else //level != 8 => < 8
    &nbsp; for (i = 0; i < 8; i++)
    &nbsp;&nbsp; dummy_dfs(current->child[i]);

    Hope this helps ..
    Last edited by lobo; 11-21-2003 at 06:00 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked list / Octree deletion
    By DrSnuggles in forum C++ Programming
    Replies: 2
    Last Post: 08-03-2008, 05:57 AM
  2. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Visual C++ 2005 linking and file sizes
    By Rune Hunter in forum C++ Programming
    Replies: 2
    Last Post: 11-12-2005, 10:41 PM