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