1 // SMESH SMESHDS : management of mesh data and SMESH document
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_SubMesh.cxx
25 // Author : Yves FRICAUD, OCC
30 #include "SMESHDS_SubMesh.hxx"
32 //=======================================================================
33 //function : AddElement
35 //=======================================================================
36 void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
38 myElements.insert(ME);
41 //=======================================================================
42 //function : RemoveElement
44 //=======================================================================
45 void SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME)
50 //=======================================================================
53 //=======================================================================
54 void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
59 //=======================================================================
60 //function : RemoveNode
62 //=======================================================================
63 void SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N)
68 //=======================================================================
69 //function : NbElements
71 //=======================================================================
72 int SMESHDS_SubMesh::NbElements() const
74 return myElements.size();
77 //=======================================================================
80 //=======================================================================
81 int SMESHDS_SubMesh::NbNodes() const
83 return myNodes.size();
86 template<typename T> class MySetIterator:public SMDS_Iterator<const T*>
88 const set<const T*>& mySet;
89 set<const T*>::const_iterator myIt;
92 MySetIterator(const set<const T*>& s):mySet(s), myIt(s.begin())
98 return myIt!=mySet.end();
107 ///////////////////////////////////////////////////////////////////////////////
108 ///Return an iterator on the elements of submesh
109 ///The created iterator must be free by the caller
110 ///////////////////////////////////////////////////////////////////////////////
111 SMDS_Iterator<const SMDS_MeshElement*> * SMESHDS_SubMesh::GetElements() const
113 return new MySetIterator<SMDS_MeshElement>(myElements);
116 ///////////////////////////////////////////////////////////////////////////////
117 ///Return an iterator on the nodes of submesh
118 ///The created iterator must be free by the caller
119 ///////////////////////////////////////////////////////////////////////////////
120 SMDS_Iterator<const SMDS_MeshNode*> * SMESHDS_SubMesh::GetNodes() const
122 return new MySetIterator<SMDS_MeshNode>(myNodes);