Version: 6.3.1
Public Member Functions | Private Attributes

SMESHDS_SubMesh Class Reference

#include <SMESHDS_SubMesh.hxx>

Inheritance diagram for SMESHDS_SubMesh:
Inheritance graph
[legend]

Public Member Functions

 SMESHDS_SubMesh (SMESHDS_Mesh *parent, int index)
 Constructor.
virtual ~SMESHDS_SubMesh ()
 Destructor.
virtual bool IsComplexSubmesh () const
virtual void AddElement (const SMDS_MeshElement *ME)
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 NbElements () const
virtual SMDS_ElemIteratorPtr GetElements () const
virtual int NbNodes () const
virtual SMDS_NodeIteratorPtr GetNodes () const
virtual bool Contains (const SMDS_MeshElement *ME) const
virtual void Clear ()
int getSize ()
void compactList ()
SMESHDS_MeshgetParent ()

Private Attributes

SMESHDS_MeshmyParent
std::vector< const
SMDS_MeshElement * > 
myElements
std::vector< const
SMDS_MeshNode * > 
myNodes
int myUnusedIdNodes
int myUnusedIdElements
int myIndex
std::set< const SMESHDS_SubMesh * > mySubMeshes

Detailed Description

Definition at line 42 of file SMESHDS_SubMesh.hxx.


Constructor & Destructor Documentation

SMESHDS_SubMesh::SMESHDS_SubMesh ( SMESHDS_Mesh parent,
int  index 
)

Constructor.

Definition at line 46 of file SMESHDS_SubMesh.cxx.

{
  myParent = parent;
  myElements.clear();
  myNodes.clear();
  myIndex = index;
  myUnusedIdNodes = 0;
  myUnusedIdElements = 0;
}
SMESHDS_SubMesh::~SMESHDS_SubMesh ( ) [virtual]

Destructor.

Definition at line 62 of file SMESHDS_SubMesh.cxx.

{
}

Member Function Documentation

void SMESHDS_SubMesh::AddElement ( const SMDS_MeshElement ME) [virtual]

Reimplemented in SMESH_ProxyMesh.SubMesh.

Definition at line 70 of file SMESHDS_SubMesh.cxx.

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

Referenced by SMESHDS_Mesh.add(), VISCOUS._ViscousBuilder.addBoundaryElements(), SMESH_MeshEditor.convertElemToQuadratic(), SMESH_MeshEditor.ConvertToQuadratic(), DriverMED_R_SMESHDS_Mesh.GetSubMesh(), StdMeshers_Import_1D.importMesh(), SMESH_Gen_i.Load(), SMESH_MeshEditor.removeQuadElem(), and SMESH_MeshEditor.SplitVolumesIntoTetra().

{
  if (!IsComplexSubmesh())
    {
      //MESSAGE("in " << myIndex << " AddElement "<< ME->GetID());
      int oldShapeId = ME->getshapeId();
      if ( oldShapeId > 0 )
        {
          if (oldShapeId != myIndex)
            {
              MESSAGE("add element in subshape already belonging to another subshape "
                << ME->GetID() << " " << oldShapeId << " " << myIndex);
              throw SALOME_Exception(LOCALIZED("add element in subshape already belonging to a subshape"));
            }
          else
            {
              int idInSubShape = ME->getIdInShape();
              if (idInSubShape >= 0)
                {
                  MESSAGE("add element in subshape already belonging to that subshape "
                      << ME->GetID() << " " << oldShapeId << " " << idInSubShape);
                  // check if ok: do nothing if ok
                  if (idInSubShape >= myElements.size())
                    {
                      MESSAGE("out of bounds " << idInSubShape << " " << myElements.size());
                      throw SALOME_Exception(LOCALIZED("out of bounds"));
                    }
                  if (ME != myElements[idInSubShape])
                    {
                      MESSAGE("not the same element");
                      throw SALOME_Exception(LOCALIZED("not the same element"));
                    }
                  MESSAGE("already done, OK, nothing to do");
                  return;
                }
            }
        }

      SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
      elem->setShapeId(myIndex);
      elem->setIdInShape(myElements.size());
      myElements.push_back(ME);
    }
}
void SMESHDS_SubMesh::AddNode ( const SMDS_MeshNode ME) [virtual]

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)

Definition at line 411 of file SMESHDS_SubMesh.cxx.

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

{
  ASSERT( theSubMesh );
  mySubMeshes.insert( theSubMesh );
}
void SMESHDS_SubMesh::Clear ( ) [virtual]

Reimplemented in SMESH_ProxyMesh.SubMesh.

Definition at line 465 of file SMESHDS_SubMesh.cxx.

{
  myElements.clear();
  myNodes.clear();
  myUnusedIdNodes = 0;
  myUnusedIdElements = 0;
  SMESHDS_SubMeshIteratorPtr sub = GetSubMeshIterator();
  while ( sub->more() ) {
    if ( SMESHDS_SubMesh* sm = (SMESHDS_SubMesh*) sub->next())
      sm->Clear();
  }
}
void SMESHDS_SubMesh::compactList ( )

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 SMESHDS_SubMesh::Contains ( const SMDS_MeshElement ME) const [virtual]

Reimplemented in SMESH_ProxyMesh.SubMesh.

Definition at line 373 of file SMESHDS_SubMesh.cxx.

References SMDS_MeshElement.getIdInShape(), SMDS_MeshElement.GetType(), and SMDSAbs_Node.

