NPAL14335 (EDF 344 SMESH : "ERROR : Iterator not implemented " when loading a script)

1) protect FindFace() from access to NULL nodes
       2) fix FindFace() for polygons
This commit is contained in:
eap 2006-12-29 16:26:27 +00:00
parent b2b776353a
commit 943384c960

View File

@ -1259,6 +1259,7 @@ const SMDS_MeshEdge* SMDS_Mesh::FindEdge(int idnode1, int idnode2) const
const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1, const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2) const SMDS_MeshNode * node2)
{ {
if ( !node1 ) return 0;
const SMDS_MeshEdge * toReturn=NULL; const SMDS_MeshEdge * toReturn=NULL;
//PROFILER_Init(); //PROFILER_Init();
//PROFILER_Set(); //PROFILER_Set();
@ -1314,6 +1315,7 @@ const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2, const SMDS_MeshNode * node2,
const SMDS_MeshNode * node3) const SMDS_MeshNode * node3)
{ {
if ( !node1 ) return 0;
SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Edge); SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Edge);
while(it1->more()) { while(it1->more()) {
const SMDS_MeshElement * e = it1->next(); const SMDS_MeshElement * e = it1->next();
@ -1345,6 +1347,7 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2, const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3) const SMDS_MeshNode *node3)
{ {
if ( !node1 ) return 0;
SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face); SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face);
while(it1->more()) { while(it1->more()) {
const SMDS_MeshElement * e = it1->next(); const SMDS_MeshElement * e = it1->next();
@ -1390,6 +1393,7 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node3, const SMDS_MeshNode *node3,
const SMDS_MeshNode *node4) const SMDS_MeshNode *node4)
{ {
if ( !node1 ) return 0;
SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face); SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face);
while(it1->more()) { while(it1->more()) {
const SMDS_MeshElement* f = it1->next(); const SMDS_MeshElement* f = it1->next();
@ -1441,6 +1445,7 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node5, const SMDS_MeshNode *node5,
const SMDS_MeshNode *node6) const SMDS_MeshNode *node6)
{ {
if ( !node1 ) return 0;
SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face); SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face);
while(it1->more()) { while(it1->more()) {
const SMDS_MeshElement* f = it1->next(); const SMDS_MeshElement* f = it1->next();
@ -1486,6 +1491,7 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node7, const SMDS_MeshNode *node7,
const SMDS_MeshNode *node8) const SMDS_MeshNode *node8)
{ {
if ( !node1 ) return 0;
SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face); SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face);
while(it1->more()) { while(it1->more()) {
const SMDS_MeshElement* f = it1->next(); const SMDS_MeshElement* f = it1->next();
@ -1537,8 +1543,9 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace (std::vector<const SMDS_MeshNode *> nod
const SMDS_MeshElement* f = itF->next(); const SMDS_MeshElement* f = itF->next();
if ( f->NbNodes() == nodes.size() ) { if ( f->NbNodes() == nodes.size() ) {
int ok = true, i = 1; int ok = true, i = 1;
while ( ok && i < nodes.size() ) while ( ok && i < nodes.size() ) {
ok = ( f->GetNodeIndex( nodes[ i ] ) >= 0 ); ok = ( f->GetNodeIndex( nodes[ i++ ] ) >= 0 );
}
if ( ok ) if ( ok )
return static_cast<const SMDS_MeshFace *>( f ); return static_cast<const SMDS_MeshFace *>( f );
} }