1 /*****************************************************************************
2  *
3  *  Elmer, A Finite Element Software for Multiphysical Problems
4  *
5  *  Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
6  *
7  *  This program is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU General Public License
9  *  as published by the Free Software Foundation; either version 2
10  *  of the License, or (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program (in file fem/GPL-2); if not, write to the
19  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  *  Boston, MA 02110-1301, USA.
21  *
22  *****************************************************************************/
23 
24 /*******************************************************************************
25  *
26  * Visual class definitions.
27  *
28  *******************************************************************************
29  *
30  *                     Author:       Juha Ruokolainen
31  *
32  *                    Address: CSC - IT Center for Science Ltd.
33  *                                Keilaranta 14, P.O. BOX 405
34  *                                  02101 Espoo, Finland
35  *                                  Tel. +358 0 457 2723
36  *                                Telefax: +358 0 457 2302
37  *                              EMail: Juha.Ruokolainen@csc.fi
38  *
39  *                       Date: 27 Sep 1995
40  *
41  *
42  * Modification history:
43  *
44  * 28 Sep 1995, modified visual_t and visual_type_t structures to make a list
45  *              rather than an array of visual types.
46  *
47  ******************************************************************************/
48 
49 #ifdef EXT
50 #undef EXT
51 #endif
52 
53 #ifdef MODULE_VISUALS
54 #define EXT
55 #else
56 #define EXT extern
57 #endif
58 
59 #ifdef MODULE_VISUALS
60     double TooLong1 = 0.30,TooLong2 = 0.5;
61 #else
62     extern double TooLong1,TooLong2;
63 #endif
64 
65 #define VIS_VISUAL_PARAM_LOGICAL 1
66 #define VIS_VISUAL_PARAM_INT     2
67 #define VIS_VISUAL_PARAM_FLOAT   4
68 #define VIS_VISUAL_PARAM_POINTER 8
69 
70 typedef struct visual_param_s
71 {
72    /*
73     * Name string for the parameter
74     */
75    char *Name;
76 
77    /*
78     * Format string for scanf when scanning parameter value
79     */
80    char *Format;
81 
82    /*
83     * Parameter offset from structure beginning
84     */
85    long int Offset;
86 
87    /*
88     *  type of the parameter (one of VIS_VISUAL_PARAM_*)
89     */
90    int   ParamType;
91 
92    /*
93     * Initial values for the parameters
94     */
95    int IntValue;
96    double FloatValue;
97    void *PointerValue;
98 } visual_param_t;
99 
100 typedef struct visual_type_s
101 {
102     /*
103      * Next visual type in the list
104     */
105     struct visual_type_s *Next;
106 
107     /*
108      * One line description of the visual
109      */
110     char *VisualName;
111 
112     /*
113      *  Alloc memory for parameters
114      */
115     void *(*AllocParams)();
116 
117     /*
118      * Dispose a visual
119      */
120     void (*DeleteParams)(void *);
121 
122     /*
123      * Realize a visual instance
124      */
125     int (*RealizeVisual)(geometry_t *,element_model_t *,void *,double);
126 
127     /*
128      * Structure holding names and offsets of particular
129      * visual types parameters
130      */
131     visual_param_t *VisualParams;
132 } visual_type_t;
133 
134 /*
135  *  visual type list (remove this)
136  */
137 typedef struct visual_defs_s
138 {
139     int NumberOfVisualTypes;
140     visual_type_t *VisualTypes;
141 } visual_defs_t;
142 
143 /*
144  * Global variable holding start of the list of visual types
145  */
146 EXT visual_defs_t VisualDefs;
147 
148 typedef struct visual_s
149 {
150     /*
151      *  Next visual in list
152      */
153     struct visual_s *Next;
154 
155     /*
156      * Name of the visual instance
157      */
158     char *Name;
159 
160    /*
161     * this  is pointer to arrow_t,mesh_t etc. structures, see below
162     */
163     void *VisualParams;
164 
165     /*
166      * Pointer to visual type structure holding the function pointers
167      * acting on this type of visual
168      */
169 
170     visual_type_t *VisualType;
171 } visual_t;
172 
173 typedef enum
174 {
175     mesh_style_none,mesh_style_line,mesh_style_surf,mesh_style_line_and_surf
176 } mesh_style_t;
177 
178 typedef enum
179 {
180     arrow_style_stick,arrow_style_arrow
181 } arrow_style_t;
182 
183 typedef enum
184 {
185     particle_style_vector,particle_style_sphere
186 } particle_style_t;
187 
188 typedef enum
189 {
190     particle_integ_euler, particle_integ_runge_kutta
191 } particle_integ_method_t;
192 
193 typedef enum
194 {
195     particle_policy_fixed, particle_policy_adaptive
196 } particle_integ_policy_t;
197 
198 
199 int vis_initialize_arrow_visual();
200 int vis_initialize_colscale_visual();
201 int vis_initialize_contour_line_visual();
202 int vis_initialize_isosurface_visual();
203 void vis_triangle ( triangle_t *t,vertex_t *v,double *color,double CScl,double CAdd);
204 int vis_initialize_mesh_visual();
205 int vis_initialize_particle_visual();
206 int vis_initialize_sphere_visual();
207 int vis_add_visual_type( visual_type_t *VisualDef );
208 visual_type_t *vis_get_visual_type(char *name);
209 char *vis_get_visual_type_name(visual_t *visual);
210 char *vis_get_visual_name(visual_t *visual);
211 int vis_set_param( visual_t *visual, char *name,int intvalue,double doublevalue,void *ptrvalue );
212 void vis_default_params( visual_t *visual );
213 visual_t *vis_new_visual(char *name);
214 visual_t *vis_link_visual( visual_t *list,visual_t *new );
215 visual_t *vis_add_visual(visual_t *visual,char *name);
216 void vis_delete_visual( visual_t *visual );
217 int vis_display_visual( geometry_t *geometry, element_model_t *model, visual_t *VL,double t );
218 int vis_display_list( geometry_t *geometry, element_model_t *model, visual_t *VL,double t );
219 int vis_initialize_visual_types();
220