22599: EDF 8159 SMESH: Bad groups created by extrusion

Attemp no.2
This commit is contained in:
eap 2014-05-29 18:12:12 +04:00
parent a4f4aea846
commit fb5ce7193e
2 changed files with 15 additions and 18 deletions

View File

@ -6428,7 +6428,7 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
if ( ( theMakeGroups && theCopy ) || if ( ( theMakeGroups && theCopy ) ||
( theMakeGroups && theTargetMesh ) ) ( theMakeGroups && theTargetMesh ) )
newGroupIDs = generateGroups( srcNodes, srcElems, groupPostfix, theTargetMesh ); newGroupIDs = generateGroups( srcNodes, srcElems, groupPostfix, theTargetMesh, false );
return newGroupIDs; return newGroupIDs;
} }
@ -6436,9 +6436,11 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
//======================================================================= //=======================================================================
/*! /*!
* \brief Create groups of elements made during transformation * \brief Create groups of elements made during transformation
* \param nodeGens - nodes making corresponding myLastCreatedNodes * \param nodeGens - nodes making corresponding myLastCreatedNodes
* \param elemGens - elements making corresponding myLastCreatedElems * \param elemGens - elements making corresponding myLastCreatedElems
* \param postfix - to append to names of new groups * \param postfix - to append to names of new groups
* \param targetMesh - mesh to create groups in
* \param topPresent - is there "top" elements that are created by sweeping
*/ */
//======================================================================= //=======================================================================
@ -6446,7 +6448,8 @@ SMESH_MeshEditor::PGroupIDs
SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens, SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
const SMESH_SequenceOfElemPtr& elemGens, const SMESH_SequenceOfElemPtr& elemGens,
const std::string& postfix, const std::string& postfix,
SMESH_Mesh* targetMesh) SMESH_Mesh* targetMesh,
const bool topPresent)
{ {
PGroupIDs newGroupIDs( new list<int> ); PGroupIDs newGroupIDs( new list<int> );
SMESH_Mesh* mesh = targetMesh ? targetMesh : GetMesh(); SMESH_Mesh* mesh = targetMesh ? targetMesh : GetMesh();
@ -6485,10 +6488,6 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
// Loop on nodes and elements to add them in new groups // Loop on nodes and elements to add them in new groups
// is there elements of different types generated from one source element;
// it is false for transformations and true for sweeping
bool isTwoTypesResult = false;
vector< const SMDS_MeshElement* > resultElems; vector< const SMDS_MeshElement* > resultElems;
for ( int isNodes = 0; isNodes < 2; ++isNodes ) for ( int isNodes = 0; isNodes < 2; ++isNodes )
{ {
@ -6521,9 +6520,8 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
if ( resElem != sourceElem ) if ( resElem != sourceElem )
resultElems.push_back( resElem ); resultElems.push_back( resElem );
// there must be a top element
const SMDS_MeshElement* topElem = 0; const SMDS_MeshElement* topElem = 0;
if ( isNodes ) if ( isNodes ) // there must be a top element
{ {
topElem = resultElems.back(); topElem = resultElems.back();
resultElems.pop_back(); resultElems.pop_back();
@ -6539,7 +6537,6 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
break; break;
} }
} }
// add resultElems to groups originted from ones the sourceElem belongs to // add resultElems to groups originted from ones the sourceElem belongs to
list< TOldNewGroup >::iterator gOldNew, gLast = groupsOldNew.end(); list< TOldNewGroup >::iterator gOldNew, gLast = groupsOldNew.end();
for ( gOldNew = groupsOldNew.begin(); gOldNew != gLast; ++gOldNew ) for ( gOldNew = groupsOldNew.begin(); gOldNew != gLast; ++gOldNew )
@ -6559,10 +6556,7 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
{ {
SMDS_MeshGroup & newTopGroup = gOldNew->get<2>()->SMDSGroup(); SMDS_MeshGroup & newTopGroup = gOldNew->get<2>()->SMDSGroup();
newTopGroup.Add( topElem ); newTopGroup.Add( topElem );
}
if ( !newGroup.IsEmpty() )
isTwoTypesResult = true;
}
} }
} }
} // loop on created elements } // loop on created elements
@ -6589,7 +6583,7 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
newGroupDS->SetType( newGroupDS->GetElements()->next()->GetType() ); newGroupDS->SetType( newGroupDS->GetElements()->next()->GetType() );
// make a name // make a name
const bool isTop = ( isTwoTypesResult && const bool isTop = ( topPresent &&
newGroupDS->GetType() == oldGroupDS->GetType() && newGroupDS->GetType() == oldGroupDS->GetType() &&
is2nd ); is2nd );

View File

@ -605,11 +605,14 @@ public:
* \param nodeGens - nodes making corresponding myLastCreatedNodes * \param nodeGens - nodes making corresponding myLastCreatedNodes
* \param elemGens - elements making corresponding myLastCreatedElems * \param elemGens - elements making corresponding myLastCreatedElems
* \param postfix - to append to names of new groups * \param postfix - to append to names of new groups
* \param targetMesh - mesh to create groups in
* \param topPresent - is there "top" elements that are created by sweeping
*/ */
PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens, PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
const SMESH_SequenceOfElemPtr& elemGens, const SMESH_SequenceOfElemPtr& elemGens,
const std::string& postfix, const std::string& postfix,
SMESH_Mesh* targetMesh=0); SMESH_Mesh* targetMesh=0,
const bool topPresent=true);
/*! /*!
* \brief Create elements by sweeping an element * \brief Create elements by sweeping an element
* \param elem - element to sweep * \param elem - element to sweep