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
29 #include "SMESHDS_Document.hxx"
30 #include "utilities.h"
34 //=======================================================================
37 //=======================================================================
38 SMESHDS_Document::SMESHDS_Document(int UserID):myUserID(UserID)
42 //=======================================================================
45 //=======================================================================
46 int SMESHDS_Document::NewMesh(bool theIsEmbeddedMode)
48 static int aNewMeshID = 0;
50 SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(aNewMeshID,theIsEmbeddedMode);
51 myMeshes[aNewMeshID] = aNewMesh;
55 //=======================================================================
58 //=======================================================================
59 SMESHDS_Mesh *SMESHDS_Document::GetMesh(int MeshID)
61 map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
62 if (it==myMeshes.end())
64 MESSAGE("SMESHDS_Document::GetMesh : ID not found");
67 else return (*it).second;
70 //=======================================================================
71 //function : RemoveMesh
73 //=======================================================================
74 void SMESHDS_Document::RemoveMesh(int MeshID)
76 map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
77 if (it==myMeshes.end())
78 MESSAGE("SMESHDS_Document::RemoveMesh : ID not found");
82 //=======================================================================
83 //function : AddHypothesis
85 //=======================================================================
86 void SMESHDS_Document::AddHypothesis(SMESHDS_Hypothesis * H)
88 myHypothesis[H->GetID()]=H;
91 //=======================================================================
92 //function : GetHypothesis
94 //=======================================================================
95 SMESHDS_Hypothesis * SMESHDS_Document::GetHypothesis(int HypID)
97 map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
98 if (it==myHypothesis.end())
100 MESSAGE("SMESHDS_Document::GetHypothesis : ID not found");
103 else return (*it).second;
106 //=======================================================================
107 //function : RemoveHypothesis
109 //=======================================================================
110 void SMESHDS_Document::RemoveHypothesis(int HypID)
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);
118 //=======================================================================
119 //function : NbMeshes
121 //=======================================================================
122 int SMESHDS_Document::NbMeshes()
124 return myMeshes.size();
127 //=======================================================================
128 //function : NbHypothesis
130 //=======================================================================
131 int SMESHDS_Document::NbHypothesis()
133 return myHypothesis.size();
136 //=======================================================================
137 //function : InitMeshesIterator
139 //=======================================================================
140 void SMESHDS_Document::InitMeshesIterator()
142 myMeshesIt=myMeshes.begin();
145 //=======================================================================
146 //function : NextMesh
148 //=======================================================================
149 SMESHDS_Mesh * SMESHDS_Document::NextMesh()
151 SMESHDS_Mesh * toReturn=(*myMeshesIt).second;
156 //=======================================================================
157 //function : MoreMesh
159 //=======================================================================
160 bool SMESHDS_Document::MoreMesh()
162 return myMeshesIt!=myMeshes.end();
165 //=======================================================================
166 //function : InitHypothesisIterator
168 //=======================================================================
169 void SMESHDS_Document::InitHypothesisIterator()
171 myHypothesisIt=myHypothesis.begin();
174 //=======================================================================
175 //function : NextMesh
177 //=======================================================================
178 SMESHDS_Hypothesis * SMESHDS_Document::NextHypothesis()
180 SMESHDS_Hypothesis * toReturn=(*myHypothesisIt).second;
185 //=======================================================================
186 //function : MoreMesh
188 //=======================================================================
189 bool SMESHDS_Document::MoreHypothesis()
191 return myHypothesisIt!=myHypothesis.end();