Version: 6.3.1
Public Member Functions | Private Attributes | Friends

SMESH_ProxyMesh.SubMesh Class Reference

Proxy sub-mesh. More...

#include <SMESH_ProxyMesh.hxx>

Inheritance diagram for SMESH_ProxyMesh.SubMesh:
Inheritance graph
[legend]

Public Member Functions

const TN2NMapGetNodeNodeMap () const
const SMDS_MeshNodeGetProxyNode (const SMDS_MeshNode *n) const
 Return a proxy node or an input node.
virtual void AddElement (const SMDS_MeshElement *e)
 Store an element.
virtual int NbElements () const
 Return number of elements in a proxy submesh.
virtual SMDS_ElemIteratorPtr GetElements () const
 Return elements of a proxy submesh.
virtual void Clear ()
 Deletes temporary elements.
virtual bool Contains (const SMDS_MeshElement *ME) const
 Check presence of element inside it-self.
template<class ITERATOR >
void ChangeElements (ITERATOR it, ITERATOR end)
 SubMesh (int index=0)
 ~SubMesh ()
virtual bool IsComplexSubmesh () const
virtual bool RemoveElement (const SMDS_MeshElement *ME, bool isElemDeleted)
virtual void AddNode (const SMDS_MeshNode *ME)
virtual bool RemoveNode (const SMDS_MeshNode *ME, bool isNodeDeleted)
void AddSubMesh (const SMESHDS_SubMesh *theSubMesh)
bool RemoveSubMesh (const SMESHDS_SubMesh *theSubMesh)
void RemoveAllSubmeshes ()
bool ContainsSubMesh (const SMESHDS_SubMesh *theSubMesh) const
int NbSubMeshes () const
SMESHDS_SubMeshIteratorPtr GetSubMeshIterator () const
virtual int NbNodes () const
virtual SMDS_NodeIteratorPtr GetNodes () const
int getSize ()
void compactList ()
SMESHDS_MeshgetParent ()

Private Attributes

std::vector< const
SMDS_MeshElement * > 
_elements
TN2NMap_n2n

Friends

class SMESH_ProxyMesh

Detailed Description

Proxy sub-mesh.

Definition at line 57 of file SMESH_ProxyMesh.hxx.


Constructor & Destructor Documentation

SMESH_ProxyMesh.SubMesh.SubMesh ( int  index = 0)

Definition at line 77 of file SMESH_ProxyMesh.hxx.

:SMESHDS_SubMesh(0,index),_n2n(0) {}
SMESH_ProxyMesh.SubMesh.~SubMesh ( )

Definition at line 78 of file SMESH_ProxyMesh.hxx.

{ Clear(); }

Member Function Documentation

void SMESH_ProxyMesh.SubMesh::AddElement ( const SMDS_MeshElement e) [virtual]

Store an element.

Reimplemented from SMESHDS_SubMesh.

Definition at line 529 of file SMESH_ProxyMesh.cxx.

Referenced by StdMeshers_QuadToTriaAdaptor.Compute(), VISCOUS._ViscousBuilder.makeLayer(), and VISCOUS._ViscousBuilder.shrink().

{
  _elements.push_back( e );
}
void SMESHDS_SubMesh::AddNode ( const SMDS_MeshNode ME) [virtual, inherited]

Definition at line 153 of file SMESHDS_SubMesh.cxx.

References SMDS_MeshElement.GetID(), SMDS_MeshElement.getIdInShape(), SMDS_MeshElement.getshapeId(), MESSAGE, ex29_refine.node(), SMDS_MeshElement.setIdInShape(), and SMDS_MeshElement.setShapeId().

Referenced by SMESHDS_Mesh.add(), DriverMED_R_SMESHDS_Mesh.GetSubMesh(), StdMeshers_Import_1D.importMesh(), SMESH_Gen_i.Load(), and SMESH_MeshEditor.SplitVolumesIntoTetra().

{
  if ( !IsComplexSubmesh() )
    {
      int idInSubShape = N->getIdInShape();
      int shapeId = N->getshapeId();
      if ((shapeId > 0) && (idInSubShape >= 0))
        {
          MESSAGE("========== AddNode already belonging to other subShape " << N->GetID());
          // OK for vertex nodes
          //this->getParent()->UnSetNodeOnShape(N);
        }
      SMDS_MeshNode* node = (SMDS_MeshNode*)(N);
      node->setShapeId(myIndex);
      node->setIdInShape(myNodes.size());
      myNodes.push_back(N);
      //MESSAGE("in "<< myIndex << " AddNode " << node->GetID());
    }
  //MESSAGE("try to add node in a complex submesh " << N->GetID());
}
void SMESHDS_SubMesh::AddSubMesh ( const SMESHDS_SubMesh theSubMesh) [inherited]

Definition at line 411 of file SMESHDS_SubMesh.cxx.

Referenced by SMESHDS_Mesh.AddCompoundSubmesh(), and SMESH_ProxyMesh.GetFaces().

