X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Pattern.cxx;h=eae5aee77376184e0c0b280ba077ec7d2b506e7a;hb=fd96feab4b58b9ebe8706e44b35006e0122d682e;hp=2264ba3d16503b8664ef57b2cf539d77bf44d631;hpb=f488c3c07d53aacb42ff2a143fb4a0cbfe8d5fc0;p=modules%2Fsmesh.git diff --git a/src/SMESH/SMESH_Pattern.cxx b/src/SMESH/SMESH_Pattern.cxx index 2264ba3d1..eae5aee77 100644 --- a/src/SMESH/SMESH_Pattern.cxx +++ b/src/SMESH/SMESH_Pattern.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 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 @@ -103,7 +103,7 @@ inline int getInt( const char * theSring ) int val = strtol( theSring, &ptr, 10 ); if ( ptr == theSring || // there must not be neither '.' nor ',' nor 'E' ... - (*ptr != ' ' && *ptr != '\n' && *ptr != '\0')) + (*ptr != ' ' && *ptr != '\n' && *ptr != '\0' && *ptr != '\r')) return -1; return val; @@ -540,7 +540,7 @@ static bool isMeshBoundToShape(SMESHDS_Mesh * aMeshDS, SMESHDS_SubMesh * aFaceSubmesh, const bool isMainShape) { - if ( isMainShape ) { + if ( isMainShape && aFaceSubmesh ) { // check that all faces are bound to aFaceSubmesh if ( aMeshDS->NbFaces() != aFaceSubmesh->NbElements() ) return false; @@ -620,39 +620,26 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, // --------------------------------------------------------------- // get all faces - list< const SMDS_MeshElement* > faces; - if ( nbElems > 0 ) { - SMDS_ElemIteratorPtr fIt = fSubMesh->GetElements(); - while ( fIt->more() ) { - const SMDS_MeshElement* f = fIt->next(); - if ( f && f->GetType() == SMDSAbs_Face ) - faces.push_back( f ); - } - } - else { - SMDS_FaceIteratorPtr fIt = aMeshDS->facesIterator(); - while ( fIt->more() ) - faces.push_back( fIt->next() ); - } + SMDS_ElemIteratorPtr fIt; + if ( nbElems > 0 ) + fIt = fSubMesh->GetElements(); + else + fIt = aMeshDS->elementsIterator( SMDSAbs_Face ); // put nodes of all faces into the nodePointIDMap and fill myElemPointIDs - list< const SMDS_MeshElement* >::iterator fIt = faces.begin(); - for ( ; fIt != faces.end(); ++fIt ) + while ( fIt->more() ) { + const SMDS_MeshElement* face = fIt->next(); myElemPointIDs.push_back( TElemDef() ); TElemDef& elemPoints = myElemPointIDs.back(); - int nbNodes = (*fIt)->NbCornerNodes(); + int nbNodes = face->NbCornerNodes(); for ( int i = 0;i < nbNodes; ++i ) { - const SMDS_MeshElement* node = (*fIt)->GetNode( i ); + const SMDS_MeshElement* node = face->GetNode( i ); TNodePointIDMap::iterator nIdIt = nodePointIDMap.insert( make_pair( node, -1 )).first; if ( nIdIt->second == -1 ) - { - elemPoints.push_back( iPoint ); nIdIt->second = iPoint++; - } - else - elemPoints.push_back( (*nIdIt).second ); + elemPoints.push_back( (*nIdIt).second ); } } myPoints.resize( iPoint ); @@ -716,12 +703,12 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, { if ( isClosed && ( iE == 0 || iE == *nbEinW )) { - // new wire begins; put EDGEs in eVec + // new wire begins; put wire EDGEs in eVec list::iterator eEnd = elIt; + if ( iE == *nbEinW ) + ++nbEinW; std::advance( eEnd, *nbEinW ); eVec.assign( elIt, eEnd ); - if ( iE > 0 ) - ++nbEinW; iE = 0; } TopoDS_Edge & edge = *elIt; @@ -733,7 +720,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, TopoDS_Shape v1 = TopExp::FirstVertex( edge, true ); // always FORWARD TopoDS_Shape v2 = TopExp::LastVertex( edge, true ); // always REVERSED // to make adjacent edges share key-point, we make v2 FORWARD too - // (as we have different points for same shape with different orienation) + // (as we have different points for same shape with different orientation) v2.Reverse(); // on closed face we must have REVERSED some of seam vertices @@ -745,7 +732,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, v2.Reverse(); } } - else { // on CLOSED edge (i.e. having one vertex with different orienations) + else { // on CLOSED edge (i.e. having one vertex with different orientations) for ( int is2 = 0; is2 < 2; ++is2 ) { TopoDS_Shape & v = is2 ? v2 : v1; if ( helper.IsRealSeam( v ) ) { @@ -2516,7 +2503,7 @@ bool SMESH_Pattern::Apply (const TopoDS_Face& theFace, list< TopoDS_Edge >& wire = (*wlIt); int nbEdges = wire.size(); wlIt++; - if ( wlIt == wireList.end() || (*wlIt).size() != nbEdges ) // a unique size wire + if ( wlIt != wireList.end() && (*wlIt).size() != nbEdges ) // a unique size wire { // choose the best first edge of a wire setFirstEdge( wire, id1 ); @@ -3554,13 +3541,7 @@ void SMESH_Pattern:: myPolyElems.reserve( myIdsOnBoundary.size() ); // make a set of refined elements - TIDSortedElemSet avoidSet, elemSet; - std::vector::iterator itv = myElements.begin(); - for(; itv!=myElements.end(); itv++) { - const SMDS_MeshElement* el = (*itv); - avoidSet.insert( el ); - } - //avoidSet.insert( myElements.begin(), myElements.end() ); + TIDSortedElemSet elemSet, avoidSet( myElements.begin(), myElements.end() ); map< TNodeSet, list< list< int > > >::iterator indListIt, nn_IdList; @@ -4448,7 +4429,7 @@ void SMESH_Pattern::arrangeBoundaries (list< list< TPoint* > >& boundaryList) } if ( outerBndPos != boundaryList.begin() ) - boundaryList.splice( boundaryList.begin(), boundaryList, outerBndPos, ++outerBndPos ); + boundaryList.splice( boundaryList.begin(), boundaryList, outerBndPos ); } // if nbBoundaries > 1