Version: 6.3.1
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Friends

SMESH_subMesh_i Class Reference

#include <SMESH_subMesh_i.hxx>

Inheritance diagram for SMESH_subMesh_i:
Inheritance graph
[legend]

Public Member Functions

 SMESH_subMesh_i ()
 SMESH_subMesh_i (PortableServer::POA_ptr thePOA, SMESH_Gen_i *gen_i, SMESH_Mesh_i *mesh_i, int localId)
 ~SMESH_subMesh_i ()
CORBA::Long GetNumberOfElements () throw (SALOME::SALOME_Exception)
CORBA::Long GetNumberOfNodes (CORBA::Boolean all) throw (SALOME::SALOME_Exception)
SMESH::long_arrayGetElementsId () throw (SALOME::SALOME_Exception)
SMESH::long_arrayGetElementsByType (SMESH::ElementType theElemType) throw (SALOME::SALOME_Exception)
SMESH::ElementType GetElementType (CORBA::Long id, bool iselem) throw (SALOME::SALOME_Exception)
SMESH::long_arrayGetNodesId () throw (SALOME::SALOME_Exception)
SMESH::SMESH_Mesh_ptr GetFather () throw (SALOME::SALOME_Exception)
GEOM::GEOM_Object_ptr GetSubShape () throw (SALOME::SALOME_Exception)
CORBA::Long GetId ()
SALOME_MED::FAMILY_ptr GetFamily () throw (SALOME::SALOME_Exception)
virtual SMESH::long_arrayGetIDs ()
 Returns a sequence of all element IDs.
virtual SMESH::long_arrayGetMeshInfo ()
 Returns statistic of mesh elements Result array of number enityties Inherited from SMESH_IDSource.
virtual
SMESH::array_of_ElementType
GetTypes ()
 Returns types of elements it contains.
SMESH::SMESH_Mesh_ptr GetMesh ()
 Returns the mesh.

Data Fields

SMESH_Mesh_i_mesh_i

Protected Member Functions

void changeLocalId (int localId)

Protected Attributes

SMESH_Gen_i_gen_i
int _localId

Friends

void SMESH_Mesh_i::CheckGeomGroupModif ()

Detailed Description

Definition at line 44 of file SMESH_subMesh_i.hxx.


Constructor & Destructor Documentation

SMESH_subMesh_i::SMESH_subMesh_i ( )

Definition at line 49 of file SMESH_subMesh_i.cxx.

References MESSAGE.

     : SALOME::GenericObj_i( PortableServer::POA::_nil() )
{
  MESSAGE("SMESH_subMesh_i::SMESH_subMesh_i default, not for use");
    ASSERT(0);
}
SMESH_subMesh_i::SMESH_subMesh_i ( PortableServer::POA_ptr  thePOA,
SMESH_Gen_i gen_i,
SMESH_Mesh_i mesh_i,
int  localId 
)

Definition at line 62 of file SMESH_subMesh_i.cxx.

References _gen_i, _localId, _mesh_i, and MESSAGE.

     : SALOME::GenericObj_i( thePOA )
{
  MESSAGE("SMESH_subMesh_i::SMESH_subMesh_i");
  _gen_i = gen_i;
  _mesh_i = mesh_i;
  _localId = localId;
  // ****
}
SMESH_subMesh_i::~SMESH_subMesh_i ( )

Definition at line 80 of file SMESH_subMesh_i.cxx.

References MESSAGE.

{
  MESSAGE("SMESH_subMesh_i::~SMESH_subMesh_i");
  // ****
}

Member Function Documentation

void SMESH_subMesh_i.changeLocalId ( int  localId) [protected]

Definition at line 115 of file SMESH_subMesh_i.hxx.

{ _localId = localId; }
SMESH::long_array * SMESH_subMesh_i::GetElementsByType ( SMESH::ElementType  theElemType) throw (SALOME::SALOME_Exception)

Definition at line 304 of file SMESH_subMesh_i.cxx.

References SMESH.ALL, SMESHDS_SubMesh.GetElements(), SMDS_MeshElement.GetID(), SMESHDS_SubMesh.GetNodes(), getSubMeshes(), SMDS_MeshElement.GetType(), MESSAGE, SMESHDS_SubMesh.NbElements(), SMESH.NODE, and SMDS_MeshElement.nodesIterator().

Referenced by GetNodesId().

{
  Unexpect aCatch(SALOME_SalomeException);
  MESSAGE("SMESH_subMesh_i::GetElementsByType");
  SMESH::long_array_var aResult = new SMESH::long_array();

  if ( _mesh_i->_mapSubMesh.find( _localId ) == _mesh_i->_mapSubMesh.end() )
    return aResult._retn();

  ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId];
  SMESHDS_SubMesh* aSubMeshDS = aSubMesh->GetSubMeshDS();

  // PAL5440, return all nodes belonging to elements of submesh
  set<int> nodeIds;
  int nbElems = aSubMeshDS ? aSubMeshDS->NbElements() : 0;

  // volumes may be bound to shell instead of solid
  TListOfSubMeshes smList;
  if ( nbElems == 0 && getSubMeshes( aSubMesh, smList ))
  {
    TListOfSubMeshes::iterator sm = smList.begin();
    for ( ; sm != smList.end(); ++sm )
    {
      if ( theElemType == SMESH::NODE )
      {
        SMDS_ElemIteratorPtr eIt = (*sm)->GetElements();
        if ( eIt->more() ) {
          while ( eIt->more() ) {
            const SMDS_MeshElement* anElem = eIt->next();
            SMDS_ElemIteratorPtr nIt = anElem->nodesIterator();
            while ( nIt->more() )
              nodeIds.insert( nIt->next()->GetID() );
          }
        } else {
          SMDS_NodeIteratorPtr nIt = (*sm)->GetNodes();
          while ( nIt->more() )
            nodeIds.insert( nIt->next()->GetID() );
        }
      }
      else
      {
        nbElems += (*sm)->NbElements();
      }
    }
    aSubMeshDS = 0;
  }
  else
  {
    if ( nbElems )
      smList.push_back( aSubMeshDS );
  }

  if ( theElemType == SMESH::NODE && aSubMeshDS )
  {
    SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements();
    if ( eIt->more() ) {
      while ( eIt->more() ) {
        const SMDS_MeshElement* anElem = eIt->next();
        SMDS_ElemIteratorPtr nIt = anElem->nodesIterator();
        while ( nIt->more() )
          nodeIds.insert( nIt->next()->GetID() );
      }
    } else {
      SMDS_NodeIteratorPtr nIt = aSubMeshDS->GetNodes();
      while ( nIt->more() )
        nodeIds.insert( nIt->next()->GetID() );
    }
  }

  if ( theElemType == SMESH::NODE )
    aResult->length( nodeIds.size() );
  else
    aResult->length( nbElems );

  int i = 0, n = aResult->length();

  if ( theElemType == SMESH::NODE && !nodeIds.empty() ) {
    set<int>::iterator idIt = nodeIds.begin();
    for ( ; i < n && idIt != nodeIds.end() ; i++, idIt++ )
      aResult[i] = *idIt;
  }

  if ( theElemType != SMESH::NODE ) {
    TListOfSubMeshes::iterator sm = smList.begin();
    for ( i = 0; sm != smList.end(); sm++ )
    {
      aSubMeshDS = *sm;
      SMDS_ElemIteratorPtr anIt = aSubMeshDS->GetElements();
      while ( i < n && anIt->more() ) {
        const SMDS_MeshElement* anElem = anIt->next();
        if ( theElemType == SMESH::ALL || anElem->GetType() == (SMDSAbs_ElementType)theElemType )
          aResult[i++] = anElem->GetID();
      }
    }
  }

  aResult->length( i );

  return aResult._retn();
}
SMESH::long_array * SMESH_subMesh_i::GetElementsId ( ) throw (SALOME::SALOME_Exception)

Definition at line 257 of file SMESH_subMesh_i.cxx.

References _localId, SMESH_Mesh_i._mapSubMesh, _mesh_i, getSubMeshes(), MESSAGE, and SMESHDS_SubMesh.NbElements().

Referenced by GetIDs().

{
  Unexpect aCatch(SALOME_SalomeException);
  MESSAGE("SMESH_subMesh_i::GetElementsId");
  SMESH::long_array_var aResult = new SMESH::long_array();

  if ( _mesh_i->_mapSubMesh.find( _localId ) == _mesh_i->_mapSubMesh.end() )
    return aResult._retn();

  ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId];
  SMESHDS_SubMesh* aSubMeshDS = aSubMesh->GetSubMeshDS();

  int nbElems = aSubMeshDS ? aSubMeshDS->NbElements() : 0;
  TListOfSubMeshes smList;
  if ( nbElems )
    smList.push_back( aSubMeshDS );

  // volumes are bound to shell
  if ( nbElems == 0 && getSubMeshes( aSubMesh, smList ))
  {
    TListOfSubMeshes::iterator sm = smList.begin();
    for ( ; sm != smList.end(); ++sm )
      nbElems += (*sm)->NbElements();
  }

  aResult->length( nbElems );
  if ( nbElems )
  {
    TListOfSubMeshes::iterator sm = smList.begin();
    for ( int i = 0; sm != smList.end(); sm++ )
    {
      SMDS_ElemIteratorPtr anIt = (*sm)->GetElements();
      for ( ; i < nbElems && anIt->more(); i++ )
        aResult[i] = anIt->next()->GetID();
    }
  }
  return aResult._retn();
}
SMESH::ElementType SMESH_subMesh_i::GetElementType ( CORBA::Long  id,
bool  iselem 
) throw (SALOME::SALOME_Exception)

Definition at line 514 of file SMESH_subMesh_i.cxx.

{
  return GetFather()->GetElementType( id, iselem );
}
SALOME_MED::FAMILY_ptr SMESH_subMesh_i::GetFamily ( ) throw (SALOME::SALOME_Exception)

Definition at line 481 of file SMESH_subMesh_i.cxx.

References _localId, and GetFather().

{
  Unexpect aCatch(SALOME_SalomeException);
  SALOME_MED::MESH_var MEDMesh = GetFather()->GetMEDMesh();

  SALOME_MED::Family_array_var families = 
    MEDMesh->getFamilies(SALOME_MED::MED_NODE);
    
  for ( int i = 0; i < families->length(); i++ ) {
    if ( families[i]->getIdentifier() == ( _localId ) )
      return families[i];
  }
  
  return SALOME_MED::FAMILY::_nil();
}
SMESH::SMESH_Mesh_ptr SMESH_subMesh_i::GetFather ( ) throw (SALOME::SALOME_Exception)

Definition at line 427 of file SMESH_subMesh_i.cxx.

References _mesh_i, and MESSAGE.

Referenced by GetFamily(), and GetMesh().

{
  Unexpect aCatch(SALOME_SalomeException);
  MESSAGE("SMESH_subMesh_i::GetFather");
  return _mesh_i->_this();
}
CORBA::Long SMESH_subMesh_i::GetId ( )

Definition at line 441 of file SMESH_subMesh_i.cxx.

References _localId, and MESSAGE.

Referenced by SMESH_MEDSupport_i.SMESH_MEDSupport_i().

{
  MESSAGE("SMESH_subMesh_i::GetId");
  return _localId;
}
SMESH::long_array * SMESH_subMesh_i::GetIDs ( ) [virtual]

Returns a sequence of all element IDs.

Definition at line 503 of file SMESH_subMesh_i.cxx.

References GetElementsId().

{
  SMESH::long_array_var aResult = GetElementsId();
  return aResult._retn();
}
SMESH::SMESH_Mesh_ptr SMESH_subMesh_i::GetMesh ( )

Returns the mesh.

Definition at line 591 of file SMESH_subMesh_i.cxx.

References GetFather().

{
  return GetFather();
}
SMESH::long_array * SMESH_subMesh_i::GetMeshInfo ( ) [virtual]

