mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-28 18:30:35 +05:00
0019957: EDF 785 SMESH: Convert Quadratic and Group on GEOM
fix ConvertToQuadratic() and a reverse function: log changes
This commit is contained in:
parent
ff0fe2edd9
commit
5be5d046f6
@ -1171,11 +1171,13 @@ void SMESH_MeshEditor::AddToSameGroups (const SMDS_MeshElement* elemToAdd,
|
|||||||
SMESHDS_Mesh * aMesh)
|
SMESHDS_Mesh * aMesh)
|
||||||
{
|
{
|
||||||
const set<SMESHDS_GroupBase*>& groups = aMesh->GetGroups();
|
const set<SMESHDS_GroupBase*>& groups = aMesh->GetGroups();
|
||||||
set<SMESHDS_GroupBase*>::const_iterator grIt = groups.begin();
|
if (!groups.empty()) {
|
||||||
for ( ; grIt != groups.end(); grIt++ ) {
|
set<SMESHDS_GroupBase*>::const_iterator grIt = groups.begin();
|
||||||
SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
|
for ( ; grIt != groups.end(); grIt++ ) {
|
||||||
if ( group && group->Contains( elemInGroups ))
|
SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
|
||||||
group->SMDSGroup().Add( elemToAdd );
|
if ( group && group->Contains( elemInGroups ))
|
||||||
|
group->SMDSGroup().Add( elemToAdd );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1200,6 +1202,25 @@ void SMESH_MeshEditor::RemoveElemFromGroups (const SMDS_MeshElement* removeelem,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//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
|
//function : QuadToTri
|
||||||
@ -6610,11 +6631,13 @@ void SMESH_MeshEditor::UpdateVolumes (const SMDS_MeshNode* theBetweenNode
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
int SMESH_MeshEditor::convertElemToQuadratic(SMESHDS_SubMesh * theSm,
|
int SMESH_MeshEditor::convertElemToQuadratic(SMESHDS_SubMesh * theSm,
|
||||||
SMESH_MesherHelper& theHelper,
|
SMESH_MesherHelper& theHelper,
|
||||||
const bool theForce3d)
|
const bool theForce3d)
|
||||||
{
|
{
|
||||||
int nbElem = 0;
|
int nbElem = 0;
|
||||||
if( !theSm ) return nbElem;
|
if( !theSm ) return nbElem;
|
||||||
|
|
||||||
|
const bool notFromGroups = false;
|
||||||
SMDS_ElemIteratorPtr ElemItr = theSm->GetElements();
|
SMDS_ElemIteratorPtr ElemItr = theSm->GetElements();
|
||||||
while(ElemItr->more())
|
while(ElemItr->more())
|
||||||
{
|
{
|
||||||
@ -6632,8 +6655,7 @@ int SMESH_MeshEditor::convertElemToQuadratic(SMESHDS_SubMesh * theSm,
|
|||||||
}
|
}
|
||||||
SMDSAbs_ElementType aType = elem->GetType();
|
SMDSAbs_ElementType aType = elem->GetType();
|
||||||
|
|
||||||
theSm->RemoveElement(elem);
|
GetMeshDS()->RemoveFreeElement(elem, theSm, notFromGroups);
|
||||||
GetMeshDS()->SMDS_Mesh::RemoveFreeElement(elem);
|
|
||||||
|
|
||||||
const SMDS_MeshElement* NewElem = 0;
|
const SMDS_MeshElement* NewElem = 0;
|
||||||
|
|
||||||
@ -6664,14 +6686,14 @@ int SMESH_MeshEditor::convertElemToQuadratic(SMESHDS_SubMesh * theSm,
|
|||||||
switch(nbNodes)
|
switch(nbNodes)
|
||||||
{
|
{
|
||||||
case 4:
|
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;
|
break;
|
||||||
case 6:
|
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;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
NewElem = theHelper.AddVolume(aNds[0], aNds[1], aNds[2], aNds[3],
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
@ -6681,13 +6703,9 @@ int SMESH_MeshEditor::convertElemToQuadratic(SMESHDS_SubMesh * theSm,
|
|||||||
default :
|
default :
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
ReplaceElemInGroups( elem, NewElem, GetMeshDS());
|
||||||
if( NewElem )
|
if( NewElem )
|
||||||
{
|
|
||||||
AddToSameGroups( NewElem, elem, GetMeshDS());
|
|
||||||
theSm->AddElement( NewElem );
|
theSm->AddElement( NewElem );
|
||||||
}
|
|
||||||
if ( NewElem != elem )
|
|
||||||
RemoveElemFromGroups (elem, GetMeshDS());
|
|
||||||
}
|
}
|
||||||
return nbElem;
|
return nbElem;
|
||||||
}
|
}
|
||||||
@ -6702,6 +6720,7 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d)
|
|||||||
|
|
||||||
SMESH_MesherHelper aHelper(*myMesh);
|
SMESH_MesherHelper aHelper(*myMesh);
|
||||||
aHelper.SetIsQuadratic( true );
|
aHelper.SetIsQuadratic( true );
|
||||||
|
const bool notFromGroups = false;
|
||||||
|
|
||||||
int nbCheckedElems = 0;
|
int nbCheckedElems = 0;
|
||||||
if ( myMesh->HasShapeToMesh() )
|
if ( myMesh->HasShapeToMesh() )
|
||||||
@ -6719,8 +6738,9 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int totalNbElems = meshDS->NbEdges() + meshDS->NbFaces() + meshDS->NbVolumes();
|
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();
|
SMDS_EdgeIteratorPtr aEdgeItr = meshDS->edgesIterator();
|
||||||
while(aEdgeItr->more())
|
while(aEdgeItr->more())
|
||||||
{
|
{
|
||||||
@ -6731,13 +6751,10 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d)
|
|||||||
const SMDS_MeshNode* n1 = edge->GetNode(0);
|
const SMDS_MeshNode* n1 = edge->GetNode(0);
|
||||||
const SMDS_MeshNode* n2 = edge->GetNode(1);
|
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);
|
const SMDS_MeshEdge* NewEdge = aHelper.AddEdge(n1, n2, id, theForce3d);
|
||||||
if ( NewEdge )
|
ReplaceElemInGroups( edge, NewEdge, GetMeshDS());
|
||||||
AddToSameGroups(NewEdge, edge, meshDS);
|
|
||||||
if ( NewEdge != edge )
|
|
||||||
RemoveElemFromGroups (edge, meshDS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SMDS_FaceIteratorPtr aFaceItr = meshDS->facesIterator();
|
SMDS_FaceIteratorPtr aFaceItr = meshDS->facesIterator();
|
||||||
@ -6755,7 +6772,7 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d)
|
|||||||
aNds[i] = face->GetNode(i);
|
aNds[i] = face->GetNode(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
meshDS->SMDS_Mesh::RemoveFreeElement(face);
|
meshDS->RemoveFreeElement(face, smDS, notFromGroups);
|
||||||
|
|
||||||
SMDS_MeshFace * NewFace = 0;
|
SMDS_MeshFace * NewFace = 0;
|
||||||
switch(nbNodes)
|
switch(nbNodes)
|
||||||
@ -6769,10 +6786,7 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d)
|
|||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( NewFace )
|
ReplaceElemInGroups( face, NewFace, GetMeshDS());
|
||||||
AddToSameGroups(NewFace, face, meshDS);
|
|
||||||
if ( NewFace != face )
|
|
||||||
RemoveElemFromGroups (face, meshDS);
|
|
||||||
}
|
}
|
||||||
SMDS_VolumeIteratorPtr aVolumeItr = meshDS->volumesIterator();
|
SMDS_VolumeIteratorPtr aVolumeItr = meshDS->volumesIterator();
|
||||||
while(aVolumeItr->more())
|
while(aVolumeItr->more())
|
||||||
@ -6789,30 +6803,27 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d)
|
|||||||
aNds[i] = volume->GetNode(i);
|
aNds[i] = volume->GetNode(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
meshDS->SMDS_Mesh::RemoveFreeElement(volume);
|
meshDS->RemoveFreeElement(volume, smDS, notFromGroups);
|
||||||
|
|
||||||
SMDS_MeshVolume * NewVolume = 0;
|
SMDS_MeshVolume * NewVolume = 0;
|
||||||
switch(nbNodes)
|
switch(nbNodes)
|
||||||
{
|
{
|
||||||
case 4:
|
case 4:
|
||||||
NewVolume = aHelper.AddVolume(aNds[0], aNds[1], aNds[2],
|
NewVolume = aHelper.AddVolume(aNds[0], aNds[1], aNds[2],
|
||||||
aNds[3], id, true );
|
aNds[3], id, theForce3d );
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
NewVolume = aHelper.AddVolume(aNds[0], aNds[1], aNds[2],
|
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;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
NewVolume = aHelper.AddVolume(aNds[0], aNds[1], aNds[2], aNds[3],
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( NewVolume )
|
ReplaceElemInGroups(volume, NewVolume, meshDS);
|
||||||
AddToSameGroups(NewVolume, volume, meshDS);
|
|
||||||
if ( NewVolume != volume )
|
|
||||||
RemoveElemFromGroups (volume, meshDS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6830,6 +6841,8 @@ int SMESH_MeshEditor::removeQuadElem(SMESHDS_SubMesh * theSm,
|
|||||||
{
|
{
|
||||||
int nbElem = 0;
|
int nbElem = 0;
|
||||||
SMESHDS_Mesh* meshDS = GetMeshDS();
|
SMESHDS_Mesh* meshDS = GetMeshDS();
|
||||||
|
const bool notFromGroups = false;
|
||||||
|
|
||||||
while( theItr->more() )
|
while( theItr->more() )
|
||||||
{
|
{
|
||||||
const SMDS_MeshElement* elem = theItr->next();
|
const SMDS_MeshElement* elem = theItr->next();
|
||||||
@ -6855,15 +6868,10 @@ int SMESH_MeshEditor::removeQuadElem(SMESHDS_SubMesh * theSm,
|
|||||||
SMDSAbs_ElementType aType = elem->GetType();
|
SMDSAbs_ElementType aType = elem->GetType();
|
||||||
|
|
||||||
//remove old quadratic element
|
//remove old quadratic element
|
||||||
meshDS->SMDS_Mesh::RemoveFreeElement( elem );
|
meshDS->RemoveFreeElement( elem, theSm, notFromGroups );
|
||||||
if ( theSm )
|
|
||||||
theSm->RemoveElement( elem );
|
|
||||||
|
|
||||||
SMDS_MeshElement * NewElem = AddElement( aNds, aType, false, id );
|
SMDS_MeshElement * NewElem = AddElement( aNds, aType, false, id );
|
||||||
if ( NewElem )
|
ReplaceElemInGroups(elem, NewElem, meshDS);
|
||||||
AddToSameGroups(NewElem, elem, meshDS);
|
|
||||||
if ( NewElem != elem )
|
|
||||||
RemoveElemFromGroups (elem, meshDS);
|
|
||||||
if( theSm && NewElem )
|
if( theSm && NewElem )
|
||||||
theSm->AddElement( NewElem );
|
theSm->AddElement( NewElem );
|
||||||
|
|
||||||
@ -6906,7 +6914,7 @@ bool SMESH_MeshEditor::ConvertFromQuadratic()
|
|||||||
|
|
||||||
int totalNbElems =
|
int totalNbElems =
|
||||||
GetMeshDS()->NbEdges() + GetMeshDS()->NbFaces() + GetMeshDS()->NbVolumes();
|
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;
|
SMESHDS_SubMesh *aSM = 0;
|
||||||
removeQuadElem( aSM, GetMeshDS()->elementsIterator(), 0 );
|
removeQuadElem( aSM, GetMeshDS()->elementsIterator(), 0 );
|
||||||
|
@ -445,11 +445,16 @@ public:
|
|||||||
static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
|
static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
|
||||||
const SMDS_MeshElement* elemInGroups,
|
const SMDS_MeshElement* elemInGroups,
|
||||||
SMESHDS_Mesh * aMesh);
|
SMESHDS_Mesh * aMesh);
|
||||||
// Add elemToAdd to the groups the elemInGroups belongs to
|
// Add elemToAdd to the all groups the elemInGroups belongs to
|
||||||
|
|
||||||
static void RemoveElemFromGroups (const SMDS_MeshElement* removeelem,
|
static void RemoveElemFromGroups (const SMDS_MeshElement* element,
|
||||||
SMESHDS_Mesh * aMesh);
|
SMESHDS_Mesh * aMesh);
|
||||||
// remove elemToAdd from the groups
|
// remove element from the all groups
|
||||||
|
|
||||||
|
static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
|
||||||
|
const SMDS_MeshElement* elemToAdd,
|
||||||
|
SMESHDS_Mesh * aMesh);
|
||||||
|
// replace elemToRm by elemToAdd in the all groups
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Return nodes linked to the given one in elements of the type
|
* \brief Return nodes linked to the given one in elements of the type
|
||||||
|
Loading…
Reference in New Issue
Block a user