POV-Ray : Newsgroups : povray.newusers : Problem with recursion Server Time
25 Nov 2024 05:50:34 EST (-0500)
  Problem with recursion (Message 1 to 6 of 6)  
From: MSAB
Subject: Problem with recursion
Date: 10 Jul 2006 15:20:01
Message: <web.44b2a7c45951bb615fe996d0@news.povray.org>
Hi,
I've got a little problem with recursion and include-files.

I write a macro with recursion which works well. Now I want to write some of
the object defining (I'm not sure, about that word) in another Include(or
Pov)-file. In that file are also some if-commands with variables, which I
defined in the actual file. Than of course the massage came "too many
nested include files". I think that came because of the recursion, but I'm
not sure.

Is there any other possibility, or must I leave the object defining the
actual file?

Please help, and sorry for my bad English.


Post a reply to this message

From: Warp
Subject: Re: Problem with recursion
Date: 10 Jul 2006 15:30:39
Message: <44b2aadf$1@news.povray.org>
A short scene demonstrating the problem would be of great help
answering your question.


Post a reply to this message

From: Alain
Subject: Re: Problem with recursion
Date: 10 Jul 2006 19:32:14
Message: <44b2e37e$1@news.povray.org>
MSAB nous apporta ses lumieres en ce 10/07/2006 15:17:
> Hi,
> I've got a little problem with recursion and include-files.
> 
> I write a macro with recursion which works well. Now I want to write some of
> the object defining (I'm not sure, about that word) in another Include(or
> Pov)-file. In that file are also some if-commands with variables, which I
> defined in the actual file. Than of course the massage came "too many
> nested include files". I think that came because of the recursion, but I'm
> not sure.
> 
> Is there any other possibility, or must I leave the object defining the
> actual file?
> 
> Please help, and sorry for my bad English.
> 
> 
> 
> 
A solution would be to include your file(s) before the recursive part. If the included
file is an 
object deffinition, you can make it a free standing object.
#declare MyObject = object{#include<your include>}

Then, you use MyObject in your recursive macro/function.

-- 
Alain
-------------------------------------------------
'Power corrupts. Absolute power is kind of neat, though.'


Post a reply to this message

From: MSAB
Subject: Re: Problem with recursion
Date: 11 Jul 2006 05:45:00
Message: <web.44b3718ef80db1394e1457560@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> A short scene demonstrating the problem would be of great help
> answering your question.

Here's a simple scene, to see, where my problem is (my actual file is much
more complexer)
The main-file:

#macro Test (Art,P1,P2,n)

#local P3 = P1+ (P2-P1)/2 ;

#include "Obj_def.pov"
#include "Typ_def.pov"

union{

#if (n=0)

cylinder{P1,P2,0.5}
object{Ba}

#else

cylinder{P1,P2,0.5}
object{R}

#end
}
#end

Now, the Include-file "Obj_def.pov":

#if (Art = 1)
#declare B = box{1,1}
#end

#if (Art = 2)
#declare B = box{1.1,1.1}
#end

And this is the file "Typ_def.pov". I think there's the problem:

#if (Art = 1)

#declare Ba = union{
object{B translate P1}
object{B translate P2}
object{B translate P3}
}
#declare R = union{
object{Test (Art,P3,P3+vrotate(P2,<0,0, 45>),n-1)}
object{Test (Art,P2,P2+vrotate(P2,<0,0,-45>),n-1)}
}

#end

#if (Art = 2)

#declare Ba = union{
object{B translate P2}
object{B translate P3}
}
#declare R = union{
object{Test (Art,P1,P1+vrotate(P2,<0,0, 45>),n-1)}
object{Test (Art,P2,P2+vrotate(P2,<0,0,-45>),n-1)}
}

#end

Thanks for your answers.


Post a reply to this message

