This tutorial shows how to pass files to and from a remote host. In the example a tool is developed which allows you to distribute the task of rendering POV files across a NetSolve network. Povray is executed at the servers to render a part of the picture and the parts from all the servers are put together from the client.
The tutorial includes the following steps:
Building and configuring the library
Installing the problem to the NetSolve repository
Rendering a test image via NetSolve
Requirements on each server
libpovray.c
povray.idl - a file which describes how the problem should be included into the NetSolve repository (Interface Definition Language)
the image renderer PovRay - available at http://www.povray.org/
Requirements on the client
nspovray.c - the client program which invokes the various instances of PovRay via NetSolve and puts together the final image
*.pov and *.ini - sample PovRay files
the image processing tool ImageMagick - available at http://www.imagemagick.org/
the mpeg encoder mpeg_encode - available at http://bmrc.berkeley.edu/frame/research/mpeg/mpeg_encode.html
the Netpbm library - available at http://netpbm.sourceforge.net/
Instructions
1. Building and Configuring the Library
At first make sure to have a working copy of PovRay on the server. Either it is already installed or download it and run(configure and make). To test povray try to render a POV file on the server, e.g. (assuming icl.pov in the current directory):
UNIX> /home/user/povray/src/povray +Iicl.pov +Oicl.png +L/home/user/povray/include |
Edit libpovray.c and provide in the first two lines the povray executable If the executable is not in your PATH include the path, and the path to the PovRay include directory (contains all the INC files)
Execute the following steps to build libpovray.a
UNIX> gcc -c libpovray.c UNIX> ar rc libpovray.a libpovray.o |
2. Installing the Problem to the NetSolve Repository Use idltopdf to convert povray.idl to povray.pdf. Since the library makes an external call to a programm it can not take advantage of the Hardware/Software server feature of NetSolve (i.e., it cannot be transfered from one server to another). To mark a problem as non-moveable edit the newly created file povray.pdf and add the following line after the @PATH statement:
@MOVEABLE 0 |
UNIX> make server |
3. Rendering a Test Image Via NetSolve
The file nspovray.c demonstrates how to invoke the newly created function povray via NetSolve.
Edit nspovray.c and provide in the first three lines the path to ImageMagick, mpeg_encode, and mmv.
Edit animation.parm and set in the 4th line the path to the programm tgatoppm if it is not in your PATH
Compile nspovray then with the following command:
UNIX> gcc nspovray.c -o nspovray -I$NETSOLVE_ROOT/include -lnetsolve \
-L$NETSOLVE_ROOT/lib/$NETSOLVE_ARCH |
![]() | Note |
|---|---|
On Solaris you may need to add the following two libraries, -lsocket and -lnsl. |
To render an example file you have the following options:
blocking calls: provides exactly the same syntax as calling povray, but use the command nspovray instead; e.g.:
UNIX> ./nspovray +Iicl.pov +Oicl.png +H400 +W500 |
non-blocking calls: uses non-blocking calls and is invoked with the option -nonblocking, additionally you can specify with the -n option how many instances (= parallel NetSolve calls) you want to start; e.g.:
UNIX> ./nspovray +Iicl1.pov +Oicl1.png +H400 +W500 -n2 -nonblocking |
task-farming: again as above but use with the option -farming; to produce an animation use for example:
UNIX> ./nspovray icl_animation.ini -oanimation.mpg -n2 -farming |
![]() | Note |
|---|---|
Be sure to have an agent and at least one instance of the new server running. Also check that the NETSOLVE_AGENT environment variable is set on the client (it should be the same value as the @AGENT: line in server_config in the NETSOLVE_ROOT directory). |