POV-Ray : Newsgroups : povray.general : View_POV_Include_Stack Server Time
29 Oct 2024 22:46:59 EDT (-0400)
  View_POV_Include_Stack (Message 1 to 9 of 9)  
From: ingo
Subject: View_POV_Include_Stack
Date: 5 Dec 2018 10:43:59
Message: <XnsA9AFAA38DF87Bseed7@news.povray.org>
Is there any documentation on "View_POV_Include_Stack"? 
#ifdef(View_POV_Include_Stack) ... #end
 
I tried to use it to not render test scenes in an include file when the 
file is included instead of stand alone. Didn't succeed so far, only 
acheived the opposite result.

ingo


Post a reply to this message

From: clipka
Subject: Re: View_POV_Include_Stack
Date: 5 Dec 2018 13:59:48
Message: <5c082024$1@news.povray.org>
Am 05.12.2018 um 16:43 schrieb ingo:
> Is there any documentation on "View_POV_Include_Stack"?
> #ifdef(View_POV_Include_Stack) ... #end
>   
> I tried to use it to not render test scenes in an include file when the
> file is included instead of stand alone. Didn't succeed so far, only
> acheived the opposite result.

Technically, this is just a variable like any other; no further 
documentation is available, but it is quite certainly intended as an aid 
in debugging the standard include files: Explicitly specifying `#declare 
View_POV_Include_Stack = true;` in the main scene file before including 
any of the standard include files will cause those include files to 
print a debug message, to identify which standard include files are 
actually pulled in, and in which order.


Post a reply to this message

From: clipka
Subject: Re: View_POV_Include_Stack
Date: 5 Dec 2018 14:32:29
Message: <5c0827cd$1@news.povray.org>
Am 05.12.2018 um 16:43 schrieb ingo:

> I tried to use it to not render test scenes in an include file when the
> file is included instead of stand alone. Didn't succeed so far, only
> acheived the opposite result.

The simplest way to check whether your file is included or loaded as a 
main scene file is to set a certain variable wherever you include the 
file, and in the file itself test whether that variable is set, like so:

     // some scene file
     #declare FooIncluded = true;
     #include "foo.pov"

     // foo.pov
     #if (FooIncluded)
         // This is the main scene file.
     #else
         // This is an included file.
     #end


Alternatively, you can detect whether you're in the main scene file by 
exploiting the fact that local variables in the main scene file are 
actually global. Here are two such hacks (untested, but the concepts 
should work):

(1) This one sets a global variable, then sets a local variable of the 
same name. In an include file this will create an additional variable 
that just "eclipses" the global one, while in the main file this will 
change the variable. To test which of these happened, the "most local" 
variable is then destroyed again. In an include file this will just 
destroy the local variable, revealing the global variable again; in the 
main file, it will instead destroy the single global=local variable, 
leaving the variable name undefined:

     // foo.pov
     #declare FooIncludeTest = true;
     #local FooIncludeTest = true;
     #undef FooIncludeTest
     #ifdef (FooIncludeTest)
         #undef FooIncludeTest
         // We're included (or in a macro)
     #else
         // We're the main scene file (outside any macros)
     #end

Note that the global variable must be declared first; if a local 
variable of the same name already exists, `#declare` will change that 
variable instead of defining a global variable.

(2) This one is a bit more elegant, but requires POV-Ray v3.8-alpha. It 
sets a local variable, then uses the pseudo-dictionary `global` to check 
whether that variable ended up as a global variable:

     // foo.pov
     #local FooIncludeTest = true;
     #ifdef (global.FooIncludeTest)
         // We're the main scene file (outside any macros)
     #else
         // We're included (or in a macro)
     #end


Post a reply to this message

From: Bald Eagle
Subject: Re: View_POV_Include_Stack
Date: 5 Dec 2018 14:45:00
Message: <web.5c082a46d772a8a8765e06870@news.povray.org>
ingo <ing### [at] tagpovrayorg> wrote:


> I tried to use it to not render test scenes in an include file when the
> file is included instead of stand alone. Didn't succeed so far, only
> acheived the opposite result.

I usually define a variable at the top of my main scene files.
#declare SDL = true;

