|
|
Hi all,
Just curious, is there a way to have Povray call an external C or C++ (compiled)
function? I have a series of functions used in an isosurface, that get layered
so many times that they are extremely slow. I'm sure they can be written in C or
C++ and run a lot faster, if Povray can call C functions...
Here are all the functions just for fun ;) ...
#declare Q = function(x,y,z,Rx,Ry,Rz) {sqrt( pow(max(abs(x)-Rx,0),2) +
pow(max(abs(y)-Ry,0),2) + pow(max(abs(z)-Rz,0),2) )}
#declare QX = function (x, Rx) {max(abs(x)-Rx, 0)}
#declare QY = function (y, Ry) {max(abs(y)-Ry, 0)}
#declare QZ = function (z, Rz) {max(abs(z)-Rz, 0)}
#declare BOX = function (x,y,z,Rx,Ry,Rz) {Q (x,y,z, Rx/2, Ry/2, Rz/2) + min(max(
QX(x, Rx/2), max(QY(y, Ry/2), QZ(z, Rz/2)) ), 0)}
#declare ASTER = function {min(BOX(x-0*Sz,y-0*Sz,z-0*Sz,Sz,Sz,Sz),
BOX(x-1*Sz,y-0*Sz,z-0*Sz,Sz,Sz,Sz), BOX(x-2*Sz,y-0*Sz,z-0*Sz,Sz,Sz,Sz),
BOX(x-2*Sz,y-1*Sz,z-0*Sz,Sz,Sz,Sz), BOX(x-2*Sz,y-0*Sz,z-1*Sz,Sz,Sz,Sz),
BOX(x-2*Sz,y-1*Sz,z-1*Sz,Sz,Sz,Sz), BOX(x-2*Sz,y+1*Sz,z-0*Sz,Sz,Sz,Sz),
BOX(x+2*Sz,y-0*Sz,z-0*Sz,Sz,Sz,Sz), BOX(x+1*Sz,y-0*Sz,z-0*Sz,Sz,Sz,Sz),
BOX(x+2*Sz,y-1*Sz,z-0*Sz,Sz,Sz,Sz), BOX(x+2*Sz,y-0*Sz,z-1*Sz,Sz,Sz,Sz),
BOX(x+1*Sz,y+1*Sz,z-0*Sz,Sz,Sz,Sz))}
Josh
Post a reply to this message
|
|
|
|
"jr" <cre### [at] gmailcom> wrote:
I have a series of functions used in an isosurface, that get layered
> > so many times that they are extremely slow. I'm sure they can be written in C > >
or C++ and run a lot faster, if P
ovray can call C functions...
Welcome to my world. :D
I asked this a few years back - no you can't do that because POV-Ray has no
mechanism to compile code nor any way to execute compiled code during the parse
and render phases.
It likely won't ever - because that would open a security hole to execute
malicious code.
If you are brave and capable enough to wade through and edit POV-Ray's modest
amount of code, you could insert your own functions and re-compile.
https://www.linuxjournal.com/article/7486
https://www.researchgate.net/profile/Leigh_Orf/publication/234831963_Scientific_visualizations_with_POV-Ray/links/579a8
1e708ae2e0b31b156f5/Scientific-visualizations-with-POV-Ray.pdf
This would probably best be done with 3.6, since as I understand it, the
multi-thread architecture makes the code a LOT more complex.
> not from within your scene code, afaik. however, if your compiled program
> writes the function results to a file, you could read those in, before every
> frame; you can use an .ini file to control it all.
> <http://wiki.povray.org/content/Reference:Shell_Command_Options>
Yep - plenty of third party softwares do this, and if you don't want to go that
route, you can always just use POV-Ray to (slowly) write your data to a file.
Another option is to decrease the number points you need to calculate, thus
speeding up the process.
Rather than solve for every point in your contained_by bounding object, you can
"scan" the x, y, and z in a nested loop, find all the points where the result
is less than the isosurface threshold, and either use those points as a grid of
corners to render triangle{} objects with, or write THAT sparse data to a file
and then read it back in.
http://www.econym.demon.co.uk/isotut/approx.htm
I think the link is broken but TdG posted the code to a "recent" thread.
Post a reply to this message
|
|
|
|
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> I have a series of functions used in an isosurface, that get layered
> > > so many times that they are extremely slow. I'm sure they can be written in C >
> or C++ and run a lot faster, if
P
> ovray can call C functions...
>
> Welcome to my world. :D
> I asked this a few years back - no you can't do that because POV-Ray has no
> mechanism to compile code nor any way to execute compiled code during the parse
> and render phases.
> It likely won't ever - because that would open a security hole to execute
> malicious code.
>
> If you are brave and capable enough to wade through and edit POV-Ray's modest
> amount of code, you could insert your own functions and re-compile.
> https://www.linuxjournal.com/article/7486
>
>
>
https://www.researchgate.net/profile/Leigh_Orf/publication/234831963_Scientific_visualizations_with_POV-Ray/links/579
a8
> 1e708ae2e0b31b156f5/Scientific-visualizations-with-POV-Ray.pdf
>
> This would probably best be done with 3.6, since as I understand it, the
> multi-thread architecture makes the code a LOT more complex.
>
> > not from within your scene code, afaik. however, if your compiled program
> > writes the function results to a file, you could read those in, before every
> > frame; you can use an .ini file to control it all.
> > <http://wiki.povray.org/content/Reference:Shell_Command_Options>
>
> Yep - plenty of third party softwares do this, and if you don't want to go that
> route, you can always just use POV-Ray to (slowly) write your data to a file.
>
> Another option is to decrease the number points you need to calculate, thus
> speeding up the process.
> Rather than solve for every point in your contained_by bounding object, you can
> "scan" the x, y, and z in a nested loop, find all the points where the result
> is less than the isosurface threshold, and either use those points as a grid of
> corners to render triangle{} objects with, or write THAT sparse data to a file
> and then read it back in.
>
> http://www.econym.demon.co.uk/isotut/approx.htm
>
> I think the link is broken but TdG posted the code to a "recent" thread.
Ok, thanks for the info. Worth checking anyway...
Josh
Post a reply to this message
|
|