Salome HOME
[Bug SMESH4830] bug in instal with gcc 2.95. Bug fixed.
[modules/smesh.git] / src / SMESHDS / SMESHDS_Document.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   : SMESHDS_Document.cxx
25 //  Author : Yves FRICAUD, OCC
26 //  Module : SMESH
27 //  $Header: 
28
29 #include "SMESHDS_Document.hxx"
30 #include "utilities.h"
31
32 //=======================================================================
33 //function : Create
34 //purpose  : 
35 //=======================================================================
36 SMESHDS_Document::SMESHDS_Document(int UserID):myUserID(UserID)
37 {
38 }
39
40 //=======================================================================
41 //function : NewMesh
42 //purpose  : 
43 //=======================================================================
44 int SMESHDS_Document::NewMesh()
45 {
46         static int NewMeshID = 0;
47         NewMeshID++;
48         SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(NewMeshID);
49         myMeshes[NewMeshID] = aNewMesh;
50         return NewMeshID;
51 }
52
53 //=======================================================================
54 //function : GetMesh
55 //purpose  : 
56 //=======================================================================
57 SMESHDS_Mesh *SMESHDS_Document::GetMesh(int MeshID)
58 {
59         map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
60         if (it==myMeshes.end())
61         {
62                 MESSAGE("SMESHDS_Document::GetMesh : ID not found");
63                 return NULL;
64         }
65         else return (*it).second;
66 }
67
68 //=======================================================================
69 //function : RemoveMesh
70 //purpose  : 
71 //=======================================================================
72 void SMESHDS_Document::RemoveMesh(int MeshID)
73 {
74         map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
75         if (it==myMeshes.end())
76                 MESSAGE("SMESHDS_Document::RemoveMesh : ID not found"); 
77         myMeshes.erase(it);
78 }
79
80 //=======================================================================
81 //function : AddHypothesis
82 //purpose  : 
83 //=======================================================================
84 void SMESHDS_Document::AddHypothesis(SMESHDS_Hypothesis * H)
85 {
86         myHypothesis[H->GetID()]=H;
87 }
88
89 //=======================================================================
90 //function : GetHypothesis
91 //purpose  : 
92 //=======================================================================
93 SMESHDS_Hypothesis * SMESHDS_Document::GetHypothesis(int HypID)
94 {
95         map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
96         if (it==myHypothesis.end())
97         {
98                 MESSAGE("SMESHDS_Document::GetHypothesis : ID not found");
99                 return NULL;
100         }
101         else return (*it).second;
102 }
103
104 //=======================================================================
105 //function : RemoveHypothesis
106 //purpose  : 
107 //=======================================================================
108 void SMESHDS_Document::RemoveHypothesis(int HypID)
109 {
110         map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
111         if (it==myHypothesis.end())
112                 MESSAGE("SMESHDS_Document::RemoveHypothesis : ID not found");   
113         myHypothesis.erase(it);
114 }
115
116 //=======================================================================
117 //function : NbMeshes
118 //purpose  : 
119 //=======================================================================
120 int SMESHDS_Document::NbMeshes()
121 {
122         return myMeshes.size();
123 }
124
125 //=======================================================================
126 //function : NbHypothesis
127 //purpose  : 
128 //=======================================================================
129 int SMESHDS_Document::NbHypothesis()
130 {
131         return myHypothesis.size();
132 }
133
134 //=======================================================================
135 //function : InitMeshesIterator
136 //purpose  : 
137 //=======================================================================
138 void SMESHDS_Document::InitMeshesIterator()
139 {
140         myMeshesIt=myMeshes.begin();
141 }
142
143 //=======================================================================
144 //function : NextMesh
145 //purpose  : 
146 //=======================================================================
147 SMESHDS_Mesh * SMESHDS_Document::NextMesh()
148 {
149         SMESHDS_Mesh * toReturn=(*myMeshesIt).second;
150         myMeshesIt++;
151         return toReturn;
152 }
153
154 //=======================================================================
155 //function : MoreMesh
156 //purpose  : 
157 //=======================================================================
158 bool SMESHDS_Document::MoreMesh()
159 {
160         return myMeshesIt!=myMeshes.end();
161 }
162
163 //=======================================================================
164 //function : InitHypothesisIterator
165 //purpose  : 
166 //=======================================================================
167 void SMESHDS_Document::InitHypothesisIterator()
168 {
169         myHypothesisIt=myHypothesis.begin();
170 }
171
172 //=======================================================================
173 //function : NextMesh
174 //purpose  : 
175 //=======================================================================
176 SMESHDS_Hypothesis * SMESHDS_Document::NextHypothesis()
177 {
178         SMESHDS_Hypothesis * toReturn=(*myHypothesisIt).second;
179         myHypothesisIt++;
180         return toReturn;
181 }
182
183 //=======================================================================
184 //function : MoreMesh
185 //purpose  : 
186 //=======================================================================
187 bool SMESHDS_Document::MoreHypothesis()
188 {
189         return myHypothesisIt!=myHypothesis.end();
190 }