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