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 bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME)
48 return myElements.erase(ME);
53 //=======================================================================
56 //=======================================================================
57 void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
62 //=======================================================================
63 //function : RemoveNode
65 //=======================================================================
66 bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N)
69 return myNodes.erase(N);
74 //=======================================================================
75 //function : NbElements
77 //=======================================================================
78 int SMESHDS_SubMesh::NbElements() const
80 return myElements.size();
83 //=======================================================================
86 //=======================================================================
87 int SMESHDS_SubMesh::NbNodes() const
89 return myNodes.size();
92 template<typename T> class MySetIterator:public SMDS_Iterator<const T*>
94 typedef const set<const T*> TSet;
95 typename TSet::const_iterator myIt;
99 MySetIterator(const set<const T*>& s):mySet(s), myIt(s.begin())
105 return myIt!=mySet.end();
114 ///////////////////////////////////////////////////////////////////////////////
115 ///Return an iterator on the elements of submesh
116 ///The created iterator must be free by the caller
117 ///////////////////////////////////////////////////////////////////////////////
118 SMDS_ElemIteratorPtr SMESHDS_SubMesh::GetElements() const
120 return SMDS_ElemIteratorPtr(new MySetIterator<SMDS_MeshElement>(myElements));
123 ///////////////////////////////////////////////////////////////////////////////
124 ///Return an iterator on the nodes of submesh
125 ///The created iterator must be free by the caller
126 ///////////////////////////////////////////////////////////////////////////////
127 SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes() const
129 return SMDS_NodeIteratorPtr(new MySetIterator<SMDS_MeshNode>(myNodes));