POV-Ray : Newsgroups : povray.general : reading uv vectors from file Server Time
27 Dec 2024 14:47:57 EST (-0500)
  reading uv vectors from file (Message 1 to 5 of 5)  
From: Thomas de Groot
Subject: reading uv vectors from file
Date: 13 Dec 2012 04:34:20
Message: <50c9a11c@news.povray.org>
I have a problem.

I want to read a file with successions of 6 3D vectors followed by 3 2D 
vectors on each line (yes, smoothed triangles) looking like this (two 
first lines):

<1.53223, 5.20003, -0.91979>, <-0.9382721, -0.3187213, -0.1343958>, 
<1.55159, 5.13053, -0.89013>, <-0.9382817, -0.3187565, -0.1342448>, 
<1.50766, 5.24892, -0.8642>, <-0.9382815, -0.3187583, -0.1342426>, <0.5, 
1>, <0.71485, 0.85355>, <0.28515, 0.85355>,
<1.55159, 5.13053, -0.89013>, <-0.9382817, -0.3187565, -0.1342448>, 
<1.47353, 5.29913, -0.74484>, <-0.9382809, -0.3187523, -0.1342607>, 
<1.50766, 5.24892, -0.8642>, <-0.9382815, -0.3187583, -0.1342426>, 
<0.71485, 0.85355>, <0.01267, 0.5>, <0.28515, 0.85355>,

My code looks like this:

#fopen Triangles1 "MyFile.inc" read
#while (defined(Triangles1))
   #read (Triangles1, T1, T2, T3, T4, T5, T6, UV1, UV2, UV3)
   etc...
#end

I get immediately a parse error at the end of the first line saying: 
"Parse error: Expected 'undeclared identifier', uv vector identifier 
found instead"

How should I then declare the 2D vectors in order to be read correctly?

Thanks!

Thomas


Post a reply to this message

From: Le Forgeron
Subject: Re: reading uv vectors from file
Date: 13 Dec 2012 12:51:11
Message: <50ca158f@news.povray.org>
Le 13/12/2012 10:34, Thomas de Groot nous fit lire :
> I have a problem.

> #fopen Triangles1 "MyFile.inc" read
> #while (defined(Triangles1))
>   #read (Triangles1, T1, T2, T3, T4, T5, T6, UV1, UV2, UV3)
>   etc...
> #end
> 
> I get immediately a parse error at the end of the first line saying:
> "Parse error: Expected 'undeclared identifier', uv vector identifier
> found instead"
> 
> How should I then declare the 2D vectors in order to be read correctly?
> 

If I read the error message, I would conclude that at the start of the
*second* iteration, UV1 & pal are still defined

Try something like:

#fopen Triangles1 "MyFile.inc" read
#while (defined(Triangles1))
  #read (Triangles1, T1, T2, T3, T4, T5, T6, UV1, UV2, UV3)
  etc...
  #undef UV1
  #undef UV2
  #undef UV3
#undef T1
#undef T2
#undef T3
#undef T4
#undef T5
#undef T6
#end


> Thanks!
> 
> Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: reading uv vectors from file
Date: 14 Dec 2012 03:02:41
Message: <50cadd21$1@news.povray.org>
On 13-12-2012 18:51, Le_Forgeron wrote:

> If I read the error message, I would conclude that at the start of the
> *second* iteration, UV1 & pal are still defined
>
> Try something like:
>
> #fopen Triangles1 "MyFile.inc" read
> #while (defined(Triangles1))
>    #read (Triangles1, T1, T2, T3, T4, T5, T6, UV1, UV2, UV3)
>    etc...
>    #undef UV1
>    #undef UV2
>    #undef UV3
> #undef T1
> #undef T2
> #undef T3
> #undef T4
> #undef T5
> #undef T6
> #end
>

Works! Thanks!

I think I understand /why/ this happened in this particular case. Within 
the #while block I do a #write of some of the vectors to another file. 
Before reading a new line I must first #undef them. Simple ;-)

Thomas


Post a reply to this message

From: Kenneth
Subject: Re: reading uv vectors from file
Date: 14 Dec 2012 07:10:01
Message: <web.50cb16077df411b6c2d977c20@news.povray.org>
This is an interesting post. For a long time, I've been trying to figure out how
to do almost the same thing.

Thanks for both the question and the reply. I have a better understanding of the
process now.


Post a reply to this message

From: Thomas de Groot
Subject: Re: reading uv vectors from file
Date: 14 Dec 2012 08:05:22
Message: <50cb2412$1@news.povray.org>
On 14-12-2012 13:05, Kenneth wrote:
> This is an interesting post. For a long time, I've been trying to figure out how
> to do almost the same thing.
>
> Thanks for both the question and the reply. I have a better understanding of the
> process now.
>
>

I always read and write files separately. In this case, I did write 
within the read block and that was obviously a new territory for me to 
discover.

One learns every day ;-)

Thomas


Post a reply to this message

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