|
|
This is perhaps the simplest patch ever written,
but is nevertheless of considerable power. It is
an implementation of a "#system" directive -- similar
in syntax to the "#render" directive. However,
instead of writing the associated string to an
output stream, it uses it as an argument to the
C "system()" function.
The power is that code and/or image generators can be
called from within POV scripts. Even POV itself could
be recursively called -- those "recursive art" images
which are so popular can thus be fully specified within
a single .pov file.
Other options include the calling of such external codes
as torpatch or gforge from within POV.
Basically, it's a poor man's #macro, but with considerably
extended capabilities.
A very simple UNIX example follows:
-------------------------------------------------
#system "echo parsing about to begin :"
#system "date"
global_settings {
max_trace_level 12
}
camera {
location <0, 0, -10>
look_at <0, 0, 0>
}
light_source {
<2, 5, -15>
color rgb 1
}
#system "echo \"sphere {0,1 pigment{color rgb 1}}\" > system_test.inc"
#include "system_test.inc"
#system "echo \"plane {-z,-3 pigment{color rgb <0,1,0>}}\" > system_test.inc"
#include "system_test.inc"
#system "echo parsing done :"
#system "date"
-------------------------------------------------------
A context diff for the patch relative to the tmpov
version of the 3.02 source follows. It should be
completely trivial to convert it to other 3.02 codes,
and hopefully similarly so for 3.1 codes.
Note there are three changes:
1. In parse.h, add a line assigning a number to the token,
calling it SYSTEM_TOKEN.
Increment following tokens (in this case, only LAST_TOKEN)
to make room for it.
2. in tokenize.c, assign the keyword "system" to SYSTEM_TOKEN.
3. in tokenize.c, repeat the code for DEBUG_TOKEN, changing
references to DEBUG_TOKEN to SYSTEM_TOKEN, and calling
system() with the parsed string.
There is no status checking and no capability for piping stdout
into the current POV process, so intermediate files must be
used.
Dan
*** parse.h Sun Aug 23 10:57:37 1998
--- parse.h.tmpov Sun Aug 23 10:54:57 1998
***************
*** 515,525 ****
#define FUNC_ID_TOKEN ( COLOUR_ID_TOKEN + 364 )
#define JULIA_TEXTURE_TOKEN ( COLOUR_ID_TOKEN + 365 )
/* -hdf- Apr 98 */
! #define SLOPE_TOKEN ( COLOUR_ID_TOKEN + 366 )
! /* djconnel 23Aug1998 */
! #define SYSTEM_TOKEN ( COLOUR_ID_TOKEN + 367 )
/* the last token */
! #define LAST_TOKEN ( COLOUR_ID_TOKEN + 368 )
--- 515,523 ----
#define FUNC_ID_TOKEN ( COLOUR_ID_TOKEN + 364 )
#define JULIA_TEXTURE_TOKEN ( COLOUR_ID_TOKEN + 365 )
/* -hdf- Apr 98 */
! #define SLOPE_TOKEN ( COLOUR_ID_TOKEN +
366
)
/* the last token */
! #define LAST_TOKEN ( COLOUR_ID_TOKEN + 367 )
*** tokenize.c Sun Aug 23 11:04:07 1998
--- tokenize.c.tmpov Sun Aug 23 10:54:08 1998
***************
*** 520,526 ****
{SUPERELLIPSOID_TOKEN, "superellipsoid"},
{SWITCH_TOKEN, "switch"},
{SYS_TOKEN, "sys"},
- {SYSTEM_TOKEN, "system"}, /* added djconnel 23Aug1998 */
{T_TOKEN, "t"},
{TAN_TOKEN, "tan"},
{TANH_TOKEN,"tanh"},
--- 520,525 ----
***************
*** 2561,2583 ****
}
EXIT
END_CASE
-
- /* begin added djconnel : 23 Aug 1998 */
- CASE(SYSTEM_TOKEN)
- if (Skipping)
- {
- UNGET
- EXIT
- }
- else
- {
- ts=Parse_Formatted_String();
- system(ts);
- POV_FREE(ts);
- }
- EXIT
- END_CASE
- /* end added djconnel : 23 Aug 1998 */
OTHERWISE
UNGET
--- 2560,2565 ----
Dan Connelly
http://www.flash.net/~djconnel
Post a reply to this message
|
|
|
|
> This is perhaps the simplest patch ever written,
> but is nevertheless of considerable power. It is
> an implementation of a "#system" directive -- similar
> in syntax to the "#render" directive. However,
> instead of writing the associated string to an
> output stream, it uses it as an argument to the
> C "system()" function.
>
> The power is that code and/or image generators can be
> called from within POV scripts. Even POV itself could
> be recursively called -- those "recursive art" images
> which are so popular can thus be fully specified within
> a single .pov file.
>
> Other options include the calling of such external codes
> as torpatch or gforge from within POV.
>
> Basically, it's a poor man's #macro, but with considerably
> extended capabilities.
It's also a can of worms for viral infection...
I guess your next step will be to have an 'emacs'-like command
extension in the pov code, just to read the newsgroup in
pov-script...
IMNSHO, "#system" is dangerous and unwanted.
Post a reply to this message
|
|
|
|
On Thu, 27 Nov 2003 15:26:33 +0100, Le Forgeron <jgr### [at] freefr> wrote:
> It's also a can of worms for viral infection...
> I guess your next step will be to have an 'emacs'-like command
> extension in the pov code, just to read the newsgroup in
> pov-script...
>
> IMNSHO, "#system" is dangerous and unwanted.
Jerome, please look into settings of your news reader. You have answered to
five years old message.
ABX
Post a reply to this message
|
|