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  * Type & structure definitions for objects & geometry. This is really the
27  * definition of the structure of ElmerPost.
28  *
29  *******************************************************************************
30  *
31  *                     Author:       Juha Ruokolainen
32  *
33  *                    Address: CSC - IT Center for Science Ltd.
34  *                                Keilaranta 14, P.O. BOX 405
35  *                                  02101 Espoo, Finland
36  *                                  Tel. +358 0 457 2723
37  *                                Telefax: +358 0 457 2302
38  *                              EMail: Juha.Ruokolainen@csc.fi
39  *
40  *                       Date: 26 Sep 1995
41  *
42  *                Modified by:
43  *
44  *       Date of modification:
45  *
46  ******************************************************************************/
47 
48 #ifdef MODULE_GEOMETRY
49 #   define GEO_EXT
50 #else
51 #   define GEO_EXT extern
52 #endif
53 
54 #define GEO_TRIANGLE_BLOCK_SIZE 4096
55 #define GEO_VERTEX_BLOCK_SIZE   4096
56 
57 #define FLOAT float
58 
59 typedef struct group_s
60 {
61     struct group_s *Next;
62     int status,Open;
63     char *Name;
64 } group_t;
65 
66 /*
67  * Triangle
68  */
69 typedef struct
70 {
71     int   v[3];    /* vertex pointers */
72     FLOAT Fu[3];   /* triangle normal */
73     FLOAT u[3][3]; /* vertex normals  */
74 
75     struct element_s *Element;
76 
77     int Count;
78     logical_t Edge[3];  /* beginning of an edge flag */
79 } triangle_t;
80 
81 /*
82  * list of faces connected to a vertex
83  */
84 typedef struct vertex_face_s
85 {
86     int Face;
87     struct vertex_face_s *Next;
88 } vertex_face_t;
89 
90 /*
91  *  vertex def's
92  */
93 typedef struct vertex_s
94 {
95     FLOAT x[3];
96     vertex_face_t *Faces;
97     logical_t ElementModelNode;
98 } vertex_t;
99 
100 typedef struct
101 {
102     FLOAT x[3],y[3],z[3];
103     FLOAT u[3],v[3],w[3];
104     FLOAT c[3],f[3];
105 } polygon_t;
106 
107 typedef enum
108 {
109     line_style_line,line_style_cylinder
110 } line_style_t;
111 
112 typedef struct line_s
113 {
114     float x[3];
115     float y[3];
116     float z[3];
117     float f[3],c[3];
118 } line_t;
119 
120 /*
121  * Edges of elements are hold in an array of lists that are
122  * indexed by smallest numbered vertex of a particular edge.
123  */
124 typedef enum
125 {
126     edge_style_all, edge_style_free
127 } edge_style_t;
128 
129 typedef struct edge_list_s
130 {
131     struct edge_list_s *Next;
132     int Entry,Count;
133     struct element_s *Element;
134 } edge_list_t;
135 
136 typedef struct edge_s
137 {
138      edge_list_t *EdgeList;
139 } edge_t;
140 
141 /*
142  *  geometry def's
143  */
144 typedef struct geometry_s
145 {
146     struct Geometry_s *Next;
147     char *Name;
148 
149     triangle_t *Triangles;
150     int TriangleCount,MaxTriangleCount;
151 
152     vertex_t *Vertices;
153     int VertexCount,MaxVertexCount;
154 
155     edge_t *Edges;
156 
157     double Scale;
158     vertex_t MinMax[2];
159 } geometry_t;
160 
161 GEO_EXT geometry_t Geometry;
162 
163 typedef struct data_s
164 {
165     int a;
166 } data_t;
167 
168 
169 void geo_free_groups( group_t *groups );
170 int geo_add_vertex( geometry_t *geometry, vertex_t *vertex );
171 void geo_free_edge_tables( geometry_t *geometry );
172 void geo_free_vertex_face_tables( geometry_t *geometry );
173 int geo_add_triangle( geometry_t *geometry, triangle_t *triangle );
174 void geo_triangle_normal( geometry_t *geom,triangle_t *triangle );
175 void geo_vertex_normals( geometry_t *geometry, double Ang ) ;
176