POV-Ray : Newsgroups : povray.pov4.discussion.general : Request for *.df4 format (ASCII text based) Server Time
18 May 2024 16:52:02 EDT (-0400)
  Request for *.df4 format (ASCII text based) (Message 21 to 30 of 34)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 4 Messages >>>
From: bapt
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 06:40:00
Message: <web.4c779501f13a83cff7b786010@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 27.08.2010 07:39, schrieb bapt:
>
> >> You might consider this a case of "POV-Ray fails to help you with a
> >> useful error message": Your media has a density, but no type. Is it
> >> supposed to be absorbing, emitting or scattering?
> >
> > I see, I added the following but still get a blank page,
> >
> > #declare theinterior = interior {
> >     media {
> >      emission<1,1,1>  / 10
> >       absorption<1,1,1>  / 30
> >       scattering { 1,<0,0,0>  }
> >        density {
> >           density_file df3 "data.df3"
> >           interpolate 1
> >           color_map {
> >              [0.00 rgb<0,0,0>]
> >              [0.2 rgb<0,0,1>]
> >              [0.4 rgb<0,1,0>]
> >              [1.00 rgb<1,0,0>]
> >           }
> >        }
> >     }
> > }
>
> - Emission will be invisible, as your background is plain white.
>
> - You can leave out scattering, as with a value of <0,0,0> it does
> nothing (the scattering color specifies how much the red, green and blue
> components of the light will be affected).
>
> - Your absorption is simply too weak. Try absorption <1,1,1>*30 instead.
> Depends on how dense your density map actually is, though. Note that the
> smaller the distances in your scene are, the higher your media
> parameters have to be for the same effect.


Hi again,

I really appreciate your comments. Still not working though. I'm using megapov
on a Mac by the way, if it should make any difference.

Is there somewhere I could find a minimal example of what I should export as a
density file, some specification of what coordinates and values I should use to
see something within my box?

box {
   <0,0,0>, <1,1,1>
   pigment { rgbf 1 }
   interior { theinterior }
   }

I'm using R to create a table of values, with the following script

N <- 100
xx <- seq(0,1, length=N)
d <- expand.grid(x=xx,y=xx,z=xx)
d$t <- runif(nrow(d), 0, 255) # random values

cat(file="data.dat", "1 1 1\n")
write.table(d,file="data.dat",row.names = F,
            col.names = F,append=T)


Thanks,

baptiste


Post a reply to this message

From: clipka
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 07:32:09
Message: <4c77a239@news.povray.org>
Am 27.08.2010 12:35, schrieb bapt:

> Is there somewhere I could find a minimal example of what I should export as a
> density file, some specification of what coordinates and values I should use to
> see something within my box?

> I'm using R to create a table of values, with the following script
>
> N<- 100
> xx<- seq(0,1, length=N)
> d<- expand.grid(x=xx,y=xx,z=xx)
> d$t<- runif(nrow(d), 0, 255) # random values
>
> cat(file="data.dat", "1 1 1\n")
> write.table(d,file="data.dat",row.names = F,
>              col.names = F,append=T)

I'm sorry, I have no idea what "R" is.

To make sure what I told you would indeed to the trick, I generated a 
sample density file by adding the following additional statements at the 
beginning of the scene file you provided:

   #include "arrays.inc"

   #declare A = array[2][2][2] {
     { { 0.1, 0.2 }, { 0.3, 0.4 } },
     { { 0.5, 0.6 }, { 0.7, 0.8 } }
   }

   ARRAYS_WriteDF3(A, "data.df3", 8)

