+ //================================================================================
+ /*!
+ * \brief [Issue #19913] Modify _hexLinks._splits to prevent creating overlapping volumes
+ */
+ //================================================================================
+
+ void Hexahedron::preventVolumesOverlapping()
+ {
+ // Cut off a quadrangle corner if two links sharing the corner
+ // are shared by same two solids, in this case each of solids gets
+ // a triangle for it-self.
+ std::vector< TGeomID > soIDs[4];
+ for ( int iF = 0; iF < 6; ++iF ) // loop on 6 sides of a hexahedron
+ {
+ _Face& quad = _hexQuads[ iF ] ;
+
+ int iFOpposite = iF + ( iF % 2 ? -1 : 1 );
+ _Face& quadOpp = _hexQuads[ iFOpposite ] ;
+
+ int nbSides = 0, nbSidesOpp = 0;
+ for ( int iE = 0; iE < 4; ++iE ) // loop on 4 sides of a quadrangle
+ {
+ nbSides += ( quad._links [ iE ].NbResultLinks() > 0 );
+ nbSidesOpp += ( quadOpp._links[ iE ].NbResultLinks() > 0 );
+ }
+ if ( nbSides < 4 || nbSidesOpp != 2 )
+ continue;
+
+ for ( int iE = 0; iE < 4; ++iE )
+ {
+ soIDs[ iE ].clear();
+ _Node* n = quad._links[ iE ].FirstNode();
+ if ( n->_intPoint && n->_intPoint->_faceIDs.size() )
+ soIDs[ iE ] = _grid->GetSolidIDs( n->_intPoint->_faceIDs[0] );
+ }
+ if ((( soIDs[0].size() >= 2 ) +
+ ( soIDs[1].size() >= 2 ) +
+ ( soIDs[2].size() >= 2 ) +
+ ( soIDs[3].size() >= 2 ) ) < 3 )
+ continue;
+
+ bool done = false;
+ for ( int i = 0; i < 4; ++i )
+ {
+ int i1 = _grid->_helper->WrapIndex( i + 1, 4 );
+ int i2 = _grid->_helper->WrapIndex( i + 2, 4 );
+ int i3 = _grid->_helper->WrapIndex( i + 3, 4 );
+ if ( soIDs[i1].size() == 2 && soIDs[i ] != soIDs[i1] &&
+ soIDs[i2].size() == 2 && soIDs[i1] == soIDs[i2] &&
+ soIDs[i3].size() == 2 && soIDs[i2] == soIDs[i3] )
+ {
+ quad._links[ i1 ]._link->_splits.clear();
+ quad._links[ i2 ]._link->_splits.clear();
+ done = true;
+ break;
+ }
+ }
+ if ( done )
+ break;
+ }
+ return;
+ } // preventVolumesOverlapping()
+