Bug Summary

File:aim/egadsTess/egadsTessAIM.c
Warning:line 989, column 7
Value stored to 'numSurface' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name egadsTessAIM.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=none -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -D REVISION=7.7 -I /home/jenkins/workspace/ESP_Stanalizer/LINUX64/CAPS/scan-build/ESP/LINUX64/include -I ../utils -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-dangling-else -Wno-parentheses -Wno-unused-result -Wno-format-truncation -fdebug-compilation-dir /home/jenkins/workspace/ESP_Stanalizer/LINUX64/CAPS/scan-build/CAPS/aim/egadsTess -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/jenkins/workspace/ESP_Stanalizer/LINUX64/CAPS/scan-build/scanCAPS/2023-09-12-170855-27566-1 -x c egadsTessAIM.c
1/*
2 * CAPS: Computational Aircraft Prototype Syntheses
3 *
4 * EGADS Tessellation AIM
5 *
6 * * Copyright 2014-2023, 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 * This software has been cleared for public release on 05 Nov 2020, case number 88ABW-2020-3462.
11 */
12
13/*!\mainpage Introduction
14 *
15 * \section overviewEgadsTess EGADS Tessellation AIM Overview
16 * A module in the Computational Aircraft Prototype Syntheses (CAPS) has been developed to interact internal meshing
17 * capability for the EGADS library.
18 *
19 * An outline of the AIM's inputs and outputs are provided in \ref aimInputsEgadsTess and \ref aimOutputsEgadsTess, respectively.
20 *
21 * \section clearanceEgadsTess Clearance Statement
22 * This software has been cleared for public release on 05 Nov 2020, case number 88ABW-2020-3462.
23 *
24 */
25
26
27
28#include <string.h>
29#include <math.h>
30#include "capsTypes.h"
31#include "aimUtil.h"
32
33#include "meshUtils.h" // Collection of helper functions for meshing
34#include "miscUtils.h"
35#include "deprecateUtils.h"
36
37#ifdef WIN32
38#define strcasecmp stricmp
39#define strncasecmp _strnicmp
40#endif
41
42
43enum aimInputs
44{
45 Proj_Name = 1, /* index is 1-based */
46 Mesh_Quiet_Flag,
47 Mesh_Length_Factor,
48 Tess_Params,
49 Mesh_Format,
50 Mesh_ASCII_Flag,
51 Edge_Point_Min,
52 Edge_Point_Max,
53 Mesh_Sizing,
54 Mesh_Elements,
55 Multiple_Mesh,
56 TFI_Templates,
57 NUMINPUT = TFI_Templates /* Total number of inputs */
58};
59
60enum aimOutputs
61{
62 Done = 1, /* index is 1-based */
63 NumberOfElement,
64 NumberOfNode,
65 Surface_Mesh,
66 NUMOUT = Surface_Mesh /* Total number of outputs */
67};
68
69
70#define MXCHAR255 255
71#define EGADSTESSFILE"egadsTess_%d.eto" "egadsTess_%d.eto"
72
73//#define DEBUG
74
75typedef struct {
76
77 // quad meshing flag
78 int quadMesh;
79
80 // reference length
81 double refLen;
82
83 // Container for surface mesh
84 aimMeshRef meshRef;
85
86 // Container for mesh input
87 meshInputStruct meshInput;
88
89 // Attribute to index map
90 mapAttrToIndexStruct groupMap;
91
92 mapAttrToIndexStruct meshMap;
93
94 int numNodeTotal;
95 int numElemTotal;
96
97} aimStorage;
98
99
100static int destroy_aimStorage(aimStorage *egadsInstance)
101{
102 int status; // Function return status
103
104 egadsInstance->quadMesh = 0;
105
106 // Destroy meshInput
107 status = destroy_meshInputStruct(&egadsInstance->meshInput);
108 if (status != CAPS_SUCCESS0)
109 printf("Status = %d, egadsTessAIM meshInput cleanup!!!\n", status);
110
111 // Destroy surface mesh allocated arrays
112 status = aim_freeMeshRef(&egadsInstance->meshRef);
113 if (status != CAPS_SUCCESS0)
114 printf("Status = %d, egadsTessAIM surfaceMesh cleanup!!!\n", status);
115
116 egadsInstance->numNodeTotal = 0;
117 egadsInstance->numElemTotal = 0;
118
119 // Destroy attribute to index map
120 status = destroy_mapAttrToIndexStruct(&egadsInstance->groupMap);
121 if (status != CAPS_SUCCESS0)
122 printf("Status = %d, egadsTessAIM attributeMap cleanup!!!\n", status);
123
124 status = destroy_mapAttrToIndexStruct(&egadsInstance->meshMap);
125 if (status != CAPS_SUCCESS0)
126 printf("Status = %d, egadsTessAIM attributeMap cleanup!!!\n", status);
127 return CAPS_SUCCESS0;
128}
129
130
131/* ********************** Exposed AIM Functions ***************************** */
132
133int aimInitialize(int inst, /*@unused@*/ const char *unitSys, void *aimInfo,
134 /*@unused@*/ void **instStore, /*@unused@*/ int *major,
135 /*@unused@*/ int *minor, int *nIn, int *nOut,
136 int *nFields, char ***fnames, int **franks, int **fInOut)
137{
138 int status; // Function return status
139
140 aimStorage *egadsInstance=NULL((void*)0);
141
142#ifdef DEBUG
143 printf("\n egadsTessAIM/aimInitialize inst = %d!\n", inst);
144#endif
145
146 // Specify the number of analysis input and out "parameters"
147 *nIn = NUMINPUT;
148 *nOut = NUMOUT;
149 if (inst == -1) return CAPS_SUCCESS0;
150
151 /* specify the field variables this analysis can generate and consume */
152 *nFields = 0;
153 *fnames = NULL((void*)0);
154 *franks = NULL((void*)0);
155 *fInOut = NULL((void*)0);
156
157 // Allocate egadsInstance
158 AIM_ALLOC(egadsInstance, 1, aimStorage, aimInfo, status){ if (egadsInstance != ((void*)0)) { status = -4; aim_status(
aimInfo, status, "egadsTessAIM.c", 158, __func__, 1, "AIM_ALLOC: %s != NULL"
, "egadsInstance"); goto cleanup; } size_t memorysize = 1; egadsInstance
= (aimStorage *) EG_alloc(memorysize*sizeof(aimStorage)); if
(egadsInstance == ((void*)0)) { status = -4; aim_status(aimInfo
, status, "egadsTessAIM.c", 158, __func__, 3, "AIM_ALLOC: %s size %zu type %s"
, "egadsInstance", memorysize, "aimStorage"); goto cleanup; }
}
;
159 *instStore = egadsInstance;
160
161 // Set initial values for egadsInstance //
162
163 egadsInstance->quadMesh = 0;
164 egadsInstance->refLen = 0.0;
165
166 // Container for surface meshes
167 (void) aim_initMeshRef(&egadsInstance->meshRef, aimSurfaceMesh);
168
169 // Container for attribute to index map
170 status = initiate_mapAttrToIndexStruct(&egadsInstance->groupMap);
171 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 171, __func__, 0); goto cleanup; }
;
172
173 status = initiate_mapAttrToIndexStruct(&egadsInstance->meshMap);
174 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 174, __func__, 0); goto cleanup; }
;
175
176 // Container for mesh input
177 status = initiate_meshInputStruct(&egadsInstance->meshInput);
178 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 178, __func__, 0); goto cleanup; }
;
179
180cleanup:
181 if (status != CAPS_SUCCESS0) AIM_FREE(*instStore){ EG_free(*instStore); *instStore = ((void*)0); };
182
183 return status;
184}
185
186
187// ********************** AIM Function Break *****************************
188int aimInputs(/*@unused@*/ void *aimStore, /*@unused@*/ void *aimInfo,
189 int index, char **ainame, capsValue *defval)
190{
191
192 /*! \page aimInputsEgadsTess AIM Inputs
193 * The following list outlines the EGADS Tessellation meshing options along with their default value available
194 * through the AIM interface.
195 */
196
197#ifdef DEBUG
198 printf(" egadsTessAIM/aimInputs index = %d!\n", index);
199#endif
200
201 // Meshing Inputs
202 if (index == Proj_Name) {
203 *ainame = EG_strdup("Proj_Name"); // If NULL a volume grid won't be written by the AIM
204 defval->type = String;
205 defval->nullVal = IsNull;
206 defval->vals.string = NULL((void*)0);
207 //defval->vals.string = EG_strdup("CAPS");
208 defval->lfixed = Change;
209
210 /*! \page aimInputsEgadsTess
211 * - <B> Proj_Name = NULL</B> <br>
212 * This corresponds to the output name of the mesh. If left NULL, the mesh is not written to a file.
213 */
214
215 } else if (index == Mesh_Quiet_Flag) {
216 *ainame = AIM_NAME(Mesh_Quiet_Flag)EG_strdup("Mesh_Quiet_Flag");
217 defval->type = Boolean;
218 defval->vals.integer = false0;
219
220 /*! \page aimInputsAFLR4
221 * - <B> Mesh_Quiet_Flag = False</B> <br>
222 * Complete suppression of mesh generator (not including errors)
223 */
224
225 } else if (index == Mesh_Length_Factor) {
226 *ainame = EG_strdup("Mesh_Length_Factor");
227 defval->type = Double;
228 defval->dim = Scalar;
229 defval->vals.real = 1;
230 defval->nullVal = NotNull;
231
232 /*! \page aimInputsEgadsTess
233 * - <B> Mesh_Length_Factor = 1</B> <br>
234 * Scaling factor to compute a meshing Reference_Length via:<br>
235 * <br>
236 * Reference_Length = capsMeshLength*Mesh_Length_Factor<br>
237 * <br>
238 * Reference_Length scales Tess_Params[0] and Tess_Params[1] in both aimInputs and Mesh_Sizing
239 */
240
241 } else if (index == Tess_Params) {
242 *ainame = EG_strdup("Tess_Params");
243 defval->type = Double;
244 defval->dim = Vector;
245 defval->nrow = 3;
246 defval->ncol = 1;
247 defval->units = NULL((void*)0);
248 defval->lfixed = Fixed;
249 defval->vals.reals = (double *) EG_alloc(defval->nrow*sizeof(double));
250 if (defval->vals.reals != NULL((void*)0)) {
251 defval->vals.reals[0] = 0.10;
252 defval->vals.reals[1] = 0.01;
253 defval->vals.reals[2] = 15.0;
254 } else return EGADS_MALLOC-4;
255
256 /*! \page aimInputsEgadsTess
257 * - <B> Tess_Params = [0.1, 0.01, 15.0]</B> <br>
258 * Body tessellation parameters. Tess_Params[0] and Tess_Params[1] get scaled by Reference_Length if
259 * it is set, otherwise by the bounding box of the largest body. (From the EGADS manual)
260 * A set of 3 parameters that drive the EDGE discretization
261 * and the FACE triangulation. The first is the maximum length of an EDGE segment or triangle side
262 * (in physical space). A zero is flag that allows for any length. The second is a curvature-based
263 * value that looks locally at the deviation between the centroid of the discrete object and the
264 * underlying geometry. Any deviation larger than the input value will cause the tessellation to
265 * be enhanced in those regions. The third is the maximum interior dihedral angle (in degrees)
266 * between triangle facets (or Edge segment tangents for a WIREBODY tessellation), note that a
267 * zero ignores this phase
268 */
269 } else if (index == Mesh_Format) {
270 *ainame = EG_strdup("Mesh_Format");
271 defval->type = String;
272 defval->vals.string = EG_strdup("AFLR3"); // TECPLOT, VTK, AFLR3, STL, AF, FAST, NASTRAN
273 defval->lfixed = Change;
274
275 /*! \page aimInputsEgadsTess
276 * - <B> Mesh_Format = "AFLR3"</B> <br>
277 * Mesh output format. Available format names include: "AFLR3", "VTK", "TECPLOT", "STL" (quadrilaterals will be
278 * split into triangles), "Airfoil", "FAST", "Nastran".
279 *
280 * - "Airfoil" corresponds to the following file format in which the nodal coordinates of the body's edges
281 * are written. Bodies should be face bodies, planar, and have no holes. A *.af suffix is used for the file:
282 * <br>"Character Name"
283 * <br>x[0] y[0] x y coordinates
284 * <br>x[1] y[1]
285 * <br>... ...
286 */
287 } else if (index == Mesh_ASCII_Flag) {
288 *ainame = EG_strdup("Mesh_ASCII_Flag");
289 defval->type = Boolean;
290 defval->vals.integer = true1;
291
292 /*! \page aimInputsEgadsTess
293 * - <B> Mesh_ASCII_Flag = True</B> <br>
294 * Output mesh in ASCII format, otherwise write a binary file if applicable.
295 */
296
297 } else if (index == Edge_Point_Min) {
298 *ainame = EG_strdup("Edge_Point_Min");
299 defval->type = Integer;
300 defval->vals.integer = 0;
301 defval->lfixed = Fixed;
302 defval->nrow = 1;
303 defval->ncol = 1;
304 defval->nullVal = IsNull;
305
306 /*! \page aimInputsEgadsTess
307 * - <B> Edge_Point_Min = NULL</B> <br>
308 * Minimum number of points on an edge including end points to use when creating a surface mesh (min 2).
309 */
310
311 } else if (index == Edge_Point_Max) {
312 *ainame = EG_strdup("Edge_Point_Max");
313 defval->type = Integer;
314 defval->vals.integer = 0;
315 defval->lfixed = Fixed;
316 defval->nrow = 1;
317 defval->ncol = 1;
318 defval->nullVal = IsNull;
319
320 /*! \page aimInputsEgadsTess
321 * - <B> Edge_Point_Max = NULL</B> <br>
322 * Maximum number of points on an edge including end points to use when creating a surface mesh (min 2).
323 */
324
325 } else if (index == Mesh_Sizing) {
326 *ainame = EG_strdup("Mesh_Sizing");
327 defval->type = Tuple;
328 defval->nullVal = IsNull;
329 //defval->units = NULL;
330 defval->dim = Vector;
331 defval->lfixed = Change;
332 defval->vals.tuple = NULL((void*)0);
333
334 /*! \page aimInputsEgadsTess
335 * - <B>Mesh_Sizing = NULL </B> <br>
336 * See \ref meshSizingProp for additional details.
337 */
338
339 } else if (index == Mesh_Elements) {
340 *ainame = EG_strdup("Mesh_Elements");
341 defval->type = String;
342 defval->nullVal = NotNull;
343 defval->vals.string = EG_strdup("Tri");
344 defval->lfixed = Change;
345
346 /*! \page aimInputsEgadsTess
347 * - <B>Mesh_Elements = "Tri" </B> <br>
348 * Element topology in the resulting mesh:
349 * - "Tri" - All triangle elements
350 * - "Quad" - All quadrilateral elements
351 * - "Mixed" - Quad elements for four-sided faces with TFI, triangle elements otherwise
352 */
353
354 } else if (index == Multiple_Mesh) {
355 *ainame = EG_strdup("Multiple_Mesh");
356 defval->type = Boolean;
357 defval->vals.integer = (int) true1;
358
359 /*! \page aimInputsEgadsTess
360 * - <B> Multiple_Mesh = True</B> <br>
361 * If set to True (default) a surface mesh will be generated and output (given "Proj_Name" is set) for each body.
362 * When set to False only a single surface
363 * mesh will be created. Note, this only affects the mesh when writing to a
364 * file.
365 */
366
367 } else if (index == TFI_Templates) {
368 *ainame = EG_strdup("TFI_Templates");
369 defval->type = Boolean;
370 defval->vals.integer = (int) true1;
371
372 /*! \page aimInputsEgadsTess
373 * - <B> TFI_Templates = True</B> <br>
374 * Use Transfinite Interpolation and Templates to generate
375 * structured triangulations on FACEs with 3 or 4 "sides" with similar opposing vertex counts.
376 */
377 }
378
379 return CAPS_SUCCESS0;
380}
381
382
383// ********************** AIM Function Break *****************************
384int aimUpdateState(void *instStore, void *aimInfo,
385 capsValue *aimInputs)
386{
387 int status; // Function return status
388 int i;
389
390 // Body parameters
391 const char *intents;
392 int numBody = 0; // Number of bodies
393 ego *bodies = NULL((void*)0); // EGADS body objects
394
395 // Global settings
396 int minEdgePoint = -1, maxEdgePoint = -1;
397 double meshLenFac = 0, capsMeshLength = 0;
398 int bodyIndex;
399
400 // Mesh attribute parameters
401 int numMeshProp = 0;
402 meshSizingStruct *meshProp = NULL((void*)0);
403 const char *MeshElements = NULL((void*)0);
404
405 aimStorage *egadsInstance;
406
407 // Get AIM bodies
408 status = aim_getBodies(aimInfo, &intents, &numBody, &bodies);
409 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 409, __func__, 0); goto cleanup; }
;
410
411 if ((numBody <= 0) || (bodies == NULL((void*)0))) {
412 AIM_ERROR(aimInfo, "No Bodies!"){ aim_message(aimInfo, CERROR, 0 , "egadsTessAIM.c", 412, __func__
, "No Bodies!"); }
;
413 return CAPS_SOURCEERR-330;
414 }
415 AIM_NOTNULL(aimInputs, aimInfo, status){ if (aimInputs == ((void*)0)) { status = -307; aim_status(aimInfo
, status, "egadsTessAIM.c", 415, __func__, 1, "%s == NULL!", "aimInputs"
); goto cleanup; } }
;
416
417 egadsInstance = (aimStorage *) instStore;
418
419 // Cleanup previous aimStorage for the instance in case this is the second time through preAnalysis for the same instance
420 status = destroy_aimStorage(egadsInstance);
421 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 421, __func__, 0); goto cleanup; }
;
422
423 // Get capsGroup name and index mapping to make sure all faces have a capsGroup value
424 status = create_CAPSGroupAttrToIndexMap(numBody,
425 bodies,
426 3,
427 &egadsInstance->groupMap);
428 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 428, __func__, 0); goto cleanup; }
;
429
430 status = create_CAPSMeshAttrToIndexMap(numBody,
431 bodies,
432 3,
433 &egadsInstance->meshMap);
434 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 434, __func__, 0); goto cleanup; }
;
435
436
437 // Get Tessellation parameters -Tess_Params
438 egadsInstance->meshInput.paramTess[0] = aimInputs[Tess_Params-1].vals.reals[0]; // Gets multiplied by bounding box size
439 egadsInstance->meshInput.paramTess[1] = aimInputs[Tess_Params-1].vals.reals[1]; // Gets multiplied by bounding box size
440 egadsInstance->meshInput.paramTess[2] = aimInputs[Tess_Params-1].vals.reals[2];
441
442 // Max and min number of points
443 if (aimInputs[Edge_Point_Min-1].nullVal != IsNull) {
444 minEdgePoint = aimInputs[Edge_Point_Min-1].vals.integer;
445 if (minEdgePoint < 2) {
446 AIM_ERROR(aimInfo, "Edge_Point_Min = %d must be greater or equal to 2\n", minEdgePoint){ aim_message(aimInfo, CERROR, 0 , "egadsTessAIM.c", 446, __func__
, "Edge_Point_Min = %d must be greater or equal to 2\n", minEdgePoint
); }
;
447 status = CAPS_BADVALUE-311;
448 goto cleanup;
449 }
450 }
451
452 if (aimInputs[Edge_Point_Max-1].nullVal != IsNull) {
453 maxEdgePoint = aimInputs[Edge_Point_Max-1].vals.integer;
454 if (maxEdgePoint < 2) {
455 AIM_ERROR(aimInfo, "Edge_Point_Max = %d must be greater or equal to 2\n", maxEdgePoint){ aim_message(aimInfo, CERROR, 0 , "egadsTessAIM.c", 455, __func__
, "Edge_Point_Max = %d must be greater or equal to 2\n", maxEdgePoint
); }
;
456 status = CAPS_BADVALUE-311;
457 goto cleanup;
458 }
459 }
460
461 if (maxEdgePoint >= 2 && minEdgePoint >= 2 && minEdgePoint > maxEdgePoint) {
462 AIM_ERROR(aimInfo, "Edge_Point_Max must be greater or equal Edge_Point_Min\n"){ aim_message(aimInfo, CERROR, 0 , "egadsTessAIM.c", 462, __func__
, "Edge_Point_Max must be greater or equal Edge_Point_Min\n")
; }
;
463 AIM_ERROR(aimInfo, "Edge_Point_Max = %d, Edge_Point_Min = %d\n", maxEdgePoint, minEdgePoint){ aim_message(aimInfo, CERROR, 0 , "egadsTessAIM.c", 463, __func__
, "Edge_Point_Max = %d, Edge_Point_Min = %d\n", maxEdgePoint,
minEdgePoint); }
;
464 status = CAPS_BADVALUE-311;
465 goto cleanup;
466 }
467
468 // Get mesh sizing parameters
469 if (aimInputs[Mesh_Sizing-1].nullVal != IsNull) {
470
471 status = deprecate_SizingAttr(aimInfo,
472 aimInputs[Mesh_Sizing-1].length,
473 aimInputs[Mesh_Sizing-1].vals.tuple,
474 &egadsInstance->meshMap,
475 &egadsInstance->groupMap);
476 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 476, __func__, 0); goto cleanup; }
;
477
478 status = mesh_getSizingProp(aimInfo,
479 aimInputs[Mesh_Sizing-1].length,
480 aimInputs[Mesh_Sizing-1].vals.tuple,
481 &egadsInstance->meshMap,
482 &numMeshProp,
483 &meshProp);
484 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 484, __func__, 0); goto cleanup; }
;
485 }
486
487 // Get mesh element types
488 MeshElements = aimInputs[Mesh_Elements-1].vals.string;
489
490 if ( strncasecmp(MeshElements,"Tri",3) == 0 ) { egadsInstance->quadMesh = 0; }
491 else if ( strncasecmp(MeshElements,"Quad",4) == 0 ) { egadsInstance->quadMesh = 1; }
492 else if ( strncasecmp(MeshElements,"Mixed",3) == 0 ) { egadsInstance->quadMesh = 2; }
493 else {
494 AIM_ERROR( aimInfo, "Unknown Mesh_Elements = \"%s\"\n", MeshElements){ aim_message(aimInfo, CERROR, 0 , "egadsTessAIM.c", 494, __func__
, "Unknown Mesh_Elements = \"%s\"\n", MeshElements); }
;
495 AIM_ADDLINE(aimInfo, " Should be one of \"Tri\", \"Quad\", or \"Mixed\"\n"){ aim_addLine(aimInfo, " Should be one of \"Tri\", \"Quad\", or \"Mixed\"\n"
); }
;
496 status = CAPS_BADVALUE-311;
497 goto cleanup;
498 }
499
500 if (aimInputs[TFI_Templates-1].vals.integer == (int) false0) {
501 for (bodyIndex = 0; bodyIndex < numBody; bodyIndex++){
502 // Disable TFI and templates
503 status = EG_attributeAdd(bodies[bodyIndex], ".qParams", ATTRSTRING3,
504 0, NULL((void*)0), NULL((void*)0), "off");
505 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 505, __func__, 0); goto cleanup; }
;
506 }
507 }
508
509 // Reference length for meshing
510 meshLenFac = aimInputs[Mesh_Length_Factor-1].vals.real;
511
512 status = check_CAPSMeshLength(numBody, bodies, &capsMeshLength);
513
514 // TODO: Should capsMeshLength be optional?
515 if (status == CAPS_NOTFOUND-303) capsMeshLength = -1;
516 else AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 516, __func__, 0); goto cleanup; }
;
517
518 /*
519 if (capsMeshLength <= 0 || status != CAPS_SUCCESS) {
520 printf("**********************************************************\n");
521 if (status != CAPS_SUCCESS)
522 printf("capsMeshLength is not set on any body.\n");
523 else
524 printf("capsMeshLength: %f\n", capsMeshLength);
525 printf("\n");
526 printf("The capsMeshLength attribute must\n"
527 "present on at least one body.\n"
528 "\n"
529 "capsMeshLength should be a a positive value representative\n"
530 "of a characteristic length of the geometry,\n"
531 "e.g. the MAC of a wing or diameter of a fuselage.\n");
532 printf("**********************************************************\n");
533 status = CAPS_BADVALUE;
534 goto cleanup;
535 }
536 */
537
538 if (meshLenFac <= 0) {
539 AIM_ERROR(aimInfo, "Mesh_Length_Factor is: %f\n", meshLenFac){ aim_message(aimInfo, CERROR, 0 , "egadsTessAIM.c", 539, __func__
, "Mesh_Length_Factor is: %f\n", meshLenFac); }
;
540 AIM_ADDLINE(aimInfo, "Mesh_Length_Factor must be a positive number."){ aim_addLine(aimInfo, "Mesh_Length_Factor must be a positive number."
); }
;
541 status = CAPS_BADVALUE-311;
542 goto cleanup;
543 }
544
545 egadsInstance->refLen = meshLenFac*capsMeshLength;
546
547 // Modify the EGADS body tessellation based on given inputs
548/*@-nullpass@*/
549 status = mesh_modifyBodyTess(numMeshProp,
550 meshProp,
551 minEdgePoint,
552 maxEdgePoint,
553 egadsInstance->quadMesh,
554 &egadsInstance->refLen,
555 egadsInstance->meshInput.paramTess,
556 egadsInstance->meshMap,
557 numBody,
558 bodies);
559/*@+nullpass@*/
560 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 560, __func__, 0); goto cleanup; }
;
561
562 status = CAPS_SUCCESS0;
563cleanup:
564
565 // Clean up meshProps
566 if (meshProp != NULL((void*)0)) {
567 for (i = 0; i < numMeshProp; i++) {
568 (void) destroy_meshSizingStruct(&meshProp[i]);
569 }
570 AIM_FREE(meshProp){ EG_free(meshProp); meshProp = ((void*)0); };
571 }
572
573 return status;
574}
575
576
577// ********************** AIM Function Break *****************************
578int aimPreAnalysis(const void *instStore, void *aimInfo, capsValue *aimInputs)
579{
580 int status; // Status return
581
582 int bodyIndex; // Indexing
583
584 const aimStorage *egadsInstance;
585
586 // Body parameters
587 const char *intents;
588 int numBody = 0; // Number of bodies
589 ego *bodies = NULL((void*)0); // EGADS body objects
590 ego etess = NULL((void*)0);
591
592 // File output
593 char bodyNumber[42];
594 char aimFile[PATH_MAX4096];
595
596 // Get AIM bodies
597 status = aim_getBodies(aimInfo, &intents, &numBody, &bodies);
598 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 598, __func__, 0); goto cleanup; }
;
599
600#ifdef DEBUG
601 printf(" egadsTessAIM/aimPreAnalysis numBody = %d!\n", numBody);
602#endif
603
604 if ((numBody <= 0) || (bodies == NULL((void*)0))) {
605 AIM_ERROR(aimInfo, "No Bodies!"){ aim_message(aimInfo, CERROR, 0 , "egadsTessAIM.c", 605, __func__
, "No Bodies!"); }
;
606 return CAPS_SOURCEERR-330;
607 }
608 AIM_NOTNULL(aimInputs, aimInfo, status){ if (aimInputs == ((void*)0)) { status = -307; aim_status(aimInfo
, status, "egadsTessAIM.c", 608, __func__, 1, "%s == NULL!", "aimInputs"
); goto cleanup; } }
;
609
610 egadsInstance = (const aimStorage *) instStore;
611
612 // Setup meshing input structure
613
614
615 // Run egadsTess for each body
616 for (bodyIndex = 0 ; bodyIndex < numBody; bodyIndex++) {
617
618 if (aimInputs[Mesh_Quiet_Flag-1].vals.integer == (int)false0)
619 printf("Getting surface mesh for body %d (of %d)\n", bodyIndex+1, numBody);
620
621 status = mesh_surfaceMeshEGADSBody(aimInfo,
622 bodies[bodyIndex],
623 egadsInstance->refLen,
624 egadsInstance->meshInput.paramTess,
625 egadsInstance->quadMesh,
626 &etess);
627 AIM_STATUS(aimInfo, status, "Problem during surface meshing of body %d", bodyIndex+1)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 627, __func__, 2, "Problem during surface meshing of body %d"
, bodyIndex+1); goto cleanup; }
;
628 AIM_NOTNULL(etess, aimInfo, status){ if (etess == ((void*)0)) { status = -307; aim_status(aimInfo
, status, "egadsTessAIM.c", 628, __func__, 1, "%s == NULL!", "etess"
); goto cleanup; } }
;
629
630 // set the file name to write the egads file
631 snprintf(bodyNumber, 42, EGADSTESSFILE"egadsTess_%d.eto", bodyIndex);
632 status = aim_rmFile(aimInfo, bodyNumber);
633 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 633, __func__, 0); goto cleanup; }
;
634
635 status = aim_file(aimInfo, bodyNumber, aimFile);
636 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 636, __func__, 0); goto cleanup; }
;
637
638 status = EG_saveTess(etess, aimFile);
639 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 639, __func__, 0); goto cleanup; }
;
640
641 EG_deleteObject(etess);
642 }
643
644 status = CAPS_SUCCESS0;
645
646cleanup:
647
648 return status;
649}
650
651
652// ********************** AIM Function Break *****************************
653int aimExecute(/*@unused@*/ const void *aimStore, /*@unused@*/ void *aimStruc, int *state)
654{
655 *state = 0;
656 return CAPS_SUCCESS0;
657}
658
659
660// ********************** AIM Function Break *****************************
661int aimPostAnalysis(/*@unused@*/ void *aimStore, /*@unused@*/ void *aimInfo,
662 /*@unused@*/ int restart, /*@unused@*/ capsValue *aimInputs)
663{
664
665 int status = CAPS_SUCCESS0;
666 int bodyIndex;
667
668 int numNodeTotal=0, numElemTotal=0;
669
670 int numBody = 0; // Number of bodies
671 ego *bodies = NULL((void*)0); // EGADS body objects
672
673 int state, nglobal, i, iglobal=1;
674 ego body;
675
676 const char *intents;
677 char bodyNumber[42];
678 char aimFile[PATH_MAX4096];
679 char *filename = NULL((void*)0);
680
681 aimStorage *egadsInstance;
682 egadsInstance = (aimStorage *) aimStore;
683
684 // Combined mesh
685 meshStruct combineMesh;
686
687 int numSurface = 0;
688 meshStruct *surfaceMesh=NULL((void*)0);
689
690 status = initiate_meshStruct(&combineMesh);
691 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 691, __func__, 0); goto cleanup; }
;
692
693 AIM_NOTNULL(aimInputs, aimInfo, status){ if (aimInputs == ((void*)0)) { status = -307; aim_status(aimInfo
, status, "egadsTessAIM.c", 693, __func__, 1, "%s == NULL!", "aimInputs"
); goto cleanup; } }
;
694
695 // Get AIM bodies
696 status = aim_getBodies(aimInfo, &intents, &numBody, &bodies);
697 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 697, __func__, 0); goto cleanup; }
;
698 AIM_NOTNULL(bodies, aimInfo, status){ if (bodies == ((void*)0)) { status = -307; aim_status(aimInfo
, status, "egadsTessAIM.c", 698, __func__, 1, "%s == NULL!", "bodies"
); goto cleanup; } }
;
699
700 // Allocate surfaceMesh from number of bodies
701 AIM_ALLOC(surfaceMesh, numBody, meshStruct, aimInfo, status){ if (surfaceMesh != ((void*)0)) { status = -4; aim_status(aimInfo
, status, "egadsTessAIM.c", 701, __func__, 1, "AIM_ALLOC: %s != NULL"
, "surfaceMesh"); goto cleanup; } size_t memorysize = numBody
; surfaceMesh = (meshStruct *) EG_alloc(memorysize*sizeof(meshStruct
)); if (surfaceMesh == ((void*)0)) { status = -4; aim_status(
aimInfo, status, "egadsTessAIM.c", 701, __func__, 3, "AIM_ALLOC: %s size %zu type %s"
, "surfaceMesh", memorysize, "meshStruct"); goto cleanup; } }
;
702 numSurface = numBody;
703
704 // Initiate surface meshes
705 for (bodyIndex = 0; bodyIndex < numBody; bodyIndex++){
706 status = initiate_meshStruct(&surfaceMesh[bodyIndex]);
707 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 707, __func__, 0); goto cleanup; }
;
708 }
709
710 egadsInstance->meshRef.type = aimSurfaceMesh;
711
712 AIM_ALLOC(egadsInstance->meshRef.maps, numBody, aimMeshTessMap, aimInfo, status){ if (egadsInstance->meshRef.maps != ((void*)0)) { status =
-4; aim_status(aimInfo, status, "egadsTessAIM.c", 712, __func__
, 1, "AIM_ALLOC: %s != NULL", "egadsInstance->meshRef.maps"
); goto cleanup; } size_t memorysize = numBody; egadsInstance
->meshRef.maps = (aimMeshTessMap *) EG_alloc(memorysize*sizeof
(aimMeshTessMap)); if (egadsInstance->meshRef.maps == ((void
*)0)) { status = -4; aim_status(aimInfo, status, "egadsTessAIM.c"
, 712, __func__, 3, "AIM_ALLOC: %s size %zu type %s", "egadsInstance->meshRef.maps"
, memorysize, "aimMeshTessMap"); goto cleanup; } }
;
713 egadsInstance->meshRef.nmap = numBody;
714 for (bodyIndex = 0; bodyIndex < numBody; bodyIndex++) {
715 egadsInstance->meshRef.maps[bodyIndex].tess = NULL((void*)0);
716 egadsInstance->meshRef.maps[bodyIndex].map = NULL((void*)0);
717 }
718
719 if (egadsInstance->groupMap.mapName == NULL((void*)0)) {
720 // Get capsGroup name and index mapping to make sure all faces have a capsGroup value
721 status = create_CAPSGroupAttrToIndexMap(numBody,
722 bodies,
723 3,
724 &egadsInstance->groupMap);
725 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 725, __func__, 0); goto cleanup; }
;
726 }
727
728 AIM_ALLOC(egadsInstance->meshRef.bnds, egadsInstance->groupMap.numAttribute, aimMeshBnd, aimInfo, status){ if (egadsInstance->meshRef.bnds != ((void*)0)) { status =
-4; aim_status(aimInfo, status, "egadsTessAIM.c", 728, __func__
, 1, "AIM_ALLOC: %s != NULL", "egadsInstance->meshRef.bnds"
); goto cleanup; } size_t memorysize = egadsInstance->groupMap
.numAttribute; egadsInstance->meshRef.bnds = (aimMeshBnd *
) EG_alloc(memorysize*sizeof(aimMeshBnd)); if (egadsInstance->
meshRef.bnds == ((void*)0)) { status = -4; aim_status(aimInfo
, status, "egadsTessAIM.c", 728, __func__, 3, "AIM_ALLOC: %s size %zu type %s"
, "egadsInstance->meshRef.bnds", memorysize, "aimMeshBnd")
; goto cleanup; } }
;
729 egadsInstance->meshRef.nbnd = egadsInstance->groupMap.numAttribute;
730 for (i = 0; i < egadsInstance->meshRef.nbnd; i++) {
731 status = aim_initMeshBnd(egadsInstance->meshRef.bnds + i);
732 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 732, __func__, 0); goto cleanup; }
;
733 }
734
735 for (i = 0; i < egadsInstance->meshRef.nbnd; i++) {
736 AIM_STRDUP(egadsInstance->meshRef.bnds[i].groupName, egadsInstance->groupMap.attributeName[i], aimInfo, status){ if (egadsInstance->meshRef.bnds[i].groupName != ((void*)
0)) { status = -4; aim_status(aimInfo, status, "egadsTessAIM.c"
, 736, __func__, 1, "AIM_STRDUP: %s != NULL!", "egadsInstance->meshRef.bnds[i].groupName"
); goto cleanup; } egadsInstance->meshRef.bnds[i].groupName
= EG_strdup(egadsInstance->groupMap.attributeName[i]); if
(egadsInstance->meshRef.bnds[i].groupName == ((void*)0)) {
status = -4; aim_status(aimInfo, status, "egadsTessAIM.c", 736
, __func__, 2, "AIM_STRDUP: %s %s", "egadsInstance->meshRef.bnds[i].groupName"
, egadsInstance->groupMap.attributeName[i]); goto cleanup;
} }
;
737 egadsInstance->meshRef.bnds[i].ID = egadsInstance->groupMap.attributeIndex[i];
738 }
739
740 // Read egadsTess for each body
741 for (bodyIndex = 0 ; bodyIndex < numBody; bodyIndex++) {
742
743 // set the file name to read the egads file
744 snprintf(bodyNumber, 42, EGADSTESSFILE"egadsTess_%d.eto", bodyIndex);
745 status = aim_file(aimInfo, bodyNumber, aimFile);
746 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 746, __func__, 0); goto cleanup; }
;
747
748 status = EG_loadTess(bodies[bodyIndex], aimFile, &egadsInstance->meshRef.maps[bodyIndex].tess);
749 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 749, __func__, 0); goto cleanup; }
;
750
751 status = copy_mapAttrToIndexStruct( &egadsInstance->groupMap,
752 &surfaceMesh[bodyIndex].groupMap );
753 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 753, __func__, 0); goto cleanup; }
;
754
755 surfaceMesh[bodyIndex].egadsTess = egadsInstance->meshRef.maps[bodyIndex].tess;
756 status = mesh_surfaceMeshEGADSTess(aimInfo, &surfaceMesh[bodyIndex], (int)false0);
757 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 757, __func__, 0); goto cleanup; }
;
758
759 status = aim_newTess(aimInfo, egadsInstance->meshRef.maps[bodyIndex].tess);
760 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 760, __func__, 0); goto cleanup; }
;
761
762
763 status = EG_statusTessBody(egadsInstance->meshRef.maps[bodyIndex].tess, &body, &state, &nglobal);
764 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 764, __func__, 0); goto cleanup; }
;
765
766 AIM_ALLOC(egadsInstance->meshRef.maps[bodyIndex].map, nglobal, int, aimInfo, status){ if (egadsInstance->meshRef.maps[bodyIndex].map != ((void
*)0)) { status = -4; aim_status(aimInfo, status, "egadsTessAIM.c"
, 766, __func__, 1, "AIM_ALLOC: %s != NULL", "egadsInstance->meshRef.maps[bodyIndex].map"
); goto cleanup; } size_t memorysize = nglobal; egadsInstance
->meshRef.maps[bodyIndex].map = (int *) EG_alloc(memorysize
*sizeof(int)); if (egadsInstance->meshRef.maps[bodyIndex].
map == ((void*)0)) { status = -4; aim_status(aimInfo, status,
"egadsTessAIM.c", 766, __func__, 3, "AIM_ALLOC: %s size %zu type %s"
, "egadsInstance->meshRef.maps[bodyIndex].map", memorysize
, "int"); goto cleanup; } }
;
767 for (i = 0; i < nglobal; i++) egadsInstance->meshRef.maps[bodyIndex].map[i] = iglobal++;
768
769 if (restart == 0 &&
770 aimInputs[Mesh_Quiet_Flag-1].vals.integer == (int)false0) {
771 printf("Body %d (of %d)\n", bodyIndex+1, numBody);
772
773 printf("Number of nodes = %d\n", surfaceMesh[bodyIndex].numNode);
774 printf("Number of elements = %d\n", surfaceMesh[bodyIndex].numElement);
775
776 if (surfaceMesh[bodyIndex].meshQuickRef.useStartIndex == (int) true1 ||
777 surfaceMesh[bodyIndex].meshQuickRef.useListIndex == (int) true1) {
778
779 printf("Number of node elements = %d\n",
780 surfaceMesh[bodyIndex].meshQuickRef.numNode);
781 printf("Number of line elements = %d\n",
782 surfaceMesh[bodyIndex].meshQuickRef.numLine);
783 printf("Number of triangle elements = %d\n",
784 surfaceMesh[bodyIndex].meshQuickRef.numTriangle);
785 printf("Number of quadrilateral elements = %d\n",
786 surfaceMesh[bodyIndex].meshQuickRef.numQuadrilateral);
787 }
788 }
789
790 egadsInstance->numNodeTotal += surfaceMesh[bodyIndex].numNode;
791 egadsInstance->numElemTotal += surfaceMesh[bodyIndex].numElement;
792 }
793
794 if (restart == 0 &&
795 aimInputs[Mesh_Quiet_Flag-1].vals.integer == (int)false0) {
796 printf("----------------------------\n");
797 printf("Total number of nodes = %d\n", numNodeTotal);
798 printf("Total number of elements = %d\n", numElemTotal);
799 }
800
801 if (restart == 0) {
802 // Project Name
803 if (aimInputs[Proj_Name-1].nullVal != IsNull) {
804 AIM_FREE(egadsInstance->meshInput.outputFileName){ EG_free(egadsInstance->meshInput.outputFileName); egadsInstance
->meshInput.outputFileName = ((void*)0); }
;
805 AIM_STRDUP(egadsInstance->meshInput.outputFileName, aimInputs[Proj_Name-1].vals.string, aimInfo, status){ if (egadsInstance->meshInput.outputFileName != ((void*)0
)) { status = -4; aim_status(aimInfo, status, "egadsTessAIM.c"
, 805, __func__, 1, "AIM_STRDUP: %s != NULL!", "egadsInstance->meshInput.outputFileName"
); goto cleanup; } egadsInstance->meshInput.outputFileName
= EG_strdup(aimInputs[Proj_Name-1].vals.string); if (egadsInstance
->meshInput.outputFileName == ((void*)0)) { status = -4; aim_status
(aimInfo, status, "egadsTessAIM.c", 805, __func__, 2, "AIM_STRDUP: %s %s"
, "egadsInstance->meshInput.outputFileName", aimInputs[Proj_Name
-1].vals.string); goto cleanup; } }
;
806 }
807
808 // Mesh Format
809 AIM_FREE(egadsInstance->meshInput.outputFormat){ EG_free(egadsInstance->meshInput.outputFormat); egadsInstance
->meshInput.outputFormat = ((void*)0); }
;
810 AIM_STRDUP(egadsInstance->meshInput.outputFormat, aimInputs[Mesh_Format-1].vals.string, aimInfo, status){ if (egadsInstance->meshInput.outputFormat != ((void*)0))
{ status = -4; aim_status(aimInfo, status, "egadsTessAIM.c",
810, __func__, 1, "AIM_STRDUP: %s != NULL!", "egadsInstance->meshInput.outputFormat"
); goto cleanup; } egadsInstance->meshInput.outputFormat =
EG_strdup(aimInputs[Mesh_Format-1].vals.string); if (egadsInstance
->meshInput.outputFormat == ((void*)0)) { status = -4; aim_status
(aimInfo, status, "egadsTessAIM.c", 810, __func__, 2, "AIM_STRDUP: %s %s"
, "egadsInstance->meshInput.outputFormat", aimInputs[Mesh_Format
-1].vals.string); goto cleanup; } }
;
811
812 // ASCII flag
813 egadsInstance->meshInput.outputASCIIFlag = aimInputs[Mesh_ASCII_Flag-1].vals.integer;
814
815 if (egadsInstance->meshInput.outputFileName != NULL((void*)0)) {
816
817 // We need to combine the mesh
818 if (aimInputs[Multiple_Mesh-1].vals.integer == (int) false0) {
819
820 status = mesh_combineMeshStruct(numSurface,
821 surfaceMesh,
822 &combineMesh);
823
824 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 824, __func__, 0); goto cleanup; }
;
825
826 AIM_ALLOC(filename, (strlen(egadsInstance->meshInput.outputFileName) + 2), char, aimInfo, status){ if (filename != ((void*)0)) { status = -4; aim_status(aimInfo
, status, "egadsTessAIM.c", 826, __func__, 1, "AIM_ALLOC: %s != NULL"
, "filename"); goto cleanup; } size_t memorysize = (strlen(egadsInstance
->meshInput.outputFileName) + 2); filename = (char *) EG_alloc
(memorysize*sizeof(char)); if (filename == ((void*)0)) { status
= -4; aim_status(aimInfo, status, "egadsTessAIM.c", 826, __func__
, 3, "AIM_ALLOC: %s size %zu type %s", "filename", memorysize
, "char"); goto cleanup; } }
;
827
828 strcpy(filename, egadsInstance->meshInput.outputFileName);
829
830 if (strcasecmp(egadsInstance->meshInput.outputFormat, "AFLR3") == 0) {
831
832 status = mesh_writeAFLR3(aimInfo, filename,
833 egadsInstance->meshInput.outputASCIIFlag,
834 &combineMesh,
835 1.0);
836
837 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "VTK") == 0) {
838
839 status = mesh_writeVTK(aimInfo, filename,
840 egadsInstance->meshInput.outputASCIIFlag,
841 &combineMesh,
842 1.0);
843
844 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "Tecplot") == 0) {
845
846 status = mesh_writeTecplot(aimInfo, filename,
847 egadsInstance->meshInput.outputASCIIFlag,
848 &combineMesh,
849 1.0);
850
851 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "STL") == 0) {
852
853 status = mesh_writeSTL(aimInfo, filename,
854 egadsInstance->meshInput.outputASCIIFlag,
855 &combineMesh,
856 1.0);
857
858 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "Airfoil") == 0) {
859
860 status = mesh_writeAirfoil(aimInfo, filename,
861 egadsInstance->meshInput.outputASCIIFlag,
862 &combineMesh,
863 1.0);
864
865 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "FAST") == 0) {
866
867 status = mesh_writeFAST(aimInfo, filename,
868 egadsInstance->meshInput.outputASCIIFlag,
869 &combineMesh,
870 1.0);
871
872 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "Nastran") == 0) {
873
874 status = mesh_writeNASTRAN(aimInfo, filename,
875 egadsInstance->meshInput.outputASCIIFlag,
876 &combineMesh,
877 FreeField,
878 1.0);
879 } else {
880 printf("Unrecognized mesh format, \"%s\", the mesh will not be written out\n",
881 egadsInstance->meshInput.outputFormat);
882 }
883
884 AIM_FREE(filename){ EG_free(filename); filename = ((void*)0); };
885 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 885, __func__, 0); goto cleanup; }
;
886
887 } else {
888
889 for (bodyIndex = 0; bodyIndex < numSurface; bodyIndex++) {
890
891 if (numSurface > 1) {
892 snprintf(bodyNumber, 42, "%d", bodyIndex);
893 AIM_ALLOC(filename, (strlen(egadsInstance->meshInput.outputFileName) +{ if (filename != ((void*)0)) { status = -4; aim_status(aimInfo
, status, "egadsTessAIM.c", 894, __func__, 1, "AIM_ALLOC: %s != NULL"
, "filename"); goto cleanup; } size_t memorysize = (strlen(egadsInstance
->meshInput.outputFileName) + 2 + strlen("_Surf_") + strlen
(bodyNumber)); filename = (char *) EG_alloc(memorysize*sizeof
(char)); if (filename == ((void*)0)) { status = -4; aim_status
(aimInfo, status, "egadsTessAIM.c", 894, __func__, 3, "AIM_ALLOC: %s size %zu type %s"
, "filename", memorysize, "char"); goto cleanup; } }
894 2 + strlen("_Surf_") + strlen(bodyNumber)), char, aimInfo, status){ if (filename != ((void*)0)) { status = -4; aim_status(aimInfo
, status, "egadsTessAIM.c", 894, __func__, 1, "AIM_ALLOC: %s != NULL"
, "filename"); goto cleanup; } size_t memorysize = (strlen(egadsInstance
->meshInput.outputFileName) + 2 + strlen("_Surf_") + strlen
(bodyNumber)); filename = (char *) EG_alloc(memorysize*sizeof
(char)); if (filename == ((void*)0)) { status = -4; aim_status
(aimInfo, status, "egadsTessAIM.c", 894, __func__, 3, "AIM_ALLOC: %s size %zu type %s"
, "filename", memorysize, "char"); goto cleanup; } }
;
895 } else {
896 AIM_ALLOC(filename, (strlen(egadsInstance->meshInput.outputFileName) +{ if (filename != ((void*)0)) { status = -4; aim_status(aimInfo
, status, "egadsTessAIM.c", 897, __func__, 1, "AIM_ALLOC: %s != NULL"
, "filename"); goto cleanup; } size_t memorysize = (strlen(egadsInstance
->meshInput.outputFileName) + 2); filename = (char *) EG_alloc
(memorysize*sizeof(char)); if (filename == ((void*)0)) { status
= -4; aim_status(aimInfo, status, "egadsTessAIM.c", 897, __func__
, 3, "AIM_ALLOC: %s size %zu type %s", "filename", memorysize
, "char"); goto cleanup; } }
897 2), char, aimInfo, status){ if (filename != ((void*)0)) { status = -4; aim_status(aimInfo
, status, "egadsTessAIM.c", 897, __func__, 1, "AIM_ALLOC: %s != NULL"
, "filename"); goto cleanup; } size_t memorysize = (strlen(egadsInstance
->meshInput.outputFileName) + 2); filename = (char *) EG_alloc
(memorysize*sizeof(char)); if (filename == ((void*)0)) { status
= -4; aim_status(aimInfo, status, "egadsTessAIM.c", 897, __func__
, 3, "AIM_ALLOC: %s size %zu type %s", "filename", memorysize
, "char"); goto cleanup; } }
;
898
899 }
900
901 if (filename == NULL((void*)0)) goto cleanup;
902
903 strcpy(filename, egadsInstance->meshInput.outputFileName);
904
905 if (numSurface > 1) {
906 strcat(filename,"_Surf_");
907 strcat(filename, bodyNumber);
908 }
909
910 if (strcasecmp(egadsInstance->meshInput.outputFormat, "AFLR3") == 0) {
911
912 status = mesh_writeAFLR3(aimInfo, filename,
913 egadsInstance->meshInput.outputASCIIFlag,
914 &surfaceMesh[bodyIndex],
915 1.0);
916
917 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "VTK") == 0) {
918
919 status = mesh_writeVTK(aimInfo, filename,
920 egadsInstance->meshInput.outputASCIIFlag,
921 &surfaceMesh[bodyIndex],
922 1.0);
923
924 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "Tecplot") == 0) {
925
926 status = mesh_writeTecplot(aimInfo, filename,
927 egadsInstance->meshInput.outputASCIIFlag,
928 &surfaceMesh[bodyIndex],
929 1.0);
930
931 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "STL") == 0) {
932
933 status = mesh_writeSTL(aimInfo, filename,
934 egadsInstance->meshInput.outputASCIIFlag,
935 &surfaceMesh[bodyIndex],
936 1.0);
937
938 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "Airfoil") == 0) {
939
940 status = mesh_writeAirfoil(aimInfo, filename,
941 egadsInstance->meshInput.outputASCIIFlag,
942 &surfaceMesh[bodyIndex],
943 1.0);
944
945 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "FAST") == 0) {
946
947 status = mesh_writeFAST(aimInfo, filename,
948 egadsInstance->meshInput.outputASCIIFlag,
949 &surfaceMesh[bodyIndex],
950 1.0);
951
952 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "Nastran") == 0) {
953
954 status = mesh_writeNASTRAN(aimInfo, filename,
955 egadsInstance->meshInput.outputASCIIFlag,
956 &surfaceMesh[bodyIndex],
957 FreeField,
958 1.0);
959
960 } else if (strcasecmp(egadsInstance->meshInput.outputFormat, "ETO") == 0) {
961
962 AIM_REALL(filename, strlen(filename) + 5, char, aimInfo, status){ size_t memorysize = strlen(filename) + 5; filename = (char *
) EG_reall(filename, memorysize*sizeof(char)); if (filename ==
((void*)0)) { status = -4; aim_status(aimInfo, status, "egadsTessAIM.c"
, 962, __func__, 3, "AIM_REALL: %s size %zu type %s", "filename"
, memorysize, "char"); goto cleanup; } }
;
963 strcat(filename,".eto");
964
965 status = EG_saveTess(surfaceMesh[bodyIndex].egadsTess, filename);
966
967 } else {
968 printf("Unrecognized mesh format, \"%s\", the mesh will not be written out\n",
969 egadsInstance->meshInput.outputFormat);
970 }
971
972 AIM_FREE(filename){ EG_free(filename); filename = ((void*)0); };
973 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 973, __func__, 0); goto cleanup; }
;
974 }
975 }
976 }
977 }
978
979 status = CAPS_SUCCESS0;
980
981cleanup:
982
983 if (surfaceMesh != NULL((void*)0)) {
984 for (bodyIndex = 0; bodyIndex < numBody; bodyIndex++){
985 status = destroy_meshStruct(&surfaceMesh[bodyIndex]);
986 AIM_STATUS(aimInfo, status)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 986, __func__, 0); goto cleanup; }
;
987 }
988 AIM_FREE(surfaceMesh){ EG_free(surfaceMesh); surfaceMesh = ((void*)0); };
989 numSurface = numBody;
Value stored to 'numSurface' is never read
990 }
991
992 (void) destroy_meshStruct(&combineMesh);
993 AIM_FREE(filename){ EG_free(filename); filename = ((void*)0); };
994
995 return status;
996}
997
998
999// ********************** AIM Function Break *****************************
1000int aimOutputs(/*@unused@*/ void *aimStore, /*@unused@*/ void *aimStruc,
1001 /*@unused@*/ int index, char **aoname, capsValue *form)
1002{
1003 /*! \page aimOutputsEgadsTess AIM Outputs
1004 * The following list outlines the EGADS Tessellation AIM outputs available through the AIM interface.
1005 */
1006 int status = CAPS_SUCCESS0;
1007
1008#ifdef DEBUG
1009 printf(" egadsTessAIM/aimOutputs index = %d!\n", index);
1010#endif
1011
1012 if (index == Done) {
1013 *aoname = EG_strdup("Done");
1014 form->type = Boolean;
1015 form->vals.integer = (int) false0;
1016
1017 /*! \page aimOutputsEgadsTess
1018 * - <B> Done </B> <br>
1019 * True if a surface mesh was created on all surfaces, False if not.
1020 */
1021
1022 } else if (index == NumberOfElement) {
1023 *aoname = EG_strdup("NumberOfElement");
1024 form->type = Integer;
1025 form->vals.integer = 0;
1026
1027 /*! \page aimOutputsEgadsTess
1028 * - <B> NumberOfElement </B> <br>
1029 * Number of elements in the surface mesh
1030 */
1031
1032 } else if (index == NumberOfNode) {
1033 *aoname = EG_strdup("NumberOfNode");
1034 form->type = Integer;
1035 form->vals.integer = 0;
1036
1037 /*! \page aimOutputsEgadsTess
1038 * - <B> NumberOfNode </B> <br>
1039 * Number of vertices in the surface mesh
1040 */
1041
1042 } else if (index == Surface_Mesh) {
1043 *aoname = AIM_NAME(Surface_Mesh)EG_strdup("Surface_Mesh");
1044 form->type = PointerMesh;
1045 form->dim = Vector;
1046 form->lfixed = Change;
1047 form->sfixed = Fixed;
1048 form->vals.AIMptr = NULL((void*)0);
1049 form->nullVal = IsNull;
1050
1051 /*! \page aimOutputsEgadsTess
1052 * - <B> Surface_Mesh </B> <br>
1053 * The surface mesh for a link.
1054 */
1055
1056 } else {
1057 status = CAPS_BADINDEX-304;
1058 AIM_STATUS(aimStruc, status, "Unknown output index %d!", index)if (status != 0) { aim_status(aimStruc, status, "egadsTessAIM.c"
, 1058, __func__, 2, "Unknown output index %d!", index); goto
cleanup; }
;
1059 }
1060
1061 AIM_NOTNULL(*aoname, aimStruc, status){ if (*aoname == ((void*)0)) { status = -307; aim_status(aimStruc
, status, "egadsTessAIM.c", 1061, __func__, 1, "%s == NULL!",
"*aoname"); goto cleanup; } }
;
1062
1063cleanup:
1064 if (status != CAPS_SUCCESS0) AIM_FREE(*aoname){ EG_free(*aoname); *aoname = ((void*)0); };
1065 return status;
1066}
1067
1068
1069// ********************** AIM Function Break *****************************
1070int aimCalcOutput(void *aimStore, /*@unused@*/ void *aimInfo, int index,
1071 capsValue *val)
1072{
1073 int status = CAPS_SUCCESS0;
1074 aimStorage *egadsInstance;
1075
1076#ifdef DEBUG
1077 printf(" egadsTessAIM/aimCalcOutput index = %d!\n", index);
1078#endif
1079 egadsInstance = (aimStorage *) aimStore;
1080
1081 if (Done == index) {
1082
1083 if (egadsInstance->numNodeTotal > 0 && egadsInstance->numElemTotal > 0)
1084 val->vals.integer = (int) true1;
1085 else
1086 val->vals.integer = (int) false0;
1087
1088 } else if (NumberOfElement == index) {
1089
1090 val->vals.integer = egadsInstance->numElemTotal;
1091
1092 } else if (NumberOfNode == index) {
1093
1094 val->vals.integer = egadsInstance->numNodeTotal;
1095
1096 } else if (Surface_Mesh == index) {
1097
1098 // Return the surface meshes
1099 /*@-immediatetrans@*/
1100 val->vals.AIMptr = &egadsInstance->meshRef;
1101 /*@+immediatetrans@*/
1102
1103 } else {
1104
1105 status = CAPS_BADINDEX-304;
1106 AIM_STATUS(aimInfo, status, "Unknown output index %d!", index)if (status != 0) { aim_status(aimInfo, status, "egadsTessAIM.c"
, 1106, __func__, 2, "Unknown output index %d!", index); goto
cleanup; }
;
1107
1108 }
1109
1110 cleanup:
1111
1112 return status;
1113}
1114
1115
1116// ********************** AIM Function Break *****************************
1117void aimCleanup(void *aimStore)
1118{
1119 int status;
1120 aimStorage *egadsInstance;
1121
1122#ifdef DEBUG
1123 printf(" egadsTessAIM/aimClenup!\n");
1124#endif
1125 egadsInstance = (aimStorage *) aimStore;
1126 if (egadsInstance == NULL((void*)0)) return;
1127
1128 status = destroy_aimStorage(egadsInstance);
1129 if (status != CAPS_SUCCESS0)
1130 printf("Status = %d, egadsTessAIM aimStorage cleanup!!!\n", status);
1131
1132 EG_free(egadsInstance);
1133}