1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHDS : management of mesh data and SMESH document
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 //=======================================================================
43 //function : Destructor
45 //=======================================================================
47 SMESHDS_Document::~SMESHDS_Document()
54 //=======================================================================
57 //=======================================================================
58 SMESHDS_Mesh * SMESHDS_Document::NewMesh(bool theIsEmbeddedMode, int MeshID)
60 std::map<int,SMESHDS_Mesh*>::iterator i_m =
61 myMeshes.insert( make_pair( MeshID, (SMESHDS_Mesh*)0 )).first;
63 throw SALOME_Exception("SMESHDS_Document::NewMesh(): ID of existing mesh given");
64 SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(MeshID,theIsEmbeddedMode);
65 i_m->second = aNewMesh;
69 //=======================================================================
72 //=======================================================================
73 SMESHDS_Mesh *SMESHDS_Document::GetMesh(int MeshID)
75 map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
76 if (it==myMeshes.end())
78 MESSAGE("SMESHDS_Document::GetMesh : ID not found");
81 else return (*it).second;
84 //=======================================================================
85 //function : RemoveMesh
87 //=======================================================================
88 void SMESHDS_Document::RemoveMesh(int MeshID)
90 map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
91 if (it!=myMeshes.end())
95 //=======================================================================
96 //function : AddHypothesis
98 //=======================================================================
99 void SMESHDS_Document::AddHypothesis(SMESHDS_Hypothesis * H)
101 myHypothesis[H->GetID()]=H;
104 //=======================================================================
105 //function : GetHypothesis
107 //=======================================================================
108 SMESHDS_Hypothesis * SMESHDS_Document::GetHypothesis(int HypID)
110 map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
111 if (it==myHypothesis.end())
113 MESSAGE("SMESHDS_Document::GetHypothesis : ID not found");
116 else return (*it).second;
119 //=======================================================================
120 //function : RemoveHypothesis
122 //=======================================================================
123 void SMESHDS_Document::RemoveHypothesis(int HypID)
125 map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
126 if (it==myHypothesis.end())
127 MESSAGE("SMESHDS_Document::RemoveHypothesis : ID not found");
128 myHypothesis.erase(it);
131 //=======================================================================
132 //function : NbMeshes
134 //=======================================================================
135 int SMESHDS_Document::NbMeshes()
137 return myMeshes.size();
140 //=======================================================================
141 //function : NbHypothesis
143 //=======================================================================
144 int SMESHDS_Document::NbHypothesis()
146 return myHypothesis.size();
149 //=======================================================================
150 //function : InitMeshesIterator
152 //=======================================================================
153 void SMESHDS_Document::InitMeshesIterator()
155 myMeshesIt=myMeshes.begin();
158 //=======================================================================
159 //function : NextMesh
161 //=======================================================================
162 SMESHDS_Mesh * SMESHDS_Document::NextMesh()
164 SMESHDS_Mesh * toReturn=(*myMeshesIt).second;
169 //=======================================================================
170 //function : MoreMesh
172 //=======================================================================
173 bool SMESHDS_Document::MoreMesh()
175 return myMeshesIt!=myMeshes.end();
178 //=======================================================================
179 //function : InitHypothesisIterator
181 //=======================================================================
182 void SMESHDS_Document::InitHypothesisIterator()
184 myHypothesisIt=myHypothesis.begin();
187 //=======================================================================
188 //function : NextMesh
190 //=======================================================================
191 SMESHDS_Hypothesis * SMESHDS_Document::NextHypothesis()
193 SMESHDS_Hypothesis * toReturn=(*myHypothesisIt).second;
198 //=======================================================================
199 //function : MoreMesh
201 //=======================================================================
202 bool SMESHDS_Document::MoreHypothesis()
204 return myHypothesisIt!=myHypothesis.end();