1 | /***************************************
2 | $Header: /cvsroot/petscgraphics/illuminator.h,v 1.43 2006/02/05 21:14:11 hazelsct Exp $
3 |
4 | This is the interface for the Illuminator library.
5 | ***************************************/
6 |
7 | #ifndef ILLUMINATOR_H
8 | #define ILLUMINATOR_H /*+ To stop multiple inclusions. +*/
9 | #include <petscda.h>
10 | #include <glib.h>
11 | #include <gtk/gtk.h>
12 |
13 | /*+ The
14 | +latex+{\tt ISurface}
15 | +html+ <tt>ISurface</tt>
16 | type is the container (or object class) for triangle data which illuminator
17 | will render. +*/
18 | typedef void * ISurface;
19 |
20 | int ISurfCreate (ISurface *newsurf);
21 | int ISurfDestroy (ISurface Surf);
22 | int ISurfClear (ISurface Surf);
23 |
24 | /*+ The
25 | +latex+{\tt IDisplay}
26 | +html+ <tt>IDisplay</tt>
27 | type is the container for display data, such as the geomview output pipe, RGB
28 | buffer, multi-layer z-buffer, etc. +*/
29 | typedef void * IDisplay;
30 |
31 | int IDispCreate (IDisplay *newdisp, int width,int height,int rowskip,int bpp,
32 | int zbuf);
33 | int IDispResize (IDisplay Disp, int width,int height,int rowskip,int bpp,
34 | int zbuf);
35 | int IDispDestroy (IDisplay Disp);
36 | int IDispFill (IDisplay Disp, guchar *color);
37 | int IDispDrawGdk (IDisplay Disp, GtkWidget *dataview, GdkRgbDither dith);
38 | int IDispWritePPM (IDisplay Disp, char *filename);
39 |
40 | /*+ A value of
41 | +latex+{\tt field\_plot\_type}
42 | +html+ <tt>field_plot_type</tt>
43 | is attached to each field in a simulation in order to visualize them
44 | properly. Types are as follows:
45 | +*/
46 | typedef enum {
47 | /*+Scalar field.+*/
48 | FIELD_SCALAR = 0x00,
49 | /*+Ternary composition field with two components (third component is inferred
50 | from first two).+*/
51 | FIELD_TERNARY = 0x10,
52 | /*+Ternary composition with pseudo-components mapping onto a rectangle
53 | instead of a triangle.+*/
54 | FIELD_TERNARY_SQUARE = 0x18,
55 | /*+Vector field.+*/
56 | FIELD_VECTOR = 0x20,
57 | /*+Full ds*ds tensor field, e.g. transformation.+*/
58 | FIELD_TENSOR_FULL = 0x30,
59 | /*+Symmetric tensor field (using lines in principal stress directions).+*/
60 | FIELD_TENSOR_SYMMETRIC = 0x38,
61 | /*+Shear tensor field, both symmetric and inferring last diagonal from the
62 | opposite of the sum of the others.+*/
63 | FIELD_TENSOR_SHEAR = 0x39
64 | } field_plot_type;
65 |
66 | /* Core stuff in illuminator.c */
67 | int IllDrawTet (PetscScalar *coords, PetscScalar *vals, PetscScalar isoquant,
68 | PetscScalar *color);
69 | int IllDrawHex (PetscScalar *coords, PetscScalar *vals, PetscScalar isoquant,
70 | PetscScalar *color);
71 | int IllDraw3DBlock
72 | (int xd, int yd, int zd, int xs, int ys, int zs, int xm, int ym, int zm,
73 | PetscScalar *minmax, PetscScalar *vals, int skip,
74 | int n_quants, PetscScalar *isoquants, PetscScalar *colors);
75 |
76 | /* Utility stuff in utility.c */
77 | int auto_scale
78 | (PetscScalar *global_array, int points, int num_fields, int display_field,
79 | field_plot_type fieldtype, int dimensions, PetscScalar *scale);
80 | int minmax_scale
81 | (PetscScalar *global_array, int points, int num_fields, int display_field,
82 | field_plot_type fieldtype, int dimensions, PetscScalar *minmax);
83 | void field_indices (int nfields, int ds, field_plot_type *plottypes,
84 | int *indices);
85 |
86 | /* PETSc stuff; xcut, ycut and zcut should almost always be PETSC_FALSE */
87 | int DATriangulateRange
88 | (ISurface Surf, DA theda, Vec globalX, int this, PetscScalar *minmax,
89 | int n_quants, PetscScalar *isoquants, PetscScalar *colors, int xmin,int xmax,
90 | int ymin,int ymax, int zmin,int zmax);
91 | int DATriangulateLocalRange
92 | (ISurface Surf, DA theda, Vec localX, int this, PetscScalar *minmax,
93 | int n_quants, PetscScalar *isoquants, PetscScalar *colors, int xmin,int xmax,
94 | int ymin,int ymax, int zmin,int zmax);
95 | static inline int DATriangulate
96 | (ISurface Surf, DA theda, Vec globalX, int this, PetscScalar *minmax,
97 | int n_quants, PetscScalar *isoquants, PetscScalar *colors, PetscTruth xcut,
98 | PetscTruth ycut, PetscTruth zcut)
99 | { return DATriangulateRange
100 | (Surf, theda, globalX, this, minmax, n_quants, isoquants, colors,
101 | 0,xcut?-2:-1, 0,ycut?-2:-1, 0,zcut?-2:-1); }
102 | static inline int DATriangulateLocal
103 | (ISurface Surf, DA theda, Vec localX, int this, PetscScalar *minmax,
104 | int n_quants, PetscScalar *isoquants, PetscScalar *colors, PetscTruth xcut,
105 | PetscTruth ycut, PetscTruth zcut)
106 | { return DATriangulateLocalRange
107 | (Surf, theda, localX, this, minmax, n_quants, isoquants, colors,
108 | 0,xcut?-2:-1, 0,ycut?-2:-1, 0,zcut?-2:-1); }
109 | int IllErrorHandler (int id, char *message);
110 |
111 | /* Plotting functions to render data into an RGB buffer, transform #defines */
112 | int render_scale_2d (IDisplay Disp, field_plot_type fieldtype, int symmetry);
113 | int render_composition_path
114 | (IDisplay Disp, PetscScalar *comp_array, int gridpoints, int num_fields,
115 | field_plot_type fieldtype, PetscScalar *scale,
116 | PetscScalar red,PetscScalar green,PetscScalar blue,PetscScalar alpha);
117 | int render_rgb_local_2d
118 | (IDisplay Disp, PetscScalar *global_array, int num_fields, int display_field,
119 | field_plot_type fieldtype, PetscScalar *scale, int nx,int ny, int xs,int ys,
120 | int xm,int ym, int transform, IDisplay SDisp, PetscScalar dpred,
121 | PetscScalar dpgreen, PetscScalar dpblue, PetscScalar dpalpha);
122 | int render_rgb_local_3d
123 | (IDisplay Disp, ISurface Surf, PetscScalar *eye, PetscScalar *dir,
124 | PetscScalar *right);
125 | #define FLIP_HORIZONTAL 0x01
126 | #define FLIP_VERTICAL 0x02
127 | #define ROTATE_LEFT 0x04
128 |
129 | /* IlluMulti load/save stuff, including compression #defines */
130 | int IlluMultiLoad
131 | (MPI_Comm comm, char *basename, DA *theda, PetscScalar *wx,PetscScalar *wy,
132 | PetscScalar *wz, field_plot_type **fieldtypes, int *usermetacount,
133 | char ***usermetanames, char ***usermetadata);
134 | int IlluMultiRead
135 | (MPI_Comm comm, DA theda, Vec X, char *basename, int *usermetacount,
136 | char ***usermetanames, char ***usermetadata);
137 | int IlluMultiSave
138 | (MPI_Comm comm, DA theda, Vec X, char *basename, PetscScalar wx,PetscScalar wy,
139 | PetscScalar wz, field_plot_type *fieldtypes, int usermetacount,
140 | char **usermetanames, char **usermetadata, int compressed);
141 | #define COMPRESS_INT_MASK 0x30
142 | #define COMPRESS_INT_NONE 0x00
143 | #define COMPRESS_INT_LONG 0x10
144 | #define COMPRESS_INT_SHORT 0x20
145 | #define COMPRESS_INT_CHAR 0x30
146 | #define COMPRESS_GZIP_MASK 0x0F
147 | #define COMPRESS_GZIP_NONE 0x00
148 | #define COMPRESS_GZIP_FAST 0x01
149 | #define COMPRESS_GZIP_BEST 0x0A
150 |
151 | /* Geomview stuff */
152 | int GeomviewBegin (MPI_Comm comm, IDisplay *newdisp);
153 | int GeomviewEnd (MPI_Comm comm, IDisplay oldisp);
154 | int GeomviewDisplayTriangulation
155 | (MPI_Comm comm, ISurface Surf, IDisplay Disp, PetscScalar *minmax, char *name,
156 | PetscTruth transparent);
157 |
158 | /* Imlib2 stuff */
159 | #ifdef IMLIB2_EXISTS
160 | #include <X11/Xlib.h>
161 | #include <Imlib2.h>
162 | int imlib2_render_triangles (DATA32 *data, int width, int height,
163 | int num_triangles, int *triangle_coords,
164 | PetscScalar *triangle_colors, int color_skip,
165 | PetscScalar *triangle_shades, int shade_skip);
166 | #endif
167 |
168 | #endif /* ILLUMINATOR_H */