Returns statistic of mesh elements Result array of number enityties Inherited from SMESH_IDSource.

Definition at line 528 of file SMESH_subMesh_i.cxx.

References _localId, SMESH_Mesh_i._mapSubMesh, _mesh_i, SMESH_Mesh_i.CollectMeshInfo(), SMESH.Entity_Last, SMESH.Entity_Node, GetNumberOfNodes(), and getSubMeshes().

{
  SMESH::long_array_var aRes = new SMESH::long_array();
  aRes->length(SMESH::Entity_Last);
  for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++)
    aRes[i] = 0;
  
  // get number of nodes
  aRes[ SMESH::Entity_Node ] = GetNumberOfNodes(true);
 
  ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId];

  // get statistic from child sub-meshes
  TListOfSubMeshes smList;
  if ( getSubMeshes( aSubMesh, smList ) )
    for ( TListOfSubMeshes::iterator sm = smList.begin(); sm != smList.end(); ++sm )
      SMESH_Mesh_i::CollectMeshInfo( (*sm)->GetElements(), aRes );

  return aRes._retn();
}
SMESH::long_array * SMESH_subMesh_i::GetNodesId ( ) throw (SALOME::SALOME_Exception)

Definition at line 412 of file SMESH_subMesh_i.cxx.

References GetElementsByType(), MESSAGE, and SMESH.NODE.

{
  Unexpect aCatch(SALOME_SalomeException);
  MESSAGE("SMESH_subMesh_i::GetNodesId");
  SMESH::long_array_var aResult = GetElementsByType( SMESH::NODE );
  return aResult._retn();
}
CORBA::Long SMESH_subMesh_i::GetNumberOfElements ( ) throw (SALOME::SALOME_Exception)

Definition at line 161 of file SMESH_subMesh_i.cxx.

References _localId, SMESH_Mesh_i._mapSubMesh, _mesh_i, getSubMeshes(), MESSAGE, and SMESHDS_SubMesh.NbElements().

{
  Unexpect aCatch(SALOME_SalomeException);
  MESSAGE("SMESH_subMesh_i::GetNumberOfElements");
  if ( _mesh_i->_mapSubMesh.find( _localId ) == _mesh_i->_mapSubMesh.end() )
    return 0;

  ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId];
  SMESHDS_SubMesh* aSubMeshDS = aSubMesh->GetSubMeshDS();

  int nbElems = aSubMeshDS ? aSubMeshDS->NbElements() : 0;

  // volumes are bound to shell
  TListOfSubMeshes smList;
  if ( nbElems == 0 && getSubMeshes( aSubMesh, smList ))
  {
    TListOfSubMeshes::iterator sm = smList.begin();
    for ( ; sm != smList.end(); ++sm )
      nbElems += (*sm)->NbElements();
  }
  return nbElems;
}
CORBA::Long SMESH_subMesh_i::GetNumberOfNodes ( CORBA::Boolean  all) throw (SALOME::SALOME_Exception)

Definition at line 191 of file SMESH_subMesh_i.cxx.

References SMESHDS_SubMesh.GetElements(), SMESHDS_SubMesh.GetNodes(), getSubMeshes(), MESSAGE, SMESHDS_SubMesh.NbNodes(), and SMDS_MeshElement.nodesIterator().

Referenced by GetMeshInfo().

