Version: 6.3.1

src/SMESHDS/SMESHDS_Document.cxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH SMESHDS : management of mesh data and SMESH document
00024 //  File   : SMESHDS_Document.cxx
00025 //  Author : Yves FRICAUD, OCC
00026 //  Module : SMESH
00027 //  $Header: 
00028 //
00029 #include "SMESHDS_Document.hxx"
00030 #include "utilities.h"
00031 
00032 using namespace std;
00033 
00034 //=======================================================================
00035 //function : Create
00036 //purpose  : 
00037 //=======================================================================
00038 SMESHDS_Document::SMESHDS_Document(int UserID):myUserID(UserID)
00039 {
00040 }
00041 
00042 //=======================================================================
00043 //function : Destructor
00044 //purpose  : 
00045 //=======================================================================
00046 
00047 SMESHDS_Document::~SMESHDS_Document()
00048 {
00049   InitMeshesIterator();
00050   while ( MoreMesh() )
00051     delete NextMesh();
00052 }
00053 
00054 //=======================================================================
00055 //function : NewMesh
00056 //purpose  : 
00057 //=======================================================================
00058 int SMESHDS_Document::NewMesh(bool theIsEmbeddedMode)
00059 {
00060   static int aNewMeshID = 0;
00061   aNewMeshID++;
00062   SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(aNewMeshID,theIsEmbeddedMode);
00063   myMeshes[aNewMeshID] = aNewMesh;
00064   return aNewMeshID;
00065 }
00066 
00067 //=======================================================================
00068 //function : GetMesh
00069 //purpose  : 
00070 //=======================================================================
00071 SMESHDS_Mesh *SMESHDS_Document::GetMesh(int MeshID)
00072 {
00073         map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
00074         if (it==myMeshes.end())
00075         {
00076                 MESSAGE("SMESHDS_Document::GetMesh : ID not found");
00077                 return NULL;
00078         }
00079         else return (*it).second;
00080 }
00081 
00082 //=======================================================================
00083 //function : RemoveMesh
00084 //purpose  : 
00085 //=======================================================================
00086 void SMESHDS_Document::RemoveMesh(int MeshID)
00087 {
00088         map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
00089         if (it==myMeshes.end())
00090                 MESSAGE("SMESHDS_Document::RemoveMesh : ID not found"); 
00091         myMeshes.erase(it);
00092 }
00093 
00094 //=======================================================================
00095 //function : AddHypothesis
00096 //purpose  : 
00097 //=======================================================================
00098 void SMESHDS_Document::AddHypothesis(SMESHDS_Hypothesis * H)
00099 {
00100         myHypothesis[H->GetID()]=H;
00101 }
00102 
00103 //=======================================================================
00104 //function : GetHypothesis
00105 //purpose  : 
00106 //=======================================================================
00107 SMESHDS_Hypothesis * SMESHDS_Document::GetHypothesis(int HypID)
00108 {
00109         map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
00110         if (it==myHypothesis.end())
00111         {
00112                 MESSAGE("SMESHDS_Document::GetHypothesis : ID not found");
00113                 return NULL;
00114         }
00115         else return (*it).second;
00116 }
00117 
00118 //=======================================================================
00119 //function : RemoveHypothesis
00120 //purpose  : 
00121 //=======================================================================
00122 void SMESHDS_Document::RemoveHypothesis(int HypID)
00123 {
00124         map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
00125         if (it==myHypothesis.end())
00126                 MESSAGE("SMESHDS_Document::RemoveHypothesis : ID not found");   
00127         myHypothesis.erase(it);
00128 }
00129 
00130 //=======================================================================
00131 //function : NbMeshes
00132 //purpose  : 
00133 //=======================================================================
00134 int SMESHDS_Document::NbMeshes()
00135 {
00136         return myMeshes.size();
00137 }
00138 
00139 //=======================================================================
00140 //function : NbHypothesis
00141 //purpose  : 
00142 //=======================================================================
00143 int SMESHDS_Document::NbHypothesis()
00144 {
00145         return myHypothesis.size();
00146 }
00147 
00148 //=======================================================================
00149 //function : InitMeshesIterator
00150 //purpose  : 
00151 //=======================================================================
00152 void SMESHDS_Document::InitMeshesIterator()
00153 {
00154         myMeshesIt=myMeshes.begin();
00155 }
00156 
00157 //=======================================================================
00158 //function : NextMesh
00159 //purpose  : 
00160 //=======================================================================
00161 SMESHDS_Mesh * SMESHDS_Document::NextMesh()
00162 {
00163         SMESHDS_Mesh * toReturn=(*myMeshesIt).second;
00164         myMeshesIt++;
00165         return toReturn;
00166 }
00167 
00168 //=======================================================================
00169 //function : MoreMesh
00170 //purpose  : 
00171 //=======================================================================
00172 bool SMESHDS_Document::MoreMesh()
00173 {
00174         return myMeshesIt!=myMeshes.end();
00175 }
00176 
00177 //=======================================================================
00178 //function : InitHypothesisIterator
00179 //purpose  : 
00180 //=======================================================================
00181 void SMESHDS_Document::InitHypothesisIterator()
00182 {
00183         myHypothesisIt=myHypothesis.begin();
00184 }
00185 
00186 //=======================================================================
00187 //function : NextMesh
00188 //purpose  : 
00189 //=======================================================================
00190 SMESHDS_Hypothesis * SMESHDS_Document::NextHypothesis()
00191 {
00192         SMESHDS_Hypothesis * toReturn=(*myHypothesisIt).second;
00193         myHypothesisIt++;
00194         return toReturn;
00195 }
00196 
00197 //=======================================================================
00198 //function : MoreMesh
00199 //purpose  : 
00200 //=======================================================================
00201 bool SMESHDS_Document::MoreHypothesis()
00202 {
00203         return myHypothesisIt!=myHypothesis.end();
00204 }
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS