X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Hexa_3D.cxx;h=0271fc41ce80197d965c1425b2d1ef587339a42d;hp=92f00af3a8e73c604addc0deffc5afcd4ca9bcb0;hb=38ef3e316cd161424fb1156df3c223ad9de29780;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6 diff --git a/src/StdMeshers/StdMeshers_Hexa_3D.cxx b/src/StdMeshers/StdMeshers_Hexa_3D.cxx index 92f00af3a..0271fc41c 100644 --- a/src/StdMeshers/StdMeshers_Hexa_3D.cxx +++ b/src/StdMeshers/StdMeshers_Hexa_3D.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 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 @@ -222,8 +222,8 @@ namespace * \brief Finds FaceQuadStruct having a side equal to a given one and rearranges * the found FaceQuadStruct::side to have the given side at a Q_BOTTOM place */ - FaceQuadStructPtr getQuadWithBottom( StdMeshers_FaceSide* side, - FaceQuadStructPtr quad[ 6 ]) + FaceQuadStructPtr getQuadWithBottom( StdMeshers_FaceSidePtr side, + FaceQuadStructPtr quad[ 6 ]) { FaceQuadStructPtr foundQuad; for ( int i = 1; i < 6; ++i ) @@ -231,7 +231,7 @@ namespace if ( !quad[i] ) continue; for ( unsigned iS = 0; iS < quad[i]->side.size(); ++iS ) { - const StdMeshers_FaceSide* side2 = quad[i]->side[iS]; + const StdMeshers_FaceSidePtr side2 = quad[i]->side[iS]; if (( side->FirstVertex().IsSame( side2->FirstVertex() ) || side->FirstVertex().IsSame( side2->LastVertex() )) && @@ -241,7 +241,7 @@ namespace { if ( iS != Q_BOTTOM ) { - vector< StdMeshers_FaceSide*> newSides; + vector< FaceQuadStruct::Side > newSides; for ( unsigned j = iS; j < quad[i]->side.size(); ++j ) newSides.push_back( quad[i]->side[j] ); for ( unsigned j = 0; j < iS; ++j ) @@ -287,15 +287,15 @@ namespace //============================================================================= /*! * Generates hexahedron mesh on hexaedron like form using algorithm from - * "Application de l'interpolation transfinie à la création de maillages + * "Application de l'interpolation transfinie � la cr�ation de maillages * C0 ou G1 continus sur des triangles, quadrangles, tetraedres, pentaedres - * et hexaedres déformés." + * et hexaedres d�form�s." * Alain PERONNET - 8 janvier 1999 */ //============================================================================= bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, - const TopoDS_Shape & aShape)// throw(SALOME_Exception) + const TopoDS_Shape & aShape) { // PAL14921. Enable catching std::bad_alloc and Standard_OutOfMemory outside //Unexpect aCatch(SalomeException); @@ -371,20 +371,12 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, for ( int i = 0; i < 6; ++i ) { const TopoDS_Face& sideF = aCubeSide[i]._quad->face; - if ( SMESHDS_SubMesh* smDS = meshDS->MeshElements( sideF )) + if ( !SMESH_MesherHelper::IsSameElemGeometry( meshDS->MeshElements( sideF ), + SMDSGeom_QUADRANGLE, + /*nullSubMeshRes=*/false )) { - bool isAllQuad = true; - SMDS_ElemIteratorPtr fIt = smDS->GetElements(); - while ( fIt->more() && isAllQuad ) - { - const SMDS_MeshElement* f = fIt->next(); - isAllQuad = ( f->NbCornerNodes() == 4 ); - } - if ( !isAllQuad ) - { - SMESH_ComputeErrorPtr err = ComputePentahedralMesh(aMesh, aShape, proxymesh.get()); - return error( err ); - } + SMESH_ComputeErrorPtr err = ComputePentahedralMesh(aMesh, aShape, proxymesh.get()); + return error( err ); } } } @@ -399,7 +391,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, for ( int i = 0; i < 6; ++i ) { const TopoDS_Face& F = aCubeSide[i]._quad->face; - StdMeshers_FaceSide* baseQuadSide = aCubeSide[i]._quad->side[ Q_BOTTOM ]; + StdMeshers_FaceSidePtr baseQuadSide = aCubeSide[i]._quad->side[ Q_BOTTOM ]; list baseEdges( baseQuadSide->Edges().begin(), baseQuadSide->Edges().end() ); // assure correctness of node positions on baseE: @@ -749,6 +741,39 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper return error( algo->GetComputeError()); } +//================================================================================ +/*! + * \brief Return true if the algorithm can mesh this shape + * \param [in] aShape - shape to check + * \param [in] toCheckAll - if true, this check returns OK if all shapes are OK, + * else, returns OK if at least one shape is OK + */ +//================================================================================ + +bool StdMeshers_Hexa_3D::IsApplicable( const TopoDS_Shape & aShape, bool toCheckAll ) +{ + TopExp_Explorer exp0( aShape, TopAbs_SOLID ); + if ( !exp0.More() ) return false; + + for ( ; exp0.More(); exp0.Next() ) + { + int nbFoundShells = 0; + TopExp_Explorer exp1( exp0.Current(), TopAbs_SHELL ); + for ( ; exp1.More(); exp1.Next(), ++nbFoundShells) + if ( nbFoundShells == 2 ) break; + if ( nbFoundShells != 1 ) { + if ( toCheckAll ) return false; + continue; + } + exp1.Init( exp0.Current(), TopAbs_FACE ); + int nbEdges = SMESH_MesherHelper::Count( exp1.Current(), TopAbs_EDGE, /*ignoreSame=*/true ); + bool ok = ( nbEdges > 3 ); + if ( toCheckAll && !ok ) return false; + if ( !toCheckAll && ok ) return true; + } + return toCheckAll; +}; + //======================================================================= //function : ComputePentahedralMesh //purpose :