X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_VolumeTool.cxx;h=001387c5f4daa5b10efcb231c31277645c5cc80d;hb=e6d6fd4aa127fce6f9750cc84b025a333a3c78a3;hp=2c7c401cb00ecdb4ce3f64d4393b4b927a97804d;hpb=f5016d85b7b4b88623723027a1585c6414c4dc66;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index 2c7c401cb..001387c5f 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 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 @@ -132,8 +132,6 @@ static int Penta_nbN [] = { 3, 3, 4, 4, 4 }; // / | / | // N4+----------+N7 | // | | | | HEXAHEDRON -// | | | | -// | | | | // | N1+------|---+N2 // | / | / // | / | / @@ -155,6 +153,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 +278,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 }}; @@ -292,27 +291,27 @@ static int QuadPenta_RE [5][9] = { // REVERSED -> EXTERNAL static int QuadPenta_nbN [] = { 6, 6, 8, 8, 8 }; /* -// 13 -// N5+-----+-----+N6 -// /| /| -// 12+ | 14+ | -// / | / | -// N4+-----+-----+N7 | QUADRATIC -// | | 15 | | HEXAHEDRON -// | | | | -// | 17+ | +18 -// | | | | -// | | | | -// | | | | -// 16+ | +19 | -// | | | | -// | | 9 | | -// | N1+-----+-|---+N2 -// | / | / -// | +8 | +10 -// |/ |/ -// N0+-----+-----+N3 -// 11 +// 13 +// N5+-----+-----+N6 +-----+-----+ +// /| /| /| /| +// 12+ | 14+ | + | +25 + | +// / | / | / | / | +// N4+-----+-----+N7 | QUADRATIC +-----+-----+ | Central nodes +// | | 15 | | HEXAHEDRON | | | | of tri-quadratic +// | | | | | | | | HEXAHEDRON +// | 17+ | +18 | + 22+ | + +// | | | | |21 | | | +// | | | | | + | 26+ | + | +// | | | | | | |23 | +// 16+ | +19 | + | +24 + | +// | | | | | | | | +// | | 9 | | | | | | +// | N1+-----+-|---+N2 | +-----+-|---+ +// | / | / | / | / +// | +8 | +10 | + 20+ | + +// |/ |/ |/ |/ +// N0+-----+-----+N3 +-----+-----+ +// 11 */ static int QuadHexa_F [6][9] = { // FORWARD { 0, 8, 1, 9, 2, 10,3, 11,0 }, // all face normals are external, @@ -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 @@ -1493,9 +1497,7 @@ double SMDS_VolumeTool::MaxLinearSize2() const //================================================================================ /*! - * \brief check that only one volume is build on the face nodes - * - * If a face is shared by one of , it is considered free + * \brief fast check that only one volume is build on the face nodes */ //================================================================================ @@ -1503,6 +1505,42 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex, const SMDS_MeshElement** otherV { const bool isFree = true; + if (!setFace( faceIndex )) + return !isFree; + + const SMDS_MeshNode** nodes = GetFaceNodes( faceIndex ); + + const int di = myVolume->IsQuadratic() ? 2 : 1; + const SMDS_MeshNode* n1 = nodes[di*0]; + const SMDS_MeshNode* n2 = nodes[di*1]; + const SMDS_MeshNode* n3 = nodes[di*2]; + + SMDS_ElemIteratorPtr eIt = n1->GetInverseElementIterator( SMDSAbs_Volume ); + SMDS_ElemIteratorPtr nIt; + while ( eIt->more() ) { + const SMDS_MeshElement* vol = eIt->next(); + if ( vol != myVolume && + vol->GetNodeIndex( n2 ) >= 0 && + vol->GetNodeIndex( n3 ) >= 0 ) + { + if ( otherVol ) *otherVol = vol; + return !isFree; + } + } + if ( otherVol ) *otherVol = 0; + return isFree; +} + +//================================================================================ +/*! + * \brief Thorough check that only one volume is build on the face nodes + */ +//================================================================================ + +bool SMDS_VolumeTool::IsFreeFaceAdv( int faceIndex, const SMDS_MeshElement** otherVol/*=0*/ ) const +{ + const bool isFree = true; + if (!setFace( faceIndex )) return !isFree; @@ -1619,16 +1657,40 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex, const SMDS_MeshElement** otherV //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 { - for ( int iFace = 0; iFace < myNbFaces; iFace++ ) { - const SMDS_MeshNode** nodes = GetFaceNodes( iFace ); - int nbFaceNodes = NbFaceNodes( iFace ); - set nodeSet; - for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) - nodeSet.insert( nodes[ iNode ] ); - if ( theFaceNodes == nodeSet ) - return iFace; + 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++ ) + { + if ( iFace == theFaceIndexHint ) + continue; + int nbNodes = NbFaceNodes( iFace ); + if ( nbNodes == (int) theFaceNodes.size() ) + { + const SMDS_MeshNode** nodes = GetFaceNodes( iFace ); + while ( nbNodes ) + if ( theFaceNodes.count( nodes[ nbNodes-1 ])) + --nbNodes; + else + break; + if ( nbNodes == 0 ) + return iFace; + } } return -1; }