No problem, Steve, glad to hear that you got it working!
For whatever it's worth, here is the other LIBGED method I mentioned that is even more simple:
void printTops(const char *gFile) {
const char *argv[4] = {"tops", "-n", NULL, NULL};
struct ged *gedp = ged_open("db", gFile, 0);
ged_tops(gedp, 2, argv);
bu_log("TOP LEVEL OBJECTS:\n%V\n", &gedp->ged_result_str);
ged_close(gedp);
}
That is basically running mged's "tops" command directly and printing the result. It's a MUCH more limited approach since you'd have to parse the string to do anything more than print it, but it doesn't get much simpler if printing is your goal.
That said, LIBGED is our newest library and is constantly going through drastic changes, so I wouldn't recommend it for production use unless you're willing to track potentially major changes to the API. The library does expose almost every single command available in mged, though, so it's pretty powerful.
Cheers!
Sean
On Dec 02, 2010, at 01:47 PM, "Watkins, Steven M CIV NSWCDD, G24" <[email protected]> wrote:
Hi
Thanks Sean for the info. That was exactly what I was looking for. The BRLCAD_DLL preprocessor also worked. Here is some code that prints the tops of the geometry (I think).
void printBrlCadTops(char *gFileName)
{
struct rt_i *rtip;
struct directory *dp;
char idbuf[RT_BUFSIZE] = {0};
if( (rtip=rt_dirbuild(gFileName, idbuf, sizeof(idbuf))) != RTI_NULL )
{
db_update_nref(rtip->rti_dbip, &rt_uniresource);
FOR_ALL_DIRECTORY_START(dp, rtip->rti_dbip)
{
if ((dp->d_nref == 0) && (dp->d_major_type == DB5_MAJORTYPE_BRLCAD))
fprintf(stderr, "%s\n", dp->d_namep);
} FOR_ALL_DIRECTORY_END;
rt_free_rti(rtip);
}
}
Thanks again.
Steve
tops.c
Description: Binary data
------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________ BRL-CAD Developer mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/brlcad-devel
