?? graphics.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Graphics in QMG</title>
</head>
<body BGCOLOR="#E0FFE0" TEXT="#000000" LINK = "#0080C0" VLINK = "#004060" ALINK = "#FF0000" >
<center>
<table>
<tr>
<td>
<a href="qmg2_0_home.html"><img src=logo1.jpg alt="QMG logo"></a></td>
<td>
<h1>
Graphics in QMG
</h1>
</td>
</table>
</center>
QMG can display breps, simplicial complexes, and
PDE solutions (the latter in Matlab only) in color.Three-dimensional objectsin QMG are currently rendered with VRML or Matlab.
<h2><a name="color"></a>Colors in QMG</h2>
The routines for displaying breps examine the
value of the <strong>color</strong> property of
the brep's faces.
The value of this property should be a 4-tuple of
the form (<em>r g b a</em>); where each of <em>r, g, b, a</em>
is a decimal number
between 0 and 1. (Note: the parentheses are part of the syntax.)
<p>
The numbers <em>r, g, b</em> stand for red, green and blue and are the
amount of that color present in the face.
For instance,
<em>r</em>=1, <em>g</em>=0,
<em>b</em>=0 is pure red, whereas <em>r</em>=1, <em>g</em>=
1, <em>b</em>=0 is yellow.
<p>
The parameter <em>a</em> is sometimes called <strong>alpha</strong>
and is the degree
of opacity. Thus, <em>a</em>=1 means the face is completely opaque and
<em>a</em>=0 means the face is completely transparent. Somewhere in between
0 and 1 means the face is partially transparent.
<p>
Not all the graphics engines support transparency, so you may
find that modifying this parameter strictly between
0 and 1 does not yield the desired result.
It is guaranteed, however, that <em>a</em>=0 will yield a completely
transparent (invisible) face for any graphics engine and <em>a</em>=1
will yield a completely opaque face.
Making an exterior face invisible is useful for revealinginternal boundaries or completely
interior holes.
<p>
The graphics routines are as follows.
<h3><a name="gmrndcolor">gmrndcolor</a> (Matlab and Tcl)</h3>
<blockquote>
Matlab:
<strong>
<em>newbrep</em>=gmrndcolor(<em>brep {, dim}</em>);<br>
</strong>
Tcl/Tk:
<strong>
gmset <em>newbrep</em> [gmrndcolor <em>brep {dim}</em>]
</strong>
</blockquote>
This routine produces a new brep that is the same as the old
brep, except that all faces of dimension <em>dim</em> are colored according
to an ordering of 26 colors. (The ordering is randomized in Matlab
and deterministic in Tcl.)
Like all of the QMG routines, this one does not change its calling argument
and therefore is useless without a return variable.
<p>
The <em>dim</em> argument is optional;
It defaults to the embedded dimension
of the brep minus 1, or the intrinsic dimension, whichever is smaller.
The function does not alter the color ofa face that is already has a <strong>color</strong> property assignedto it.<p>
The <a href="ref.html#gmshowcolor"><code>gmshowcolor</code></a>
routine is useful for displaying the colors assigned by
<code>gmrndcolor</code>.
<h3><a name="gmviz">gmviz</a> (Matlab & Tcl/Tk)</h3>
<blockquote>
Matlab:
<strong>
gmviz(<em>obj {, colorspec {, dim}}</em>);<br>
</strong>
Tcl/Tk:
<strong>
gmviz <em>obj {colorspec {dim}}</em>
</strong>
</blockquote>
This routine displays a brep or simplicial complex. The display
is controlled by <a href="#gmvizgui"><code>gmvizgui</code></a>.
<p>
The arguments determine which dimension or dimensions of object to
display. For instance, a third argument of 1 indicates that1-dimensional faces (the edges) of the brep or simplicial
complex should be displayed. The third argument can also be a vector (a list in Tcl/Tk)
containing several dimensions of the object to plot at
once. The default for the third argument is
min(<em>d</em>−1,<em>k</em>)
where <em>d</em> is the embedded dimension and
<em>k</em> is the intrinsic dimension.
<p>
The second argument is the color to use. There must be one color
per dimension; in other words,
the second and third arguments to <code>gmviz</code> are in correspondence.
For example, in Matlab, the call
<blockquote>
<code>
gmviz(b, 'rw', [1, 2])
</code>
</blockquote>
will render the 1- and 2-dimensional faces of b (edges and facets).
The edges will be colored red and the facets will
be colored white. The equivalent in Tcl/Tk is:
<blockquote>
<code>
gmviz $b {red white} {1 2}
</code>
</blockquote>
<p>
As mentioned above, the second argument is one or more colors,
in correspondence with the dimensions. For a brep, the color specified
in the gmviz call is overridden by the property-value pair color
assigned to the faces. (No such option exists for simplicial complexes
since individual simplices do not
have property-value pairs.) The default coloris obtained from the <a href="#gmvizgui"><code>gmvizgui</code></a>control panel.
<p>
In Matlab, there are two ways to specify color to the gmviz
command. A color can
either be a one-character string <strong>y</strong>, <strong>m</strong>,
<strong>c</strong>, <strong>r</strong>, <strong>g</strong>,
<strong>b</strong>, <strong>w</strong>, <strong>k</strong> or
<strong>i</strong> standing
for yellow, magenta, cyan, red, green, blue, white, black and invisible.
Several such colors (one for each dimension) are concatenated together
into a string as in the above example.
<p>
A color in matlab can also be specified as a matrix with four entries
per row; each row is an <em>r, g, b, a</em> encoding as described
<a href="#color">above</a>. The number of rows is in correspondence
to the number of dimensions specified in the third argument.
In Tcl/Tk, a color can be any valid X11 color name such as "green".
It can also be a four-tuple of numbers.
<p>
An alternative calling format for these routines is:
<blockquote>
Matlab:
<strong>
gmviz(<em>pair {, colorspec {, dim}}</em>);<br>
</strong>
Tcl/Tk:
<strong>
gmviz <em>pair {colorspec {dim}}</em>
</strong>
</blockquote>
where pair is a mesh-brep pair (2-element cell-array in Matlab, 2-element list
in Tcl/Tk).
In this calling format, the mesh is displayedusing colors inherited from the color values of the faces of the brep.
The mesh should belong to the brep.
<p>
QMG 2.0 supports two different
graphics engine types, internal and external. For Matlab,
“internal”
means a usual Matlab graphics window. For Tcl/Tk,
“internal” means a
Tk canvas object. The Matlab internal engine can plot in both two
and three dimensions. The Tcl/Tk internal engine is for
2-dimensional objects only.
<p>
QMG 2.0 supports one external rendering format, VRML 1.0.When external rendering is requested, <code>gmviz</code> willwrite the objected to be rendered to a file in VRML format.For information about
VRML, see the <a href="http://www.web3d.org/vrml/">VRML repository.</a>
The software supports automatic notification of
<a href="http://home.netscape.com/computing/download">Netscape Communicator</a> (or Netscape Navigator)in both Unix and Windows.
“Automatic notification” means that <code>gmviz</code> or <code>gmplot</code>
will cause the Netscape browserto load the VRML image as soon as the
data has written to the file in VRML format.
To use notification, the Netscape browser must running on your
workstation (as a separate process)
at the time the <code>gmviz</code> or <code>gmplot</code>
statement is executed.
The browser must have a VRML plug-in viewer installed.You control automatic notification with buttons in
in the GUI created by <code>gmvizgui</code>.
<p>
You can also select the file
name to hold the VRML file with the <code>gmvizgui</code> control panel.The default is <code>test.wrl</code>. Always choose a file whose suffix is <code>.wrl</code>.You can also select whether that file is opened in replace-mode
or append-mode. Opening the file in append mode means that each successive
<code>gmviz</code> statement will each its VRML at the end of the file, so
that several different objects can appear at once in the browser.
<p>
For Windows only, the software also supports automatic notification of
<a href="http://www.microsoft.com/ie/">Microsoft Internet Explorer</a>.
<p>
The notification is accomplished internally via
<a href="ref.html#gm_url"><code>gm_url</code></a> in
Tcl/Tk or the built-in command <code>web</code> in Matlab.
This routine notifies Netscape or IE to load the file using
the DDE protocol under Windows. Under Unix, <code>gm_url</code> uses Netscape
Navigator's remote control feature for automatic notification.
<p>
The rendering engines (both external and internal) support
"thickening" options.
Thickening a vertex means displaying it as a disk or sphere instead of
a point. Thickening an edge means displaying it as a fat line or pipe
instead of a segment. Thickening a vertex makes it a disk or ball.
<p>
Setting the thickness in a VRML plot of either vertices or
lines to anything greater than zero increasesboth the size of the VRML file
and the time required ton render the
object. This is because vertices of width greater
than 0 are
plotted as individual spheres, whereas 0-width vertices are
plotted as a point cloud. Similarly, edges of width 0 are rendered
all together as an indexed line set in VRML, whereas edges of positive width
are rendered individually as cylinders.
<p>
When <code>gmviz</code> in Matlab displays a 2D object, it providessix control buttons as follows.<strong>Zoom In</strong> and <strong>Zoom Out</strong>
zoom in or out on the current center of
the object. <strong>Up</strong>,
<strong>Down</strong>,
<strong>Left</strong>, and
<strong>Right</strong> move your viewpoint
on the object.
<p>
When <code>gmviz</code> in Matlab displays a 3D object, the buttons <strong>Up</strong>,
<strong>Down</strong>, <strong>Left</strong> and
<strong>Right</strong> change your
viewpoint as if you are sitting on the surface of a
circumscribing sphere around the object.
<h3><a name ="gmvizgui">gmvizgui</a></h3>
Most of these properties are controlledby a panel put up by the function <code>gmvizgui</code> on your screen.Changes made to a setting in this GUI do not affect
the current plot; instead, changes take effect for the next plot. After theGUI is closed, its last settings stay in
force. Do not start two different
gmvizgui windows because they will get out of sync.
<p>
This panel controls default colors, choice of renderer, file
names (in the case of VRML rendering), and thickness of segments
and points.
<p>
It also controls the number of bezier subdivisions. When plotting
a brep with curved boundaries, the rendering routine first converts
the curve into a sequence of straight edges or flat triangles.
You can control how many subdivisions are made for this purpose.
More subdivisions gives a more accurate rendering but at the cost
of greater computation time during rendering.
<p>
To try these features out, you can use the interactive script
testviz by typing <code>testviz</code> in matlab or
<code>source $qmg_library2/testviz.tcl</code> in Tcl/Tk.
<h3>Customizing graphics</h3>
Graphics in Tcl/Tk and Matlab are both implemented in
the scripting language, and therefore are available for easy
customization.
The only part of the graphics routines coded in C++ is
<code>gm_vizp</code>. This routine takes as arguments a brep or
simplicial complex and several other parameters and returns a
list of points, edges, or triangles ready to be plotted.
<h3><a name="gmplot">gmplot</a> (Matlab only)</h3>
The gmplot routine displays a color picture of a 2D or surface
3D finite element
solution. It is available only in Matlab.
Its calling sequence is:
<blockquote>
<strong>
gmplot(<em>mesh, u {, solnrange {, cmap}}</em>);
</strong>
</blockquote>
where mesh is the simplicial complex used for the finite element
method, and u is the solution vector. The simplicial complex
must have intrinsic dimension 2, and can have embedded dimension
of either 2 or 3. The argument <em>u</em> is the value at each node of
the simplicial complex that you want plotted.
Thus, field should be
a <a href="geom.html#zba">zba</a>
column vector with real-number entries whose number of entries
is equal to the number of nodes in the simplicial complex. This is
the form of the return variable from gmfem. But you can also use
this function to show, for instance, the difference between two fem
solutions.
<p>
In the case of 3D FEM solutions, you first have to restrict the
mesh to the boundary elements with the
<a href="ref.html#gmboundary"><code>gmboundary</code></a>
function. Then you have to restrict the
FEM solution <em>u</em> to the subset of nodes in the new simplicial complex
by subscripting the full FEM solution with the index-source
vector returned by <code>gmboundary</code>. There are examples
of this technique in the test cases.
<p>
The routine defaults to the <strong>jet</strong> colormap.
The third
argument is an optional 2-vector with lower and upper bounds on <em>u</em>.
These bounds default to the min and max values of the vector <em>u</em>.
Specifying the third argument explicitlyis useful
when you are making several
different plots for which you want the same absolute color scale.
<p>
Routine <code>gmplot</code> uses
interpolated colors on each triangle in the simplicial complex.
However, it does not use the interpolated-color feature that is built in
to Matlab (I found that earlier versions of interpolated
colors did not work on my color printer. I don't know if this has
been fixed in the more recent Matlab releases). Instead, it divides
each triangle into nine smaller triangles and uses flat colors (that
are linearly interpolated by the <code>gmplot</code> program) on each of the
subtriangles.
Thus, the triangles you see with <code>gmplot</code> are subtriangles of
the actual triangles used in the finite element solver.
<p>
The matlab command <code>colorbar</code> is useful in conjunction
with the <code>gmplot</code> routine.
<hr>
<p>
This documentation is written by
<a href="http://www.cs.cornell.edu/home/vavasis/vavasis.html">Stephen A.
Vavasis</a> and is
copyright ©1999 by <a href="http://www.info.cornell.edu/CUHomePage.html">Cornell
University</a>.
Permission to reproduce this documentation is granted provided this
notice remains attached. There is no warranty of any kind on
this software or its documentation. See the accompanying file
<a href="copyright.html">'copyright'</a>
for a full statement of the copyright.
<p>
<address>
Stephen A. Vavasis, Computer Science Department, Cornell University,
Ithaca, NY 14853, vavasis@cs.cornell.edu
</address>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -