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 : SMESHDS_SubMesh
35 //=======================================================================
36 SMESHDS_SubMesh::SMESHDS_SubMesh(const SMDS_Mesh * M):myMesh(M)
38 myListOfEltIDIsUpdate = false;
39 myListOfNodeIDIsUpdate = false;
42 //=======================================================================
43 //function : AddElement
45 //=======================================================================
46 void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
48 myElements.insert(ME);
49 myListOfEltIDIsUpdate = false;
52 //=======================================================================
53 //function : RemoveElement
55 //=======================================================================
56 void SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME)
59 myListOfEltIDIsUpdate = false;
62 //=======================================================================
65 //=======================================================================
66 void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
69 myListOfNodeIDIsUpdate = false;
72 //=======================================================================
73 //function : RemoveNode
75 //=======================================================================
76 void SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N)
79 myListOfNodeIDIsUpdate = false;
82 //=======================================================================
83 //function : NbElements
85 //=======================================================================
86 int SMESHDS_SubMesh::NbElements() const
88 return myElements.size();
91 //=======================================================================
92 //function : GetElements
94 //=======================================================================
95 const set<const SMDS_MeshElement*> & SMESHDS_SubMesh::GetElements()
100 //=======================================================================
103 //=======================================================================
104 int SMESHDS_SubMesh::NbNodes() const
106 return myNodes.size();
109 //=======================================================================
110 //function : GetNodes
112 //=======================================================================
113 const set<const SMDS_MeshNode*> & SMESHDS_SubMesh::GetNodes() const
118 //=======================================================================
119 //function : GetIDElements
121 //=======================================================================
122 const vector<int> & SMESHDS_SubMesh::GetIDElements()
124 if (!myListOfEltIDIsUpdate)
126 myListOfEltID.clear();
127 set<const SMDS_MeshElement*>::iterator it=myElements.begin();
128 for (; it!=myElements.end(); it++)
130 myListOfEltID.push_back((*it)->GetID());
132 myListOfEltIDIsUpdate = true;
134 return myListOfEltID;
137 //=======================================================================
138 //function : GetIDNodes
140 //=======================================================================
141 const vector<int> & SMESHDS_SubMesh::GetIDNodes()
143 if (!myListOfNodeIDIsUpdate)
145 myListOfNodeID.clear();
146 set<const SMDS_MeshNode*>::iterator it=myNodes.begin();
147 for (; it!=myNodes.end(); it++)
149 myListOfNodeID.push_back((*it)->GetID());
151 myListOfNodeIDIsUpdate = true;
153 return myListOfNodeID;