Referenced by SMESHDS_GroupOnGeom.Contains(), SMESH_MeshEditor.ConvertToQuadratic(), StdMeshers_ProjectionUtils.FindMatchingNodesOnFaces(), VISCOUS._ViscousBuilder.findNeiborsOnEdge(), SMESH_MeshEditor.FindShape(), _QuadFaceGrid.LoadGrid(), SMESH_MesherHelper.LoadNodeColumns(), VISCOUS._ViscousBuilder.prepareEdgeToShrink(), SMESH_MeshEditor.removeQuadElem(), VISCOUS._ViscousBuilder.shrink(), SMESH_MeshEditor.SplitVolumesIntoTetra(), and VISCOUS._Shrinker1D.SwapSrcTgtNodes().

{
  // DO NOT TRY TO FIND A REMOVED ELEMENT !!
  //if ( IsComplexSubmesh() || !ME )
  if (!ME)
    return false;

  if (IsComplexSubmesh())
    {
      set<const SMESHDS_SubMesh*>::const_iterator aSubIt = mySubMeshes.begin();
      for (; aSubIt != mySubMeshes.end(); aSubIt++)
        if ((*aSubIt)->Contains(ME))
          return true;
      return false;
    }

  if (ME->GetType() == SMDSAbs_Node)
    {
      int idInShape = ME->getIdInShape();
      if ((idInShape >= 0) && (idInShape < myNodes.size()))
        if (myNodes[idInShape] == ME)
          return true;
    }
  else
    {
      int idInShape = ME->getIdInShape();
      if ((idInShape >= 0) && (idInShape < myElements.size()))
        if (myElements[idInShape] == ME)
          return true;
    }
  return false;
}
bool SMESHDS_SubMesh::ContainsSubMesh ( const SMESHDS_SubMesh theSubMesh) const

Definition at line 442 of file SMESHDS_SubMesh.cxx.

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

Reimplemented in SMESH_ProxyMesh.SubMesh.

Definition at line 348 of file SMESHDS_SubMesh.cxx.

Referenced by StdMeshers_QuadToTriaAdaptor.Compute(), StdMeshers_Projection_3D.Compute(), SMESH_MeshEditor.convertElemToQuadratic(), StdMeshers_Projection_3D.Evaluate(), StdMeshers_ProjectionUtils.FindMatchingNodesOnFaces(), MyElemIterator.getElements(), SMESH_subMesh_i.GetElementsByType(), SMESH_Algo.GetNodeParamOnEdge(), SMESH_subMesh_i.GetNumberOfNodes(), SMESH_Algo.GetSortedNodesOnEdge(), SMESH_Mesh_i.GetSubMeshElementsId(), SMESH_Mesh_i.GetSubMeshElementType(), SMESH_Mesh_i.GetSubMeshNodesId(), SMESH_Pattern.getSubmeshWithElements(), StdMeshers_PrismAsBlock.Init(), isMeshBoundToShape(), SMESH_Algo.IsReversedSubMesh(), SMESH_Pattern.Load(), _QuadFaceGrid.LoadGrid(), StdMeshers_Penta_3D.LoadIJNodes(), SMESH_MesherHelper.LoadNodeColumns(), StdMeshers_Penta_3D.MakeBlock(), VISCOUS._ViscousBuilder.makeLayer(), StdMeshers_Penta_3D.MakeMeshOnFxy1(), VISCOUS._ViscousBuilder.MakeN2NMap(), StdMeshers_Penta_3D.MakeVolumeMesh(), MyIterator< const SMDS_MeshNode * >.MyIterator(), SMESH_Gen_i.Precompute(), StdMeshers_Prism_3D.projectBottomToTop(), VISCOUS._ViscousBuilder.refine(), SMESH_Gen_i.Save(), StdMeshers_MaxElementArea.SetParametersByMesh(), VISCOUS._ViscousBuilder.shrink(), and DriverMED_Family.SplitByType().

{
  if ( IsComplexSubmesh() )
    return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes ));
  return SMDS_ElemIteratorPtr(new MySetIterator<const SMDS_MeshElement*, std::vector<const SMDS_MeshElement*> >(myElements));
}
SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes ( ) const [virtual]
SMESHDS_Mesh* SMESHDS_SubMesh.getParent ( )

Definition at line 76 of file SMESHDS_SubMesh.hxx.

{return myParent; };
int SMESHDS_SubMesh::getSize ( )

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
virtual bool SMESHDS_SubMesh.IsComplexSubmesh ( ) const [virtual]
int SMESHDS_SubMesh::NbElements ( ) const [virtual]
int SMESHDS_SubMesh::NbNodes ( ) const [virtual]
int SMESHDS_SubMesh.NbSubMeshes ( ) const

Definition at line 61 of file SMESHDS_SubMesh.hxx.

Referenced by SMESH_ProxyMesh.GetFaces().

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

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]

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]

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)

Definition at line 422 of file SMESHDS_SubMesh.cxx.

{
  return mySubMeshes.erase( theSubMesh );
}

Field Documentation

std::vector<const SMDS_MeshElement*> SMESHDS_SubMesh.myElements [private]

Definition at line 80 of file SMESHDS_SubMesh.hxx.

Definition at line 85 of file SMESHDS_SubMesh.hxx.

std::vector<const SMDS_MeshNode*> SMESHDS_SubMesh.myNodes [private]

Definition at line 81 of file SMESHDS_SubMesh.hxx.

Definition at line 76 of file SMESHDS_SubMesh.hxx.

std::set<const SMESHDS_SubMesh*> SMESHDS_SubMesh.mySubMeshes [private]

Definition at line 87 of file SMESHDS_SubMesh.hxx.

Definition at line 84 of file SMESHDS_SubMesh.hxx.

Definition at line 83 of file SMESHDS_SubMesh.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