diff --git a/scripts/genfort.pl b/scripts/genfort.pl index ce13936..2df4194 100755 --- a/scripts/genfort.pl +++ b/scripts/genfort.pl @@ -50,7 +50,7 @@ my $formatbyval = "#define %-30s \%val(%d)"; my $definebyval = "#define MMG5_ARG_%-30s \%val(%d)\n"; my $definebyval_f = "#define MMG5_ARG_%s_F %s\n"; -my $definebyval_h2t = "#define H2T_ARG_%s \%val(MMG5_ARG_%s_F)\n"; +my $definebyval_new = "#define H2T_ARG_%s \%val(%s)\n"; my %opts; ############################################################################### @@ -115,6 +115,66 @@ sub printTab # ($chaine, $tabcount, $comm) } print $chaine; } +# +# Function: printMmgHeader +# +# Prints lines from mmg c header file containing +# definition of MMG5_ARG_[.*] macros and defines +# corresponding wrappings H2T_ARG_[.*]. +# +sub printMmgHeader { + + my $chaine; + my $line_mmg; + my $line_mmg2; + my $start_comm; + my $pos_start; + my $pos_end; + my $pos_tmp; + + open (APImmg, $fichier_mmg); + + foreach $line_mmg ( ) + { + if ($line_mmg =~ /\#define MMG5_ARG_(\w*)\s+(.*)/) + { + $chaine = sprintf($definebyval_f,$1,$2); + printTab($chaine,1,0 ); + } + } + + close APImmg; +} +# +# Function: printNewMacro +# +# Returns lines defining new macros of the form +# H2T_ARG_[.*] converted into suitable Fortran format. +# +# Parameter: +# line - Input string to convert +# +# Returns: +# chaine - String to print +# +sub printNewMacro { + + my ($line) = @_; + my $chaine; + + if ($line =~ /\#define H2T_ARG_(\w*)\s+(.*)/) { + my $name = $1; + my $val = $2; + + if ($val =~ /MMG5_ARG_(\w*)/) { + $val =~ s/MMG5_ARG_(\w*)/MMG5_ARG_$1_F/g; + } + + $chaine = sprintf($definebyval_new,$name,$val); + } + + return $chaine; +} # # Function: Convert @@ -134,21 +194,7 @@ sub Convert { my $tabcount = 0; my $interfaceprinted = 0; my $modulename; - - open (APImmg, $fichier_mmg); - - foreach my $line_mmg ( ) - { - if ($line_mmg =~ /\#define MMG5_ARG_(\w*)\s+(.*)/) - { - $chaine = sprintf($definebyval_f,$1,$2); - printTab($chaine,1,0 ); - $chaine = sprintf($definebyval_h2t,$1,$1); - printTab($chaine,1,0 ); - } - } - - close APImmg; + my $mmg_header = 0; open (APIc, $fichier); @@ -222,9 +268,14 @@ sub Convert { } elsif ($line =~ /\#define H2T_ARG_(\w*)\s+(.*)/) { - $chaine = sprintf($definebyval_h2t,$1,$2); + if ($mmg_header == 0) + { + printMmgHeader(); + $mmg_header = 1; + } + $chaine = printNewMacro($line); printTab($chaine,1,0 ); - } + } elsif ($line =~ /\#define/) { printTab($line,1,0 ); diff --git a/src/libhex2tet.h b/src/libhex2tet.h index 185c117..ed7c3df 100644 --- a/src/libhex2tet.h +++ b/src/libhex2tet.h @@ -50,6 +50,110 @@ extern "C" { * \remark we cannot use an enum because used in * variadic functions). */ +/** + * \def MMG5_ARG_start + * + * To begin a list of variadic arguments (mandatory first arg for all our + * variadic functions) + * + * \remark we cannot use an enum because used in + * variadic functions). + */ +#define H2T_ARG_start 1 +/** + * \def H2T_ARG_ppMesh + * + * Pointer toward a MMG5_pMesh structure (for structure allocations purposes) + * + * \remark we cannot use an enum because used in + * variadic functions). + */ +#define H2T_ARG_ppMesh 2 +/** + * \def H2T_ARG_ppLs + * + * Pointer toward a MMG5_pSol structure storing a level-set (for structure + * allocations purposes) + * + * \remark we cannot use an enum because used in + * variadic functions). + */ +#define H2T_ARG_ppLs 3 +/** + * \def H2T_ARG_ppMet + * + * Pointer toward a MMG5_pSol structure storing a metric (for structure + * allocations purposes) + * + * \remark we cannot use an enum because used in + * variadic functions). + */ +#define H2T_ARG_ppMet 4 +/** + * \def H2T_ARG_ppDisp + * + * Pointer toward a MMG5_pSol structure storing a displacement (for structure + * allocations purposes) + * + * \remark we cannot use an enum because used in + * variadic functions). + */ +#define H2T_ARG_ppDisp 5 +/** + * \def H2T_ARG_ppSols + * + * Pointer toward an array of MMG5_Sol structures storing a list of solutions + * allocations purposes) + * + * \remark we cannot use an enum because used in + * variadic functions). + */ +#define H2T_ARG_ppSols 6 +/** + * \def H2T_ARG_pMesh + * + * MMG5_pMesh structure + * + * \remark we cannot use an enum because used in + * variadic functions). + */ +#define H2T_ARG_pMesh 7 +/** + * \def H2T_ARG_pMet + * + * MMG5_pSol structure storing a metric field + * + * \remark we cannot use an enum because used in + * variadic functions). + */ +#define H2T_ARG_pMet 8 +/** + * \def H2T_ARG_pDisp + * + * MMG5_pSol structure storing a displacement field + * + * \remark we cannot use an enum because used in + * variadic functions). + */ +#define H2T_ARG_pDisp 9 +/** + * \def H2T_ARG_end + * + * To end a list of variadic argument (mandatory last argument for all our + * variadic functions) + * + * \remark we cannot use an enum because used in + * variadic functions). + */ +#define H2T_ARG_end 10 +/** + * \def H2T_ARG_phexa + * + * integer array storing list of hexahedra + * + * \remark we cannot use an enum because used in + * variadic functions). + */ #define H2T_ARG_phexa (MMG5_ARG_end+1) /** * \param mmgMesh mesh structure with only vertices.