SMESHDS_Mesh * aMesh)
{
const set<SMESHDS_GroupBase*>& groups = aMesh->GetGroups();
- set<SMESHDS_GroupBase*>::const_iterator grIt = groups.begin();
- for ( ; grIt != groups.end(); grIt++ ) {
- SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
- if ( group && group->Contains( elemInGroups ))
- group->SMDSGroup().Add( elemToAdd );
+ if (!groups.empty()) {
+ set<SMESHDS_GroupBase*>::const_iterator grIt = groups.begin();
+ for ( ; grIt != groups.end(); grIt++ ) {
+ SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
+ if ( group && group->Contains( elemInGroups ))
+ group->SMDSGroup().Add( elemToAdd );
+ }
}
}
}
}
+//=======================================================================
+//function : ReplaceElemInGroups
+//purpose : replace elemToRm by elemToAdd in the all groups
+//=======================================================================
+
+void SMESH_MeshEditor::ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
+ const SMDS_MeshElement* elemToAdd,
+ SMESHDS_Mesh * aMesh)
+{
+ const set<SMESHDS_GroupBase*>& groups = aMesh->GetGroups();
+ if (!groups.empty()) {
+ set<SMESHDS_GroupBase*>::const_iterator grIt = groups.begin();
+ for ( ; grIt != groups.end(); grIt++ ) {
+ SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
+ if ( group && group->SMDSGroup().Remove( elemToRm ) && elemToAdd )
+ group->SMDSGroup().Add( elemToAdd );
+ }
+ }
+}
//=======================================================================
//function : QuadToTri
//=======================================================================
int SMESH_MeshEditor::convertElemToQuadratic(SMESHDS_SubMesh * theSm,
- SMESH_MesherHelper& theHelper,
- const bool theForce3d)
+ SMESH_MesherHelper& theHelper,
+ const bool theForce3d)
{
int nbElem = 0;
if( !theSm ) return nbElem;
+
+ const bool notFromGroups = false;
SMDS_ElemIteratorPtr ElemItr = theSm->GetElements();
while(ElemItr->more())
{
}
SMDSAbs_ElementType aType = elem->GetType();
- theSm->RemoveElement(elem);
- GetMeshDS()->SMDS_Mesh::RemoveFreeElement(elem);
+ GetMeshDS()->RemoveFreeElement(elem, theSm, notFromGroups);
const SMDS_MeshElement* NewElem = 0;
switch(nbNodes)
{
case 4:
- NewElem = theHelper.AddVolume(aNds[0], aNds[1], aNds[2], aNds[3], id, true);
+ NewElem = theHelper.AddVolume(aNds[0], aNds[1], aNds[2], aNds[3], id, theForce3d);
break;
case 6:
- NewElem = theHelper.AddVolume(aNds[0], aNds[1], aNds[2], aNds[3], aNds[4], aNds[5], id, true);
+ NewElem = theHelper.AddVolume(aNds[0], aNds[1], aNds[2], aNds[3], aNds[4], aNds[5], id, theForce3d);
break;
case 8:
NewElem = theHelper.AddVolume(aNds[0], aNds[1], aNds[2], aNds[3],
- aNds[4], aNds[5], aNds[6], aNds[7], id, true);
+ aNds[4], aNds[5], aNds[6], aNds[7], id, theForce3d);
break;
default:
continue;
default :
continue;
}
+ ReplaceElemInGroups( elem, NewElem, GetMeshDS());
if( NewElem )
- {
- AddToSameGroups( NewElem, elem, GetMeshDS());
theSm->AddElement( NewElem );
- }
- if ( NewElem != elem )
- RemoveElemFromGroups (elem, GetMeshDS());
}
return nbElem;
}
SMESH_MesherHelper aHelper(*myMesh);
aHelper.SetIsQuadratic( true );
+ const bool notFromGroups = false;
int nbCheckedElems = 0;
if ( myMesh->HasShapeToMesh() )
}
}
int totalNbElems = meshDS->NbEdges() + meshDS->NbFaces() + meshDS->NbVolumes();
- if ( nbCheckedElems < totalNbElems ) // not all elements in submeshes
+ if ( nbCheckedElems < totalNbElems ) // not all elements are in submeshes
{
+ SMESHDS_SubMesh *smDS = 0;
SMDS_EdgeIteratorPtr aEdgeItr = meshDS->edgesIterator();
while(aEdgeItr->more())
{
const SMDS_MeshNode* n1 = edge->GetNode(0);
const SMDS_MeshNode* n2 = edge->GetNode(1);
- meshDS->SMDS_Mesh::RemoveFreeElement(edge);
+ meshDS->RemoveFreeElement(edge, smDS, notFromGroups);
const SMDS_MeshEdge* NewEdge = aHelper.AddEdge(n1, n2, id, theForce3d);
- if ( NewEdge )
- AddToSameGroups(NewEdge, edge, meshDS);
- if ( NewEdge != edge )
- RemoveElemFromGroups (edge, meshDS);
+ ReplaceElemInGroups( edge, NewEdge, GetMeshDS());
}
}
SMDS_FaceIteratorPtr aFaceItr = meshDS->facesIterator();
aNds[i] = face->GetNode(i);
}
- meshDS->SMDS_Mesh::RemoveFreeElement(face);
+ meshDS->RemoveFreeElement(face, smDS, notFromGroups);
SMDS_MeshFace * NewFace = 0;
switch(nbNodes)
default:
continue;
}
- if ( NewFace )
- AddToSameGroups(NewFace, face, meshDS);
- if ( NewFace != face )
- RemoveElemFromGroups (face, meshDS);
+ ReplaceElemInGroups( face, NewFace, GetMeshDS());
}
SMDS_VolumeIteratorPtr aVolumeItr = meshDS->volumesIterator();
while(aVolumeItr->more())
aNds[i] = volume->GetNode(i);
}
- meshDS->SMDS_Mesh::RemoveFreeElement(volume);
+ meshDS->RemoveFreeElement(volume, smDS, notFromGroups);
SMDS_MeshVolume * NewVolume = 0;
switch(nbNodes)
{
case 4:
NewVolume = aHelper.AddVolume(aNds[0], aNds[1], aNds[2],
- aNds[3], id, true );
+ aNds[3], id, theForce3d );
break;
case 6:
NewVolume = aHelper.AddVolume(aNds[0], aNds[1], aNds[2],
- aNds[3], aNds[4], aNds[5], id, true);
+ aNds[3], aNds[4], aNds[5], id, theForce3d);
break;
case 8:
NewVolume = aHelper.AddVolume(aNds[0], aNds[1], aNds[2], aNds[3],
- aNds[4], aNds[5], aNds[6], aNds[7], id, true);
+ aNds[4], aNds[5], aNds[6], aNds[7], id, theForce3d);
break;
default:
continue;
}
- if ( NewVolume )
- AddToSameGroups(NewVolume, volume, meshDS);
- if ( NewVolume != volume )
- RemoveElemFromGroups (volume, meshDS);
+ ReplaceElemInGroups(volume, NewVolume, meshDS);
}
}
}
{
int nbElem = 0;
SMESHDS_Mesh* meshDS = GetMeshDS();
+ const bool notFromGroups = false;
+
while( theItr->more() )
{
const SMDS_MeshElement* elem = theItr->next();
SMDSAbs_ElementType aType = elem->GetType();
//remove old quadratic element
- meshDS->SMDS_Mesh::RemoveFreeElement( elem );
- if ( theSm )
- theSm->RemoveElement( elem );
+ meshDS->RemoveFreeElement( elem, theSm, notFromGroups );
SMDS_MeshElement * NewElem = AddElement( aNds, aType, false, id );
- if ( NewElem )
- AddToSameGroups(NewElem, elem, meshDS);
- if ( NewElem != elem )
- RemoveElemFromGroups (elem, meshDS);
+ ReplaceElemInGroups(elem, NewElem, meshDS);
if( theSm && NewElem )
theSm->AddElement( NewElem );
int totalNbElems =
GetMeshDS()->NbEdges() + GetMeshDS()->NbFaces() + GetMeshDS()->NbVolumes();
- if ( nbCheckedElems < totalNbElems ) // not all elements in submeshes
+ if ( nbCheckedElems < totalNbElems ) // not all elements are in submeshes
{
SMESHDS_SubMesh *aSM = 0;
removeQuadElem( aSM, GetMeshDS()->elementsIterator(), 0 );