X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_MeshEditor.cxx;h=2104c79201a169a71d80d56986caf70d78b988c9;hp=284e83277a16a8bd6d0944383ba4387163b8fac0;hb=6472eab132825fec572beda8276947593f85ffa1;hpb=385d4cede5f752d0eec26c306f3b5e14511e2a3d diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 284e83277..2104c7920 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -161,8 +161,7 @@ SMESH_MeshEditor::ElemFeatures::Init( const SMDS_MeshElement* elem, bool basicOn myIsQuad = elem->IsQuadratic(); if ( myType == SMDSAbs_Volume && !basicOnly ) { - vector quant = static_cast( elem )->GetQuantities(); - myPolyhedQuantities.swap( quant ); + myPolyhedQuantities = static_cast( elem )->GetQuantities(); } } } @@ -1093,19 +1092,37 @@ bool SMESH_MeshEditor::Reorient (const SMDS_MeshElement * theElem) MESSAGE("Warning: bad volumic element"); return false; } - const int nbFaces = aPolyedre->NbFaces(); + SMDS_VolumeTool vTool( aPolyedre ); + const int nbFaces = vTool.NbFaces(); + vector quantities( nbFaces ); vector poly_nodes; - vector quantities (nbFaces); - // reverse each face of the polyedre - for (int iface = 1; iface <= nbFaces; iface++) { - int inode, nbFaceNodes = aPolyedre->NbFaceNodes(iface); - quantities[iface - 1] = nbFaceNodes; + // check if all facets are oriented equally + bool sameOri = true; + vector& facetOri = quantities; // keep orientation in quantities so far + for (int iface = 0; iface < nbFaces; iface++) + { + facetOri[ iface ] = vTool.IsFaceExternal( iface ); + if ( facetOri[ iface ] != facetOri[ 0 ]) + sameOri = false; + } - for (inode = nbFaceNodes; inode >= 1; inode--) { - const SMDS_MeshNode* curNode = aPolyedre->GetFaceNode(iface, inode); - poly_nodes.push_back(curNode); - } + // reverse faces of the polyhedron + int neededOri = sameOri ? 1 - facetOri[0] : 1; + poly_nodes.reserve( vTool.NbNodes() ); + for ( int iface = 0; iface < nbFaces; iface++ ) + { + int nbFaceNodes = vTool.NbFaceNodes( iface ); + const SMDS_MeshNode** nodes = vTool.GetFaceNodes( iface ); + bool toReverse = ( facetOri[ iface ] != neededOri ); + + quantities[ iface ] = nbFaceNodes; + + if ( toReverse ) + for ( int inode = nbFaceNodes - 1; inode >= 0; inode-- ) + poly_nodes.push_back( nodes[ inode ]); + else + poly_nodes.insert( poly_nodes.end(), nodes, nodes + nbFaceNodes ); } return GetMeshDS()->ChangePolyhedronNodes( theElem, poly_nodes, quantities ); } @@ -5850,6 +5867,11 @@ SMESH_MeshEditor::ExtrusionSweep (TIDSortedElemSet theElemSets[2], } else { + if ( theParams.ToMakeBoundary() ) + { + GetMeshDS()->Modified(); + throw SALOME_Exception( SMESH_Comment("Can't extrude node #") << node->GetID() ); + } break; // newNodesItVec will be shorter than nbNodes } } @@ -6367,7 +6389,7 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems, * \param [in] theValue - offset value * \param [out] theTgtMesh - a mesh to add offset elements to * \param [in] theMakeGroups - to generate groups - * \return PGroupIDs - IDs of created groups + * \return PGroupIDs - IDs of created groups. NULL means failure */ //================================================================================ @@ -6454,6 +6476,8 @@ SMESH_MeshEditor::PGroupIDs SMESH_MeshEditor::Offset( TIDSortedElemSet & theElem PGroupIDs newGroupIDs; if ( theMakeGroups ) newGroupIDs = generateGroups( srcNodes, srcElems, "offset", theTgtMesh, false ); + else + newGroupIDs.reset( new std::list< int > ); return newGroupIDs; } @@ -7453,6 +7477,8 @@ void SMESH_MeshEditor::FindEqualElements( TIDSortedElemSet & theElements, while ( elemIt->more() ) { const SMDS_MeshElement* curElem = elemIt->next(); + if ( curElem->IsNull() ) + continue; ComparableElement compElem = curElem; // check uniqueness const ComparableElement& elemInSet = mapOfElements.Added( compElem ); @@ -7681,9 +7707,9 @@ bool SMESH_MeshEditor::FindFreeBorder (const SMDS_MeshNode* theFirst // push_back the best free border cNL = & contNodes[ contNodes[0].empty() ? 1 : 0 ]; cFL = & contFaces[ contFaces[0].empty() ? 1 : 0 ]; - theNodes.pop_back(); // remove nIgnore + //theNodes.pop_back(); // remove nIgnore theNodes.pop_back(); // remove nStart - theFaces.pop_back(); // remove curElem + //theFaces.pop_back(); // remove curElem theNodes.splice( theNodes.end(), *cNL ); theFaces.splice( theFaces.end(), *cFL ); return true; @@ -9853,10 +9879,10 @@ SMESH_MeshEditor::FindMatchingNodes(set& theSide1, set * faceSetPtr[] = { &theSide1, &theSide2 }; nReplaceMap.clear(); - if ( theFirstNode1 != theFirstNode2 ) - nReplaceMap.insert( make_pair( theFirstNode1, theFirstNode2 )); - if ( theSecondNode1 != theSecondNode2 ) - nReplaceMap.insert( make_pair( theSecondNode1, theSecondNode2 )); + //if ( theFirstNode1 != theFirstNode2 ) + nReplaceMap.insert( make_pair( theFirstNode1, theFirstNode2 )); + //if ( theSecondNode1 != theSecondNode2 ) + nReplaceMap.insert( make_pair( theSecondNode1, theSecondNode2 )); set< SMESH_TLink > linkSet; // set of nodes where order of nodes is ignored linkSet.insert( SMESH_TLink( theFirstNode1, theSecondNode1 )); @@ -12540,8 +12566,8 @@ int SMESH_MeshEditor::MakeBoundaryMesh(const TIDSortedElemSet& elements, for ( inode = 0; inode < srcNodes.size(); ++inode ) tgtNodes[inode] = getNodeWithSameID( tgtMeshDS, srcNodes[inode] ); if ( /*aroundElements && */tgtEditor.GetMeshDS()->FindElement( tgtNodes, - missType, - /*noMedium=*/false)) + missType, + /*noMedium=*/false)) continue; tgtEditor.AddElement( tgtNodes, elemKind.SetPoly( tgtNodes.size()/(iQuad+1) > 4 )); ++nbAddedBnd; @@ -12551,8 +12577,8 @@ int SMESH_MeshEditor::MakeBoundaryMesh(const TIDSortedElemSet& elements, { TConnectivity& nodes = missingBndElems[ i ]; if ( /*aroundElements && */tgtEditor.GetMeshDS()->FindElement( nodes, - missType, - /*noMedium=*/false)) + missType, + /*noMedium=*/false)) continue; SMDS_MeshElement* newElem = tgtEditor.AddElement( nodes, elemKind.SetPoly( nodes.size()/(iQuad+1) > 4 ));