On Oct 30, 2014, at 2:35 AM, Gurwinder Singh Bains <gswithba...@gmail.com> 
wrote:

> On Sun, Oct 19, 2014 at 11:14 PM, Gurwinder Singh Bains
> <gswithba...@gmail.com> wrote:
>> BRL-CAD stores database into binary format. I am trying to store it in
>> text format.

Why?  This is not needed or recommended.

>> I have read that in binary .g file information is stored
>> as Header, Title of database, Units, Objects, Matter, Combination etc.
>> and in last Footer. There is g2asc which converts binary data into ASC
>> but when I use command "g2asc .g_file_name .asc_file_name", it doesn't
>> write Header, Footer and other contents which are in binary file.

g2asc does set the title, units, objects, mater info, combs, and more, writing 
out a binary .g file into our .asc format.  I’m not sure why you’d want to do 
this, but it will write out all of the database information in ascii format.

>> Is there any way to get or store our brl-cad's .g into text format? I
>> have searched brlcad's directory, there are many flex and bison file
>> that are used for parsing the binary file, can they help me in doing this?

There are not flex and bison files for parsing our binary .g file format.  
There doesn’t exist a BNF either, so creating a formalized parser that way 
would be quite complicated.  Academically interesting, but certainly not easy 
or highly beneficial.

> Under BRL-CAD_directory/src/librt/ directory there are files,
> db_open.c, db_scan.c. In db_open.c It opens a file and write into it
> in "w+b" mode
> means it writes in binary mode.  I am trying to compile it so that I am
> able to write database into "w" means text mode but under
> source/src/librt/ directory it gives header files error.

You did narrow down on a few of the files related to reading/writing the .g 
format, but 'w+b’ doesn’t exactly mean what you suggest it means…  The ‘b’ is 
only used on the Windows platform and does absolutely nothing on most any other 
platform.  All it does is cause newlines to get carriage-return characters 
inserted automatically.  From your description, you’re using the function wrong 
and it’s not at all clear to me what you’re trying to accomplish where you’d be 
concerned about writing ascii data.

What exactly are you trying to accomplish?  Your comments suggest several 
misunderstandings about how file operations work, and more generally how data 
is written and read to/from memory and disk.

If this is related to your g-pov work, the best relevant examples are still the 
various other g-* converters in the src/conv directory with g-dot.c being 
particularly relevant as a simple high-level format.  Just don’t ignore all the 
other converters in there too.  Lots of examples that have different 
characteristics.

Cheers!
Sean


------------------------------------------------------------------------------
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to