(using POV-Ray 3.7 beta 38; it won't work with POV-Ray 3.6)

This would correspond to a 2x2x2 grid, with cells filled as follows:

   0,0,0   26
   0,0,1   51
   0,1,0	  77
   0,1,1  102
   1,0,0  153
   1,0,1  179
   1,1,0  204

This does work - for example - with absorption <1,1,1>*30 on a white 
background, or emission<1,1,1>*10 on a black background.

If you still can't get this to work, then something's broken in your 
workflow. Otherwise, you're just still too cautious about the absorption 
values to get your own density files working. Be bold to try out some 
insanely large values - you can't physically break anything ;-)


Post a reply to this message

From: bapt
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 11:25:00
Message: <web.4c77d867f13a83cff7b786010@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 27.08.2010 12:35, schrieb bapt:
>
> > Is there somewhere I could find a minimal example of what I should export as a
> > density file, some specification of what coordinates and values I should use to
> > see something within my box?
>
> > I'm using R to create a table of values, with the following script
> >
> > N<- 100
> > xx<- seq(0,1, length=N)
> > d<- expand.grid(x=xx,y=xx,z=xx)
> > d$t<- runif(nrow(d), 0, 255) # random values
> >
> > cat(file="data.dat", "1 1 1\n")
> > write.table(d,file="data.dat",row.names = F,
> >              col.names = F,append=T)
>
> I'm sorry, I have no idea what "R" is.
>
> To make sure what I told you would indeed to the trick, I generated a
> sample density file by adding the following additional statements at the
> beginning of the scene file you provided:
>
>    #include "arrays.inc"
>
>    #declare A = array[2][2][2] {
>      { { 0.1, 0.2 }, { 0.3, 0.4 } },
>      { { 0.5, 0.6 }, { 0.7, 0.8 } }
>    }
>
>    ARRAYS_WriteDF3(A, "data.df3", 8)
>
> (using POV-Ray 3.7 beta 38; it won't work with POV-Ray 3.6)
>
> This would correspond to a 2x2x2 grid, with cells filled as follows:
>
>    0,0,0   26
>    0,0,1   51
>    0,1,0   77
>    0,1,1  102
>    1,0,0  153
>    1,0,1  179
>    1,1,0  204
>
> This does work - for example - with absorption <1,1,1>*30 on a white
> background, or emission<1,1,1>*10 on a black background.
>
> If you still can't get this to work, then something's broken in your
> workflow. Otherwise, you're just still too cautious about the absorption
> values to get your own density files working. Be bold to try out some
> insanely large values - you can't physically break anything ;-)

Damn, it's so close but... no luck. I cannot install POV-Ray 3.7 for some reason
(Mac) and the values above run through the c++ script still give me a blank
page. Would you mind posting the df3 and pov files so I can rule out the
conversion and know for sure that my povray is broken? I have cranked up the
absorption well above reasonable values and it's still all white.

Thanks,

baptiste


Post a reply to this message

From: clipka
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 14:48:28
Message: <4c78087c$1@news.povray.org>
Am 27.08.2010 17:23, schrieb bapt:

> Damn, it's so close but... no luck. I cannot install POV-Ray 3.7 for some reason
> (Mac) and the values above run through the c++ script still give me a blank
> page. Would you mind posting the df3 and pov files so I can rule out the
> conversion and know for sure that my povray is broken? I have cranked up the
> absorption well above reasonable values and it's still all white.

Posted it in povray.binary.scene-files, I hope it helps. I must say that 
I assume your c++ program is broken in some way.


Post a reply to this message

From: bapt
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 27 Aug 2010 16:15:01
Message: <web.4c781c43f13a83cfa3b8d9490@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 27.08.2010 17:23, schrieb bapt:
>
> > Damn, it's so close but... no luck. I cannot install POV-Ray 3.7 for some reason
> > (Mac) and the values above run through the c++ script still give me a blank
> > page. Would you mind posting the df3 and pov files so I can rule out the
> > conversion and know for sure that my povray is broken? I have cranked up the
> > absorption well above reasonable values and it's still all white.
>
> Posted it in povray.binary.scene-files, I hope it helps. I must say that
> I assume your c++ program is broken in some way.

Thanks, that's very helpful. It seems to work now.

Cheers,

baptiste


Post a reply to this message

From: John VanSickle
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 28 Aug 2010 05:03:51
Message: <4c78d0f7$1@news.povray.org>
> - Your absorption is simply too weak. Try absorption <1,1,1>*30 instead.
> Depends on how dense your density map actually is, though. Note that the
> smaller the distances in your scene are, the higher your media
> parameters have to be for the same effect.

If you want realistic results, each component of absorption must be 
equal to or greater than the emission component.  Making them equal 
gives you a pure glowing effect, whereas adding a bit more absorption 
gives you some smokiness.

In nature, everything which emits light also absorbs that same frequency 
of light to the same degree.  We see only the light that is at the 
outermost edges of the glowing object, but we're used to this.

Regards,
John


Post a reply to this message

From: Woody
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 29 Dec 2010 19:05:01
Message: <web.4d1bcb91f13a83cfeb5c8e5f0@news.povray.org>
What do I need to do to modify the program code shown below, so that the first
line of the data file, instead of taking 3 parameters (Size of each dimension),
takes 4 arguments (Size of each of the three dimensins + bit resolution type).
Where the bit resolution type is 8, 16 or 32bit.


> Warp <war### [at] tagpovrayorg> wrote:
> > 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: Warp
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 30 Dec 2010 03:22:04
Message: <4d1c412b@news.povray.org>
Woody <nomail@nomail> wrote:
> What do I need to do to modify the program code shown below, so that the first
> line of the data file, instead of taking 3 parameters (Size of each dimension),
> takes 4 arguments (Size of each of the three dimensins + bit resolution type).
> Where the bit resolution type is 8, 16 or 32bit.

  It requires quite some modifications because writing the larger integrals
is slightly more complicated, but this should do it:

//---------------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cstdio>
#include <cassert>

template<typename Int_t>
void writeIntValue(Int_t value, std::ostream& os)
{
    for(unsigned byteInd = sizeof(Int_t); byteInd-- > 0;)
        os << (unsigned char)((value >> (byteInd * 8)) & 0xFF);
}

template<typename Int_t>
void createDF3(std::istream& is, std::ostream& os,
               size_t xSize, size_t ySize, size_t zSize)
{
    std::vector<Int_t> data(xSize*ySize*zSize, 0);

    while(true)
    {
        size_t x, y, z, value;
        is >> x >> y >> z >> value;
        if(!is) break;
        const size_t ind = x + y*xSize + z*xSize*ySize;
        if(ind < data.size())
            data[ind] = Int_t(value);
    }

    for(size_t i = 0; i < data.size(); ++i)
        writeIntValue(data[i], os);
}

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;

    typedef unsigned char Int8_t;
    typedef unsigned short Int16_t;
    typedef unsigned int Int32_t;
    assert(sizeof(Int16_t) == 2);
    assert(sizeof(Int32_t) == 4);

    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, bits;
        is >> xSize >> ySize >> zSize >> bits;
        if(xSize > SIZE_LIMIT || ySize > SIZE_LIMIT || zSize > SIZE_LIMIT ||
           (bits != 8 && bits != 16 && bits != 32))
        {
            std::cout << "Skipping " << argv[i] << " (invalid input)\n";
            continue;
        }

        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);

        char header[6];
        header[0] = xSize/256; header[1] = xSize%256;
        header[2] = ySize/256; header[3] = ySize%256;
        header[4] = zSize/256; header[5] = zSize%256;
        os.write(header, 6);

        switch(bits)
        {
          case 8: createDF3<Int8_t>(is, os, xSize, ySize, zSize); break;
          case 16: createDF3<Int16_t>(is, os, xSize, ySize, zSize); break;
          case 32: createDF3<Int32_t>(is, os, xSize, ySize, zSize); break;
        }

        std::cout << argv[i] << " -> " << filename << std::endl;
    }
}
//---------------------------------------------------------------------

