fix SIGSEGV in ConvertFromQuadratic() on torus

This commit is contained in:
eap 2006-05-05 08:22:25 +00:00
parent 8e5fb5d7ab
commit 1f23ca1d2d
2 changed files with 23 additions and 26 deletions

View File

@ -2481,9 +2481,6 @@ void SMESH_MeshEditor::Smooth (map<int,const SMDS_MeshElement*> & theElems,
// move medium nodes of quadratic elements // move medium nodes of quadratic elements
if ( isQuadratic ) if ( isQuadratic )
{ {
SMESH_MesherHelper helper( *GetMesh() );
if ( !face.IsNull() )
helper.SetSubShape( face );
list< const SMDS_MeshElement* >::iterator elemIt = elemsOnFace.begin(); list< const SMDS_MeshElement* >::iterator elemIt = elemsOnFace.begin();
for ( ; elemIt != elemsOnFace.end(); ++elemIt ) { for ( ; elemIt != elemsOnFace.end(); ++elemIt ) {
const SMDS_QuadraticFaceOfNodes* QF = const SMDS_QuadraticFaceOfNodes* QF =
@ -6234,7 +6231,8 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d)
//purpose : //purpose :
//======================================================================= //=======================================================================
void SMESH_MeshEditor::RemoveQuadElem(SMESHDS_SubMesh *theSm, void SMESH_MeshEditor::RemoveQuadElem(SMESHDS_SubMesh *theSm,
SMDS_ElemIteratorPtr theItr) SMDS_ElemIteratorPtr theItr,
RemoveQuadNodeMap& theRemoveNodeMap)
{ {
SMESHDS_Mesh* meshDS = GetMeshDS(); SMESHDS_Mesh* meshDS = GetMeshDS();
while( theItr->more() ) while( theItr->more() )
@ -6249,22 +6247,18 @@ void SMESH_MeshEditor::RemoveQuadElem(SMESHDS_SubMesh *theSm,
int nbNodes = elem->NbNodes(), idx = 0; int nbNodes = elem->NbNodes(), idx = 0;
vector<const SMDS_MeshNode *> aNds; vector<const SMDS_MeshNode *> aNds;
vector<const SMDS_MeshNode *> aQuadNds;
//remove all quadratic nodes
for(int i = 0; i < nbNodes; i++) for(int i = 0; i < nbNodes; i++)
{ {
const SMDS_MeshNode* n = elem->GetNode(i); const SMDS_MeshNode* n = elem->GetNode(i);
if( elem->IsMediumNode( n ) ) if( elem->IsMediumNode( n ) )
{ {
aQuadNds.push_back( n ); ItRemoveQuadNodeMap itRNM = theRemoveNodeMap.find( n );
/* ItRemoveQuadNodeMap itRNM = myRemoveNodeMap.find( n ); if( itRNM == theRemoveNodeMap.end() )
if( itRNM == myRemoveNodeMap.end() )
{ {
aQuadNds.push_back( n ); theRemoveNodeMap.insert(RemoveQuadNodeMap::value_type( n,theSm ));
myRemoveNodeMap.insert(RemoveQuadNodeMap::value_type( n,theSm )); }
}*/
} }
else else
aNds.push_back( n ); aNds.push_back( n );
@ -6277,10 +6271,6 @@ void SMESH_MeshEditor::RemoveQuadElem(SMESHDS_SubMesh *theSm,
//remove old quadratic elements //remove old quadratic elements
meshDS->RemoveFreeElement( elem, theSm ); meshDS->RemoveFreeElement( elem, theSm );
for( int j = 0; j < aQuadNds.size(); j++ )
{
meshDS->RemoveFreeNode( aQuadNds[j], theSm );
}
SMDS_MeshElement * NewElem = 0; SMDS_MeshElement * NewElem = 0;
switch(aType) switch(aType)
{ {
@ -6321,7 +6311,7 @@ void SMESH_MeshEditor::RemoveQuadElem(SMESHDS_SubMesh *theSm,
bool SMESH_MeshEditor::ConvertFromQuadratic() bool SMESH_MeshEditor::ConvertFromQuadratic()
{ {
SMESHDS_Mesh* meshDS = GetMeshDS(); SMESHDS_Mesh* meshDS = GetMeshDS();
// myRemoveNodeMap.clear(); RemoveQuadNodeMap aRemoveNodeMap;
const TopoDS_Shape& aShape = meshDS->ShapeToMesh(); const TopoDS_Shape& aShape = meshDS->ShapeToMesh();
@ -6335,23 +6325,24 @@ bool SMESH_MeshEditor::ConvertFromQuadratic()
{ {
SMESHDS_SubMesh *sm = ((*itsub).second)->GetSubMeshDS(); SMESHDS_SubMesh *sm = ((*itsub).second)->GetSubMeshDS();
if( sm ) if( sm )
RemoveQuadElem( sm, sm->GetElements() ); RemoveQuadElem( sm, sm->GetElements(), aRemoveNodeMap );
} }
SMESHDS_SubMesh *Sm = aSubMesh->GetSubMeshDS(); SMESHDS_SubMesh *Sm = aSubMesh->GetSubMeshDS();
if( Sm ) if( Sm )
RemoveQuadElem( Sm, Sm->GetElements() ); RemoveQuadElem( Sm, Sm->GetElements(), aRemoveNodeMap );
} }
else else
{ {
SMESHDS_SubMesh *aSM = 0; SMESHDS_SubMesh *aSM = 0;
RemoveQuadElem( aSM, meshDS->elementsIterator() ); RemoveQuadElem( aSM, meshDS->elementsIterator(), aRemoveNodeMap );
} }
/* ItRemoveQuadNodeMap itRNM = myRemoveNodeMap.begin(); //remove all quadratic nodes
for ( ; itRNM != myRemoveNodeMap.end(); itRNM++ ) { ItRemoveQuadNodeMap itRNM = aRemoveNodeMap.begin();
for ( ; itRNM != aRemoveNodeMap.end(); itRNM++ )
{ {
meshDS->RemoveFreeNode( (*itRNM), (*itRNM).second ); meshDS->RemoveFreeNode( (*itRNM).first, (*itRNM).second );
}*/ }
return true; return true;
} }

View File

@ -44,6 +44,9 @@
typedef map<const SMDS_MeshElement*, typedef map<const SMDS_MeshElement*,
list<const SMDS_MeshElement*> > TElemOfElemListMap; list<const SMDS_MeshElement*> > TElemOfElemListMap;
typedef map<const SMDS_MeshNode*, SMESHDS_SubMesh*> RemoveQuadNodeMap;
typedef map<const SMDS_MeshNode*, SMESHDS_SubMesh*>::iterator ItRemoveQuadNodeMap;
class SMDS_MeshElement; class SMDS_MeshElement;
class SMDS_MeshFace; class SMDS_MeshFace;
class SMDS_MeshNode; class SMDS_MeshNode;
@ -396,6 +399,8 @@ class SMESH_MeshEditor {
SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); } SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
SMESH_SequenceOfElemPtr GetLastCreatedNodes() { return myLastCreatedNodes; } SMESH_SequenceOfElemPtr GetLastCreatedNodes() { return myLastCreatedNodes; }
SMESH_SequenceOfElemPtr GetLastCreatedElems() { return myLastCreatedElems; } SMESH_SequenceOfElemPtr GetLastCreatedElems() { return myLastCreatedElems; }
@ -409,7 +414,8 @@ private:
//elements contained in submesh to quadratic //elements contained in submesh to quadratic
void RemoveQuadElem( SMESHDS_SubMesh *theSm, void RemoveQuadElem( SMESHDS_SubMesh *theSm,
SMDS_ElemIteratorPtr theItr); SMDS_ElemIteratorPtr theItr,
RemoveQuadNodeMap& theRemoveNodeMap);
//Auxiliary function for "ConvertFromQuadratic" is intended to convert quadratic //Auxiliary function for "ConvertFromQuadratic" is intended to convert quadratic
//element to ordinary and for removing quadratic nodes //element to ordinary and for removing quadratic nodes