Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
API_functions.c
Go to the documentation of this file.
1/* =============================================================================
2** This file is part of the mmg software package for the tetrahedral
3** mesh modification.
4** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004-
5**
6** mmg is free software: you can redistribute it and/or modify it
7** under the terms of the GNU Lesser General Public License as published
8** by the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** mmg is distributed in the hope that it will be useful, but WITHOUT
12** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14** License for more details.
15**
16** You should have received a copy of the GNU Lesser General Public
17** License and of the GNU General Public License along with mmg (in
18** files COPYING.LESSER and COPYING). If not, see
19** <http://www.gnu.org/licenses/>. Please read their terms carefully and
20** use this copy of the mmg distribution only if you accept them.
21** =============================================================================
22*/
23
43#include "mmgcommon_private.h"
44
52
53 memset(&mesh->info,0, sizeof(MMG5_Info));
54
55 /* default values for integers */
56 /* [-1..10], Tune level of imprim */
57 mesh->info.imprim = 1;
58 /* [0/1] ,Turn on/off levelset meshing */
60 /* [0/1] ,Turn on/off levelset meshing */
62 /* [n/10] ,Value for isosurface boundary reference */
64 /* [n/-1] ,Set memory size to n Mbytes/keep the default value */
66 /* [0/1] ,Turn on/off debug mode */
68 /* [n] ,number of local parameters */
70 /* [0/1] ,avoid/allow point insertion/deletion */
72 /* [0/1] ,avoid/allow edge or face flipping */
74 /* [0/1] ,avoid/allow point relocation */
76 /* [n] ,number of user-defined references */
78 /* [-1/val] ,Turn off/on the removal of small bubles in levelset meshing */
80 /* [0/1] ,avoid/allow */
82
83
84 /* default values for doubles */
85 /* angle detection */
87 /* minimal mesh size */
89 /* maximal mesh size */
91 /* constant mesh size */
93 /* control Hausdorff */
95 /* control gradation */
97 /* control gradation on required entities */
99 /* xreg relaxation parameter value */
101
102 /* default values for pointers */
103 /* list of user-defined references */
104 mesh->info.mat = NULL;
105
109
110 /* initial value for memMax and gap */
111 mesh->gap = MMG5_GAP;
113 if ( mesh->memMax ) {
114 /* maximal memory = 50% of total physical memory */
115 mesh->memMax = (size_t)(mesh->memMax*MMG5_MEMPERCENT);
116 } else {
117 /* default value = 800 MB */
118 printf(" Maximum memory set to default value: %d MB.\n",MMG5_MEMMAX);
120 }
121
122}
123
124
133 ) {
136
137 if ( sol ) {
140 }
141
142 return;
143}
144
154
155 if ( mesh->namein ){
157 }
158
159 if ( meshin && strlen(meshin) ) {
160 MMG5_ADD_MEM(mesh,(strlen(meshin)+1)*sizeof(char),"input mesh name",
161 fprintf(stderr," Exit program.\n");
162 return 0);
163 MMG5_SAFE_CALLOC(mesh->namein,strlen(meshin)+1,char,return 0);
164 strcpy(mesh->namein,meshin);
165 }
166 else {
167 MMG5_ADD_MEM(mesh,10*sizeof(char),"input mesh name",
168 fprintf(stderr," Exit program.\n");
169 return 0);
170 MMG5_SAFE_CALLOC(mesh->namein,10,char,return 0);
171 strcpy(mesh->namein,"mesh.mesh");
172 if ( (mesh->info.imprim > 5) || mesh->info.ddebug ) {
173 fprintf(stderr,"\n ## Warning: %s: no name given for input mesh.\n",__func__);
174 fprintf(stderr," Use of default value \"mesh.mesh\".\n");
175 }
176 }
177 return 1;
178}
179
190 char *ptr;
191
192 if ( sol->namein )
194
195 if ( solin && strlen(solin) ) {
196 MMG5_ADD_MEM(mesh,(strlen(solin)+1)*sizeof(char),"input sol name",
197 fprintf(stderr," Exit program.\n");
198 return 0);
199 MMG5_SAFE_CALLOC(sol->namein,strlen(solin)+1,char,return 0);
200 strcpy(sol->namein,solin);
201 }
202 else {
203 if ( mesh->namein && strlen(mesh->namein) ) {
204 int mesh_len = strlen(mesh->namein)+1;
205 MMG5_SAFE_CALLOC(sol->namein,mesh_len,char,return 0);
206 strcpy(sol->namein,mesh->namein);
207
208 /* Get last dot character to avoid issues with <basename>.mesh.mesh files */
209 char *dot = strrchr(sol->namein,'.');
210 ptr = NULL;
211 if ( dot) {
212 ptr = strstr(dot,".mesh");
213 }
214 if ( ptr ) {
215 /* the sol file is renamed concatening the mesh basename and the sol extension */
216 *ptr = '\0';
217 }
218 MMG5_SAFE_REALLOC(sol->namein,mesh_len,(strlen(sol->namein)+5),char,
219 "input sol name",return 0);
220
221 MMG5_ADD_MEM(mesh,(strlen(sol->namein)+5)*sizeof(char),"input sol name",
222 fprintf(stderr," Exit program.\n");
223 return 0);
224 strcat(sol->namein,".sol");
225 }
226 else {
227 MMG5_ADD_MEM(mesh,9*sizeof(char),"input sol name",
228 fprintf(stderr," Exit program.\n");
229 return 0);
230 MMG5_SAFE_CALLOC(sol->namein,9,char,return 0);
231 strcpy(sol->namein,"mesh.sol");
232 }
233 }
234 return 1;
235}
236
245int MMG5_Set_inputParamName(MMG5_pMesh mesh, const char* fparamin) {
246
247 if ( mesh->info.fparam )
249
250 if ( fparamin && strlen(fparamin) ) {
251 MMG5_ADD_MEM(mesh,(strlen(fparamin)+1)*sizeof(char),"input param name",
252 fprintf(stderr," Exit program.\n");
253 return 0);
254 MMG5_SAFE_CALLOC(mesh->info.fparam,strlen(fparamin)+1,char,return 0);
255 strcpy(mesh->info.fparam,fparamin);
256 }
257 else {
258 fprintf(stderr,"\n ## Warning: %s: no name given for the parameter file.\n",__func__);
259 fprintf(stderr," We should have never end here.\n");
260 return 0;
261 }
262 return 1;
263}
264
273int MMG5_Set_outputMeshName(MMG5_pMesh mesh, const char* meshout) {
274 int fmt = MMG5_FMT_MeditASCII,fmtin;
275 char *ptr,*ptrin;
276
277 if ( mesh->nameout )
279
280 if ( meshout && strlen(meshout) ) {
281 ptr = strrchr(meshout, '.');
282
283 MMG5_ADD_MEM(mesh,(strlen(meshout)+7)*sizeof(char),"output mesh name",
284 fprintf(stderr," Exit program.\n");
285 return 0);
286 MMG5_SAFE_CALLOC(mesh->nameout,strlen(meshout)+7,char,return 0);
287 strcpy(mesh->nameout,meshout);
288
289 if ( ( ptr && MMG5_Get_format(ptr,0)==MMG5_FMT_Unknown ) || (!ptr) || ptr == meshout ) {
290 /* No extension */
293 fmt = MMG5_FMT_Unknown;
294 }
295 strcpy(mesh->nameout,meshout);
296
297 if ( fmt == MMG5_FMT_Unknown ) {
298 /* No extension */
299 switch ( fmtin ) {
300 case ( MMG5_FMT_GmshASCII ):
301 strcat(mesh->nameout,".msh");
302 break;
303 case ( MMG5_FMT_GmshBinary ):
304 strcat(mesh->nameout,".mshb");
305 break;
306 case ( MMG5_FMT_VtkVtu ):
307 strcat(mesh->nameout,".vtu");
308 break;
309 case ( MMG5_FMT_VtkVtp ):
310 strcat(mesh->nameout,".vtp");
311 break;
312 case ( MMG5_FMT_VtkVtk ):
313 strcat(mesh->nameout,".vtk");
314 break;
315 case ( MMG5_FMT_MeditBinary ):
316 strcat(mesh->nameout,".meshb");
317 break;
318 case ( MMG5_FMT_MeditASCII ): default:
319 strcat(mesh->nameout,".mesh");
320 break;
321 }
322 }
323 }
324 else {
325 if ( mesh->namein && strlen(mesh->namein) ) {
326 MMG5_ADD_MEM(mesh,(strlen(mesh->namein)+9)*sizeof(char),"output mesh name",
327 fprintf(stderr," Exit program.\n");
328 return 0);
329 MMG5_SAFE_CALLOC(mesh->nameout,strlen(mesh->namein)+9,char,return 0);
330 strcpy(mesh->nameout,mesh->namein);
331
334
335 if ( ptr ) *ptr = '\0';
336
337 switch ( fmt ) {
338
339 case ( MMG5_FMT_GmshASCII ):
340 strcat(mesh->nameout,".o.msh");
341 break;
342 case ( MMG5_FMT_GmshBinary ):
343 strcat(mesh->nameout,".o.mshb");
344 break;
345 case ( MMG5_FMT_VtkVtu ):
346 strcat(mesh->nameout,".o.vtu");
347 break;
348 case ( MMG5_FMT_VtkVtp ):
349 strcat(mesh->nameout,".o.vtp");
350 break;
351 case ( MMG5_FMT_VtkVtk ):
352 strcat(mesh->nameout,".o.vtk");
353 break;
354 case ( MMG5_FMT_MeditBinary ):
355 strcat(mesh->nameout,".o.meshb");
356 break;
357 case ( MMG5_FMT_MeditASCII ): default:
358 strcat(mesh->nameout,".o.mesh");
359 break;
360 }
361 }
362 else {
363 MMG5_ADD_MEM(mesh,12*sizeof(char),"output mesh name",
364 fprintf(stderr," Exit program.\n");
365 return 0);
366 MMG5_SAFE_CALLOC(mesh->nameout,12,char,return 0);
367 if ( (mesh->info.imprim > 5) || mesh->info.ddebug ) {
368 fprintf(stderr,"\n ## Warning: %s: no name given for output mesh.\n",
369 __func__);
370 fprintf(stderr," Use of default value \"mesh.o.mesh\".\n");
371 }
372 strcpy(mesh->nameout,"mesh.o.mesh");
373 }
374 }
375 return 1;
376}
377
378
389 char *ptr;
390 int oldsize;
391
392 if ( sol->nameout )
394
395 if ( solout && strlen(solout) ) {
396 MMG5_ADD_MEM(mesh,(strlen(solout)+1)*sizeof(char),"output sol name",
397 fprintf(stderr," Exit program.\n");
398 return 0);
399 MMG5_SAFE_CALLOC(sol->nameout,strlen(solout)+1,char,return 0);
400 strcpy(sol->nameout,solout);
401 }
402 else {
403 if ( mesh->nameout && strlen(mesh->nameout) ) {
404 /* Get last dot character to avoid issues with <basename>.mesh.mesh files */
405 char *dot = strrchr(mesh->nameout,'.');
406 ptr = NULL;
407 if ( dot) {
408 ptr = strstr(dot,".mesh");
409 }
410 if ( ptr ) {
411 MMG5_SAFE_CALLOC(sol->nameout,strlen(mesh->nameout)+1,char,return 0);
412 oldsize = strlen(mesh->nameout)+1;
413 }
414 else {
415 MMG5_SAFE_CALLOC(sol->nameout,strlen(mesh->nameout)+6,char,return 0);
416 oldsize = strlen(mesh->nameout)+6;
417 }
418 strcpy(sol->nameout,mesh->nameout);
419 dot = strrchr(sol->nameout,'.');
420 ptr = NULL;
421 if ( dot) {
422 ptr = strstr(dot,".mesh");
423 }
424 if ( ptr )
425 /* the sol file is renamed with the meshfile basename and .sol ext */
426 *ptr = '\0';
427
428 MMG5_ADD_MEM(mesh,(strlen(sol->nameout)+5)*sizeof(char),"output sol name",
429 fprintf(stderr," Exit program.\n");
430 return 0);
431 MMG5_SAFE_REALLOC(sol->nameout,oldsize,(strlen(sol->nameout)+5),char,
432 "output sol name",return 0);
433 strcat(sol->nameout,".sol");
434
435 }
436 else {
437 fprintf(stderr,"\n ## Error: %s: no name for output mesh. please, use",
438 __func__);
439 fprintf(stderr," the MMG5_Set_outputMeshName to set the mesh name.\n");
440 return 0;
441 }
442 }
443 return 1;
444}
445
447 MMG5_pPoint ppt;
448 MMG5_int k,iadr;
449
450 if ( met->size == 1 ) {
451 for (k=1; k<=mesh->np; k++) {
452 ppt = &mesh->point[k];
453 if ( !MG_VOK(ppt) ) continue;
454 met->m[k] = hsiz;
455 }
456 }
457 else {
458 hsiz = 1./(hsiz*hsiz);
459
460 if ( mesh->dim==2 ) {
461 for (k=1; k<=mesh->np; k++) {
462 ppt = &mesh->point[k];
463 if ( !MG_VOK(ppt) ) continue;
464
465 iadr = 3*k;
466 met->m[iadr] = hsiz;
467 met->m[iadr+1] = 0.;
468 met->m[iadr+2] = hsiz;
469 }
470 }
471 else {
472 assert ( mesh->dim==3 );
473 for (k=1; k<=mesh->np; k++) {
474 ppt = &mesh->point[k];
475 if ( !MG_VOK(ppt) ) continue;
476
477 iadr = 6*k;
478 met->m[iadr] = hsiz;
479 met->m[iadr+1] = 0.;
480 met->m[iadr+2] = 0.;
481 met->m[iadr+3] = hsiz;
482 met->m[iadr+4] = 0.;
483 met->m[iadr+5] = hsiz;
484 }
485 }
486 }
487
488 return;
489}
490
492 int i;
493
494 if ( sol ) {
495 if ( mesh->nsols ) {
496 for ( i=0; i<mesh->nsols; ++i ) {
497 MMG5_DEL_MEM(mesh,(*sol)[i].m);
498 }
499 }
501 }
502
503 return 1;
504}
505
514
515 if ( mesh->point )
517
518 if ( mesh->xpoint )
520
521 if ( mesh->edge )
523
524 if ( mesh->adja )
526
527 if ( mesh->tria )
529
530 if ( mesh->adjt )
532
533 /* sol */
534 if ( sol && sol->m )
536
537 /* mesh->info */
538 if ( mesh->info.npar && mesh->info.par )
540
541 if ( mesh->info.nmat ) {
542 if( mesh->info.mat )
544 if( mesh->info.invmat.lookup )
546 }
547
548 if ( mesh->info.imprim>5 || mesh->info.ddebug ) {
549 printf(" MEMORY USED AT END (Bytes) %zu\n",mesh->memCur);
550 }
551
552 return;
553}
554
563
564 /* mesh */
565 if ( mesh->nameout ) {
567 }
568
569 if ( mesh->namein ) {
571 }
572
573 /* met */
574 if ( met ) {
575 if ( met->namein ) {
577 }
578
579 if ( met->nameout ) {
581 }
582 }
583}
584
585inline
586int MMG5_Set_defaultTruncatureSizes(MMG5_pMesh mesh,int8_t sethmin,int8_t sethmax) {
587
588 if ( !sethmin ) {
589 if ( sethmax ) {
591 } else {
593 }
594 }
595
596 if ( !sethmax ) {
597 if ( sethmin ) {
599 }
600 else {
602 }
603 }
604
605 if ( mesh->info.hmax < mesh->info.hmin ) {
606 assert ( sethmin && sethmax );
607 fprintf(stderr,"\n ## Error: %s: Mismatched options:"
608 " minimal mesh size larger than maximal one.\n",__func__);
609 return 0;
610 }
611
612 if ( mesh->info.ddebug ) {
613 /* print unscaled values for debug purpose */
614 fprintf(stdout," After truncature computation: hmin %lf (user setted %d)\n"
615 " hmax %lf (user setted %d)\n",
618 }
619
620 return 1;
621}
622
624
625 if ( mesh->info.hmin > mesh->info.hsiz ) {
626 fprintf(stderr,"\n ## Error: %s: Mismatched options: hmin (%e) is greater"
627 " than hsiz (%e). Exit Program.\n",__func__,
629 return 0;
630 }
631
632 if ( mesh->info.hmax > 0. && mesh->info.hmax < mesh->info.hsiz ) {
633 fprintf(stderr,"\n ## Error: %s: Mismatched options: hmax (%e) is lower"
634 " than hsiz (%e). Exit Program.\n",__func__,
636 return 0;
637 }
638
639 *hsiz = mesh->info.hsiz;
640
642 return 0;
643 }
644
645 if ( mesh->info.sethmin ) {
646 *hsiz = MG_MAX(mesh->info.hmin,*hsiz);
647 }
648
649 if ( mesh->info.sethmax ) {
650 *hsiz = MG_MIN(mesh->info.hmax,*hsiz);
651 }
652
653 /* Set hmin */
654 if ( !mesh->info.sethmin ) {
655 if ( mesh->info.sethmax ) {
656 mesh->info.hmin = MG_MIN(0.1*(*hsiz),0.1*mesh->info.hmax);
657 } else {
658 mesh->info.hmin = 0.1*(*hsiz);
659 }
660 }
661
662 /* Set hmax */
663 if ( !mesh->info.sethmax ) {
664 if ( mesh->info.sethmin ) {
665 mesh->info.hmax = MG_MAX(10.*(*hsiz),10.*mesh->info.hmin);
666 } else {
667 mesh->info.hmax = 10.*(*hsiz);
668 }
669 }
670
671 if ( mesh->info.ddebug ) {
672 /* print unscaled values for debug purpose */
673 fprintf(stdout," After hsiz computation: hmin %lf (user setted %d)\n"
674 " hmax %lf (user setted %d)\n",
677 }
678
679 return 1;
680}
681
682/* Useful tools to manage C strings */
683char *MMG5_Get_basename(char *path) {
684 char *s = strrchr(path, '/');
685
686 if (!s)
687 return strdup(path);
688 else
689 return strdup(s + 1);
690}
691
692
694{
695 switch (ent)
696 {
697 case MMG5_Noentity:
698 return "MMG5_Noentity";
699 break;
700 case MMG5_Vertex:
701 return "MMG5_Vertex";
702 break;
703 case MMG5_Edg:
704 return "MMG5_Edg";
705 break;
706 case MMG5_Triangle:
707 return "MMG5_Triangle";
708 break;
709 case MMG5_Tetrahedron:
710 return "MMG5_Tetrahedron";
711 break;
712 default:
713 return"MMG5_Unknown";
714 }
715}
716const char* MMG5_Get_typeName(enum MMG5_type typ)
717{
718 switch (typ)
719 {
720 case MMG5_Notype:
721 return "MMG5_Notype";
722 break;
723 case MMG5_Scalar:
724 return "MMG5_Scalar";
725 break;
726 case MMG5_Vector:
727 return "MMG5_Vector";
728 break;
729 case MMG5_Tensor:
730 return "MMG5_Tensor";
731 break;
732 default:
733 return "MMG5_Unknown";
734 }
735}
736
737const char* MMG5_Get_tagName(uint16_t tag)
738{
739 static char tags_name[1024];
740
741 if ( !tag )
742 {
743 return "No tag";
744 }
745
746 if ( tag & MG_NUL ) {
747 return "Removed";
748 }
749
750 strcpy(tags_name, "\0");
751
752 if ( tag & MG_REF ) {
753 strcat(tags_name,"Reference ");
754 }
755
756 if ( tag & MG_GEO) {
757 strcat(tags_name,"Ridge ");
758 }
759
760 if ( tag & MG_REQ) {
761 strcat(tags_name,"Required ");
762 }
763
764 if ( tag & MG_NOM) {
765 strcat(tags_name,"Non-manifold ");
766 }
767
768 if ( tag & MG_BDY) {
769 strcat(tags_name,"Boundary ");
770 }
771
772 if ( tag & MG_CRN) {
773 strcat(tags_name,"Corner ");
774 }
775
776 if ( tag & MG_NOSURF) {
777 strcat(tags_name,"Nosurf ");
778 }
779
780 if ( tag & MG_OPNBDY) {
781 strcat(tags_name,"Opnbdy ");
782 }
783
784 if ( tag & MG_OLDPARBDY) {
785 strcat(tags_name,"Old-parbdy ");
786 }
787
788 if ( tag & MG_PARBDYBDY) {
789 strcat(tags_name,"Parbdybdy ");
790 }
791
792 if ( tag & MG_PARBDY) {
793 strcat(tags_name,"Parbdy ");
794 }
795
796 if ( tag & MG_OVERLAP) {
797 strcat(tags_name,"Overlap ");
798 }
799
800 strcat(tags_name,"tag(s).");
801
802 return tags_name;
803}
804
816int MMG5_Get_format( char *ptr, int fmt ) {
817 /* Default is the Medit file format or a format given as input */
818 int defFmt = fmt;
819
820 if ( !ptr ) return defFmt;
821
822 if ( !strncmp ( ptr,".meshb",strlen(".meshb") ) ) {
824 }
825 else if ( !strncmp( ptr,".mesh",strlen(".mesh") ) ) {
826 return MMG5_FMT_MeditASCII;
827 }
828 else if ( !strncmp( ptr,".mshb",strlen(".mshb") ) ) {
829 return MMG5_FMT_GmshBinary;
830 }
831 else if ( !strncmp( ptr,".msh",strlen(".msh") ) ) {
832 return MMG5_FMT_GmshASCII;
833 }
834 else if ( !strncmp ( ptr,".pvtu",strlen(".pvtu") ) ) {
835 return MMG5_FMT_VtkPvtu;
836 }
837 else if ( !strncmp ( ptr,".vtu",strlen(".vtu") ) ) {
838 return MMG5_FMT_VtkVtu;
839 }
840 else if ( !strncmp ( ptr,".pvtp",strlen(".pvtu") ) ) {
841 return MMG5_FMT_VtkPvtp;
842 }
843 else if ( !strncmp ( ptr,".vtp",strlen(".vtp") ) ) {
844 return MMG5_FMT_VtkVtp;
845 }
846 else if ( !strncmp ( ptr,".vtk",strlen(".vtk") ) ) {
847 return MMG5_FMT_VtkVtk;
848 }
849 else if ( !strncmp ( ptr,".node",strlen(".node") ) ) {
850 return MMG5_FMT_Tetgen;
851 }
852
853 return defFmt;
854}
855
864const char* MMG5_Get_formatName(enum MMG5_Format fmt)
865{
866 switch (fmt)
867 {
869 return "MMG5_FMT_MeditASCII";
870 break;
872 return "MMG5_FMT_MeditBinary";
873 break;
874 case MMG5_FMT_VtkVtu:
875 return "MMG5_FMT_VtkVtu";
876 break;
877 case MMG5_FMT_VtkVtp:
878 return "MMG5_FMT_VtkVtp";
879 break;
880 case MMG5_FMT_VtkPvtu:
881 return "MMG5_FMT_VtkPvtu";
882 break;
883 case MMG5_FMT_VtkPvtp:
884 return "MMG5_FMT_VtkPvtp";
885 break;
886 case MMG5_FMT_VtkVtk:
887 return "MMG5_FMT_VtkVtk";
888 break;
890 return "MMG5_FMT_GmshASCII";
891 break;
893 return "MMG5_FMT_GmshBinary";
894 break;
895 case MMG5_FMT_Tetgen:
896 return "MMG5_FMT_Tetgen";
897 break;
898 default:
899 return "MMG5_Unknown";
900 }
901}
902
913 const char pathsep='/';
914 char *dot,*lastpath;
915
916 if ( !filename ) {
917 return NULL;
918 }
919
920 dot = strrchr(filename, '.');
921 lastpath = (pathsep == 0) ? NULL : strrchr (filename, pathsep);
922
923 if ( (!dot) || dot == filename || (lastpath>dot) || (!strcmp(dot,".o")) ) {
924 /* No extension */
925 return filename + strlen(filename);
926 }
927
928 return dot;
929}
930
939char *MMG5_Get_path(char *path) {
940 char *lastpath,*retpath;
941 int len;
942
943 if ( path == NULL) return NULL;
944
945 lastpath = (MMG5_PATHSEP == 0) ? NULL : strrchr (path, MMG5_PATHSEP);
946
947 if ( !lastpath ) {
948 return NULL;
949 }
950
951
952 len = 0;
953 while ( path+len != lastpath ) {
954 ++len;
955 }
956
957 MMG5_SAFE_MALLOC(retpath,len+1,char,return NULL);
958
959 /* Copy the string without the extension and add \0 */
960 strncpy ( retpath, path, len );
961 retpath[len] = '\0';
962
963 return retpath;
964}
965
974char *MMG5_Remove_ext (char* path,char *ext) {
975 int len;
976 char *retpath, *lastext, *lastpath;
977 char *extloc;
978
979 /* Default extension if not provided */
980 if ( (!ext) || !*ext ) {
981 extloc = ".";
982 }
983 else {
984 extloc = ext;
985 }
986
987 /* Error checks and string allocation. */
988 if ( path == NULL) return NULL;
989
990 /* Find the relevant characters and the length of the string without
991 * extension */
992 lastext = strstr (path, extloc);
993 lastpath = (MMG5_PATHSEP == 0) ? NULL : strrchr (path, MMG5_PATHSEP);
994
995 if ( lastext == NULL || (lastpath != NULL && lastpath > lastext) ) {
996 /* No extension or the extension is left from a separator (i.e. it is not an
997 * extension) */
998 len = strlen(path);
999 }
1000 else {
1001 /* An extension is found */
1002 len = 0;
1003 while ( path+len != lastext ) {
1004 ++len;
1005 }
1006 }
1007
1008 MMG5_SAFE_MALLOC(retpath,len+1,char,return NULL);
1009
1010 /* Copy the string without the extension and add \0 */
1011 strncpy ( retpath, path, len );
1012 retpath[len] = '\0';
1013
1014 return retpath;
1015}
const char * MMG5_Get_tagName(uint16_t tag)
const char * MMG5_Get_typeName(enum MMG5_type typ)
int MMG5_Compute_constantSize(MMG5_pMesh mesh, MMG5_pSol met, double *hsiz)
int MMG5_Set_inputParamName(MMG5_pMesh mesh, const char *fparamin)
int MMG5_Set_outputMeshName(MMG5_pMesh mesh, const char *meshout)
char * MMG5_Get_basename(char *path)
int MMG5_Set_inputSolName(MMG5_pMesh mesh, MMG5_pSol sol, const char *solin)
const char * MMG5_Get_formatName(enum MMG5_Format fmt)
int MMG5_Free_allSols(MMG5_pMesh mesh, MMG5_pSol *sol)
int MMG5_Set_defaultTruncatureSizes(MMG5_pMesh mesh, int8_t sethmin, int8_t sethmax)
int MMG5_Set_inputMeshName(MMG5_pMesh mesh, const char *meshin)
void MMG5_Init_parameters(MMG5_pMesh mesh)
Definition: API_functions.c:51
const char * MMG5_Get_entitiesName(enum MMG5_entities ent)
char * MMG5_Remove_ext(char *path, char *ext)
int MMG5_Get_format(char *ptr, int fmt)
void MMG5_mmgFree_names(MMG5_pMesh mesh, MMG5_pSol met)
void MMG5_Free_structures(MMG5_pMesh mesh, MMG5_pSol sol)
char * MMG5_Get_path(char *path)
void MMG5_Set_constantSize(MMG5_pMesh mesh, MMG5_pSol met, double hsiz)
void MMG5_Init_fileNames(MMG5_pMesh mesh, MMG5_pSol sol)
char * MMG5_Get_filenameExt(char *filename)
int MMG5_Set_outputSolName(MMG5_pMesh mesh, MMG5_pSol sol, const char *solout)
strncpy(tmp, meshin, *strlen0)
MMG5_pMesh MMG5_pSol * sol
MMG5_pMesh char * meshin
MMG5_pMesh * mesh
MMG5_pMesh char * filename
MMG5_type
Type of solutions.
Definition: libmmgtypes.h:217
@ MMG5_Vector
Definition: libmmgtypes.h:220
@ MMG5_Tensor
Definition: libmmgtypes.h:221
@ MMG5_Scalar
Definition: libmmgtypes.h:219
@ MMG5_Notype
Definition: libmmgtypes.h:218
MMG5_Format
Type of supported file format.
Definition: libmmgtypes.h:240
@ MMG5_FMT_MeditBinary
Definition: libmmgtypes.h:242
@ MMG5_FMT_Tetgen
Definition: libmmgtypes.h:250
@ MMG5_FMT_VtkVtk
Definition: libmmgtypes.h:249
@ MMG5_FMT_GmshBinary
Definition: libmmgtypes.h:244
@ MMG5_FMT_VtkPvtp
Definition: libmmgtypes.h:245
@ MMG5_FMT_Unknown
Definition: libmmgtypes.h:251
@ MMG5_FMT_GmshASCII
Definition: libmmgtypes.h:243
@ MMG5_FMT_MeditASCII
Definition: libmmgtypes.h:241
@ MMG5_FMT_VtkVtp
Definition: libmmgtypes.h:248
@ MMG5_FMT_VtkPvtu
Definition: libmmgtypes.h:246
@ MMG5_FMT_VtkVtu
Definition: libmmgtypes.h:247
#define MG_ISO
Definition: libmmgtypes.h:71
MMG5_entities
Identifies the types of mesh entities.
Definition: libmmgtypes.h:228
@ MMG5_Noentity
Definition: libmmgtypes.h:229
@ MMG5_Vertex
Definition: libmmgtypes.h:230
@ MMG5_Tetrahedron
Definition: libmmgtypes.h:233
@ MMG5_Edg
Definition: libmmgtypes.h:231
@ MMG5_Triangle
Definition: libmmgtypes.h:232
#define MG_REQ
#define MMG5_BITWIZE_MB_TO_B
#define MG_GEO
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
#define MMG5_HGRADREQ
#define MMG5_NONSET
size_t MMG5_memSize(void)
Definition: tools.c:852
#define MMG5_NONSET_HMIN
#define MG_OPNBDY
#define MG_NUL
#define MG_PARBDY
#define MMG5_LAG
#define MG_MIN(a, b)
#define MG_MAX(a, b)
#define MMG5_GAP
#define MMG5_ADD_MEM(mesh, size, message, law)
#define MMG5_SAFE_REALLOC(ptr, prevSize, newSize, type, message, law)
#define MMG5_HGRAD
#define MMG5_HMAXCOE
#define MG_OLDPARBDY
#define MMG5_NONSET_MEM
#define MMG5_PATHSEP
#define MMG5_MEMPERCENT
#define MMG5_NONSET_HMAX
#define MMG5_MEMMAX
#define MG_VOK(ppt)
#define MMG5_OFF
#define MMG5_HMINCOE
#define MG_OVERLAP
#define MG_CRN
#define MG_BDY
#define MMG5_ANGEDG
#define MMG5_SAFE_MALLOC(ptr, size, type, law)
#define MMG5_XREG
#define MMG5_NONSET_HSIZ
#define MG_NOSURF
#define MG_NOM
#define MMG5_HAUSD
int MMG5_check_setted_hminhmax(MMG5_pMesh mesh)
Definition: scalem.c:116
#define MG_REF
#define MG_PARBDYBDY
#define MMG5_DEL_MEM(mesh, ptr)
Structure to store input parameters of the job.
Definition: libmmgtypes.h:523
int8_t iso
Definition: libmmgtypes.h:541
int8_t ddebug
Definition: libmmgtypes.h:539
double delta
Definition: libmmgtypes.h:526
double hsiz
Definition: libmmgtypes.h:525
int8_t isosurf
Definition: libmmgtypes.h:542
int8_t sethmin
Definition: libmmgtypes.h:551
uint8_t noswap
Definition: libmmgtypes.h:553
double rmc
Definition: libmmgtypes.h:526
double hmin
Definition: libmmgtypes.h:525
MMG5_pMat mat
Definition: libmmgtypes.h:562
double hgrad
Definition: libmmgtypes.h:525
double lxreg
Definition: libmmgtypes.h:526
uint8_t noinsert
Definition: libmmgtypes.h:553
MMG5_int isoref
Definition: libmmgtypes.h:528
double hmax
Definition: libmmgtypes.h:525
uint8_t nomove
Definition: libmmgtypes.h:553
int8_t lag
Definition: libmmgtypes.h:547
MMG5_InvMat invmat
Definition: libmmgtypes.h:563
char * fparam
Definition: libmmgtypes.h:555
int8_t sethmax
Definition: libmmgtypes.h:552
uint8_t nosizreq
Definition: libmmgtypes.h:553
MMG5_pPar par
Definition: libmmgtypes.h:524
double dhd
Definition: libmmgtypes.h:525
double hgradreq
Definition: libmmgtypes.h:525
double hausd
Definition: libmmgtypes.h:525
int * lookup
Definition: libmmgtypes.h:515
MMG mesh structure.
Definition: libmmgtypes.h:613
size_t memCur
Definition: libmmgtypes.h:615
MMG5_Info info
Definition: libmmgtypes.h:659
MMG5_pPoint point
Definition: libmmgtypes.h:649
char * nameout
Definition: libmmgtypes.h:661
MMG5_int * adja
Definition: libmmgtypes.h:632
size_t memMax
Definition: libmmgtypes.h:614
MMG5_pxPoint xpoint
Definition: libmmgtypes.h:650
double gap
Definition: libmmgtypes.h:616
MMG5_pTria tria
Definition: libmmgtypes.h:655
MMG5_int np
Definition: libmmgtypes.h:620
MMG5_pEdge edge
Definition: libmmgtypes.h:657
char * namein
Definition: libmmgtypes.h:660
MMG5_int * adjt
Definition: libmmgtypes.h:636
Structure to store vertices of an MMG mesh.
Definition: libmmgtypes.h:276
char * nameout
Definition: libmmgtypes.h:683
char * namein
Definition: libmmgtypes.h:682
double * m
Definition: libmmgtypes.h:680