// Module : SMESH
// $Header$
-using namespace std;
using namespace std;
#include "SMESH_subMesh_i.hxx"
#include "SMESH_Gen_i.hxx"
*/
//=============================================================================
-CORBA::Long SMESH_subMesh_i::GetNumberOfNodes()
+CORBA::Long SMESH_subMesh_i::GetNumberOfNodes(CORBA::Boolean all)
throw (SALOME::SALOME_Exception)
{
Unexpect aCatch(SALOME_SalomeException);
if ( aSubMeshDS == NULL )
return 0;
+ if ( all ) { // all nodes of submesh elements
+ set<int> nodeIds;
+ SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements();
+ while ( eIt->more() ) {
+ const SMDS_MeshElement* anElem = eIt->next();
+ SMDS_ElemIteratorPtr nIt = anElem->nodesIterator();
+ while ( nIt->more() )
+ nodeIds.insert( nIt->next()->GetID() );
+ }
+ return nodeIds.size();
+ }
+
return aSubMeshDS->NbNodes();
}
if ( aSubMeshDS == NULL )
return aResult._retn();
- int i = 0;
+ // No sense in returning ids of elements along with ids of nodes:
+ // when theElemType == SMESH::ALL, return node ids only if
+ // there are no elements
+ bool retNodes = (theElemType == SMESH::NODE ||
+ (theElemType == SMESH::ALL && aSubMeshDS->NbElements() == 0));
+
+ // PAL5440, return all nodes belonging to elements of submesh
+ set<int> nodeIds;
+ if ( retNodes ) {
+ SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements();
+ while ( eIt->more() ) {
+ const SMDS_MeshElement* anElem = eIt->next();
+ SMDS_ElemIteratorPtr nIt = anElem->nodesIterator();
+ while ( nIt->more() )
+ nodeIds.insert( nIt->next()->GetID() );
+ }
+ }
+
if ( theElemType == SMESH::ALL )
- aResult->length( aSubMeshDS->NbElements() + aSubMeshDS->NbNodes() );
+ aResult->length( aSubMeshDS->NbElements() + nodeIds.size());
else if ( theElemType == SMESH::NODE )
- aResult->length( aSubMeshDS->NbNodes() );
+ aResult->length( nodeIds.size() );
else
aResult->length( aSubMeshDS->NbElements() );
- int n = aResult->length();
+ int i = 0, n = aResult->length();
- if ( theElemType == SMESH::ALL || theElemType == SMESH::NODE ) {
- SMDS_NodeIteratorPtr anIt = aSubMeshDS->GetNodes();
- while ( i < n && anIt->more() )
- aResult[i++] = anIt->next()->GetID();
+ if ( retNodes && !nodeIds.empty() ) {
+ set<int>::iterator idIt = nodeIds.begin();
+ for ( ; i < n && idIt != nodeIds.end() ; i++, idIt++ )
+ aResult[i] = *idIt;
}
if ( theElemType == SMESH::ALL || theElemType != SMESH::NODE ) {
if ( families[i]->getIdentifier() == ( _localId ) )
return families[i];
}
+
+ return SALOME_MED::FAMILY::_nil();
}