POV-Ray : Newsgroups : povray.general : POV Includes note Server Time
9 Aug 2024 01:20:11 EDT (-0400)
  POV Includes note (Message 1 to 9 of 9)  
From: disnel
Subject: POV Includes note
Date: 28 Sep 2000 08:21:40
Message: <39D338B9.6750D83A@hlavacek-partner.cz>
It can be useful to enable multiple #include of some file
to POV source (for example when I include colors.inc in
my main POV file a it is also included in some other
include).

It can be done like C includes:

#ifndef (_INCLUDE_NAME)
  #declare _INCLUDE_NAME=yes;

.... include file content ....

#end

Disnel


Post a reply to this message

From: Warp
Subject: Re: POV Includes note
Date: 28 Sep 2000 10:06:42
Message: <39d35071@news.povray.org>
Also includes that need other includes should include those themselves.

  For example, if textures.inc needs colors.inc, then textures.inc should
#include "colors.inc"

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Josh English
Subject: Re: POV Includes note
Date: 28 Sep 2000 10:46:39
Message: <39D359CF.7DAE8354@spiritone.com>
I thought that including a file like "colors.inc" increased the memory usage
or had some other effect to slow down parsing.

Josh

Warp wrote:

>   Also includes that need other includes should include those themselves.
>
>   For example, if textures.inc needs colors.inc, then textures.inc should
> #include "colors.inc"
>
> --
> main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
> ):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/

--
Josh English -- Lexiphanic Lethomaniac
eng### [at] spiritonecom
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/


Post a reply to this message

From: Warp
Subject: Re: POV Includes note
Date: 28 Sep 2000 11:05:18
Message: <39d35e2d@news.povray.org>
Josh English <eng### [at] spiritonecom> wrote:
: I thought that including a file like "colors.inc" increased the memory usage
: or had some other effect to slow down parsing.

  But if textures.inc doesn't include colors.inc then it will not parse at
all (unless you have included colors.inc yourself).

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Disnel
Subject: Re: POV Includes note
Date: 29 Sep 2000 05:19:23
Message: <39D45E9B.380C6DB@itam.cas.cz>
Josh English wrote:
> 
> I thought that including a file like "colors.inc" increased the memory usage
> or had some other effect to slow down parsing.

But if you inlude texture.inc, for example, you NEED colors.inc,
regardless
if it is included automatically from  textures.inc or manually from your
POV file before #include "textures.inc".

> 
> Josh
> 
> Warp wrote:
> 
> >   Also includes that need other includes should include those themselves.
> >
> >   For example, if textures.inc needs colors.inc, then textures.inc should
> > #include "colors.inc"
> >
> > --
> > main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
> > ):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
> 
> --
> Josh English -- Lexiphanic Lethomaniac
> eng### [at] spiritonecom
> The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/


Post a reply to this message

From: Geoff Wedig
Subject: Re: POV Includes note
Date: 29 Sep 2000 08:49:11
Message: <39d48fc7@news.povray.org>
Disnel <dis### [at] itamcascz> wrote:
> Josh English wrote:
>> 
>> I thought that including a file like "colors.inc" increased the memory usage
>> or had some other effect to slow down parsing.

> But if you inlude texture.inc, for example, you NEED colors.inc,
> regardless
> if it is included automatically from  textures.inc or manually from your
> POV file before #include "textures.inc".

Does POV make sure it hasn't already included a particular include?  I think
not, or a lot of the include file style functions wouldn't work multiple
times.  Parsing a long include of essentially just definitions (even if they
overwrite only themselves) could take quite a bit of time, if it's a long
file.

So there is some use in checking to see if a particular include (not of the
type where including multiple times can have different results) has already
been included.

Geoff


Post a reply to this message

From: Disnel
Subject: Re: POV Includes note
Date: 29 Sep 2000 08:57:55
Message: <39D491D2.AB8632AE@itam.cas.cz>
I tried following:

test.pov:

#include "test1.inc"
#include "test2.inc"

test1.inc:

#debug "\ntest1.inc included\n"

test2:inc:

#include "test1.inc"

and then:

POV_Mega +itest.pov

.... pov mesasges ...
Parsing...
test1.inc included

test1.inc include

 <----ERROR

test1.inc:2: error: No objects in scene.

So, included test1.inc two times.

If I understand you correctly, then such check would disallow recursive
tricks with includes.

Geoff Wedig wrote:
> 
> Disnel <dis### [at] itamcascz> wrote:
> > Josh English wrote:
> >>
> >> I thought that including a file like "colors.inc" increased the memory usage
> >> or had some other effect to slow down parsing.
> 
> > But if you inlude texture.inc, for example, you NEED colors.inc,
> > regardless
> > if it is included automatically from  textures.inc or manually from your
> > POV file before #include "textures.inc".
> 
> Does POV make sure it hasn't already included a particular include?  I think
> not, or a lot of the include file style functions wouldn't work multiple
> times.  Parsing a long include of essentially just definitions (even if they
> overwrite only themselves) could take quite a bit of time, if it's a long
> file.
> 
> So there is some use in checking to see if a particular include (not of the
> type where including multiple times can have different results) has already
> been included.
> 
> Geoff


Post a reply to this message

From: Peter J  Holzer
Subject: Re: POV Includes note
Date: 29 Sep 2000 18:01:22
Message: <slrn8t9tdl.r5e.hjp-usenet@teal.h.hjp.at>
On 29 Sep 2000 08:49:11 -0400, Geoff Wedig wrote:
>Does POV make sure it hasn't already included a particular include?

No. But see below.

>I think not, or a lot of the include file style functions wouldn't work
>multiple times.

Yes.

>Parsing a long include of essentially just definitions (even if they
>overwrite only themselves) could take quite a bit of time, if it's a
>long file.
>
>So there is some use in checking to see if a particular include (not of
>the type where including multiple times can have different results) has
>already been included.

In C the standard way to avoid including files twice has always been
to put something like

#ifndef __this_file_INCLUDED__
    #define __this_file_INCLUDED__

    ...

#endif

around the whole file. If you look at colors.inc, you can see that
povray uses a similar technique.

However, while this prevents any untoward effects of redeclaring
variables, and speeds up the parsing of the file quite a bit, it doesn't
normally prevent the compiler (or povray) from parsing the file a second
(and third, fourth, ...) time, so it isn't as fast as it could be.

Gcc uses two tricks to prevent that:

Firstly, it introduced a directive #import, which was similar to
#include, but would do nothing if the file had already been imported.
Being gcc-specific, this didn't help programs designed to be portable
and is rarely used. Povray doesn't have this problem, so this solution
might be viable for povray.

Secondly, the compiler[1] checks whether the include file conforms to
the #ifndef MACRO; #define MACRO; ...; #endif layout, and if it does,
it won't include the file again if MACRO is defined. This is a bit more
complicated but helps existing scene files. (But if someone want's to
implement this, DON'T take the code from cccp, the GPL is incompatible
with povray's license).

	hp

[1] Actually the preprocessor, cccp.

-- 

|_|_) | Sysadmin WSR       | vor dem rechner.

__/   | http://www.hjp.at/ |       at.linux, 2000-09-24


Post a reply to this message

From: Philippe Debar
Subject: Re: POV Includes note
Date: 3 Oct 2000 04:58:12
Message: <39d99fa4@news.povray.org>
If you include a common *.inc file in every file that need it, when you
include these files, you parse the common file multiple time, which can be
slow. What I do is check with ifndef if the file isn't already included (by
checking either the first #declared identifier in the #included file or the
first #declared identifier the current file needs from the #included file).


Povingly,

Philippe


Post a reply to this message

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