POV-Ray : Newsgroups : povray.general : How does povray read files? Server Time
4 Nov 2024 19:19:08 EST (-0500)
  How does povray read files? (Message 1 to 3 of 3)  
From: gregjohn
Subject: How does povray read files?
Date: 30 May 2008 12:10:00
Message: <web.484025c52c2d78f40d56c170@news.povray.org>
I've got a file with data in it that I want povray to consider (read).

There are several lines in the file which I want povray to ignore outright.
Others have text like,
[quote]
TEXTONE TEXTTWO TEXTTHREE  0.0 34.00 27.0
[/quote]
.... where I want povray to be able to use the values of 0.0, 34.00, and 27.0 as
variables in what it does.

I could probably use a spreadsheet or text editor to re-format the file with
#declares and brackets and the like, but with great headaches. And that would
sort of ruin the whole point of my exercise.

Q: is there any way to get povray to read space-separated variables, to ignore
lines in a file it has #opened which are bad povray syntax. ?

May I do something like:

#fopen MyInput file
#read Garbage_variable
#read Garbage_variable,Garbage_variable,Garbage_variable, Useful_variable_01,
Useful_variable_02, Useful_variable_01

etc?


Post a reply to this message

From: Warp
Subject: Re: How does povray read files?
Date: 30 May 2008 12:40:10
Message: <48402dea@news.povray.org>
The #read command can not be used to freely parse an input file. It can
only be used to read in comma-separated (in some cases space-separated
works) values which have the same format as a regular pov-file would have
(eg. something you would write at the right of a "#declare Value =").

  (As a curiosity, if the input file being #read has any #-commands,
those will be parsed in the regular way until POV-Ray finds a value
which it can read.)

-- 
                                                          - Warp


Post a reply to this message

From: Alain
Subject: Re: How does povray read files?
Date: 30 May 2008 12:45:18
Message: <48402f1e$1@news.povray.org>
gregjohn nous illumina en ce 2008-05-30 12:05 -->
> I've got a file with data in it that I want povray to consider (read).
> 
> There are several lines in the file which I want povray to ignore outright.
> Others have text like,
> [quote]
> TEXTONE TEXTTWO TEXTTHREE  0.0 34.00 27.0
> [/quote]
> .... where I want povray to be able to use the values of 0.0, 34.00, and 27.0 as
> variables in what it does.
> 
> I could probably use a spreadsheet or text editor to re-format the file with
> #declares and brackets and the like, but with great headaches. And that would
> sort of ruin the whole point of my exercise.
> 
> Q: is there any way to get povray to read space-separated variables, to ignore
> lines in a file it has #opened which are bad povray syntax. ?
> 
> May I do something like:
> 
> #fopen MyInput file
> #read Garbage_variable
> #read Garbage_variable,Garbage_variable,Garbage_variable, Useful_variable_01,
> Useful_variable_02, Useful_variable_01
It's:

#fopen FileHandle MyInput_File read
#read(FileHandle, Garbage_variable,Garbage_variable,Garbage_variable, Variable1, 
Variable2, Variable3)
It will read 6 entries from your file, and discard the first 2.

If the numerical values represent a vector, you can enclose then in angle 
brackets and they will be read as a single vector:

#fopen FileHandle MyInput_File read
#read(FileHandle, Garbage_variable,Garbage_variable,Garbage_variable, Vector_value)

> 
> etc?
> 
> 
> 
> 
If all the numerical values are positive, there is no problem. If some of the 
values are negative, then POV-Ray will calculate the difference between the 
preceding value and the negative one unless they are separated by a comma.
It is preferable to convert your file from a space separated one to comma separated.

Please read the documentations. Search for #fopen, #read and #fclose.


-- 
Alain
-------------------------------------------------
Don't argue with an idiot; people watching may not be able to tell the difference.


Post a reply to this message

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