1 // Copyright (C) 2007-2012 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.
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 int SMESHDS_Document::NewMesh(bool theIsEmbeddedMode)
60 static int aNewMeshID = 0;
62 SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(aNewMeshID,theIsEmbeddedMode);
63 myMeshes[aNewMeshID] = aNewMesh;
67 //=======================================================================
70 //=======================================================================
71 SMESHDS_Mesh *SMESHDS_Document::GetMesh(int MeshID)
73 map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
74 if (it==myMeshes.end())
76 MESSAGE("SMESHDS_Document::GetMesh : ID not found");
79 else return (*it).second;
82 //=======================================================================
83 //function : RemoveMesh
85 //=======================================================================
86 void SMESHDS_Document::RemoveMesh(int MeshID)
88 map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
89 if (it!=myMeshes.end())
93 //=======================================================================
94 //function : AddHypothesis
96 //=======================================================================
97 void SMESHDS_Document::AddHypothesis(SMESHDS_Hypothesis * H)
99 myHypothesis[H->GetID()]=H;
102 //=======================================================================
103 //function : GetHypothesis
105 //=======================================================================
106 SMESHDS_Hypothesis * SMESHDS_Document::GetHypothesis(int HypID)
108 map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
109 if (it==myHypothesis.end())
111 MESSAGE("SMESHDS_Document::GetHypothesis : ID not found");
114 else return (*it).second;
117 //=======================================================================
118 //function : RemoveHypothesis
120 //=======================================================================
121 void SMESHDS_Document::RemoveHypothesis(int HypID)
123 map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
124 if (it==myHypothesis.end())
125 MESSAGE("SMESHDS_Document::RemoveHypothesis : ID not found");
126 myHypothesis.erase(it);
129 //=======================================================================
130 //function : NbMeshes
132 //=======================================================================
133 int SMESHDS_Document::NbMeshes()
135 return myMeshes.size();
138 //=======================================================================
139 //function : NbHypothesis
141 //=======================================================================
142 int SMESHDS_Document::NbHypothesis()
144 return myHypothesis.size();
147 //=======================================================================
148 //function : InitMeshesIterator
150 //=======================================================================
151 void SMESHDS_Document::InitMeshesIterator()
153 myMeshesIt=myMeshes.begin();
156 //=======================================================================
157 //function : NextMesh
159 //=======================================================================
160 SMESHDS_Mesh * SMESHDS_Document::NextMesh()
162 SMESHDS_Mesh * toReturn=(*myMeshesIt).second;
167 //=======================================================================
168 //function : MoreMesh
170 //=======================================================================
171 bool SMESHDS_Document::MoreMesh()
173 return myMeshesIt!=myMeshes.end();
176 //=======================================================================
177 //function : InitHypothesisIterator
179 //=======================================================================
180 void SMESHDS_Document::InitHypothesisIterator()
182 myHypothesisIt=myHypothesis.begin();
185 //=======================================================================
186 //function : NextMesh
188 //=======================================================================
189 SMESHDS_Hypothesis * SMESHDS_Document::NextHypothesis()
191 SMESHDS_Hypothesis * toReturn=(*myHypothesisIt).second;
196 //=======================================================================
197 //function : MoreMesh
199 //=======================================================================
200 bool SMESHDS_Document::MoreHypothesis()
202 return myHypothesisIt!=myHypothesis.end();