|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I would like to read data (float or vectors of float) from an ascii file and use
the data as coordinates for the geometry in the scene: some spheres connected by
cylinders.
I tried with the following code and an input file with a sequence of floats.
The problem is that some data in the input file are not read (I checked with the
#write): sometimes every second float is read, sometimes there is no regular
pattern. Moreover, sometimes the minus sign is not read.
(I got a similar error with vectors of floats)
Am I doing something wrong or is there a bug in the I/O functions?
I'm using povray-3.6.1-12 on ubuntu 9.04 but I get the same error in windows
both with 3.6.1 and 3.6.2.
Thanks
Ester
#fopen inputfile "in.dat" read
//#fopen outputfile "out.dat" write
#if (defined(inputfile))
#read (inputfile, y1, y2, y3)
#end
#while (defined(inputfile))
#declare x1 = y1;
#declare x2 = y2;
#declare x3 = y3;
#read (inputfile, y1,y2,y3)
sphere { <x1,x2,x3>, 0.3 pigment {color Green}}
#if (!(x1 = y1 & x2 = y2 & x3 = y3))
cylinder { <x1,x2,x3>, <y1,y2,y3>, 0.1 pigment {color Red}}
#end
// #write (outputfile, x1, " ", x2, " ", x3, "\n")
#end
#fclose inputfile
//#fclose outputfile
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"esterichia" <est### [at] gmailcom> schreef in bericht
news:web.4ad872742aad556549aa3f520@news.povray.org...
>I would like to read data (float or vectors of float) from an ascii file
>and use
> the data as coordinates for the geometry in the scene: some spheres
> connected by
> cylinders.
>
> I tried with the following code and an input file with a sequence of
> floats.
> The problem is that some data in the input file are not read (I checked
> with the
> #write): sometimes every second float is read, sometimes there is no
> regular
> pattern. Moreover, sometimes the minus sign is not read.
> (I got a similar error with vectors of floats)
>
> Am I doing something wrong or is there a bug in the I/O functions?
>
> I'm using povray-3.6.1-12 on ubuntu 9.04 but I get the same error in
> windows
> both with 3.6.1 and 3.6.2.
>
> Thanks
> Ester
>
> #fopen inputfile "in.dat" read
> //#fopen outputfile "out.dat" write
>
> #if (defined(inputfile))
> #read (inputfile, y1, y2, y3)
> #end
>
> #while (defined(inputfile))
> #declare x1 = y1;
> #declare x2 = y2;
> #declare x3 = y3;
>
> #read (inputfile, y1,y2,y3)
>
> sphere { <x1,x2,x3>, 0.3 pigment {color Green}}
> #if (!(x1 = y1 & x2 = y2 & x3 = y3))
> cylinder { <x1,x2,x3>, <y1,y2,y3>, 0.1 pigment {color Red}}
> #end
>
> // #write (outputfile, x1, " ", x2, " ", x3, "\n")
> #end
>
> #fclose inputfile
> //#fclose outputfile
>
I think commas are missing in the write statement because they are needed to
separate the written parameters in the file in order to be read correctly.
Check that your input file has commas too between parametersAlso you can
simplify your define as you do not need the #if statement. Just write:
#while (defined(inputfile))
#declare x1 = y1;
#declare x2 = y2;
#declare x3 = y3;
#read (inputfile, y1, y2, y3)
....
....
#write (outputfile, x1,", ", x2,", ", x3,",","\n")
....
#end
Hope this helps.
Thomas
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
esterichia schrieb:
>
> I tried with the following code and an input file with a sequence of floats.
> The problem is that some data in the input file are not read (I checked with the
> #write): sometimes every second float is read, sometimes there is no regular
> pattern. Moreover, sometimes the minus sign is not read.
> (I got a similar error with vectors of floats)
...
> // #write (outputfile, x1, " ", x2, " ", x3, "\n")
See section 3.2.2.3.4 "The #write Directive" of the POV-Ray inbuilt help:
"Note: data read by the #read directive must have comma delimiters
between values and quotes around string data but the #write directive
does not automatically output commas or quotes."
It appears that in the absence of a separating comma, POV-Ray will
instead "eat" the next number entirely if it is positive, OR its minus
sign if it is negative.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thomas de Groot schrieb:
> Also you can
> simplify your define as you do not need the #if statement. Just write:
>
> #while (defined(inputfile))
> #declare x1 = y1;
> #declare x2 = y2;
> #declare x3 = y3;
> #read (inputfile, y1, y2, y3)
> ....
> ....
> #write (outputfile, x1,", ", x2,", ", x3,",","\n")
> ....
> #end
I guess without the pre-read this will cause a parse error, as y1,y2,y3
will be undefined at this point.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"clipka" <ano### [at] anonymousorg> schreef in bericht
news:4ad88125$1@news.povray.org...
>
> I guess without the pre-read this will cause a parse error, as y1,y2,y3
> will be undefined at this point.
Aaah... yes, indeed. In this case that is required. But then, why not put
the #read as the first line in the #while loop? Then the #if statement could
be omitted.
Thomas
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> I would like to read data (float or vectors of float) from an ascii file and use
> the data as coordinates for the geometry in the scene: some spheres connected by
> cylinders.
>
> I tried with the following code and an input file with a sequence of floats.
> The problem is that some data in the input file are not read (I checked with the
> #write): sometimes every second float is read, sometimes there is no regular
> pattern. Moreover, sometimes the minus sign is not read.
> (I got a similar error with vectors of floats)
>
> Am I doing something wrong or is there a bug in the I/O functions?
>
> I'm using povray-3.6.1-12 on ubuntu 9.04 but I get the same error in windows
> both with 3.6.1 and 3.6.2.
>
> Thanks
> Ester
>
> #fopen inputfile "in.dat" read
> //#fopen outputfile "out.dat" write
>
> #if (defined(inputfile))
> #read (inputfile, y1, y2, y3)
> #end
>
> #while (defined(inputfile))
> #declare x1 = y1;
> #declare x2 = y2;
> #declare x3 = y3;
>
> #read (inputfile, y1,y2,y3)
>
> sphere { <x1,x2,x3>, 0.3 pigment {color Green}}
> #if (!(x1 = y1 & x2 = y2 & x3 = y3))
> cylinder { <x1,x2,x3>, <y1,y2,y3>, 0.1 pigment {color Red}}
> #end
>
> // #write (outputfile, x1, " ", x2, " ", x3, "\n")
> #end
>
> #fclose inputfile
> //#fclose outputfile
>
>
Make sure that your file is comma separated. You don't always need the
comma if all the values are positive, but you absolutely need them
before any negative value.
Whenever you get a negative value preceded by a float or a vector, the
negative value get substracted from the preceding one.
Normaly, <1 2 3><4 5 6, 7> is read correctly as a 3D and a 4D vectors,<1
2 3>4.56 as a 3D vector and a float and 1.23 4.56 as two floats.
BUT!
17 -5 becomes 12
<12, 5, 9> -8 becomes <4, -3, 1>
100 -5 -33 becomes 62
Alain
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Alain schrieb:
> Make sure that your file is comma separated. You don't always need the
> comma if all the values are positive, but you absolutely need them
> before any negative value.
> Whenever you get a negative value preceded by a float or a vector, the
> negative value get substracted from the preceding one.
That's actually the case only when you #include the file. If you #read
it, no arithmetics are done - but then lack of commas is problematic
even with positive values.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote:
> I think commas are missing in the write statement because they are needed to
> separate the written parameters in the file in order to be read correctly.
> Check that your input file has commas too between parameters
Thank you, this works. It was my mistake.
> Also you can
> simplify your define as you do not need the #if statement. Just write:
>
> #while (defined(inputfile))
> #declare x1 = y1;
> #declare x2 = y2;
> #declare x3 = y3;
> #read (inputfile, y1, y2, y3)
> ....
> ....
> #write (outputfile, x1,", ", x2,", ", x3,",","\n")
> ....
> #end
> > I guess without the pre-read this will cause a parse error, as y1,y2,y3
> > will be undefined at this point.
>
> Aaah... yes, indeed. In this case that is required. But then, why not put
> the #read as the first line in the #while loop? Then the #if statement could
> be omitted.
I need two points to draw the cylinder, that is the first time I have to read 2
points and then only one for each cycle.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"esterichia" <est### [at] gmailcom> wrote:
> "Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote:
> > I think commas are missing in the write statement because they are needed to
> > separate the written parameters in the file in order to be read correctly.
> > Check that your input file has commas too between parameters
>
> Thank you, this works. It was my mistake.
>
> > Also you can
> > simplify your define as you do not need the #if statement. Just write:
> >
> > #while (defined(inputfile))
> > #declare x1 = y1;
> > #declare x2 = y2;
> > #declare x3 = y3;
> > #read (inputfile, y1, y2, y3)
> > ....
> > ....
> > #write (outputfile, x1,", ", x2,", ", x3,",","\n")
> > ....
> > #end
>
> > > I guess without the pre-read this will cause a parse error, as y1,y2,y3
> > > will be undefined at this point.
> >
> > Aaah... yes, indeed. In this case that is required. But then, why not put
> > the #read as the first line in the #while loop? Then the #if statement could
> > be omitted.
>
> I need two points to draw the cylinder, that is the first time I have to read 2
> points and then only one for each cycle.
Esterichia-
What is the range of data points you are having povray run through? Any idea how
to make it run through a couple thousand points?
-Thanks
--Addison
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"addison.merchut" <add### [at] gmailcom> wrote:
> "esterichia" <est### [at] gmailcom> wrote:
> > "Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote:
> > > I think commas are missing in the write statement because they are needed to
> > > separate the written parameters in the file in order to be read correctly.
> > > Check that your input file has commas too between parameters
> >
> > Thank you, this works. It was my mistake.
> >
> > > Also you can
> > > simplify your define as you do not need the #if statement. Just write:
> > >
> > > #while (defined(inputfile))
> > > #declare x1 = y1;
> > > #declare x2 = y2;
> > > #declare x3 = y3;
> > > #read (inputfile, y1, y2, y3)
> > > ....
> > > ....
> > > #write (outputfile, x1,", ", x2,", ", x3,",","\n")
> > > ....
> > > #end
> >
> > > > I guess without the pre-read this will cause a parse error, as y1,y2,y3
> > > > will be undefined at this point.
> > >
> > > Aaah... yes, indeed. In this case that is required. But then, why not put
> > > the #read as the first line in the #while loop? Then the #if statement could
> > > be omitted.
> >
> > I need two points to draw the cylinder, that is the first time I have to read 2
> > points and then only one for each cycle.
> Esterichia-
>
> What is the range of data points you are having povray run through? Any idea how
> to make it run through a couple thousand points?
>
> -Thanks
> --Addison
Nevermind. Got it. My mistake.
-Addison
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|