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