0020213: RadialPrism_3D_4 failed on V5_1 64 bits

0020214: Project_2D_4 failed on V5_1 64 bits
   different ways of removing deleted and alive elements from submesh
This commit is contained in:
eap 2009-03-12 09:47:59 +00:00
parent bebf85204e
commit a84fe0415c
3 changed files with 87 additions and 42 deletions

View File

@ -652,6 +652,8 @@ static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
} }
} }
const bool deleted=true;
// Rm from sub-meshes // Rm from sub-meshes
// Element should belong to only one sub-mesh // Element should belong to only one sub-mesh
map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin(); map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
@ -665,9 +667,9 @@ static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
{ {
bool removed = false; bool removed = false;
if ( isNode ) if ( isNode )
removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt) ); removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
else else
removed = (*SubIt).second->RemoveElement( *elIt ); removed = (*SubIt).second->RemoveElement( *elIt, deleted );
if (removed) if (removed)
{ {
@ -689,6 +691,23 @@ static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
//======================================================================= //=======================================================================
void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n) void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
{ {
if ( n->NbInverseElements() == 0 && !(hasConstructionEdges() || hasConstructionFaces()))
{
SMESHDS_SubMesh* subMesh=0;
map<int,SMESHDS_SubMesh*>::iterator SubIt =
myShapeIndexToSubMesh.find( n->GetPosition()->GetShapeId() );
if ( SubIt != myShapeIndexToSubMesh.end() )
subMesh = SubIt->second;
else
SubIt = myShapeIndexToSubMesh.begin();
for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
if ( SubIt->second->Contains( n ))
subMesh = SubIt->second;
RemoveFreeNode( n, subMesh, true);
return;
}
myScript->RemoveNode(n->GetID()); myScript->RemoveNode(n->GetID());
list<const SMDS_MeshElement *> removedElems; list<const SMDS_MeshElement *> removedElems;
@ -724,7 +743,7 @@ void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n,
// Rm from sub-mesh // Rm from sub-mesh
// Node should belong to only one sub-mesh // Node should belong to only one sub-mesh
if( subMesh ) if( subMesh )
subMesh->RemoveNode(n); subMesh->RemoveNode(n,/*deleted=*/false);
SMDS_Mesh::RemoveFreeElement(n); SMDS_Mesh::RemoveFreeElement(n);
} }
@ -740,6 +759,17 @@ void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
RemoveNode( static_cast<const SMDS_MeshNode*>( elt )); RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
return; return;
} }
if (!hasConstructionEdges() && !hasConstructionFaces())
{
SMESHDS_SubMesh* subMesh=0;
map<int,SMESHDS_SubMesh*>::iterator SubIt = myShapeIndexToSubMesh.begin();
for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
if ( SubIt->second->Contains( elt ))
subMesh = SubIt->second;
RemoveFreeElement( elt, subMesh, true);
return;
}
myScript->RemoveElement(elt->GetID()); myScript->RemoveElement(elt->GetID());
@ -784,7 +814,7 @@ void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
// Rm from sub-mesh // Rm from sub-mesh
// Element should belong to only one sub-mesh // Element should belong to only one sub-mesh
if( subMesh ) if( subMesh )
subMesh->RemoveElement(elt); subMesh->RemoveElement(elt, /*deleted=*/false);
SMDS_Mesh::RemoveFreeElement(elt); SMDS_Mesh::RemoveFreeElement(elt);
} }
@ -965,7 +995,7 @@ void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
map<int,SMESHDS_SubMesh*>::iterator it = map<int,SMESHDS_SubMesh*>::iterator it =
myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() ); myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
if ( it != myShapeIndexToSubMesh.end() ) if ( it != myShapeIndexToSubMesh.end() )
it->second->RemoveNode( aNode ); it->second->RemoveNode( aNode, /*deleted=*/false );
} }
} }
@ -991,9 +1021,9 @@ void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index ); map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
if ( it != myShapeIndexToSubMesh.end() ) if ( it != myShapeIndexToSubMesh.end() )
if ( elem->GetType() == SMDSAbs_Node ) if ( elem->GetType() == SMDSAbs_Node )
it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem )); it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ), /*deleted=*/false );
else else
it->second->RemoveElement( elem ); it->second->RemoveElement( elem, /*deleted=*/false );
} }
//======================================================================= //=======================================================================

