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

use GetInverseElementIterator(type) instead of node->facesIterator ()
        and node->edgesIterator() to avoid infinite recursion from
        volume->facesIterator()
This commit is contained in:
eap 2006-12-29 14:36:25 +00:00
parent 3103371901
commit d2cde5340a

View File

@ -1262,17 +1262,14 @@ const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1,
const SMDS_MeshEdge * toReturn=NULL; const SMDS_MeshEdge * toReturn=NULL;
//PROFILER_Init(); //PROFILER_Init();
//PROFILER_Set(); //PROFILER_Set();
SMDS_ElemIteratorPtr it1=node1->edgesIterator(); SMDS_ElemIteratorPtr it1=node1->GetInverseElementIterator(SMDSAbs_Edge);
//PROFILER_Get(0); //PROFILER_Get(0);
//PROFILER_Set(); //PROFILER_Set();
while(it1->more()) { while(it1->more()) {
const SMDS_MeshEdge * e=static_cast<const SMDS_MeshEdge *> (it1->next()); const SMDS_MeshElement * e = it1->next();
SMDS_ElemIteratorPtr it2=e->nodesIterator(); if ( e->NbNodes() == 2 && e->GetNodeIndex( node2 ) >= 0 ) {
while(it2->more()) { toReturn = static_cast<const SMDS_MeshEdge*>( e );
if(it2->next()->GetID()==node2->GetID()) { break;
toReturn = e;
break;
}
} }
} }
//PROFILER_Get(1); //PROFILER_Get(1);
@ -1317,25 +1314,16 @@ 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 || !node2 || !node3 ) return 0; SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Edge);
const SMDS_MeshEdge * toReturn = NULL;
SMDS_ElemIteratorPtr it1 = node1->edgesIterator();
while(it1->more()) { while(it1->more()) {
const SMDS_MeshEdge * e = static_cast<const SMDS_MeshEdge *> (it1->next()); const SMDS_MeshElement * e = it1->next();
SMDS_ElemIteratorPtr it2 = e->nodesIterator(); if ( e->NbNodes() == 3 &&
int tmp = 0; e->GetNodeIndex( node2 ) >= 0 &&
while(it2->more()) { e->GetNodeIndex( node3 ) >= 0 ) {
int nID = it2->next()->GetID(); return static_cast<const SMDS_MeshEdge*>( e );
if( nID==node2->GetID() || nID==node3->GetID() ) {
tmp++;
if(tmp==2) {
toReturn = e;
break;
}
}
} }
} }
return toReturn; return 0;
} }
@ -1357,25 +1345,14 @@ 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 || !node2 || !node3 ) return 0; SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face);
const SMDS_MeshFace * face;
const SMDS_MeshElement * node;
bool node2found, node3found;
SMDS_ElemIteratorPtr it1 = node1->facesIterator();
while(it1->more()) { while(it1->more()) {
face = static_cast<const SMDS_MeshFace*>(it1->next()); const SMDS_MeshElement * e = it1->next();
if(face->NbNodes()!=3) continue; if ( e->NbNodes() == 3 &&
SMDS_ElemIteratorPtr it2 = face->nodesIterator(); e->GetNodeIndex( node2 ) >= 0 &&
node2found = false; e->GetNodeIndex( node3 ) >= 0 ) {
node3found = false; return static_cast<const SMDS_MeshFace*>( e );
while(it2->more()) {
node = it2->next();
if(node->GetID()==node2->GetID()) node2found = true;
if(node->GetID()==node3->GetID()) node3found = true;
} }
if( node2found && node3found )
return face;
} }
return NULL; return NULL;
} }
@ -1413,27 +1390,14 @@ 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==NULL) || (node2==NULL) || (node3==NULL) || (node4==NULL) ) SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face);
return NULL;
const SMDS_MeshFace * face;
const SMDS_MeshElement * node;
bool node2found, node3found, node4found;
SMDS_ElemIteratorPtr it1 = node1->facesIterator();
while(it1->more()) { while(it1->more()) {
face = static_cast<const SMDS_MeshFace *>(it1->next()); const SMDS_MeshElement* f = it1->next();
if(face->NbNodes()!=4) continue; if ( f->NbNodes() == 4 &&
SMDS_ElemIteratorPtr it2 = face->nodesIterator(); f->GetNodeIndex( node2 ) >= 0 &&
node2found = false; f->GetNodeIndex( node3 ) >= 0 &&
node3found = false; f->GetNodeIndex( node4 ) >= 0 )
node4found = false; return static_cast<const SMDS_MeshFace *>( f );
while(it2->more()) {
node=it2->next();
if(node->GetID()==node2->GetID()) node2found = true;
if(node->GetID()==node3->GetID()) node3found = true;
if(node->GetID()==node4->GetID()) node4found = true;
}
if( node2found && node3found && node4found )
return face;
} }
return NULL; return NULL;
} }
@ -1477,26 +1441,16 @@ 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==NULL) || (node2==NULL) || (node3==NULL) || SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face);
(node4==NULL) || (node5==NULL) || (node6==NULL) ) return NULL;
const SMDS_MeshFace * face;
const SMDS_MeshElement * node;
SMDS_ElemIteratorPtr it1 = node1->facesIterator();
while(it1->more()) { while(it1->more()) {
face = static_cast<const SMDS_MeshFace*>(it1->next()); const SMDS_MeshElement* f = it1->next();
if(face->NbNodes()!=6) continue; if ( f->NbNodes() == 6 &&
SMDS_ElemIteratorPtr it2 = face->nodesIterator(); f->GetNodeIndex( node2 ) >= 0 &&
int tmp = 0; f->GetNodeIndex( node3 ) >= 0 &&
while(it2->more()) { f->GetNodeIndex( node4 ) >= 0 &&
node = it2->next(); f->GetNodeIndex( node5 ) >= 0 &&
if(node->GetID()==node2->GetID()) tmp++; f->GetNodeIndex( node6 ) >= 0 )
if(node->GetID()==node3->GetID()) tmp++; return static_cast<const SMDS_MeshFace *>( f );
if(node->GetID()==node4->GetID()) tmp++;
if(node->GetID()==node5->GetID()) tmp++;
if(node->GetID()==node6->GetID()) tmp++;
}
if( tmp==5 )
return static_cast<const SMDS_MeshFace*>(face);
} }
return NULL; return NULL;
} }
@ -1532,29 +1486,18 @@ 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==NULL) || (node2==NULL) || (node3==NULL) || (node4==NULL) || SMDS_ElemIteratorPtr it1 = node1->GetInverseElementIterator(SMDSAbs_Face);
(node5==NULL) || (node6==NULL) || (node7==NULL) || (node8==NULL) )
return NULL;
const SMDS_MeshFace * face;
const SMDS_MeshElement * node;
SMDS_ElemIteratorPtr it1 = node1->facesIterator();
while(it1->more()) { while(it1->more()) {
face = static_cast<const SMDS_MeshFace *>(it1->next()); const SMDS_MeshElement* f = it1->next();
if(face->NbNodes()!=8) continue; if ( f->NbNodes() == 8 &&
SMDS_ElemIteratorPtr it2 = face->nodesIterator(); f->GetNodeIndex( node2 ) >= 0 &&
int tmp = 0; f->GetNodeIndex( node3 ) >= 0 &&
while(it2->more()) { f->GetNodeIndex( node4 ) >= 0 &&
node = it2->next(); f->GetNodeIndex( node5 ) >= 0 &&
if(node->GetID()==node2->GetID()) tmp++; f->GetNodeIndex( node6 ) >= 0 &&
if(node->GetID()==node3->GetID()) tmp++; f->GetNodeIndex( node7 ) >= 0 &&
if(node->GetID()==node4->GetID()) tmp++; f->GetNodeIndex( node8 ) >= 0 )
if(node->GetID()==node5->GetID()) tmp++; return static_cast<const SMDS_MeshFace *>( f );
if(node->GetID()==node6->GetID()) tmp++;
if(node->GetID()==node7->GetID()) tmp++;
if(node->GetID()==node8->GetID()) tmp++;
}
if( tmp==7 )
return face;
} }
return NULL; return NULL;
} }
@ -1588,36 +1531,19 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace (std::vector<int> nodes_ids) const
const SMDS_MeshFace* SMDS_Mesh::FindFace (std::vector<const SMDS_MeshNode *> nodes) const SMDS_MeshFace* SMDS_Mesh::FindFace (std::vector<const SMDS_MeshNode *> nodes)
{ {
int nbNodes = nodes.size(); if ( nodes.size() > 2 && nodes[0] ) {
if (nbNodes < 1) return NULL; SMDS_ElemIteratorPtr itF = nodes[0]->GetInverseElementIterator(SMDSAbs_Face);
bool isFound = true;
const SMDS_MeshFace * face;
set<const SMDS_MeshFace *> faces;
for (int inode = 0; inode < nbNodes && isFound; inode++) {
if ( !nodes[ inode ]) return 0;
set<const SMDS_MeshFace *> new_faces;
SMDS_ElemIteratorPtr itF = nodes[inode]->facesIterator();
while (itF->more()) { while (itF->more()) {
face = static_cast<const SMDS_MeshFace *>(itF->next()); const SMDS_MeshElement* f = itF->next();
if (face->NbNodes() == nbNodes) { if ( f->NbNodes() == nodes.size() ) {
if (inode == 0 || faces.find(face) != faces.end()) { int ok = true, i = 1;
new_faces.insert(face); while ( ok && i < nodes.size() )
} ok = ( f->GetNodeIndex( nodes[ i ] ) >= 0 );
if ( ok )
return static_cast<const SMDS_MeshFace *>( f );
} }
} }
faces = new_faces;
if (new_faces.size() == 0) {
isFound = false;
}
} }
if (isFound)
return face;
return NULL; return NULL;
} }