Salome HOME
4b47835e4b40ddc7eb20fe8159c868b700bd09fe
[modules/smesh.git] / src / SMESHDS / SMESHDS_Document.cxx
1 using namespace std;
2 //=============================================================================
3 // File      : SMESHDS_Document.cxx
4 // Created   : 
5 // Author    : Yves FRICAUD, OCC
6 // Project   : SALOME
7 // Copyright : OCC 2002
8 // $Header: 
9 //=============================================================================
10
11 #include "SMESHDS_Document.ixx"
12 #include "SMESHDS_Hypothesis.hxx"
13
14 #include <Standard_OutOfRange.hxx>
15
16 //=======================================================================
17 //function : Create
18 //purpose  : 
19 //=======================================================================
20 SMESHDS_Document::SMESHDS_Document(const Standard_Integer UserID): myUserID(UserID)
21 {}
22
23 //=======================================================================
24 //function : NewMesh
25 //purpose  : 
26 //=======================================================================
27 Standard_Integer SMESHDS_Document::NewMesh()
28 {
29   static Standard_Integer NewMeshID = 0;
30   NewMeshID++;
31   Handle (SMESHDS_Mesh) aNewMesh = new SMESHDS_Mesh (NewMeshID);
32   myMeshes.Bind(NewMeshID ,aNewMesh);
33   return NewMeshID;
34 }
35
36 //=======================================================================
37 //function : GetMesh
38 //purpose  : 
39 //=======================================================================
40 Handle(SMESHDS_Mesh) SMESHDS_Document::GetMesh(const Standard_Integer MeshID) 
41 {
42   if (!myMeshes.IsBound(MeshID)) 
43     Standard_OutOfRange::Raise("SMESHDS_Document::RemoveMesh");
44   return myMeshes.Find(MeshID);
45 }
46
47 //=======================================================================
48 //function : RemoveMesh
49 //purpose  : 
50 //=======================================================================
51 void SMESHDS_Document::RemoveMesh(const Standard_Integer MeshID)
52 {
53   if (!myMeshes.IsBound(MeshID)) 
54     Standard_OutOfRange::Raise("SMESHDS_Document::RemoveMesh");
55   myMeshes.UnBind(MeshID);
56 }
57
58 //=======================================================================
59 //function : AddHypothesis
60 //purpose  : 
61 //=======================================================================
62 void  SMESHDS_Document::AddHypothesis(const SMESHDS_PtrHypothesis& H)
63 {
64   myHypothesis.Bind (H->GetID(), H);
65 }
66
67 //=======================================================================
68 //function : GetHypothesis
69 //purpose  : 
70 //=======================================================================
71 SMESHDS_PtrHypothesis  SMESHDS_Document::GetHypothesis(const Standard_Integer HypID) 
72 {
73   if (!myHypothesis.IsBound(HypID)) 
74     Standard_OutOfRange::Raise("SMESHDS_Document::GetHypothesis");
75   return myHypothesis.Find(HypID);
76 }
77
78 //=======================================================================
79 //function : RemoveHypothesis
80 //purpose  : 
81 //=======================================================================
82 void SMESHDS_Document::RemoveHypothesis(const Standard_Integer HypID)
83 {
84   if (!myHypothesis.IsBound(HypID)) 
85     Standard_OutOfRange::Raise("SMESHDS_Document::RemoveHypothesis");
86   myMeshes.UnBind(HypID);
87 }
88
89 //=======================================================================
90 //function : NbMeshes
91 //purpose  : 
92 //=======================================================================
93 Standard_Integer SMESHDS_Document::NbMeshes() 
94 {
95   return myMeshes.Extent();
96 }
97
98 //=======================================================================
99 //function : NbHypothesis
100 //purpose  : 
101 //=======================================================================
102 Standard_Integer SMESHDS_Document::NbHypothesis() 
103 {
104   return myHypothesis.Extent();
105 }
106
107 //=======================================================================
108 //function : InitMeshesIterator
109 //purpose  : 
110 //=======================================================================
111 void SMESHDS_Document::InitMeshesIterator() 
112 {
113   myMeshesIt.Initialize(myMeshes);
114 }
115 //=======================================================================
116 //function : NextMesh
117 //purpose  : 
118 //=======================================================================
119 void SMESHDS_Document::NextMesh() 
120 {
121   myMeshesIt.Next();
122 }
123 //=======================================================================
124 //function : MoreMesh
125 //purpose  : 
126 //=======================================================================
127 Standard_Boolean SMESHDS_Document::MoreMesh() 
128 {
129   return myMeshesIt.More();
130 }
131 //=======================================================================
132 //function : CurrentMesh
133 //purpose  : 
134 //=======================================================================
135 Handle_SMESHDS_Mesh SMESHDS_Document::CurrentMesh() 
136 {
137  return  myMeshesIt.Value();
138 }
139
140 //=======================================================================
141 //function : InitHypothesisIterator
142 //purpose  : 
143 //=======================================================================
144 void SMESHDS_Document::InitHypothesisIterator() 
145 {
146   myHypothesisIt.Initialize(myHypothesis);
147 }
148 //=======================================================================
149 //function : NextMesh
150 //purpose  : 
151 //=======================================================================
152 void SMESHDS_Document::NextHypothesis() 
153 {
154   myHypothesisIt.Next();
155 }
156 //=======================================================================
157 //function : MoreMesh
158 //purpose  : 
159 //=======================================================================
160 Standard_Boolean SMESHDS_Document::MoreHypothesis() 
161 {
162   return myHypothesisIt.More();
163 }
164 //=======================================================================
165 //function : CurrentMesh
166 //purpose  : 
167 //=======================================================================
168 SMESHDS_PtrHypothesis SMESHDS_Document::CurrentHypothesis() 
169 {
170  return  myHypothesisIt.Value();
171 }
172
173