View File

@ -46,10 +46,20 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
//function : RemoveElement //function : RemoveElement
//purpose : //purpose :
//======================================================================= //=======================================================================
bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME) bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted)
{ {
if ( !IsComplexSubmesh() && NbElements() ) if ( !IsComplexSubmesh() && NbElements() ) {
return myElements.erase(ME);
if (!isElemDeleted) // alive element has valid ID and can be found
return myElements.erase(ME);
TElemSet::iterator e = myElements.begin(), eEnd = myElements.end();
for ( ; e != eEnd; ++e )
if ( ME == *e ) {
myElements.erase( e );
return true;
}
}
return false; return false;
} }
@ -69,10 +79,20 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
//purpose : //purpose :
//======================================================================= //=======================================================================
bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N) bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted)
{ {
if ( !IsComplexSubmesh() && NbNodes() ) if ( !IsComplexSubmesh() && NbNodes() ) {
return myNodes.erase(N);
if (!isNodeDeleted) // alive node has valid ID and can be found
return myNodes.erase(N);
TElemSet::iterator e = myNodes.begin(), eEnd = myNodes.end();
for ( ; e != eEnd; ++e )
if ( N == *e ) {
myNodes.erase( e );
return true;
}
}
return false; return false;
} }
@ -116,12 +136,12 @@ int SMESHDS_SubMesh::NbNodes() const
// class MySetIterator // class MySetIterator
// ===================== // =====================
template<typename TSet> class MySetIterator: public SMDS_SetIterator<typename TSet::key_type, template<class ELEM, typename TSET> class MySetIterator:
typename TSet::const_iterator > public SMDS_SetIterator<ELEM, typename TSET::const_iterator >
{ {
typedef SMDS_SetIterator<typename TSet::key_type, typename TSet::const_iterator > TFather; typedef SMDS_SetIterator<ELEM, typename TSET::const_iterator > TFather;
public: public:
MySetIterator(const TSet& s):TFather(s.begin(),s.end()) MySetIterator(const TSET& s):TFather(s.begin(),s.end())
{ {
} }
}; };
@ -134,12 +154,11 @@ template<typename VALUE> class MyIterator : public SMDS_Iterator<VALUE>
{ {
public: public:
MyIterator (const set<const SMESHDS_SubMesh*>& theSubMeshes) MyIterator (const set<const SMESHDS_SubMesh*>& theSubMeshes)
: mySubMeshes( theSubMeshes ), mySubIt( theSubMeshes.begin() ), myMore(false) : mySubIt( theSubMeshes.begin() ), mySubEnd( theSubMeshes.end() ), myMore(false)
{} {}
bool more() bool more()
{ {
while (( !myElemIt.get() || !myElemIt->more() ) && while (( !myElemIt.get() || !myElemIt->more() ) && mySubIt != mySubEnd)
mySubIt != mySubMeshes.end())
{ {
myElemIt = getElements(*mySubIt); myElemIt = getElements(*mySubIt);
mySubIt++; mySubIt++;
@ -160,8 +179,7 @@ template<typename VALUE> class MyIterator : public SMDS_Iterator<VALUE>
private: private:
bool myMore; bool myMore;
const set<const SMESHDS_SubMesh*>& mySubMeshes; set<const SMESHDS_SubMesh*>::const_iterator mySubIt, mySubEnd;
set<const SMESHDS_SubMesh*>::const_iterator mySubIt;
boost::shared_ptr< SMDS_Iterator<VALUE> > myElemIt; boost::shared_ptr< SMDS_Iterator<VALUE> > myElemIt;
}; };
@ -201,7 +219,7 @@ SMDS_ElemIteratorPtr SMESHDS_SubMesh::GetElements() const
if ( IsComplexSubmesh() ) if ( IsComplexSubmesh() )
return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes )); return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes ));
return SMDS_ElemIteratorPtr(new MySetIterator<TElemSet>(myElements)); return SMDS_ElemIteratorPtr(new MySetIterator<const SMDS_MeshElement*,TElemSet>(myElements));
} }
//======================================================================= //=======================================================================
@ -214,7 +232,7 @@ SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes() const
if ( IsComplexSubmesh() ) if ( IsComplexSubmesh() )
return SMDS_NodeIteratorPtr( new MyNodeIterator( mySubMeshes )); return SMDS_NodeIteratorPtr( new MyNodeIterator( mySubMeshes ));
return SMDS_NodeIteratorPtr(new MySetIterator<TNodeSet>(myNodes)); return SMDS_NodeIteratorPtr(new MySetIterator<const SMDS_MeshNode*,TElemSet>(myNodes));
} }
//======================================================================= //=======================================================================
@ -225,23 +243,20 @@ SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes() const
bool SMESHDS_SubMesh::Contains(const SMDS_MeshElement * ME) const bool SMESHDS_SubMesh::Contains(const SMDS_MeshElement * ME) const
{ {
// DO NOT TRY TO FIND A REMOVED ELEMENT !! // DO NOT TRY TO FIND A REMOVED ELEMENT !!
if ( !ME ) if ( IsComplexSubmesh() || !ME )
return false; return false;
if ( IsComplexSubmesh() ) // if ( IsComplexSubmesh() )
{ // {
set<const SMESHDS_SubMesh*>::const_iterator aSubIt = mySubMeshes.begin(); // set<const SMESHDS_SubMesh*>::const_iterator aSubIt = mySubMeshes.begin();
for ( ; aSubIt != mySubMeshes.end(); aSubIt++ ) // for ( ; aSubIt != mySubMeshes.end(); aSubIt++ )
if ( (*aSubIt)->Contains( ME )) // if ( (*aSubIt)->Contains( ME ))
return true; // return true;
return false; // return false;
} // }
if ( ME->GetType() == SMDSAbs_Node ) if ( ME->GetType() == SMDSAbs_Node )
{ return ( myNodes.find( ME ) != myNodes.end() );
const SMDS_MeshNode* n = static_cast<const SMDS_MeshNode*>( ME );
return ( myNodes.find( n ) != myNodes.end() );
}
return ( myElements.find( ME ) != myElements.end() ); return ( myElements.find( ME ) != myElements.end() );
} }

