X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHDS%2FSMESHDS_Document.cxx;h=f533a72a7873fe8dd5f5f6da94c5188b5d457026;hp=4b47835e4b40ddc7eb20fe8159c868b700bd09fe;hb=0febe018bcde111dc7aca1f3e44d4aa2995b59a2;hpb=bef9beee88cac57394b8dc3bc914381c1a2fff83 diff --git a/src/SMESHDS/SMESHDS_Document.cxx b/src/SMESHDS/SMESHDS_Document.cxx index 4b47835e4..f533a72a7 100644 --- a/src/SMESHDS/SMESHDS_Document.cxx +++ b/src/SMESHDS/SMESHDS_Document.cxx @@ -1,173 +1,192 @@ -using namespace std; -//============================================================================= -// File : SMESHDS_Document.cxx -// Created : -// Author : Yves FRICAUD, OCC -// Project : SALOME -// Copyright : OCC 2002 -// $Header: -//============================================================================= +// SMESH SMESHDS : management of mesh data and SMESH document +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHDS_Document.cxx +// Author : Yves FRICAUD, OCC +// Module : SMESH +// $Header: -#include "SMESHDS_Document.ixx" -#include "SMESHDS_Hypothesis.hxx" +#include "SMESHDS_Document.hxx" +#include "utilities.h" -#include +using namespace std; //======================================================================= //function : Create //purpose : //======================================================================= -SMESHDS_Document::SMESHDS_Document(const Standard_Integer UserID): myUserID(UserID) -{} +SMESHDS_Document::SMESHDS_Document(int UserID):myUserID(UserID) +{ +} //======================================================================= //function : NewMesh //purpose : //======================================================================= -Standard_Integer SMESHDS_Document::NewMesh() +int SMESHDS_Document::NewMesh() { - static Standard_Integer NewMeshID = 0; - NewMeshID++; - Handle (SMESHDS_Mesh) aNewMesh = new SMESHDS_Mesh (NewMeshID); - myMeshes.Bind(NewMeshID ,aNewMesh); - return NewMeshID; + static int NewMeshID = 0; + NewMeshID++; + SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(NewMeshID); + myMeshes[NewMeshID] = aNewMesh; + return NewMeshID; } //======================================================================= //function : GetMesh //purpose : //======================================================================= -Handle(SMESHDS_Mesh) SMESHDS_Document::GetMesh(const Standard_Integer MeshID) +SMESHDS_Mesh *SMESHDS_Document::GetMesh(int MeshID) { - if (!myMeshes.IsBound(MeshID)) - Standard_OutOfRange::Raise("SMESHDS_Document::RemoveMesh"); - return myMeshes.Find(MeshID); + map::iterator it=myMeshes.find(MeshID); + if (it==myMeshes.end()) + { + MESSAGE("SMESHDS_Document::GetMesh : ID not found"); + return NULL; + } + else return (*it).second; } //======================================================================= //function : RemoveMesh //purpose : //======================================================================= -void SMESHDS_Document::RemoveMesh(const Standard_Integer MeshID) +void SMESHDS_Document::RemoveMesh(int MeshID) { - if (!myMeshes.IsBound(MeshID)) - Standard_OutOfRange::Raise("SMESHDS_Document::RemoveMesh"); - myMeshes.UnBind(MeshID); + map::iterator it=myMeshes.find(MeshID); + if (it==myMeshes.end()) + MESSAGE("SMESHDS_Document::RemoveMesh : ID not found"); + myMeshes.erase(it); } //======================================================================= //function : AddHypothesis //purpose : //======================================================================= -void SMESHDS_Document::AddHypothesis(const SMESHDS_PtrHypothesis& H) +void SMESHDS_Document::AddHypothesis(SMESHDS_Hypothesis * H) { - myHypothesis.Bind (H->GetID(), H); + myHypothesis[H->GetID()]=H; } //======================================================================= //function : GetHypothesis //purpose : //======================================================================= -SMESHDS_PtrHypothesis SMESHDS_Document::GetHypothesis(const Standard_Integer HypID) +SMESHDS_Hypothesis * SMESHDS_Document::GetHypothesis(int HypID) { - if (!myHypothesis.IsBound(HypID)) - Standard_OutOfRange::Raise("SMESHDS_Document::GetHypothesis"); - return myHypothesis.Find(HypID); + map::iterator it=myHypothesis.find(HypID); + if (it==myHypothesis.end()) + { + MESSAGE("SMESHDS_Document::GetHypothesis : ID not found"); + return NULL; + } + else return (*it).second; } //======================================================================= //function : RemoveHypothesis //purpose : //======================================================================= -void SMESHDS_Document::RemoveHypothesis(const Standard_Integer HypID) +void SMESHDS_Document::RemoveHypothesis(int HypID) { - if (!myHypothesis.IsBound(HypID)) - Standard_OutOfRange::Raise("SMESHDS_Document::RemoveHypothesis"); - myMeshes.UnBind(HypID); + map::iterator it=myHypothesis.find(HypID); + if (it==myHypothesis.end()) + MESSAGE("SMESHDS_Document::RemoveHypothesis : ID not found"); + myHypothesis.erase(it); } //======================================================================= //function : NbMeshes //purpose : //======================================================================= -Standard_Integer SMESHDS_Document::NbMeshes() +int SMESHDS_Document::NbMeshes() { - return myMeshes.Extent(); + return myMeshes.size(); } //======================================================================= //function : NbHypothesis //purpose : //======================================================================= -Standard_Integer SMESHDS_Document::NbHypothesis() +int SMESHDS_Document::NbHypothesis() { - return myHypothesis.Extent(); + return myHypothesis.size(); } //======================================================================= //function : InitMeshesIterator //purpose : //======================================================================= -void SMESHDS_Document::InitMeshesIterator() +void SMESHDS_Document::InitMeshesIterator() { - myMeshesIt.Initialize(myMeshes); + myMeshesIt=myMeshes.begin(); } + //======================================================================= //function : NextMesh //purpose : //======================================================================= -void SMESHDS_Document::NextMesh() +SMESHDS_Mesh * SMESHDS_Document::NextMesh() { - myMeshesIt.Next(); + SMESHDS_Mesh * toReturn=(*myMeshesIt).second; + myMeshesIt++; + return toReturn; } + //======================================================================= //function : MoreMesh //purpose : //======================================================================= -Standard_Boolean SMESHDS_Document::MoreMesh() -{ - return myMeshesIt.More(); -} -//======================================================================= -//function : CurrentMesh -//purpose : -//======================================================================= -Handle_SMESHDS_Mesh SMESHDS_Document::CurrentMesh() +bool SMESHDS_Document::MoreMesh() { - return myMeshesIt.Value(); + return myMeshesIt!=myMeshes.end(); } //======================================================================= //function : InitHypothesisIterator //purpose : //======================================================================= -void SMESHDS_Document::InitHypothesisIterator() +void SMESHDS_Document::InitHypothesisIterator() { - myHypothesisIt.Initialize(myHypothesis); + myHypothesisIt=myHypothesis.begin(); } + //======================================================================= //function : NextMesh //purpose : //======================================================================= -void SMESHDS_Document::NextHypothesis() +SMESHDS_Hypothesis * SMESHDS_Document::NextHypothesis() { - myHypothesisIt.Next(); + SMESHDS_Hypothesis * toReturn=(*myHypothesisIt).second; + myHypothesisIt++; + return toReturn; } + //======================================================================= //function : MoreMesh //purpose : //======================================================================= -Standard_Boolean SMESHDS_Document::MoreHypothesis() -{ - return myHypothesisIt.More(); -} -//======================================================================= -//function : CurrentMesh -//purpose : -//======================================================================= -SMESHDS_PtrHypothesis SMESHDS_Document::CurrentHypothesis() +bool SMESHDS_Document::MoreHypothesis() { - return myHypothesisIt.Value(); + return myHypothesisIt!=myHypothesis.end(); } - -