@@ -69,7 +69,7 @@ int MMG2D_anatri(MMG5_pMesh mesh,MMG5_pSol met,int8_t typchk) {
6969 }
7070
7171 /* Collapse short edges */
72- nc = MMG2D_colelt (mesh ,met ,typchk );
72+ nc = MMG2D_colelt (mesh ,met ,typchk , MMG2D_LSHRT );
7373 if ( nc < 0 ) {
7474 fprintf (stderr ," ## Unable to collapse mesh. Exiting.\n" );
7575 return 0 ;
@@ -434,18 +434,17 @@ int MMG2D_dichoto(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int *vx) {
434434}
435435
436436/* Travel triangles and collapse short edges */
437- MMG5_int MMG2D_colelt (MMG5_pMesh mesh ,MMG5_pSol met ,int typchk ) {
437+ MMG5_int MMG2D_colelt (MMG5_pMesh mesh ,MMG5_pSol met ,int typchk , double lmax ) {
438438 MMG5_pTria pt ;
439439 MMG5_pPoint p1 ,p2 ;
440- double ux , uy , ll , hmin2 ;
440+ double ll ;
441441 MMG5_int k ;
442442 int ilist ;
443443 MMG5_int nc ;
444444 uint8_t i ,i1 ,i2 ,open ;
445445 MMG5_int list [MMG5_TRIA_LMAX + 2 ];
446446
447447 nc = 0 ;
448- hmin2 = mesh -> info .hmin * mesh -> info .hmin ;
449448
450449 for (k = 1 ; k <=mesh -> nt ; k ++ ) {
451450 pt = & mesh -> tria [k ];
@@ -476,14 +475,16 @@ MMG5_int MMG2D_colelt(MMG5_pMesh mesh,MMG5_pSol met,int typchk) {
476475
477476 /* Check length */
478477 if ( typchk == 1 ) {
478+ double ux , uy , hmin2 ;
479479 ux = p2 -> c [0 ] - p1 -> c [0 ];
480480 uy = p2 -> c [1 ] - p1 -> c [1 ];
481481 ll = ux * ux + uy * uy ;
482+ hmin2 = mesh -> info .hmin * mesh -> info .hmin ;
482483 if ( ll > hmin2 ) continue ;
483484 }
484485 else {
485486 ll = MMG2D_lencurv (mesh ,met ,pt -> v [i1 ],pt -> v [i2 ]);
486- if ( ll > MMG2D_LSHRT ) continue ;
487+ if ( ll > lmax ) continue ;
487488 }
488489
489490 /* Check whether the geometry is preserved */
@@ -564,9 +565,9 @@ int MMG2D_adptri(MMG5_pMesh mesh,MMG5_pSol met) {
564565 return 0 ;
565566 }
566567
567- nc = MMG2D_adpcol (mesh ,met );
568+ nc = MMG2D_colelt (mesh ,met , 2 , MMG2D_LOPTS );
568569 if ( nc < 0 ) {
569- fprintf (stderr ," ## Problem in function adpcol ."
570+ fprintf (stderr ," ## Problem in function colelt ."
570571 " Unable to complete mesh. Exit program.\n" );
571572 return 0 ;
572573 }
@@ -692,65 +693,6 @@ MMG5_int MMG2D_adpspl(MMG5_pMesh mesh,MMG5_pSol met) {
692693 return ns ;
693694}
694695
695- /* Analysis and collapse routine for edges in the final step of the algorithm */
696- int MMG2D_adpcol (MMG5_pMesh mesh ,MMG5_pSol met ) {
697- MMG5_pTria pt ;
698- MMG5_pPoint p1 ,p2 ;
699- double len ;
700- MMG5_int k ,nc ;
701- int ilist ;
702- int8_t i ,i1 ,i2 ,open ;
703- MMG5_int list [MMG5_TRIA_LMAX + 2 ];
704-
705- nc = 0 ;
706- for (k = 1 ; k <=mesh -> nt ; k ++ ) {
707- pt = & mesh -> tria [k ];
708- if ( !MG_EOK (pt ) || pt -> ref < 0 ) continue ;
709-
710- /* Check edge length, and attempt collapse */
711- pt -> flag = 0 ;
712- for (i = 0 ; i < 3 ; i ++ ) {
713- if ( MG_SIN (pt -> tag [i ]) ) continue ;
714-
715- open = ( mesh -> adja [3 * (k - 1 )+ 1 + i ] == 0 ) ? 1 : 0 ;
716-
717- i1 = MMG5_inxt2 [i ];
718- i2 = MMG5_iprv2 [i ];
719- p1 = & mesh -> point [pt -> v [i1 ]];
720- p2 = & mesh -> point [pt -> v [i2 ]];
721-
722- if ( MG_SIN (p1 -> tag ) || p1 -> tag & MG_NOM ) continue ;
723- else if ( p1 -> tag & MG_GEO ) {
724- if ( ! (p2 -> tag & MG_GEO ) || !(pt -> tag [i ] & MG_GEO ) ) continue ;
725- }
726- else if ( p1 -> tag & MG_REF ) {
727- if ( ! (p2 -> tag & MG_GEO || p2 -> tag & MG_REF ) || !(pt -> tag [i ] & MG_REF ) ) continue ;
728- }
729-
730- len = MMG2D_lencurv (mesh ,met ,pt -> v [i1 ],pt -> v [i2 ]);
731-
732- if ( len > MMG2D_LOPTS ) continue ;
733-
734- ilist = MMG2D_chkcol (mesh ,met ,k ,i ,list ,2 );
735-
736- if ( ilist > 3 || ( ilist == 3 && open ) ) {
737- nc += MMG2D_colver (mesh ,ilist ,list );
738- break ;
739- }
740- else if ( ilist == 3 ) {
741- nc += MMG2D_colver3 (mesh ,list );
742- break ;
743- }
744- else if ( ilist == 2 ) {
745- nc += MMG2D_colver2 (mesh ,list );
746- break ;
747- }
748- }
749- }
750-
751- return nc ;
752- }
753-
754696/* Analyze points to relocate them according to a quality criterion */
755697MMG5_int MMG2D_movtri (MMG5_pMesh mesh ,MMG5_pSol met ,int maxit ,int8_t improve ) {
756698 MMG5_pTria pt ;
0 commit comments