X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_HexaFromSkin_3D.cxx;h=403de38f6e22f4b259b0bec2d962dda786b1e81d;hb=a5ebdbe87e2c7f21e10a0db66022e6ca0f9ad1c5;hp=58a90931c73d32924e057b65e8d2cf16bf66de48;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_HexaFromSkin_3D.cxx b/src/StdMeshers/StdMeshers_HexaFromSkin_3D.cxx index 58a90931c..403de38f6 100644 --- a/src/StdMeshers/StdMeshers_HexaFromSkin_3D.cxx +++ b/src/StdMeshers/StdMeshers_HexaFromSkin_3D.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // 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 @@ -25,14 +25,18 @@ #include "SMDS_VolumeOfNodes.hxx" #include "SMDS_VolumeTool.hxx" +#include "SMESHDS_Mesh.hxx" #include "SMESH_Block.hxx" +#include "SMESH_Mesh.hxx" +#include "SMESH_MeshAlgos.hxx" #include "SMESH_MesherHelper.hxx" #include -//#include "utilities.h" #include +using namespace std; + // Define error message and _MYDEBUG_ if needed #ifdef _DEBUG_ #define BAD_MESH_ERR \ @@ -107,14 +111,14 @@ namespace return true; set nodesInInverseFaces; - SMDS_ElemIteratorPtr fIt = n->GetInverseElementIterator(SMDSAbs_Face ); + SMDS_ElemIteratorPtr fIt = n->GetInverseElementIterator( SMDSAbs_Face ); while ( fIt->more() ) { const SMDS_MeshElement* face = fIt->next(); nodesInInverseFaces.insert( face->begin_nodes(), face->end_nodes() ); } - return nodesInInverseFaces.size() != ( 6 + (nbF/2-1)*3 ); + return (int)nodesInInverseFaces.size() != ( 6 + (nbF/2-1)*3 ); } //================================================================================ @@ -141,7 +145,7 @@ namespace //================================================================================ /*! - * \brief Convertor of a pair of integers to a sole index + * \brief Converter of a pair of integers to a sole index */ struct _Indexer { @@ -152,7 +156,7 @@ namespace }; //================================================================================ /*! - * \brief Oriented convertor of a pair of integers to a sole index + * \brief Oriented converter of a pair of integers to a sole index */ class _OrientedIndexer : public _Indexer { @@ -212,7 +216,7 @@ namespace int _nbBlocksFound; #ifdef _DEBUG_ // want to get SIGSEGV in case of invalid index -#define _grid_access_(pobj, i) pobj->_grid[ ((i) < pobj->_grid.size()) ? i : int(1e100)] +#define _grid_access_(pobj, i) pobj->_grid[ ((i) < (int)pobj->_grid.size()) ? i : int(1e100)] #else #define _grid_access_(pobj, i) pobj->_grid[ i ] #endif @@ -269,8 +273,8 @@ namespace //!< safely return a node by XY const SMDS_MeshNode* node(int x, int y) const { - int i = _index( x, y ); - return ( i < 0 || i >= _side->_grid.size()) ? 0 : _side->_grid[i]; + size_t i = _index( x, y ); + return ( i >= _side->_grid.size() ) ? 0 : _side->_grid[i]; } //!< Return an edge SMESH_OrientedLink edge(EQuadEdge edge) const @@ -372,7 +376,7 @@ namespace //================================================================================ /*! - * \brief Find and return number of submeshes corresponding to blocks + * \brief Find blocks and return their number */ //================================================================================ @@ -382,7 +386,7 @@ namespace // Find a node at any block corner - SMDS_NodeIteratorPtr nIt = meshDS->nodesIterator(/*idInceasingOrder=*/true); + SMDS_NodeIteratorPtr nIt = meshDS->nodesIterator(); if ( !nIt->more() ) return error("Empty mesh"); const SMDS_MeshNode* nCorner = 0; @@ -421,7 +425,7 @@ namespace _allSides.push_back( _BlockSide() ); _BlockSide& side = _allSides.back(); - if ( !fillSide( side, face, *corner ) ) + if ( !fillSide( side, face, *corner )) { if ( !_error.empty() ) return false; @@ -522,7 +526,7 @@ namespace ok = block.setSide( i, findBlockSide( B_FRONT, edgeOfFront[i], edgeOfAdj[i], advAnalys, sidesAround)); // try to find a BACK side by a TOP one - if ( ok || !advAnalys) + if ( ok || !advAnalys ) if ( !block._side[B_BACK] && block._side[B_TOP] ) ok = block.setSide( B_BACK, findBlockSide( B_TOP, Q_TOP, Q_TOP, advAnalys, sidesAround )); @@ -533,7 +537,7 @@ namespace { // check if just found block is same as one of previously found blocks bool isSame = false; - for ( int i = 1; i < _blocks.size() && !isSame; ++i ) + for ( size_t i = 1; i < _blocks.size() && !isSame; ++i ) isSame = ( block._corners == _blocks[i-1]._corners ); ok = !isSame; } @@ -584,7 +588,7 @@ namespace const SMDS_MeshElement* cornerQuad, const SMDS_MeshNode* nCorner) { - // Find out size of block side mesured in nodes and by the way find two rows + // Find out size of block side measured in nodes and by the way find two rows // of nodes in two directions. int x, y, nbX, nbY; @@ -606,12 +610,12 @@ namespace side._index._ySize = verRow1.size(); side._grid.resize( side._index.size(), NULL ); - for ( x = 0; x < horRow1.size(); ++x ) + for ( x = 0; x < nbX; ++x ) { side.setNode( x, 0, horRow1[x] ); side.setNode( x, 1, horRow2[x] ); } - for ( y = 0; y < verRow1.size(); ++y ) + for ( y = 0; y < nbY; ++y ) { side.setNode( 0, y, verRow1[y] ); side.setNode( 1, y, verRow2[y] ); @@ -635,7 +639,7 @@ namespace const SMDS_MeshNode* n1down = side.getNode( 0, y-1 ); const SMDS_MeshNode* n2down = side.getNode( 1, y-1 ); avoidSet.clear(); avoidSet.insert( firstQuad ); - firstQuad = SMESH_MeshEditor::FindFaceInSet( n1down, n2down, emptySet, avoidSet, + firstQuad = SMESH_MeshAlgos::FindFaceInSet( n1down, n2down, emptySet, avoidSet, &i1down, &i2down); if ( !isQuadrangle( firstQuad )) return BAD_MESH_ERR; @@ -648,7 +652,7 @@ namespace x = 1; while ( ++x < nbX ) { - const SMDS_MeshElement* quad = SMESH_MeshEditor::FindFaceInSet( n2up, n2down, emptySet, + const SMDS_MeshElement* quad = SMESH_MeshAlgos::FindFaceInSet( n2up, n2down, emptySet, avoidSet, &i2up, &i2down); if ( !isQuadrangle( quad )) return BAD_MESH_ERR; @@ -725,7 +729,9 @@ namespace if ( !n ) return false; prevSide = nextSide; - nbChainLinks++; + + if ( ++nbChainLinks > NB_QUAD_SIDES ) + return false; } return ( n == n2 && nbChainLinks == NB_QUAD_SIDES ); @@ -942,7 +948,7 @@ namespace while ( !isCornerNode( n2 ) ) { avoidSet.clear(); avoidSet.insert( quad ); - quad = SMESH_MeshEditor::FindFaceInSet( n1, n2, emptySet, avoidSet, &i1, &i2 ); + quad = SMESH_MeshAlgos::FindFaceInSet( n1, n2, emptySet, avoidSet, &i1, &i2 ); if ( !isQuadrangle( quad )) return BAD_MESH_ERR; @@ -1003,6 +1009,9 @@ namespace SMESH_OrientedLink eAdja = _side[ adjacent[i] ].edge( edgeAdj[i] ); ok = ( eBack == eAdja ); } + ok = ok && ( _side[ B_BOTTOM ]._index.size() == _side[ B_TOP ]._index.size() && + _side[ B_RIGHT ]._index.size() == _side[ B_LEFT ]._index.size() && + _side[ B_FRONT ]._index.size() == _side[ B_BACK ]._index.size() ); return ok; } @@ -1016,13 +1025,11 @@ namespace StdMeshers_HexaFromSkin_3D::StdMeshers_HexaFromSkin_3D(int hypId, int studyId, SMESH_Gen* gen) :SMESH_3D_Algo(hypId, studyId, gen) { - MESSAGE("StdMeshers_HexaFromSkin_3D::StdMeshers_HexaFromSkin_3D"); _name = "HexaFromSkin_3D"; } StdMeshers_HexaFromSkin_3D::~StdMeshers_HexaFromSkin_3D() { - MESSAGE("StdMeshers_HexaFromSkin_3D::~StdMeshers_HexaFromSkin_3D"); } //================================================================================ @@ -1250,7 +1257,7 @@ bool StdMeshers_HexaFromSkin_3D::Evaluate(SMESH_Mesh & aMesh, int entity = secondOrder ? SMDSEntity_Quad_Hexa : SMDSEntity_Hexa; vector& nbByType = aResMap[ aMesh.GetSubMesh( aShape )]; - if ( entity >= nbByType.size() ) + if ( entity >= (int) nbByType.size() ) nbByType.resize( SMDSEntity_Last, 0 ); for ( int i = 0; i < nbBlocks; ++i )