octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

3D plotting solutions


From: Johan Jansson
Subject: 3D plotting solutions
Date: Thu, 4 Dec 2003 15:23:07 -0600
User-agent: Mutt/1.5.4i

Hi!

I'm part of a group at Chalmers University which focuses on the FEM (Finite
Element Method) (http://www.phi.chalmers.se/). We are using Matlab and
Octave as tools both in the research work and in education. There is a
drive now to see if we can use only Octave. This would also generalize
to the entire university in the longer perspective, but as a first
step we can consider only our group.

Octave can replace Matlab for most tasks, such as writing prototype
equation solvers in education and research and implementing standard
numerical algorithms in education. However, visualization of 3D data
is an important part of our work, and here Octave is not fully up to
Matlab's level yet (Matlab itself is not always very good either).

A concrete example is plotting the solution of a partial differential
equation solved by the FEM. A typical solution consists of a
triangulated domain (in 2D) with scalar values in the nodes
(vertices). Visualization of this solution can be done by plotting the
triangulated domain with colors representing the nodal values, or
letting the nodal values represent a z component, or a combination.

Currently there appears to be no simple way of plotting such a
solution in Octave. "mesh" plots values on a structured grid on a
square domain. The underlying plotting primitive, Gnuplot, also has
this restriction. I have looked at the "pm3d" extension, and while it
looks like a great implementation of its scope, it still has the same
restriction.

It doesn't seem like this plotting primitive is powerful enough.

I have a proposal on how to improve this:

Add a plotting primitive which takes a 3D geometry as input, for
example as a data file. It doesn't really matter which format this 3D
geometry has, as long as it covers triangles, line segments and
colors (perhaps a few more less critical, such as text for
annotation). This would suffice to implement the plotting example I
described previously, as well as "mesh", "surf", and any other 3D
plotting function, such as isosurface plotting.

An external application could then be used to render this geometry,
just as Gnuplot is used today. It would thus follow the same interface
structure as with Gnuplot, and keep Octave a data processor, leaving
visualization and graphics to other applications. It would then be up
to the Octave plotting functions to generate the appropriate geometry.

I have made a prototype implementation of this idea using the Open
Inventor format, the Open Inventor "ivview" application for rendering,
and implemented a basic version of the "pdeplot" function in the PDE
Toolbox package in Matlab. "pdeplot" takes as inputs the points,
edges, and triangles of the triangulated domain as well as the nodal
values. The original "pdeplot" has many more arguments, supporting
many options, but this is the basic functionality.

Here are two screenshots:
http://www.math.chalmers.se/~johanjan/octave/dolfin-top.png
http://www.math.chalmers.se/~johanjan/octave/dolfin-shaded.png

Here is the function "pdeplot_inventor" together with the solution
file output by the GPL DOLFIN PDE solver (http://www.phi.chalmers.se/dolfin/),
"convdiff.m":
http://www.math.chalmers.se/~johanjan/octave/pdeplot_inventor-2003-12-04.tgz

The function opens a pipe to the rendering application "ivview" and
constructs an Open Inventor file representing the solution, which it
writes to the pipe.

To try it, unpack the files and type this (in Octave):

> convdiff
> pdeplot_inventor(points, edges, cells, '', u{2});

I have tried it with Octave 2.1.50.

Phong shading can be turned on by commenting out the line:

fprintf(fd, '  model BASE_COLOR\n');

and uncommenting the line:

fprintf(fd, ' model PHONG\n');

Open Inventor has been released as LGPL by SGI and is maintained by
SGI. It is very much a scene graph representation of OpenGL. The
renderer exists in Debian in the package "inventor-clients". VRML 1.0
is essentially identical to the Open Inventor data format. Coin is
also a GPL/LGPL implementation of the Open Inventor specification.

I have seen a previous proposal, Oplot++, writing a graphics handler
for Octave using the Open Inventor/Coin API. I have used a standard
renderer application, but perhaps customizing a renderer would also be
a good idea. It would be necessary if commands in Octave should be
able to modify the state of the plot, which is the case in Matlab.

What do you think?

  Johan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]