PAL15188 (wrong groups after Concatenate with merge nodes and rename groups)

in MergeEqualElements(), add kept elem in groups of removed one
This commit is contained in:
eap 2007-03-12 10:08:53 +00:00
parent 22f813c1d6
commit 0811f12dda

View File

@ -5038,31 +5038,31 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
} }
// ================================================= // ========================================================
// class : SortableElement // class : SortableElement
// purpose : auxilary // purpose : allow sorting elements basing on their nodes
// ================================================= // ========================================================
class SortableElement : public set <const SMDS_MeshElement*> class SortableElement : public set <const SMDS_MeshElement*>
{ {
public: public:
SortableElement( const SMDS_MeshElement* theElem ) SortableElement( const SMDS_MeshElement* theElem )
{ {
myID = theElem->GetID(); myElem = theElem;
SMDS_ElemIteratorPtr nodeIt = theElem->nodesIterator(); SMDS_ElemIteratorPtr nodeIt = theElem->nodesIterator();
while ( nodeIt->more() ) while ( nodeIt->more() )
this->insert( nodeIt->next() ); this->insert( nodeIt->next() );
} }
const long GetID() const const SMDS_MeshElement* Get() const
{ return myID; } { return myElem; }
void SetID(const long anID) const void Set(const SMDS_MeshElement* e) const
{ myID = anID; } { myElem = e; }
private: private:
mutable long myID; mutable const SMDS_MeshElement* myElem;
}; };
@ -5104,14 +5104,18 @@ void SMESH_MeshEditor::MergeEqualElements()
// check uniqueness // check uniqueness
pair< set<SortableElement>::iterator, bool> pp = setOfNodeSet.insert(SE); pair< set<SortableElement>::iterator, bool> pp = setOfNodeSet.insert(SE);
if( !(pp.second) ) { if( !(pp.second) ) {
set<SortableElement>::iterator itSE = pp.first; set<SortableElement>::iterator & itSE = pp.first;
SortableElement SEold = *itSE; const SortableElement & SEold = *itSE;
if( SEold.GetID() > SE.GetID() ) { if( SEold.Get()->GetID() > elem->GetID() ) {
rmElemIds.push_back( SEold.GetID() ); // keep elem, remove old
(*itSE).SetID(SE.GetID()); rmElemIds.push_back( SEold.Get()->GetID() );
// add kept elem in groups of removed one (PAL15188)
AddToSameGroups( elem, SEold.Get(), GetMeshDS() );
SEold.Set( elem );
} }
else { else { // remove elem
rmElemIds.push_back( SE.GetID() ); rmElemIds.push_back( elem->GetID() );
AddToSameGroups( SEold.Get(), elem, GetMeshDS() );
} }
} }
} }