POV-Ray : Newsgroups : povray.pov4.discussion.general : Request for *.df4 format (ASCII text based) Server Time
22 Dec 2024 12:22:58 EST (-0500)
  Request for *.df4 format (ASCII text based) (Message 1 to 10 of 34)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Woody
Subject: Request for *.df4 format (ASCII text based)
Date: 15 Feb 2008 07:35:00
Message: <web.47b586279e245a8f94e61a50@news.povray.org>
While working with MS VC++ trying to create programs to create *.df3 I've found
it very difficult. I can only imagine how difficult it is, with the limited
number of converters, for people who have little or no C++ experience (such as
myself, never heard of big endian or little endian till working with *.df3
files in C++).

Would it be possible to include a *.df4 format where instead of dimension and
voxel data being in byte code, it was in some type of standard *.txt format?
Possibly ASCII? I realize it increase runtime (not sure how much, but I suppose
"Dramatically increase runtime" might be the right answer"). Even thought a
*.df4 option is included the *.df3 option can also be included for people where
runtime does matter.

Any possibility of this?


Post a reply to this message

From: Warp
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 15 Feb 2008 12:06:32
Message: <47b5c698@news.povray.org>
Woody <nomail@nomail> wrote:
> Would it be possible to include a *.df4 format where instead of dimension and
> voxel data being in byte code, it was in some type of standard *.txt format?
> Possibly ASCII? I realize it increase runtime (not sure how much, but I suppose
> "Dramatically increase runtime" might be the right answer"). Even thought a
> *.df4 option is included the *.df3 option can also be included for people where
> runtime does matter.

  Nobody would write those files by hand anyways, so what's the point in
having them in readable ascii format?

  Writing the current DF3 file from a program (in basically any language)
is quite trivial. If you don't know how, just ask.

-- 
                                                          - Warp


Post a reply to this message

From: triple r
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 15 Feb 2008 12:20:01
Message: <web.47b5c907f13a83cfae42298f0@news.povray.org>
"Woody" <nomail@nomail> wrote:.
>
> Any possibility of this?

A good learning opportunity if nothing else (it was for me), but Paul Bourke's
page provides a full working c code to produce a df3 file.  Probably about a
five or ten minute effort and you could turn it into a conversion program.  Not
as accessible as a new format, but at least if you render it multiple times,
POV-Ray doesn't have to read an ASCII file every time.  Seems like a trivial
patch to switch it to ASCII-based df3 files too.

http://ozviz.wasp.uwa.edu.au/~pbourke/modelling_rendering/df3/
http://www.linuxjournal.com/article/7486

 - Ricky


Post a reply to this message

From: Woody
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 15 Feb 2008 21:35:00
Message: <web.47b64b5ff13a83cf7ad34f770@news.povray.org>
"triple_r" <rre### [at] hotmailcom> wrote:
> "Woody" <nomail@nomail> wrote:.
> >
> > Any possibility of this?
>
> A good learning opportunity if nothing else (it was for me), but Paul Bourke's
> page provides a full working c code to produce a df3 file.  Probably about a
> five or ten minute effort and you could turn it into a conversion program.  Not
> as accessible as a new format, but at least if you render it multiple times,
> POV-Ray doesn't have to read an ASCII file every time.  Seems like a trivial
> patch to switch it to ASCII-based df3 files too.
>
> http://ozviz.wasp.uwa.edu.au/~pbourke/modelling_rendering/df3/
> http://www.linuxjournal.com/article/7486
>
>  - Ricky

I did check out the first website. However I found the endian preprocessor macro
confusing. To be honest. I was never trained in plain C, only C++.

I used the VC++ toolkit MS put out in 2003. Anybody know any free C compilers
where this might work for an intel Machine?

Which Preprocessor Macro on the Paul Bourkes page should I be using?


Post a reply to this message

From: Woody
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 15 Feb 2008 21:55:01
Message: <web.47b64fc7f13a83cf7ad34f770@news.povray.org>
>   Writing the current DF3 file from a program (in basically any language)
> is quite trivial. If you don't know how, just ask.
>
> --
>                                                           - Warp

Warp,

If you every have a few moments do you think you could modify the source code
you posted at http://news.povray.org/4799ff49%40news.povray.org, so that it can
take one or more *.txt files specified in the command line (instead of the
testdata.txt) and output them into df3 format with the same name (except for
the txt extension).

If nothing is entered in the command line have it print the directions and a
"C++ Code developed by Warp". But this last part is just being needy on my part
and I can probably write that code myself.

-Jeff


Post a reply to this message

From: triple r
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 15 Feb 2008 22:05:01
Message: <web.47b651dbf13a83cfae42298f0@news.povray.org>
"Woody" <nomail@nomail> wrote:
> I did check out the first website. However I found the endian preprocessor macro
> confusing. To be honest. I was never trained in plain C, only C++.

Fair enough.  It could be worse though.  I suppose I was only 'trained' (hardly)
in Visual Basic (shudder) and Fortran (marginally less shudder).  So I agree,
but maybe this would be a good start:

http://www.space.unibe.ch/comp_doc/c_manual/C/CONCEPT/bitwise.html

> I used the VC++ toolkit MS put out in 2003. Anybody know any free C compilers
> where this might work for an intel Machine?

Doesn't work in VC++?  Haven't used that compiler and for that matter I don't do
much in C++, but I would think it would be mostly compatible.

http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B

> Which Preprocessor Macro on the Paul Bourkes page should I be using?

Hmm.  One then the other?  Can never remember.  Sorry I'm just dismissing your
questions with links, but the bottom line is that C/C++ is very easy to learn
since there are so many good webpages on the matter.  Takes some time, but it's
not bad.  Good luck.

 - Ricky


Post a reply to this message

From: Woody
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 15 Feb 2008 22:35:00
Message: <web.47b658cef13a83cf7ad34f770@news.povray.org>
>
>   Nobody would write those files by hand anyways, so what's the point in
> having them in readable ascii format?
>
>   Writing the current DF3 file from a program (in basically any language)
> is quite trivial. If you don't know how, just ask.
>
When you say no one writes them by hand anyway, do you mean its unlikely someone
would code each individual voxel in this manner?

I just thought sinc *.pov files and *.inc files are in ascii text it would make
sense to have non standard files (standard being GIF JPEG etc) also in txt so
they would be relatively easy to edit.

But your point is taken, that you are much more likely to edit a single line of
a POV or INC file then you are to edit a single voxel in a DF3 file.


Post a reply to this message

From: Warp
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 16 Feb 2008 06:10:31
Message: <47b6c4a6@news.povray.org>
Woody <nomail@nomail> wrote:
> If you every have a few moments do you think you could modify the source code
> you posted at http://news.povray.org/4799ff49%40news.povray.org, so that it can
> take one or more *.txt files specified in the command line (instead of the
> testdata.txt) and output them into df3 format with the same name (except for
> the txt extension).

  You mean with the same input file format?
  How about this:


#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cstdio>

int main(int argc, char* argv[])
{
    // Limit the size of the df3 dimensions (safeguard against invalid input).
    // Maximum df3 size will be SIZE_LIMIT*SIZE_LIMIT*SIZE_LIMIT.
    const size_t SIZE_LIMIT = 256;

    if(argc < 2)
    {
        std::cout << "Usage: " << argv[0] << " <files>\n";
        return 0;
    }

    for(int i = 1; i < argc; ++i) // for each input file
    {
        std::ifstream is(argv[i]);
        if(!is.good())
        {
            std::cerr << "Couldn't open ";
            std::perror(argv[i]);
            continue;
        }

        size_t xSize, ySize, zSize;
        is >> xSize >> ySize >> zSize;
        if(xSize > SIZE_LIMIT || ySize > SIZE_LIMIT || zSize > SIZE_LIMIT)
        {
            std::cout << "Skipping " << argv[i] << " (invalid input)\n";
            continue;
        }

        std::vector<char> data(xSize*ySize*zSize + 6, 0);

        // Setup df3 header:
        data[0] = xSize/256; data[1] = xSize%256;
        data[2] = ySize/256; data[3] = ySize%256;
        data[4] = zSize/256; data[5] = zSize%256;

        // Read input data and create df3 data:
        while(true)
        {
            size_t x, y, z, value;
            is >> x >> y >> z >> value;
            if(!is.good()) break;
            const size_t ind = x + y*xSize + z*xSize*ySize + 6;
            if(ind < data.size())
                data[ind] = char(value);
        }

        // Write df3 file:
        std::string filename = argv[i];
        size_t ind = filename.find_last_of('.');
        if(ind != filename.npos) filename.resize(ind);
        filename += ".df3";
        std::ofstream os(filename.c_str(), std::ios::binary);
        os.write(&data[0], data.size());
        std::cout << argv[i] << " -> " << filename << std::endl;
    }
}


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 16 Feb 2008 07:39:38
Message: <47b6d98a$1@news.povray.org>

> But your point is taken, that you are much more likely to edit a single line of
> a POV or INC file then you are to edit a single voxel in a DF3 file.
> 

And even if you wanted to edit a single voxel in a DF3, you could use an 
hex editor :)


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 26 Feb 2008 17:04:58
Message: <47c48d0a$1@news.povray.org>
Warp wrote:
> Woody <nomail@nomail> wrote:
>> Would it be possible to include a *.df4 format where instead of dimension and
>> voxel data being in byte code, it was in some type of standard *.txt format?
>> Possibly ASCII? I realize it increase runtime (not sure how much, but I suppose
>> "Dramatically increase runtime" might be the right answer"). Even thought a
>> *.df4 option is included the *.df3 option can also be included for people where
>> runtime does matter.
> 
>   Nobody would write those files by hand anyways, so what's the point in
> having them in readable ascii format?
> 
>   Writing the current DF3 file from a program (in basically any language)
> is quite trivial. If you don't know how, just ask.

But some might want to use POV-Ray SDL to write them...

=)

-- 
Tor Olav
http://subcube.com


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.