View File

@ -43,9 +43,9 @@ class SMESHDS_EXPORT SMESHDS_SubMesh
// if !IsComplexSubmesh() // if !IsComplexSubmesh()
void AddElement(const SMDS_MeshElement * ME); void AddElement(const SMDS_MeshElement * ME);
bool RemoveElement(const SMDS_MeshElement * ME); // ret true if ME was in bool RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted); // ret true if ME was in
void AddNode(const SMDS_MeshNode * ME); void AddNode(const SMDS_MeshNode * ME);
bool RemoveNode(const SMDS_MeshNode * ME); // ret true if ME was in bool RemoveNode(const SMDS_MeshNode * ME, bool isNodeDeleted); // ret true if ME was in
// if IsComplexSubmesh() // if IsComplexSubmesh()
void AddSubMesh( const SMESHDS_SubMesh* theSubMesh ); void AddSubMesh( const SMESHDS_SubMesh* theSubMesh );
@ -65,14 +65,14 @@ class SMESHDS_EXPORT SMESHDS_SubMesh
void Clear(); void Clear();
private: private:
struct TIDCompare { // to have nodes and elements sorted by ID struct TIDCompare { // to have nodes and elements sorted by ID
bool operator () (const SMDS_MeshElement* e1, const SMDS_MeshElement* e2) const bool operator () (const SMDS_MeshElement* e1, const SMDS_MeshElement* e2) const
{ return e1->GetID() < e2->GetID(); } { return e1->GetID() < e2->GetID(); }
}; };
typedef std::set<const SMDS_MeshElement*, TIDCompare > TElemSet; typedef std::set<const SMDS_MeshElement*, TIDCompare > TElemSet;
typedef std::set<const SMDS_MeshNode* , TIDCompare> TNodeSet; TElemSet myElements, myNodes;
TElemSet myElements;
TNodeSet myNodes;
std::set<const SMESHDS_SubMesh*> mySubMeshes; std::set<const SMESHDS_SubMesh*> mySubMeshes;
}; };
#endif #endif