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.hxx"
31 #include <utilities.h>
33 //=======================================================================
36 //=======================================================================
37 SMESHDS_Document::SMESHDS_Document(int UserID):myUserID(UserID)
41 //=======================================================================
44 //=======================================================================
45 int SMESHDS_Document::NewMesh()
47 static int NewMeshID = 0;
49 SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(NewMeshID);
50 myMeshes[NewMeshID] = aNewMesh;
54 //=======================================================================
57 //=======================================================================
58 SMESHDS_Mesh *SMESHDS_Document::GetMesh(int MeshID)
60 map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
61 if (it==myMeshes.end())
63 MESSAGE("SMESHDS_Document::GetMesh : ID not found");
66 else return (*it).second;
69 //=======================================================================
70 //function : RemoveMesh
72 //=======================================================================
73 void SMESHDS_Document::RemoveMesh(int MeshID)
75 map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
76 if (it==myMeshes.end())
77 MESSAGE("SMESHDS_Document::RemoveMesh : ID not found");
81 //=======================================================================
82 //function : AddHypothesis
84 //=======================================================================
85 void SMESHDS_Document::AddHypothesis(SMESHDS_Hypothesis * H)
87 myHypothesis[H->GetID()]=H;
90 //=======================================================================
91 //function : GetHypothesis
93 //=======================================================================
94 SMESHDS_Hypothesis * SMESHDS_Document::GetHypothesis(int HypID)
96 map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
97 if (it==myHypothesis.end())
99 MESSAGE("SMESHDS_Document::GetHypothesis : ID not found");
102 else return (*it).second;
105 //=======================================================================
106 //function : RemoveHypothesis
108 //=======================================================================
109 void SMESHDS_Document::RemoveHypothesis(int HypID)
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);
117 //=======================================================================
118 //function : NbMeshes
120 //=======================================================================
121 int SMESHDS_Document::NbMeshes()
123 return myMeshes.size();
126 //=======================================================================
127 //function : NbHypothesis
129 //=======================================================================
130 int SMESHDS_Document::NbHypothesis()
132 return myHypothesis.size();
135 //=======================================================================
136 //function : InitMeshesIterator
138 //=======================================================================
139 void SMESHDS_Document::InitMeshesIterator()
141 myMeshesIt=myMeshes.begin();
144 //=======================================================================
145 //function : NextMesh
147 //=======================================================================
148 SMESHDS_Mesh * SMESHDS_Document::NextMesh()
150 SMESHDS_Mesh * toReturn=(*myMeshesIt).second;
155 //=======================================================================
156 //function : MoreMesh
158 //=======================================================================
159 bool SMESHDS_Document::MoreMesh()
161 return myMeshesIt!=myMeshes.end();
164 //=======================================================================
165 //function : InitHypothesisIterator
167 //=======================================================================
168 void SMESHDS_Document::InitHypothesisIterator()
170 myHypothesisIt=myHypothesis.begin();
173 //=======================================================================
174 //function : NextMesh
176 //=======================================================================
177 SMESHDS_Hypothesis * SMESHDS_Document::NextHypothesis()
179 SMESHDS_Hypothesis * toReturn=(*myHypothesisIt).second;
184 //=======================================================================
185 //function : MoreMesh
187 //=======================================================================
188 bool SMESHDS_Document::MoreHypothesis()
190 return myHypothesisIt!=myHypothesis.end();