{
  ASSERT( theSubMesh );
  mySubMeshes.insert( theSubMesh );
}
template<class ITERATOR >
void SMESH_ProxyMesh.SubMesh.ChangeElements ( ITERATOR  it,
ITERATOR  end 
)

Definition at line 70 of file SMESH_ProxyMesh.hxx.

Referenced by StdMeshers_QuadToTriaAdaptor.Compute().

    {
      // change SubMesh contents without deleting tmp faces
      // for which the caller is responsible
      _elements.clear();
      while ( it != end ) _elements.push_back( *it++ );
    }
void SMESH_ProxyMesh.SubMesh::Clear ( ) [virtual]

Deletes temporary elements.

Reimplemented from SMESHDS_SubMesh.

Definition at line 490 of file SMESH_ProxyMesh.cxx.

{
  for ( unsigned i = 0; i < _elements.size(); ++i )
    if ( _elements[i]->GetID() < 0 )
      delete _elements[i];
  _elements.clear();
  if ( _n2n )
    delete _n2n, _n2n = 0;
}
void SMESHDS_SubMesh::compactList ( ) [inherited]

Definition at line 487 of file SMESHDS_SubMesh.cxx.

References ex29_refine.node(), and SMDS_MeshElement.setIdInShape().

{
  //MESSAGE("compactList old: nodes " << myNodes.size() << " elements " << myElements.size());
  //stringstream a;
  //stringstream b;
  //stringstream c;
  //stringstream d;

  std::vector<const SMDS_MeshElement*> newElems;
  newElems.clear();
  for (int i = 0; i < myElements.size(); i++)
    if (myElements[i])
      {
        SMDS_MeshElement* elem = (SMDS_MeshElement*)myElements[i];
        elem->setIdInShape(newElems.size());
        newElems.push_back(elem);
        //a << elem->GetID() << " ";
        //b << elem->GetID() << " ";
      }
    //else
    //  a << "_ ";
  myElements.swap(newElems);
  myUnusedIdElements = 0;
  //MESSAGE("in " << myIndex << " oldElems " << a.str());
  //MESSAGE("in " << myIndex << " newElems " << b.str());

  std::vector<const SMDS_MeshNode*> newNodes;
  newNodes.clear();
  for (int i = 0; i < myNodes.size(); i++)
    if (myNodes[i])
      {
        SMDS_MeshNode* node = (SMDS_MeshNode*)myNodes[i];
        node->setIdInShape(newNodes.size());
        newNodes.push_back(node);
        //c << node->GetID() << " ";
        //d << node->GetID() << " ";
      }
    //else
    //  c << "_ ";
  myNodes.swap(newNodes);
  myUnusedIdNodes = 0;
  //MESSAGE("in " << myIndex << " oldNodes " << c.str());
  //MESSAGE("in " << myIndex << " newNodes " << d.str());
  //MESSAGE("compactList new: nodes " << myNodes.size() << " elements " << myElements.size());
}
bool SMESH_ProxyMesh.SubMesh::Contains ( const SMDS_MeshElement ME) const [virtual]

Check presence of element inside it-self.

Reimplemented from SMESHDS_SubMesh.

Definition at line 540 of file SMESH_ProxyMesh.cxx.

References SMDS_MeshElement.GetType(), and SMDSAbs_Node.

{
  if ( ME->GetType() != SMDSAbs_Node )
    return find( _elements.begin(), _elements.end(), ME ) != _elements.end();
  return false;
}
bool SMESHDS_SubMesh::ContainsSubMesh ( const SMESHDS_SubMesh theSubMesh) const [inherited]

Definition at line 442 of file SMESHDS_SubMesh.cxx.

{
  return mySubMeshes.find( theSubMesh ) != mySubMeshes.end();
}
SMDS_ElemIteratorPtr SMESH_ProxyMesh.SubMesh::GetElements ( ) const [virtual]

Return elements of a proxy submesh.

Reimplemented from SMESHDS_SubMesh.

Definition at line 517 of file SMESH_ProxyMesh.cxx.

Referenced by VISCOUS._ViscousBuilder.MakeN2NMap(), and VISCOUS._ViscousBuilder.shrink().

const TN2NMap* SMESH_ProxyMesh.SubMesh.GetNodeNodeMap ( ) const

Definition at line 61 of file SMESH_ProxyMesh.hxx.

{ return _n2n; }
SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes ( ) const [virtual, inherited]
SMESHDS_Mesh* SMESHDS_SubMesh.getParent ( ) [inherited]

Definition at line 76 of file SMESHDS_SubMesh.hxx.

{return myParent; };
const SMDS_MeshNode * SMESH_ProxyMesh.SubMesh::GetProxyNode ( const SMDS_MeshNode n) const

Return a proxy node or an input node.

Definition at line 476 of file SMESH_ProxyMesh.cxx.

References SMESH_ProxyMesh.SubMesh._n2n.

{
  TN2NMap::iterator n2n;
  if ( _n2n && ( n2n = _n2n->find( n )) != _n2n->end())
    return n2n->second;
  return n;
}
int SMESHDS_SubMesh::getSize ( ) [inherited]

