Newer
Older
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
#include <string>
extern "C"
{
#include "msh.h"
}
#include "libmeshb7.h"
static inline int isParameter(char *str)
{
if (str == NULL)
return 0;
if (str[0] == '-')
return 0;
return 1;
}
int main(int argc, char **argv)
{
printf(" \n");
printf(" ----------------------------------------------------------------------- \n");
printf("| |\n");
printf("| |\n");
printf(" -----------------------------------------------------------------------\n");
printf(" \n");
int i;
char InpMshNam[1024], noMshNam[1024], noSolNam[1024], OutMshNam[1024], OutSolNam[1024];
int ierro;
bool ascii = false;
VizObject *Obj_surf = NULL;
VizIntStatus status;
double t0 = GetWallClock();
{
cout << " ERROR: missing arguments" << endl;
goto errormessage;
errormessage: //-- error message
printf("\n");
cout << " The format is: cgns2meshb xxx.cgns yyy.cgns zzz.cgns (-ascii)" << endl;
cout << " several cgns files can be provided" << endl;
cout << " -ascii is optional to define ascii output (binary by default otherwise)" << endl;
return 0;
}
for (i = 1; i < argc; i++)
{
if (strcmp(argv[i], "-ascii") == 0)
ascii = true;
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
if ((isParameter(argv[i]) == 1))
{
sprintf(InpMshNam, "%s", argv[i]);
sprintf(noMshNam, "%s", InpMshNam);
if (strstr(InpMshNam, ".cgns") != NULL)
{
//-- cgns file found
printf("Case of cgns file: %s\n", argv[i]);
noMshNam[strstr(InpMshNam, ".cgns") - InpMshNam] = '\0'; // check if it has the extension .cgns[b] and remove it if it is the case
sprintf(OutMshNam, "%s", noMshNam);
sprintf(OutSolNam, "%s", noMshNam);
if (ascii)
strcat(OutMshNam, ".mesh");
else
strcat(OutMshNam, ".meshb");
if (ascii)
strcat(OutSolNam, ".sol");
else
strcat(OutSolNam, ".solb");
ierro = viz_NewInterface(&Obj_surf);
if (ierro != 0)
printf(" viz_NewInterface status %d \n", ierro);
ierro = viz_OpenMesh(Obj_surf, InpMshNam, &status);
if (ierro != VIZINT_SUCCESS)
printf(" viz_OpenMesh failed error %3d : %s\n", ierro, status.ErrMsg);
else
printf(" %%%% %s OPENED\n", status.InfoMsg);
viz_PrintMeshInfo(Obj_surf, &status);
ierro = viz_WriteMesh(Obj_surf, OutMshNam, &status);
if (ierro != VIZINT_SUCCESS)
printf(" viz_WriteMesh failed error %3d : %s\n", ierro, status.ErrMsg);
else
printf(" %%%% Mesh written in %s\n", status.InfoMsg);
}
}