Well shoot, that's even easier and you definitely don't need a struct region to 
do that! :-)  An extension of the db_walk_tree() example on the wiki will do 
the trick.  The trick being that the region_end hook will only visit positive 
regions and the tree state has all the attributes already loaded.

Cheers!
Sean

p.s. The example below doesn't have a slew of error checking that you should 
add.


#include "common.h"
#include "bu.h"
#include "raytrace.h"

union tree *region_attrs(struct db_tree_state *tsp, struct db_full_path *pathp, 
union tree *tp, genptr_t data)
{
  int i;
  char *path = db_path_to_string(pathp);
  struct bu_attribute_value_pair *avpp;

  bu_log("REGION: %s\n", bu_basename(path));
  bu_free(path, "path");
  avpp = tsp->ts_attrs.avp;
  for (i = 0; i < tsp->ts_attrs.count; i++, avpp++) {
    bu_log("\t%s=%s\n", avpp->name, avpp->value);
  }

  return 0;
}

int
main(int argc, char *argv[])
{
  struct db_i *dbip;
  struct db_tree_state state = rt_initial_tree_state;

  if (argc < 2) {
    bu_exit(0, "Usage: %s db.g obj\n", argv[0]);
  }

  dbip = db_open(argv[1], "r");
  db_dirbuild(dbip);
  db_lookup(dbip, argv[2], 1);

  state.ts_dbip = dbip;
  state.ts_resp = &rt_uniresource;
  rt_init_resource( &rt_uniresource, 0, NULL );

  db_walk_tree(dbip, 1, (const char **)argv+2, 1, &state, NULL, region_attrs, 
NULL, NULL);

  return 0;
}


>Well, what I really want during this walk is to enter at a tree top
>(say 'all') and list every positive region under it (no dups).  For
>each region i want all its attributes.
>
>That's it.
>
>Thanks, Sean.
>
>-Tom


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
BRL-CAD Developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to