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