Definition at line 478 of file SMESHDS_SubMesh.cxx.

References ex13_hole1partial.d.

{
  int c = NbNodes();
  int d = NbElements();
  //cerr << "SMESHDS_SubMesh::NbNodes " << c << endl;
  //cerr << "SMESHDS_SubMesh::NbElements " << d << endl;
  return c+d;
}
SMESHDS_SubMeshIteratorPtr SMESHDS_SubMesh::GetSubMeshIterator ( ) const [inherited]
virtual bool SMESHDS_SubMesh.IsComplexSubmesh ( ) const [virtual, inherited]
int SMESH_ProxyMesh.SubMesh::NbElements ( ) const [virtual]

Return number of elements in a proxy submesh.

Reimplemented from SMESHDS_SubMesh.

Definition at line 506 of file SMESH_ProxyMesh.cxx.

Referenced by VISCOUS._ViscousBuilder.MakeN2NMap().

{
  return _elements.size();
}
int SMESHDS_SubMesh::NbNodes ( ) const [virtual, inherited]
int SMESHDS_SubMesh.NbSubMeshes ( ) const [inherited]

Definition at line 61 of file SMESHDS_SubMesh.hxx.

Referenced by SMESH_ProxyMesh.GetFaces().

{ return mySubMeshes.size(); }
void SMESHDS_SubMesh::RemoveAllSubmeshes ( ) [inherited]

Definition at line 432 of file SMESHDS_SubMesh.cxx.

Referenced by SMESH_ProxyMesh.GetFaces().

{
  mySubMeshes.clear();
}
bool SMESHDS_SubMesh::RemoveElement ( const SMDS_MeshElement ME,
bool  isElemDeleted 
) [virtual, inherited]

Definition at line 119 of file SMESHDS_SubMesh.cxx.

References SMDS_MeshElement.getIdInShape(), SMDS_MeshElement.getshapeId(), MESSAGE, SMDS_MeshElement.setIdInShape(), and SMDS_MeshElement.setShapeId().

Referenced by SMESHDS_Mesh.RemoveFreeElement().

{
  if (!ME)
    {
      MESSAGE("-----------------> Remove Null Element " << isElemDeleted);
      return false;
    }
  //MESSAGE("-----------------> RemoveElement "<< ME->GetID() << " " << isElemDeleted);
  if (!IsComplexSubmesh())
    {
      if ( ME->getshapeId() != myIndex )
        return false;
      int idInSubShape = ME->getIdInShape();
      //MESSAGE("in "<< myIndex << " RemoveElement " << ME->GetID() << " " << idInSubShape << " " << myUnusedIdElements);
      SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
      elem->setShapeId(0);
      elem->setIdInShape(-1);
      if ((idInSubShape >= 0) && (idInSubShape < myElements.size()))
        {
          myElements[idInSubShape] = 0; // this vector entry is no more used
          myUnusedIdElements++;
          return true;
        }
      return false;
      //  }
    }
  MESSAGE("Try to remove an element from a complex submesh ");
  return false;
}
bool SMESHDS_SubMesh::RemoveNode ( const SMDS_MeshNode ME,
bool  isNodeDeleted 
) [virtual, inherited]

Definition at line 179 of file SMESHDS_SubMesh.cxx.

References SMDS_MeshElement.getIdInShape(), SMDS_MeshElement.getshapeId(), MESSAGE, ex29_refine.node(), SMDS_MeshElement.setIdInShape(), and SMDS_MeshElement.setShapeId().

Referenced by SMESHDS_Mesh.RemoveFreeNode().

{
  if (!IsComplexSubmesh())
    {
      // if (!isNodeDeleted) // alive node has valid ID and can be found
      // {
      if ( N->getshapeId() != myIndex )
        return false;
      int idInSubShape = N->getIdInShape();
      //int shapeId = N->getshapeId();
      //MESSAGE("in "<< myIndex << " RemoveNode " << shapeId << " " << idInSubShape << " " << N->GetID());
      SMDS_MeshNode* node = (SMDS_MeshNode*) (N);
      node->setShapeId(0);
      node->setIdInShape(-1);
      if ((idInSubShape >= 0) && (idInSubShape < myNodes.size()))
        {
          myNodes[idInSubShape] = 0; // this vector entry is no more used
          myUnusedIdNodes++;
          return true;
        }
      return false;
      // }
    }
  MESSAGE("Try to remove a node from a complex submesh");
  return false;
}
bool SMESHDS_SubMesh::RemoveSubMesh ( const SMESHDS_SubMesh theSubMesh) [inherited]

Definition at line 422 of file SMESHDS_SubMesh.cxx.

{
  return mySubMeshes.erase( theSubMesh );
}

Friends And Related Function Documentation

friend class SMESH_ProxyMesh [friend]

Definition at line 83 of file SMESH_ProxyMesh.hxx.


Field Documentation

std::vector<const SMDS_MeshElement *> SMESH_ProxyMesh.SubMesh._elements [private]

Definition at line 81 of file SMESH_ProxyMesh.hxx.

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