POV-Ray : Newsgroups : povray.pov4.discussion.general : Request for *.df4 format (ASCII text based) Server Time
2 Jun 2024 03:39:41 EDT (-0400)
  Request for *.df4 format (ASCII text based) (Message 5 to 14 of 34)  
<<< Previous 4 Messages Goto Latest 10 Messages Next 10 Messages >>>
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

From: Warp
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 26 Feb 2008 18:31:05
Message: <47c4a139@news.povray.org>
Tor Olav Kristensen <tor### [at] toberemovedgmailcom> wrote:
> But some might want to use POV-Ray SDL to write them...

  Then it would be better to enhance the SDL (or better yet, redesign it
from scratch) so that you can create DF3's with it, rather than change
the DF3 so that you can create them with the current SDL...

  The latter only helps creating DF3 files. The former helps creating
tons of other files too.

-- 
                                                          - Warp


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 26 Feb 2008 19:36:32
Message: <47c4b090@news.povray.org>
Warp wrote:
> Tor Olav Kristensen <tor### [at] toberemovedgmailcom> wrote:
>> But some might want to use POV-Ray SDL to write them...
> 
>   Then it would be better to enhance the SDL (or better yet, redesign it
> from scratch) so that you can create DF3's with it, rather than change
> the DF3 so that you can create them with the current SDL...
> 
>   The latter only helps creating DF3 files. The former helps creating
> tons of other files too.

Yes, I agree.

-- 
Tor Olav
http://subcube.com


Post a reply to this message

From: ingo
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Feb 2008 15:16:13
Message: <Xns9A51D85816D16seed7@news.povray.org>
in news:web.47b586279e245a8f94e61a50@news.povray.org Woody 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?

Have a look at the PGM file format 
http://netpbm.sourceforge.net/doc/pgm.html it supports multiple layers. I 
don't know how much of the spec is supported by POV-Ray, I doubt it deals 
with multiple images.

Ingo


Post a reply to this message

From: Antonio Ferrari
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 4 Mar 2008 11:25:00
Message: <web.47cd7729f13a83cf29aed21e0@news.povray.org>
Tor Olav Kristensen <tor### [at] TOBEREMOVEDgmailcom> wrote:

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

Yes. Sometimes ago I needed to write df3 files from SDL, but that's impossible.
On the other side, Povray read only df files in binary format. I think that one
would want to create df3 files in his macros...


Post a reply to this message

<<< Previous 4 Messages Goto Latest 10 Messages Next 10 Messages >>>

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