File: | vtkWriter.c |
Warning: | line 254, column 21 Value stored to 'jface' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * CAPS: Computational Aircraft Prototype Syntheses |
3 | * |
4 | * vtk 3D Mesh Writer Code |
5 | * |
6 | * Copyright 2014-2024, Massachusetts Institute of Technology |
7 | * Licensed under The GNU Lesser General Public License, version 2.1 |
8 | * See http://www.opensource.org/licenses/lgpl-2.1.php |
9 | * |
10 | */ |
11 | |
12 | #include <string.h> |
13 | #include "aimUtil.h" |
14 | #include "aimMesh.h" |
15 | |
16 | #include "vtkWriter.h" |
17 | |
18 | #define CHECK_STATUS(X)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "X", routine, 18); goto cleanup; } \ |
19 | if (status < EGADS_SUCCESS0) { \ |
20 | printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n", status, #X, routine, __LINE__20); \ |
21 | goto cleanup; \ |
22 | } |
23 | #define MALLOC(PTR,TYPE,SIZE)if (PTR != ((void*)0)) { printf("ERROR:: MALLOC overwrites for %s=%llx (called from %s:%d)\n" , "PTR", (long long)PTR, routine, 23); status = -4; goto cleanup ; } PTR = (TYPE *) EG_alloc((SIZE) * sizeof(TYPE)); if (PTR == ((void*)0)) { printf("ERROR:: MALLOC PROBLEM for %s (called from %s:%d)\n" , "PTR", routine, 23); status = -4; goto cleanup; } \ |
24 | if (PTR != NULL((void*)0)) { \ |
25 | printf("ERROR:: MALLOC overwrites for %s=%llx (called from %s:%d)\n", #PTR, (long long)PTR, routine, __LINE__25); \ |
26 | status = EGADS_MALLOC-4; \ |
27 | goto cleanup; \ |
28 | } \ |
29 | PTR = (TYPE *) EG_alloc((SIZE) * sizeof(TYPE)); \ |
30 | if (PTR == NULL((void*)0)) { \ |
31 | printf("ERROR:: MALLOC PROBLEM for %s (called from %s:%d)\n", #PTR, routine, __LINE__31); \ |
32 | status = EGADS_MALLOC-4; \ |
33 | goto cleanup; \ |
34 | } |
35 | #define FREE(PTR)if (PTR != ((void*)0)) { EG_free(PTR); } PTR = ((void*)0); \ |
36 | if (PTR != NULL((void*)0)) { \ |
37 | EG_free(PTR); \ |
38 | } \ |
39 | PTR = NULL((void*)0); |
40 | |
41 | const char *meshExtension() |
42 | { |
43 | /*@-observertrans@*/ |
44 | return MESHEXTENSION".vtk"; |
45 | /*@+observertrans@*/ |
46 | } |
47 | |
48 | |
49 | int meshWrite(void *aimInfo, aimMesh *mesh) |
50 | { |
51 | int status; // Function return status |
52 | int nLine=0, nTri=0, nQuad=0; |
53 | int nTet=0, nPyramid=0, nPrism=0, nHex=0; |
54 | int ivrtx, igroup, ielem; |
55 | int ntess, itess; |
56 | |
57 | |
58 | int nedge, iedge; |
59 | int nface, iface, jface; |
60 | int npnt, npnt2, ipnt; |
61 | int ntri, ntri2, itri, jtri; |
62 | int it0, it1, it2, ig0, ig1, ig2, IG0, IG1, IG2; |
63 | const int *ptype, *ptype2, *pindx, *pindx2, *tris, *tris2, *tric, *tric2; |
64 | int *edgeLeft=NULL((void*)0), *edgeRite=NULL((void*)0), *faceOffset=NULL((void*)0); |
65 | const double *xyz, *xyz2, *uv, *uv2; |
66 | char filename[PATH_MAX4096]; |
67 | ego etess; |
68 | FILE *fp=NULL((void*)0); |
69 | aimMeshData *meshData = NULL((void*)0); |
70 | |
71 | char routine[] = "meshWrite(vtk)"; |
72 | |
73 | printf("\nWriting vtk file ....\n"); |
74 | |
75 | if (mesh == NULL((void*)0)) return CAPS_NULLVALUE-307; |
76 | if (mesh->meshRef == NULL((void*)0)) return CAPS_NULLVALUE-307; |
77 | if (mesh->meshData == NULL((void*)0)) return CAPS_NULLVALUE-307; |
78 | |
79 | meshData = mesh->meshData; |
80 | |
81 | if (meshData->dim != 3) { |
82 | AIM_ERROR(aimInfo, "meshData dim = %d must be 3!!!", meshData->dim){ aim_message(aimInfo, CERROR, 0 , "vtkWriter.c", 82, __func__ , "meshData dim = %d must be 3!!!", meshData->dim); }; |
83 | return CAPS_BADVALUE-311; |
84 | } |
85 | |
86 | snprintf(filename, PATH_MAX4096, "%s%s", mesh->meshRef->fileName, MESHEXTENSION".vtk"); |
87 | |
88 | for (igroup = 0; igroup < meshData->nElemGroup; igroup++) { |
89 | if (meshData->elemGroups[igroup].order != 1) { |
90 | AIM_ERROR(aimInfo, "vtk files only supports linear mesh elements! group %d order = %d",{ aim_message(aimInfo, CERROR, 0 , "vtkWriter.c", 91, __func__ , "vtk files only supports linear mesh elements! group %d order = %d" , igroup, meshData->elemGroups[igroup].order); } |
91 | igroup, meshData->elemGroups[igroup].order){ aim_message(aimInfo, CERROR, 0 , "vtkWriter.c", 91, __func__ , "vtk files only supports linear mesh elements! group %d order = %d" , igroup, meshData->elemGroups[igroup].order); }; |
92 | status = CAPS_IOERR-332; |
93 | goto cleanup; |
94 | } |
95 | |
96 | // count the number of element types |
97 | if (meshData->elemGroups[igroup].elementTopo == aimLine ) { |
98 | nLine += meshData->elemGroups[igroup].nElems; |
99 | } else if (meshData->elemGroups[igroup].elementTopo == aimTri ) { |
100 | nTri += meshData->elemGroups[igroup].nElems; |
101 | } else if (meshData->elemGroups[igroup].elementTopo == aimQuad ) { |
102 | nQuad += meshData->elemGroups[igroup].nElems; |
103 | } else if (meshData->elemGroups[igroup].elementTopo == aimTet ) { |
104 | nTet += meshData->elemGroups[igroup].nElems; |
105 | } else if (meshData->elemGroups[igroup].elementTopo == aimPyramid) { |
106 | nPyramid += meshData->elemGroups[igroup].nElems; |
107 | } else if (meshData->elemGroups[igroup].elementTopo == aimPrism ) { |
108 | nPrism += meshData->elemGroups[igroup].nElems; |
109 | } else if (meshData->elemGroups[igroup].elementTopo == aimHex ) { |
110 | nHex += meshData->elemGroups[igroup].nElems; |
111 | } else { |
112 | AIM_ERROR(aimInfo, "Unknown group %d element topology: %d", igroup+1, meshData->elemGroups[igroup].elementTopo){ aim_message(aimInfo, CERROR, 0 , "vtkWriter.c", 112, __func__ , "Unknown group %d element topology: %d", igroup+1, meshData ->elemGroups[igroup].elementTopo); }; |
113 | status = CAPS_MISMATCH-324; |
114 | goto cleanup; |
115 | } |
116 | } |
117 | |
118 | /* only allow Triangles (for now) */ |
119 | if (nLine != 0 || |
120 | nQuad != 0 || |
121 | nTet != 0 || |
122 | nPyramid != 0 || |
123 | nPrism != 0 || |
124 | nHex != 0 ) { |
125 | AIM_ERROR(aimInfo, "only Triangles are currently supported"){ aim_message(aimInfo, CERROR, 0 , "vtkWriter.c", 125, __func__ , "only Triangles are currently supported"); }; |
126 | status = CAPS_BADVALUE-311; |
127 | goto cleanup; |
128 | } |
129 | |
130 | /* open the file */ |
131 | fp = fopen(filename, "w"); |
132 | if (fp == NULL((void*)0)) { |
133 | AIM_ERROR(aimInfo, "Cannot open file: %s\n", filename){ aim_message(aimInfo, CERROR, 0 , "vtkWriter.c", 133, __func__ , "Cannot open file: %s\n", filename); }; |
134 | return CAPS_IOERR-332; |
135 | } |
136 | |
137 | /* write the header */ |
138 | fprintf(fp, "# vtk DataFile Version 3.0\n"); |
139 | fprintf(fp, "written by CAPS\n"); |
140 | fprintf(fp, "ASCII\n"); |
141 | fprintf(fp, "DATASET POLYDATA\n"); |
142 | |
143 | /* write all of the verticies */ |
144 | fprintf(fp, "POINTS %d double\n", meshData->nVertex); |
145 | for (ivrtx = 0; ivrtx < meshData->nVertex; ivrtx++) { |
146 | fprintf(fp, "%16.8f %16.8f %16.8f\n", |
147 | meshData->verts[ivrtx][0], |
148 | meshData->verts[ivrtx][1], |
149 | meshData->verts[ivrtx][2]); |
150 | } |
151 | |
152 | /* write out each of the polygons */ |
153 | fprintf(fp, "POLYGONS %d %d\n", nTri, 4*nTri); |
154 | |
155 | for (igroup = 0; igroup < meshData->nElemGroup; igroup++) { |
156 | if (meshData->elemGroups[igroup].elementTopo != aimTri) { |
157 | AIM_ERROR(aimInfo, "igroup=%d are not Triangles\n", igroup){ aim_message(aimInfo, CERROR, 0 , "vtkWriter.c", 157, __func__ , "igroup=%d are not Triangles\n", igroup); }; |
158 | return CAPS_BADVALUE-311; |
159 | } |
160 | |
161 | for (ielem = 0; ielem < meshData->elemGroups[igroup].nElems; ielem++) { |
162 | fprintf(fp, "%d %8d %8d %8d\n", 3, |
163 | meshData->elemGroups[igroup].elements[3*ielem ]-1, |
164 | meshData->elemGroups[igroup].elements[3*ielem+1]-1, |
165 | meshData->elemGroups[igroup].elements[3*ielem+2]-1); |
166 | } |
167 | } |
168 | |
169 | /* write out the body number and connectivity for each triangle */ |
170 | fprintf(fp, "CELL_DATA %d\n", nTri); |
171 | fprintf(fp, "SCALARS body/connectivity int 4\n"); |
172 | fprintf(fp, "LOOKUP_TABLE default\n"); |
173 | |
174 | ntess = mesh->meshRef->nmap; |
175 | for (itess = 0; itess < ntess; itess++) { |
176 | etess = mesh->meshRef->maps[itess].tess; |
177 | |
178 | /* find the number of Edges and Faces */ |
179 | nedge = 0; |
180 | for (iedge = 1; iedge < 99999; iedge++) { |
181 | status = EG_getTessEdge(etess, iedge, |
182 | &npnt, &xyz, &uv); |
183 | if (status < EGADS_SUCCESS0) break; |
184 | nedge++; |
185 | } |
186 | |
187 | MALLOC(edgeLeft, int, nedge+1)if (edgeLeft != ((void*)0)) { printf("ERROR:: MALLOC overwrites for %s=%llx (called from %s:%d)\n" , "edgeLeft", (long long)edgeLeft, routine, 187); status = -4 ; goto cleanup; } edgeLeft = (int *) EG_alloc((nedge+1) * sizeof (int)); if (edgeLeft == ((void*)0)) { printf("ERROR:: MALLOC PROBLEM for %s (called from %s:%d)\n" , "edgeLeft", routine, 187); status = -4; goto cleanup; }; |
188 | MALLOC(edgeRite, int, nedge+1)if (edgeRite != ((void*)0)) { printf("ERROR:: MALLOC overwrites for %s=%llx (called from %s:%d)\n" , "edgeRite", (long long)edgeRite, routine, 188); status = -4 ; goto cleanup; } edgeRite = (int *) EG_alloc((nedge+1) * sizeof (int)); if (edgeRite == ((void*)0)) { printf("ERROR:: MALLOC PROBLEM for %s (called from %s:%d)\n" , "edgeRite", routine, 188); status = -4; goto cleanup; }; |
189 | |
190 | nface = 0; |
191 | for (iface = 1; iface < 99999; iface++) { |
192 | status = EG_getTessFace(etess, iface, |
193 | &npnt, &xyz, &uv, &ptype, &pindx, |
194 | &ntri, &tris, &tric); |
195 | if (status < EGADS_SUCCESS0) break; |
196 | nface++; |
197 | } |
198 | |
199 | MALLOC(faceOffset, int, nface+2)if (faceOffset != ((void*)0)) { printf("ERROR:: MALLOC overwrites for %s=%llx (called from %s:%d)\n" , "faceOffset", (long long)faceOffset, routine, 199); status = -4; goto cleanup; } faceOffset = (int *) EG_alloc((nface+2) * sizeof(int)); if (faceOffset == ((void*)0)) { printf("ERROR:: MALLOC PROBLEM for %s (called from %s:%d)\n" , "faceOffset", routine, 199); status = -4; goto cleanup; }; |
200 | |
201 | /* set up Edge and Face info */ |
202 | for (iedge = 1; iedge <= nedge; iedge++) { |
203 | edgeLeft[iedge] = 0; |
204 | edgeRite[iedge] = 0; |
205 | } |
206 | |
207 | faceOffset[1] = 0; |
208 | for (iface = 1; iface <= nface; iface++) { |
209 | status = EG_getTessFace(etess, iface, |
210 | &npnt, &xyz, &uv, &ptype, &pindx, |
211 | &ntri, &tris, &tric); |
212 | CHECK_STATUS(EG_getTessFace)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_getTessFace", routine, 212); goto cleanup; }; |
213 | |
214 | faceOffset[iface+1] = faceOffset[iface] + ntri; |
215 | |
216 | for (ipnt = 0; ipnt < npnt; ipnt++) { |
217 | if (ptype[ipnt] < 0) { |
218 | break; |
219 | } else if (ptype[ipnt] == 0) { |
220 | continue; |
221 | } else { |
222 | iedge = pindx[ipnt]; |
223 | if (edgeLeft[iedge] == 0) { |
224 | edgeLeft[iedge] = iface; |
225 | } else if (edgeLeft[iedge] != iface) { |
226 | edgeRite[iedge] = iface; |
227 | } |
228 | } |
229 | } |
230 | } |
231 | |
232 | /* process all Triangles in all Faces */ |
233 | for (iface = 1; iface <= nface; iface++) { |
234 | status = EG_getTessFace(etess, iface, |
235 | &npnt, &xyz, &uv, &ptype, &pindx, |
236 | &ntri, &tris, &tric); |
237 | CHECK_STATUS(EG_getTessFace)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_getTessFace", routine, 237); goto cleanup; }; |
238 | |
239 | for (itri = 0; itri < ntri; itri++) { |
240 | |
241 | /* find neighbor it0 */ |
242 | if (tric[3*itri ] > 0) { |
243 | it0 = tric[3*itri ] + faceOffset[iface]; |
244 | } else { |
245 | it0 = -1; |
246 | |
247 | status = EG_localToGlobal(etess, iface, tris[3*itri+1], &ig1); |
248 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 248); goto cleanup; }; |
249 | |
250 | status = EG_localToGlobal(etess, iface, tris[3*itri+2], &ig2); |
251 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 251); goto cleanup; }; |
252 | |
253 | iedge = -tric[3*itri ]; |
254 | jface = 0; |
Value stored to 'jface' is never read | |
255 | if ( edgeLeft[iedge] == iface) { |
256 | jface = edgeRite[iedge]; |
257 | } else if ( edgeRite[iedge] == iface) { |
258 | jface = edgeLeft[iedge]; |
259 | } else { |
260 | printf("WE SHOULD NOT GET HERE %d: iface=%d, itri=%d, iedge=%d\n", __LINE__260, iface, itri, iedge); |
261 | exit(0); |
262 | } |
263 | |
264 | if (jface != 0) { |
265 | status = EG_getTessFace(etess, jface, |
266 | &npnt2, &xyz2, &uv2, &ptype2, &pindx2, |
267 | &ntri2, &tris2, &tric2); |
268 | CHECK_STATUS(EG_getTessFace)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_getTessFace", routine, 268); goto cleanup; }; |
269 | |
270 | for (jtri = 0; jtri < ntri2; jtri++) { |
271 | if (tric2[3*jtri] == -iedge || tric2[3*jtri+1] == -iedge || tric2[3*jtri+2] == -iedge) { |
272 | status = EG_localToGlobal(etess, jface, tris2[3*jtri ], &IG0); |
273 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 273); goto cleanup; }; |
274 | |
275 | status = EG_localToGlobal(etess, jface, tris2[3*jtri+1], &IG1); |
276 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 276); goto cleanup; }; |
277 | |
278 | status = EG_localToGlobal(etess, jface, tris2[3*jtri+2], &IG2); |
279 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 279); goto cleanup; }; |
280 | |
281 | if ((ig1 == IG2 && ig2 == IG1) || |
282 | (ig1 == IG1 && ig2 == IG0) || |
283 | (ig1 == IG0 && ig2 == IG2) ) { |
284 | it0 = (jtri+1) + faceOffset[jface]; |
285 | break; |
286 | } |
287 | } |
288 | } |
289 | } else { |
290 | it0 = 0; |
291 | } |
292 | } |
293 | |
294 | /* find neighbor it1 */ |
295 | if (tric[3*itri+1] > 0) { |
296 | it1 = tric[3*itri+1] + faceOffset[iface]; |
297 | } else { |
298 | it1 = -1; |
299 | |
300 | status = EG_localToGlobal(etess, iface, tris[3*itri+2], &ig2); |
301 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 301); goto cleanup; }; |
302 | |
303 | status = EG_localToGlobal(etess, iface, tris[3*itri ], &ig0); |
304 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 304); goto cleanup; }; |
305 | |
306 | iedge = -tric[3*itri+1]; |
307 | jface = 0; |
308 | if ( edgeLeft[iedge] == iface) { |
309 | jface = edgeRite[iedge]; |
310 | } else if ( edgeRite[iedge] == iface) { |
311 | jface = edgeLeft[iedge]; |
312 | } else { |
313 | printf("WE SHOULD NOT GET HERE %d: iface=%d, itri=%d, iedge=%d\n", __LINE__313, iface, itri, iedge); |
314 | exit(0); |
315 | } |
316 | |
317 | if (jface != 0) { |
318 | status = EG_getTessFace(etess, jface, |
319 | &npnt2, &xyz2, &uv2, &ptype2, &pindx2, |
320 | &ntri2, &tris2, &tric2); |
321 | CHECK_STATUS(EG_getTessFace)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_getTessFace", routine, 321); goto cleanup; }; |
322 | |
323 | for (jtri = 0; jtri < ntri2; jtri++) { |
324 | if (tric2[3*jtri] == -iedge || tric2[3*jtri+1] == -iedge || tric2[3*jtri+2] == -iedge) { |
325 | status = EG_localToGlobal(etess, jface, tris2[3*jtri ], &IG0); |
326 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 326); goto cleanup; }; |
327 | |
328 | status = EG_localToGlobal(etess, jface, tris2[3*jtri+1], &IG1); |
329 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 329); goto cleanup; }; |
330 | |
331 | status = EG_localToGlobal(etess, jface, tris2[3*jtri+2], &IG2); |
332 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 332); goto cleanup; }; |
333 | |
334 | if ((ig2 == IG2 && ig0 == IG1) || |
335 | (ig2 == IG1 && ig0 == IG0) || |
336 | (ig2 == IG0 && ig0 == IG2) ) { |
337 | it1 = (jtri+1) + faceOffset[jface]; |
338 | break; |
339 | } |
340 | } |
341 | } |
342 | } else { |
343 | it1 = 0; |
344 | } |
345 | } |
346 | |
347 | /* find neighbor it2 */ |
348 | if (tric[3*itri+2] > 0) { |
349 | it2 = tric[3*itri+2] + faceOffset[iface]; |
350 | } else { |
351 | it2 = -1; |
352 | |
353 | status = EG_localToGlobal(etess, iface, tris[3*itri ], &ig0); |
354 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 354); goto cleanup; }; |
355 | |
356 | status = EG_localToGlobal(etess, iface, tris[3*itri+1], &ig1); |
357 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 357); goto cleanup; }; |
358 | |
359 | iedge = -tric[3*itri+2]; |
360 | jface = 0; |
361 | if ( edgeLeft[iedge] == iface) { |
362 | jface = edgeRite[iedge]; |
363 | } else if ( edgeRite[iedge] == iface) { |
364 | jface = edgeLeft[iedge]; |
365 | } else { |
366 | printf("WE SHOULD NOT GET HERE %d: iface=%d, itri=%d, iedge=%d\n", __LINE__366, iface, itri, iedge); |
367 | exit(0); |
368 | } |
369 | |
370 | if (jface != 0) { |
371 | status = EG_getTessFace(etess, jface, |
372 | &npnt2, &xyz2, &uv2, &ptype2, &pindx2, |
373 | &ntri2, &tris2, &tric2); |
374 | CHECK_STATUS(EG_getTessFace)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_getTessFace", routine, 374); goto cleanup; }; |
375 | |
376 | for (jtri = 0; jtri < ntri2; jtri++) { |
377 | if (tric2[3*jtri] == -iedge || tric2[3*jtri+1] == -iedge || tric2[3*jtri+2] == -iedge) { |
378 | status = EG_localToGlobal(etess, jface, tris2[3*jtri ], &IG0); |
379 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 379); goto cleanup; }; |
380 | |
381 | status = EG_localToGlobal(etess, jface, tris2[3*jtri+1], &IG1); |
382 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 382); goto cleanup; }; |
383 | |
384 | status = EG_localToGlobal(etess, jface, tris2[3*jtri+2], &IG2); |
385 | CHECK_STATUS(EG_localToGlobal)if (status < 0) { printf( "ERROR:: BAD STATUS = %d from %s (called from %s:%d)\n" , status, "EG_localToGlobal", routine, 385); goto cleanup; }; |
386 | |
387 | if ((ig0 == IG2 && ig1 == IG1) || |
388 | (ig0 == IG1 && ig1 == IG0) || |
389 | (ig0 == IG0 && ig1 == IG2) ) { |
390 | it2 = (jtri+1) + faceOffset[jface]; |
391 | break; |
392 | } |
393 | } |
394 | } |
395 | } else { |
396 | it2 = 0; |
397 | } |
398 | } |
399 | |
400 | /* add to file */ |
401 | fprintf(fp, "%8d %8d %8d %8d\n", itess, it0-1, it1-1, it2-1); |
402 | } |
403 | } |
404 | |
405 | FREE(edgeLeft)if (edgeLeft != ((void*)0)) { EG_free(edgeLeft); } edgeLeft = ((void*)0);; |
406 | FREE(edgeRite)if (edgeRite != ((void*)0)) { EG_free(edgeRite); } edgeRite = ((void*)0);; |
407 | FREE(faceOffset)if (faceOffset != ((void*)0)) { EG_free(faceOffset); } faceOffset = ((void*)0);; |
408 | } |
409 | |
410 | printf("Finished writing vtk file\n\n"); |
411 | |
412 | status = CAPS_SUCCESS0; |
413 | |
414 | cleanup: |
415 | FREE(edgeLeft)if (edgeLeft != ((void*)0)) { EG_free(edgeLeft); } edgeLeft = ((void*)0);; |
416 | FREE(edgeRite)if (edgeRite != ((void*)0)) { EG_free(edgeRite); } edgeRite = ((void*)0);; |
417 | FREE(faceOffset)if (faceOffset != ((void*)0)) { EG_free(faceOffset); } faceOffset = ((void*)0);; |
418 | |
419 | if (fp != NULL((void*)0)) fclose(fp); |
420 | |
421 | return status; |
422 | } |