Salome HOME
Remove no longer needed files
[modules/smesh.git] / src / SMESHDS / SMESHDS_SubMesh.cxx
1 //  SMESH SMESHDS : management of mesh data and SMESH document
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESH_SubMesh.cxx
25 //  Author : Yves FRICAUD, OCC
26 //  Module : SMESH
27 //  $Header: 
28
29 using namespace std;
30 #include "SMESHDS_SubMesh.hxx"
31
32 //=======================================================================
33 //function : SMESHDS_SubMesh
34 //purpose  : 
35 //=======================================================================
36 SMESHDS_SubMesh::SMESHDS_SubMesh(const SMDS_Mesh * M):myMesh(M)
37 {
38         myListOfEltIDIsUpdate = false;
39         myListOfNodeIDIsUpdate = false;
40 }
41
42 //=======================================================================
43 //function : AddElement
44 //purpose  : 
45 //=======================================================================
46 void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
47 {
48         myElements.insert(ME);
49         myListOfEltIDIsUpdate = false;
50 }
51
52 //=======================================================================
53 //function : RemoveElement
54 //purpose  : 
55 //=======================================================================
56 void SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME)
57 {
58         myElements.erase(ME);
59         myListOfEltIDIsUpdate = false;
60 }
61
62 //=======================================================================
63 //function : AddNode
64 //purpose  : 
65 //=======================================================================
66 void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
67 {
68         myNodes.insert(N);
69         myListOfNodeIDIsUpdate = false;
70 }
71
72 //=======================================================================
73 //function : RemoveNode
74 //purpose  : 
75 //=======================================================================
76 void SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N)
77 {
78         myNodes.erase(N);
79         myListOfNodeIDIsUpdate = false;
80 }
81
82 //=======================================================================
83 //function : NbElements
84 //purpose  : 
85 //=======================================================================
86 int SMESHDS_SubMesh::NbElements() const
87 {
88         return myElements.size();
89 }
90
91 //=======================================================================
92 //function : GetElements
93 //purpose  : 
94 //=======================================================================
95 const set<const SMDS_MeshElement*> & SMESHDS_SubMesh::GetElements()
96 {
97         return myElements;
98 }
99
100 //=======================================================================
101 //function : NbNodes
102 //purpose  : 
103 //=======================================================================
104 int SMESHDS_SubMesh::NbNodes() const
105 {
106         return myNodes.size();
107 }
108
109 //=======================================================================
110 //function : GetNodes
111 //purpose  : 
112 //=======================================================================
113 const set<const SMDS_MeshNode*> & SMESHDS_SubMesh::GetNodes() const
114 {
115         return myNodes;
116 }
117
118 //=======================================================================
119 //function : GetIDElements
120 //purpose  : 
121 //=======================================================================
122 const vector<int> & SMESHDS_SubMesh::GetIDElements()
123 {
124         if (!myListOfEltIDIsUpdate)
125         {
126                 myListOfEltID.clear();
127                 set<const SMDS_MeshElement*>::iterator it=myElements.begin();
128                 for (; it!=myElements.end(); it++)
129                 {
130                         myListOfEltID.push_back((*it)->GetID());
131                 }
132                 myListOfEltIDIsUpdate = true;
133         }
134         return myListOfEltID;
135 }
136
137 //=======================================================================
138 //function : GetIDNodes
139 //purpose  : 
140 //=======================================================================
141 const vector<int> & SMESHDS_SubMesh::GetIDNodes()
142 {
143         if (!myListOfNodeIDIsUpdate)
144         {
145                 myListOfNodeID.clear();
146                 set<const SMDS_MeshNode*>::iterator it=myNodes.begin();
147                 for (; it!=myNodes.end(); it++)
148                 {
149                         myListOfNodeID.push_back((*it)->GetID());
150                 }
151                 myListOfNodeIDIsUpdate = true;
152         }
153         return myListOfNodeID;
154 }