{
  Unexpect aCatch(SALOME_SalomeException);
  MESSAGE("SMESH_subMesh_i::GetNumberOfNodes");
  if ( _mesh_i->_mapSubMesh.find( _localId ) == _mesh_i->_mapSubMesh.end() )
    return 0;

  ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId];
  SMESHDS_SubMesh* aSubMeshDS = aSubMesh->GetSubMeshDS();

  set<int> nodeIds;

  // nodes are bound to shell instead of solid
  TListOfSubMeshes smList;
  if ( all && getSubMeshes( aSubMesh, smList ))
  {
    TListOfSubMeshes::iterator sm = smList.begin();
    for ( ; sm != smList.end(); ++sm )
    {
      SMDS_ElemIteratorPtr eIt = (*sm)->GetElements();
      if ( eIt->more() ) {
        while ( eIt->more() ) {
          const SMDS_MeshElement* anElem = eIt->next();
          SMDS_ElemIteratorPtr nIt = anElem->nodesIterator();
          while ( nIt->more() )
            nodeIds.insert( nIt->next()->GetID() );
        }
      } else {
        SMDS_NodeIteratorPtr nIt = (*sm)->GetNodes();
        while ( nIt->more() )
          nodeIds.insert( nIt->next()->GetID() );
      }      
    }
    return nodeIds.size();
  }

  if ( aSubMeshDS == NULL )
    return 0;

  if ( all ) { // all nodes of submesh elements
    SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements();
    if ( eIt->more() ) {
      while ( eIt->more() ) {
        const SMDS_MeshElement* anElem = eIt->next();
        SMDS_ElemIteratorPtr nIt = anElem->nodesIterator();
        while ( nIt->more() )
          nodeIds.insert( nIt->next()->GetID() );
      }
    } else {
      SMDS_NodeIteratorPtr nIt = aSubMeshDS->GetNodes();
      while ( nIt->more() )
        nodeIds.insert( nIt->next()->GetID() );
    }
    return nodeIds.size();
  }

  return aSubMeshDS->NbNodes();
}
GEOM::GEOM_Object_ptr SMESH_subMesh_i::GetSubShape ( ) throw (SALOME::SALOME_Exception)

Definition at line 452 of file SMESH_subMesh_i.cxx.

References _gen_i, _localId, SMESH_Mesh_i._mapSubMesh, _mesh_i, and SMESH_Gen_i.ShapeToGeomObject().

{
  Unexpect aCatch(SALOME_SalomeException);
  GEOM::GEOM_Object_var aShapeObj;
  try {
    if ( _mesh_i->_mapSubMesh.find( _localId ) != _mesh_i->_mapSubMesh.end()) {
      TopoDS_Shape S = _mesh_i->_mapSubMesh[ _localId ]->GetSubShape();
      if ( !S.IsNull() ) {
        aShapeObj = _gen_i->ShapeToGeomObject( S );
        //mzn: N7PAL16232, N7PAL16233
        //In some cases it's possible that GEOM_Client contains the shape same to S, but
        //with another orientation.
        if (aShapeObj->_is_nil())
          aShapeObj = _gen_i->ShapeToGeomObject( S.Reversed() );
      }
    }
  }
  catch(SALOME_Exception & S_ex) {
    THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
  }
  return aShapeObj._retn();
}
SMESH::array_of_ElementType * SMESH_subMesh_i::GetTypes ( ) [virtual]

Returns types of elements it contains.

Definition at line 555 of file SMESH_subMesh_i.cxx.

References _localId, SMESH_Mesh_i._mapSubMesh, _mesh_i, SMESH.NODE, and SMESH_fixation.shape.

{
  SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;

  ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId];
  if ( SMESHDS_SubMesh* smDS = aSubMesh->GetSubMeshDS() )
  {
    SMDS_ElemIteratorPtr eIt = smDS->GetElements();
    if ( eIt->more() )
    {
      types->length( 1 );
      types[0] = SMESH::ElementType( eIt->next()->GetType());
    }
    else if ( smDS->GetNodes()->more() )
    {
      TopoDS_Shape shape = aSubMesh->GetSubShape();
      while ( !shape.IsNull() && shape.ShapeType() == TopAbs_COMPOUND )
      {
        TopoDS_Iterator it( shape );
        shape = it.More() ? it.Value() : TopoDS_Shape();
      }
      if ( !shape.IsNull() && shape.ShapeType() == TopAbs_VERTEX )
      {
        types->length( 1 );
        types[0] = SMESH::NODE;
      }
    }
  }
  return types._retn();
}

Friends And Related Function Documentation

void SMESH_Mesh_i::CheckGeomGroupModif ( ) [friend]

Field Documentation

Definition at line 116 of file SMESH_subMesh_i.hxx.

Referenced by GetSubShape(), and SMESH_subMesh_i().

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS