Searching an octree

This is a discussion on Searching an octree within the C Programming forums, part of the General Programming Boards category; Hello, I'm trying to devise a method for searching an octree in a particular way. To elaborate, I'm using the ...

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

    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, 06:57 AM
  2. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 06:20 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21