Then in any include file that I want to render when I'm working on them solo,
but just use as a plain include file when it's included, I do:

#ifdef (SDL)
     // do nothing
#else
     (all your global, camera, include, and other stuff you need to render the
file)
#end


and then at the end of the file I do the same check again


#ifdef (SDL)
     // do nothing
#else
     object {whatever}
     and any other stuff that needs to be rendered
#end



I'll also usually write a check for a variable named "Verbose"
which triggers macros and such to spill their guts to the debug stream
if it's false, then everything just runs silent.


Post a reply to this message

From: ingo
Subject: Re: View_POV_Include_Stack
Date: 5 Dec 2018 16:55:20
Message: <XnsA9AFE92DEAFD0seed7@news.povray.org>
in news:5c0827cd$1@news.povray.org clipka wrote:

> Am 05.12.2018 um 16:43 schrieb ingo:
> 
>> I tried to use it to not render test scenes in an include file when
>> the file is included instead of stand alone. Didn't succeed so far,
>> only acheived the opposite result.
> 
> The simplest way to check [...]

Danke, I'll try a few ways like this,

ingo


Post a reply to this message

From: ingo
Subject: Re: View_POV_Include_Stack
Date: 5 Dec 2018 16:57:53
Message: <XnsA9AFE99CE8626seed7@news.povray.org>
in news:web.5c082a46d772a8a8765e06870@news.povray.org Bald Eagle wrote:

> ingo <ing### [at] tagpovrayorg> wrote:
> 
> 
>> I tried to use it to not render test scenes in an include file when
>> the file is included instead of stand alone. Didn't succeed so far,
>> only acheived the opposite result.
> 
> [...]
> I'll also usually write a check for a variable named "Verbose"
> which triggers macros and such to spill their guts to the debug
> stream if it's false, then everything just runs silent.
> 

Thanks.
Regarding Verbose, is it just me or is the +/-GD commandline switch not 
working win10 8.3alpha?

ingo


Post a reply to this message

From: Bald Eagle
Subject: Re: View_POV_Include_Stack
Date: 5 Dec 2018 18:00:01
Message: <web.5c0857a1d772a8a8765e06870@news.povray.org>
ingo <ing### [at] tagpovrayorg> wrote:

> Thanks.
> Regarding Verbose, is it just me or is the +/-GD commandline switch not
> working win10 8.3alpha?
>
> ingo

It's been a while since I've dabbled with that - but I do recall there being
some discussion about some of the switches not working.


http://news.povray.org/povray.beta-test/thread/%3Cweb.58c29fc186a7d0f7c437ac910%40news.povray.org%3E/

not the biggest deal - and I'm sure there's a bug report already filed on that.


Post a reply to this message

From: ingo
Subject: Re: View_POV_Include_Stack
Date: 6 Dec 2018 06:28:56
Message: <XnsA9B07EFB638A6seed7@news.povray.org>
//test.pov
#version 3.8;
#debug concat("\n",input_file_name,"\n")
#local FN = input_file_name;

#include "sphere.inc"


//sphere.inc
#version 3.8

#debug concat("\n",input_file_name,"\n")
#local FN = input_file_name;
  
sphere{0,1}

// test scene here
#if (FN = "sphere.inc")
  #global_settings {assumed_gamma 1.0 }
  #default {pigment{rgb 1} finish{ ambient 0.2 diffuse 0.9 }}

  light_source{<1000,1000,-1000>, rgb 1}
  camera {location <0, 0,-5> look_at <0,0,0>}
#end  

ingo


Post a reply to this message

From: ingo
Subject: Re: View_POV_Include_Stack
Date: 6 Dec 2018 06:34:16
Message: <XnsA9B07FE291C07seed7@news.povray.org>
in news:XnsA9B07EFB638A6seed7@news.povray.org ingo wrote:

> //test.pov
> #version 3.8;
> #debug concat("\n",input_file_name,"\n")
> #local FN = input_file_name;
> [...]

Sorry, messed up threading and was to quick with the submit button.
I suddenly remembered the pre defined build in variable 'input_file_name' 
that perfectly suits my needs.

ingo


Post a reply to this message

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