From: Alain
Subject: Re: Problem with recursion
Date: 11 Jul 2006 19:45:09
Message: <44b43805@news.povray.org>
MSAB nous apporta ses lumieres en ce 11/07/2006 05:40:
> Warp <war### [at] tagpovrayorg> wrote:
>> A short scene demonstrating the problem would be of great help
>> answering your question.
> 
> Here's a simple scene, to see, where my problem is (my actual file is much
> more complexer)
> The main-file:
> 
> #macro Test (Art,P1,P2,n)
> 
> #local P3 = P1+ (P2-P1)/2 ;
> 
> #include "Obj_def.pov"
> #include "Typ_def.pov"
> 
> union{
> 
> #if (n=0)
> 
> cylinder{P1,P2,0.5}
> object{Ba}
> 
> #else
> 
> cylinder{P1,P2,0.5}
> object{R}
> 
> #end
> }
> #end
> 
> Now, the Include-file "Obj_def.pov":
> 
Add:
#macro ArtMac(Art)
> #if (Art = 1)
> #declare B = box{1,1}
> #end
> 
> #if (Art = 2)
> #declare B = box{1.1,1.1}
> #end
#end
> 
> And this is the file "Typ_def.pov". I think there's the problem:
> 
Add:
#macro TypMac(Art,B)
> #if (Art = 1)
> 
> #declare Ba = union{
> object{B translate P1}
> object{B translate P2}
> object{B translate P3}
> }
> #declare R = union{
> object{Test (Art,P3,P3+vrotate(P2,<0,0, 45>),n-1)}
> object{Test (Art,P2,P2+vrotate(P2,<0,0,-45>),n-1)}
> }
> 
> #end
> 
> #if (Art = 2)
> 
> #declare Ba = union{
> object{B translate P2}
> object{B translate P3}
> }
> #declare R = union{
> object{Test (Art,P1,P1+vrotate(P2,<0,0, 45>),n-1)}
> object{Test (Art,P2,P2+vrotate(P2,<0,0,-45>),n-1)}
> }
> 
> #end
#end
> 
> Thanks for your answers.
> 
> 
Now, include those before your recursive macro.
In the macro, just call the 2 macro instead of including the files.

-- 
Alain
-------------------------------------------------
I used to have an open mind but my brains kept falling out.


Post a reply to this message

From: MSAB
Subject: Re: Problem with recursion
Date: 12 Jul 2006 06:10:01
Message: <web.44b4c927f80db139963bb1b0@news.povray.org>
Alain <ele### [at] netscapenet> wrote:
> MSAB nous apporta ses lumieres en ce 11/07/2006 05:40:
> > Warp <war### [at] tagpovrayorg> wrote:
> >> A short scene demonstrating the problem would be of great help
> >> answering your question.
> >
> > Here's a simple scene, to see, where my problem is (my actual file is much
> > more complexer)
> > The main-file:
> >
> > #macro Test (Art,P1,P2,n)
> >
> > #local P3 = P1+ (P2-P1)/2 ;
> >
> > #include "Obj_def.pov"
> > #include "Typ_def.pov"
> >
> > union{
> >
> > #if (n=0)
> >
> > cylinder{P1,P2,0.5}
> > object{Ba}
> >
> > #else
> >
> > cylinder{P1,P2,0.5}
> > object{R}
> >
> > #end
> > }
> > #end
> >
> > Now, the Include-file "Obj_def.pov":
> >
> Add:
> #macro ArtMac(Art)
> > #if (Art = 1)
> > #declare B = box{1,1}
> > #end
> >
> > #if (Art = 2)
> > #declare B = box{1.1,1.1}
> > #end
> #end
> >
> > And this is the file "Typ_def.pov". I think there's the problem:
> >
> Add:
> #macro TypMac(Art,B)
> > #if (Art = 1)
> >
> > #declare Ba = union{
> > object{B translate P1}
> > object{B translate P2}
> > object{B translate P3}
> > }
> > #declare R = union{
> > object{Test (Art,P3,P3+vrotate(P2,<0,0, 45>),n-1)}
> > object{Test (Art,P2,P2+vrotate(P2,<0,0,-45>),n-1)}
> > }
> >
> > #end
> >
> > #if (Art = 2)
> >
> > #declare Ba = union{
> > object{B translate P2}
> > object{B translate P3}
> > }
> > #declare R = union{
> > object{Test (Art,P1,P1+vrotate(P2,<0,0, 45>),n-1)}
> > object{Test (Art,P2,P2+vrotate(P2,<0,0,-45>),n-1)}
> > }
> >
> > #end
> #end
> >
> > Thanks for your answers.
> >
> >
> Now, include those before your recursive macro.
> In the macro, just call the 2 macro instead of including the files.
>
> --
> Alain
> -------------------------------------------------
> I used to have an open mind but my brains kept falling out.

Thanks, it works great.
I changed yours a little bit (e.x.:
object{ObjMac (Art)
object{TypMacB (Art,Blatt)
object{Ba}}}
), but the idea is yours.

Thanks
MfG
MSAB


Post a reply to this message

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