-- 
                                                          - Warp


Post a reply to this message

From: Woody
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 4 Jan 2011 16:55:01
Message: <web.4d239653f13a83cfc41e4df50@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Woody <nomail@nomail> wrote:
> > What do I need to do to modify the program code shown below, so that the first
> > line of the data file, instead of taking 3 parameters (Size of each dimension),
> > takes 4 arguments (Size of each of the three dimensins + bit resolution type).
> > Where the bit resolution type is 8, 16 or 32bit.
>
>   It requires quite some modifications because writing the larger integrals
> is slightly more complicated, but this should do it:
>
> //---------------------------------------------------------------------
> #include <iostream>
> #include <fstream>
> #include <vector>
> #include <string>
> #include <cstdio>
> #include <cassert>
>
> template<typename Int_t>
> void writeIntValue(Int_t value, std::ostream& os)
> {
>     for(unsigned byteInd = sizeof(Int_t); byteInd-- > 0;)
>         os << (unsigned char)((value >> (byteInd * 8)) & 0xFF);
> }
>
> template<typename Int_t>
> void createDF3(std::istream& is, std::ostream& os,
>                size_t xSize, size_t ySize, size_t zSize)
> {
>     std::vector<Int_t> data(xSize*ySize*zSize, 0);
>
>     while(true)
>     {
>         size_t x, y, z, value;
>         is >> x >> y >> z >> value;
>         if(!is) break;
>         const size_t ind = x + y*xSize + z*xSize*ySize;
>         if(ind < data.size())
>             data[ind] = Int_t(value);
>     }
>
>     for(size_t i = 0; i < data.size(); ++i)
>         writeIntValue(data[i], os);
> }
>
> 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;
>
>     typedef unsigned char Int8_t;
>     typedef unsigned short Int16_t;
>     typedef unsigned int Int32_t;
>     assert(sizeof(Int16_t) == 2);
>     assert(sizeof(Int32_t) == 4);
>
>     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, bits;
>         is >> xSize >> ySize >> zSize >> bits;
>         if(xSize > SIZE_LIMIT || ySize > SIZE_LIMIT || zSize > SIZE_LIMIT ||
>            (bits != 8 && bits != 16 && bits != 32))
>         {
>             std::cout << "Skipping " << argv[i] << " (invalid input)\n";
>             continue;
>         }
>
>         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);
>
>         char header[6];
>         header[0] = xSize/256; header[1] = xSize%256;
>         header[2] = ySize/256; header[3] = ySize%256;
>         header[4] = zSize/256; header[5] = zSize%256;
>         os.write(header, 6);
>
>         switch(bits)
>         {
>           case 8: createDF3<Int8_t>(is, os, xSize, ySize, zSize); break;
>           case 16: createDF3<Int16_t>(is, os, xSize, ySize, zSize); break;
>           case 32: createDF3<Int32_t>(is, os, xSize, ySize, zSize); break;
>         }
>
>         std::cout << argv[i] << " -> " << filename << std::endl;
>     }
> }
> //---------------------------------------------------------------------
>
> --
>                                                           - Warp

