1 // SMESH SMESHDS : management of mesh data and SMESH document
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESHDS_Document.cxx
25 // Author : Yves FRICAUD, OCC
30 #include "SMESHDS_Document.ixx"
31 #include "SMESHDS_Hypothesis.hxx"
33 #include <Standard_OutOfRange.hxx>
35 //=======================================================================
38 //=======================================================================
39 SMESHDS_Document::SMESHDS_Document(const Standard_Integer UserID): myUserID(UserID)
42 //=======================================================================
45 //=======================================================================
46 Standard_Integer SMESHDS_Document::NewMesh()
48 static Standard_Integer NewMeshID = 0;
50 Handle (SMESHDS_Mesh) aNewMesh = new SMESHDS_Mesh (NewMeshID);
51 myMeshes.Bind(NewMeshID ,aNewMesh);
55 //=======================================================================
58 //=======================================================================
59 Handle(SMESHDS_Mesh) SMESHDS_Document::GetMesh(const Standard_Integer MeshID)
61 if (!myMeshes.IsBound(MeshID))
62 Standard_OutOfRange::Raise("SMESHDS_Document::RemoveMesh");
63 return myMeshes.Find(MeshID);
66 //=======================================================================
67 //function : RemoveMesh
69 //=======================================================================
70 void SMESHDS_Document::RemoveMesh(const Standard_Integer MeshID)
72 if (!myMeshes.IsBound(MeshID))
73 Standard_OutOfRange::Raise("SMESHDS_Document::RemoveMesh");
74 myMeshes.UnBind(MeshID);
77 //=======================================================================
78 //function : AddHypothesis
80 //=======================================================================
81 void SMESHDS_Document::AddHypothesis(const SMESHDS_PtrHypothesis& H)
83 myHypothesis.Bind (H->GetID(), H);
86 //=======================================================================
87 //function : GetHypothesis
89 //=======================================================================
90 SMESHDS_PtrHypothesis SMESHDS_Document::GetHypothesis(const Standard_Integer HypID)
92 if (!myHypothesis.IsBound(HypID))
93 Standard_OutOfRange::Raise("SMESHDS_Document::GetHypothesis");
94 return myHypothesis.Find(HypID);
97 //=======================================================================
98 //function : RemoveHypothesis
100 //=======================================================================
101 void SMESHDS_Document::RemoveHypothesis(const Standard_Integer HypID)
103 if (!myHypothesis.IsBound(HypID))
104 Standard_OutOfRange::Raise("SMESHDS_Document::RemoveHypothesis");
105 myMeshes.UnBind(HypID);
108 //=======================================================================
109 //function : NbMeshes
111 //=======================================================================
112 Standard_Integer SMESHDS_Document::NbMeshes()
114 return myMeshes.Extent();
117 //=======================================================================
118 //function : NbHypothesis
120 //=======================================================================
121 Standard_Integer SMESHDS_Document::NbHypothesis()
123 return myHypothesis.Extent();
126 //=======================================================================
127 //function : InitMeshesIterator
129 //=======================================================================
130 void SMESHDS_Document::InitMeshesIterator()
132 myMeshesIt.Initialize(myMeshes);
134 //=======================================================================
135 //function : NextMesh
137 //=======================================================================
138 void SMESHDS_Document::NextMesh()
142 //=======================================================================
143 //function : MoreMesh
145 //=======================================================================
146 Standard_Boolean SMESHDS_Document::MoreMesh()
148 return myMeshesIt.More();
150 //=======================================================================
151 //function : CurrentMesh
153 //=======================================================================
154 Handle_SMESHDS_Mesh SMESHDS_Document::CurrentMesh()
156 return myMeshesIt.Value();
159 //=======================================================================
160 //function : InitHypothesisIterator
162 //=======================================================================
163 void SMESHDS_Document::InitHypothesisIterator()
165 myHypothesisIt.Initialize(myHypothesis);
167 //=======================================================================
168 //function : NextMesh
170 //=======================================================================
171 void SMESHDS_Document::NextHypothesis()
173 myHypothesisIt.Next();
175 //=======================================================================
176 //function : MoreMesh
178 //=======================================================================
179 Standard_Boolean SMESHDS_Document::MoreHypothesis()
181 return myHypothesisIt.More();
183 //=======================================================================
184 //function : CurrentMesh
186 //=======================================================================
187 SMESHDS_PtrHypothesis SMESHDS_Document::CurrentHypothesis()
189 return myHypothesisIt.Value();