X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMDS%2FSMDS_VolumeTool.cxx;h=b86dc16c377a99bae4f78b2a322e75bc97aecd23;hp=982942827e4894c135d20277b890179ff61fdc6c;hb=b22e182dd1a2c30be324b21074158390d00714b3;hpb=5030955be884848b884ceb675e6dc35b0d36ede8 diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index 982942827..b86dc16c3 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -43,6 +43,8 @@ using namespace std; +namespace +{ // ====================================================== // Node indices in faces depending on volume orientation // making most faces normals external @@ -132,8 +134,6 @@ static int Penta_nbN [] = { 3, 3, 4, 4, 4 }; // / | / | // N4+----------+N7 | // | | | | HEXAHEDRON -// | | | | -// | | | | // | N1+------|---+N2 // | / | / // | / | / @@ -155,6 +155,7 @@ static int Hexa_RE [6][5] = { // REVERSED -> EXTERNAL { 3, 7, 6, 2, 3 }, { 0, 4, 7, 3, 0 }}; static int Hexa_nbN [] = { 4, 4, 4, 4, 4, 4 }; +static int Hexa_oppF[] = { 1, 0, 4, 5, 2, 3 }; // oppopsite facet indices /* // N8 +------+ N9 @@ -279,7 +280,7 @@ static int QuadPyram_nbN [] = { 8, 6, 6, 6, 6 }; */ static int QuadPenta_F [5][9] = { // FORWARD { 0, 6, 1, 7, 2, 8, 0, 0, 0 }, - { 3,11, 5, 10,4, 9, 3, 3, 3 }, + { 3, 11,5, 10,4, 9, 3, 3, 3 }, { 0, 12,3, 9, 4, 13,1, 6, 0 }, { 1, 13,4, 10,5, 14,2, 7, 1 }, { 0, 8, 2, 14,5, 11,3, 12,0 }}; @@ -350,8 +351,6 @@ static int TriQuadHexa_nbN [] = { 9, 9, 9, 9, 9, 9 }; // ======================================================== // to perform some calculations without linkage to CASCADE // ======================================================== -namespace -{ struct XYZ { double x; double y; @@ -1147,12 +1146,7 @@ int SMDS_VolumeTool::GetOppFaceIndex( int faceIndex ) const break; case 20: case 27: - if ( faceIndex <= 1 ) // top or bottom - ind = 1 - faceIndex; - else { - const int nbSideFaces = myAllFacesNbNodes[0] / 2; - ind = ( faceIndex - nbHoriFaces + nbSideFaces/2 ) % nbSideFaces + nbHoriFaces; - } + ind = GetOppFaceIndexOfHex( faceIndex ); break; default:; } @@ -1160,6 +1154,16 @@ int SMDS_VolumeTool::GetOppFaceIndex( int faceIndex ) const return ind; } +//======================================================================= +//function : GetOppFaceIndexOfHex +//purpose : Return index of the opposite face of the hexahedron +//======================================================================= + +int SMDS_VolumeTool::GetOppFaceIndexOfHex( int faceIndex ) +{ + return Hexa_oppF[ faceIndex ]; +} + //======================================================================= //function : IsLinked //purpose : return true if theNode1 is linked with theNode2 @@ -1494,6 +1498,7 @@ double SMDS_VolumeTool::MaxLinearSize2() const //================================================================================ /*! * \brief fast check that only one volume is build on the face nodes + * This check is valid for conformal meshes only */ //================================================================================ @@ -1506,24 +1511,32 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex, const SMDS_MeshElement** otherV const SMDS_MeshNode** nodes = GetFaceNodes( faceIndex ); - // a set of facet nodes w/o medium ones and w/o nodes[0] - set< const SMDS_MeshNode* > nodeSet; - const int di = myVolume->IsQuadratic() ? 2 : 1; - for ( int i = di; i < myFaceNbNodes; i += di ) - nodeSet.insert( nodes[i] ); + const int di = myVolume->IsQuadratic() ? 2 : 1; + const int nbN = ( myFaceNbNodes/di <= 4 && !IsPoly()) ? 3 : myFaceNbNodes/di; // nb nodes to check SMDS_ElemIteratorPtr eIt = nodes[0]->GetInverseElementIterator( SMDSAbs_Volume ); - while ( eIt->more() ) { + while ( eIt->more() ) + { const SMDS_MeshElement* vol = eIt->next(); - if ( vol != myVolume ) { - size_t nbShared = 0; - SMDS_NodeIteratorPtr nIt = vol->nodeIterator(); - while ( nIt->more() ) - if (( nbShared += nodeSet.count( nIt->next() )) == nodeSet.size() ) - { - if ( otherVol ) *otherVol = vol; - return !isFree; - } + if ( vol == myVolume ) + continue; + int iN; + for ( iN = 1; iN < nbN; ++iN ) + if ( vol->GetNodeIndex( nodes[ iN*di ]) < 0 ) + break; + if ( iN == nbN ) // nbN nodes are shared with vol + { + // if ( vol->IsPoly() || vol->NbFaces() > 6 ) // vol is polyhed or hex prism + // { + // int nb = myFaceNbNodes; + // if ( myVolume->GetEntityType() != vol->GetEntityType() ) + // nb -= ( GetCenterNodeIndex(0) > 0 ); + // set faceNodes( nodes, nodes + nb ); + // if ( SMDS_VolumeTool( vol ).GetFaceIndex( faceNodes ) < 0 ) + // continue; + // } + if ( otherVol ) *otherVol = vol; + return !isFree; } } if ( otherVol ) *otherVol = 0; @@ -1656,16 +1669,38 @@ bool SMDS_VolumeTool::IsFreeFaceAdv( int faceIndex, const SMDS_MeshElement** oth //purpose : Return index of a face formed by theFaceNodes //======================================================================= -int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodes ) const +int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodes, + const int theFaceIndexHint ) const { + if ( theFaceIndexHint >= 0 ) + { + int nbNodes = NbFaceNodes( theFaceIndexHint ); + if ( nbNodes == (int) theFaceNodes.size() ) + { + const SMDS_MeshNode** nodes = GetFaceNodes( theFaceIndexHint ); + while ( nbNodes ) + if ( theFaceNodes.count( nodes[ nbNodes-1 ])) + --nbNodes; + else + break; + if ( nbNodes == 0 ) + return theFaceIndexHint; + } + } for ( int iFace = 0; iFace < myNbFaces; iFace++ ) { - const int nbNodes = NbFaceNodes( iFace ); + if ( iFace == theFaceIndexHint ) + continue; + int nbNodes = NbFaceNodes( iFace ); if ( nbNodes == (int) theFaceNodes.size() ) { const SMDS_MeshNode** nodes = GetFaceNodes( iFace ); - set nodeSet( nodes, nodes + nbNodes); - if ( theFaceNodes == nodeSet ) + while ( nbNodes ) + if ( theFaceNodes.count( nodes[ nbNodes-1 ])) + --nbNodes; + else + break; + if ( nbNodes == 0 ) return iFace; } }