So does this always use 255 as the max voxel value regardless of the bit
resolution?

How does 255 (besides being 256 minus 1) relate to the bit resolution?

Sorry, I don't know a whole lot about bytes and bits.


Post a reply to this message

From: Warp
Subject: Re: Request for *.df4 format (ASCII text based)
Date: 4 Jan 2011 17:08:35
Message: <4d239a63@news.povray.org>
Woody <nomail@nomail> wrote:
> [-- text/plain, encoding 8bit, charset: iso-8859-1, 117 lines --]

> Warp <war### [at] tagpovrayorg> wrote:
> > Woody <nomail@nomail> wrote:
> > > What do I need to do to modify the program code shown below, so that the first
> > > line of the data file, instead of taking 3 parameters (Size of each dimension),
> > > takes 4 arguments (Size of each of the three dimensins + bit resolution type).
> > > Where the bit resolution type is 8, 16 or 32bit.
> >
> >   It requires quite some modifications because writing the larger integrals
> > is slightly more complicated, but this should do it:
> >
> > //---------------------------------------------------------------------
> > #include <iostream>
> > #include <fstream>
> > #include <vector>
> > #include <string>
> > #include <cstdio>
> > #include <cassert>
> >
> > template<typename Int_t>
> > void writeIntValue(Int_t value, std::ostream& os)
> > {
> >     for(unsigned byteInd = sizeof(Int_t); byteInd-- > 0;)
> >         os << (unsigned char)((value >> (byteInd * 8)) & 0xFF);
> > }
> >
> > template<typename Int_t>
> > void createDF3(std::istream& is, std::ostream& os,
> >                size_t xSize, size_t ySize, size_t zSize)
> > {
> >     std::vector<Int_t> data(xSize*ySize*zSize, 0);
> >
> >     while(true)
> >     {
> >         size_t x, y, z, value;
> >         is >> x >> y >> z >> value;
> >         if(!is) break;
> >         const size_t ind = x + y*xSize + z*xSize*ySize;
> >         if(ind < data.size())
> >             data[ind] = Int_t(value);
> >     }
> >
> >     for(size_t i = 0; i < data.size(); ++i)
> >         writeIntValue(data[i], os);
> > }
> >
> > 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;
> >
> >     typedef unsigned char Int8_t;
> >     typedef unsigned short Int16_t;
> >     typedef unsigned int Int32_t;
> >     assert(sizeof(Int16_t) == 2);
> >     assert(sizeof(Int32_t) == 4);
> >
> >     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, bits;
> >         is >> xSize >> ySize >> zSize >> bits;
> >         if(xSize > SIZE_LIMIT || ySize > SIZE_LIMIT || zSize > SIZE_LIMIT ||
> >            (bits != 8 && bits != 16 && bits != 32))
> >         {
> >             std::cout << "Skipping " << argv[i] << " (invalid input)\n";
> >             continue;
> >         }
> >
> >         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);
> >
> >         char header[6];
> >         header[0] = xSize/256; header[1] = xSize%256;
> >         header[2] = ySize/256; header[3] = ySize%256;
> >         header[4] = zSize/256; header[5] = zSize%256;
> >         os.write(header, 6);
> >
> >         switch(bits)
> >         {
> >           case 8: createDF3<Int8_t>(is, os, xSize, ySize, zSize); break;
> >           case 16: createDF3<Int16_t>(is, os, xSize, ySize, zSize); break;
> >           case 32: createDF3<Int32_t>(is, os, xSize, ySize, zSize); break;
> >         }
> >
> >         std::cout << argv[i] << " -> " << filename << std::endl;
> >     }
> > }
> > //---------------------------------------------------------------------
> >
> > --
> >                                                           - Warp

> So does this always use 255 as the max voxel value regardless of the bit
> resolution?

> How does 255 (besides being 256 minus 1) relate to the bit resolution?

  Where do you see a 255 in the program?

  The maximum value for each voxel is dependent on the bit size. If you
are eg. using 16 bits, the maximum value is 65535.

-- 
                                                          - Warp


Post a reply to this message

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

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