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