-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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// 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 <Standard_OutOfRange.hxx>
+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 : Destructor
+//purpose :
+//=======================================================================
+
+SMESHDS_Document::~SMESHDS_Document()
+{
+ InitMeshesIterator();
+ while ( MoreMesh() )
+ delete NextMesh();
+}
//=======================================================================
//function : NewMesh
//purpose :
//=======================================================================
-Standard_Integer SMESHDS_Document::NewMesh()
+int SMESHDS_Document::NewMesh(bool theIsEmbeddedMode)
{
- static Standard_Integer NewMeshID = 0;
- NewMeshID++;
- Handle (SMESHDS_Mesh) aNewMesh = new SMESHDS_Mesh (NewMeshID);
- myMeshes.Bind(NewMeshID ,aNewMesh);
- return NewMeshID;
+ static int aNewMeshID = 0;
+ aNewMeshID++;
+ SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(aNewMeshID,theIsEmbeddedMode);
+ myMeshes[aNewMeshID] = aNewMesh;
+ return aNewMeshID;
}
//=======================================================================
//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<int,SMESHDS_Mesh*>::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<int,SMESHDS_Mesh*>::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<int,SMESHDS_Hypothesis*>::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<int,SMESHDS_Hypothesis*>::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()
+bool SMESHDS_Document::MoreMesh()
{
- return myMeshesIt.More();
-}
-//=======================================================================
-//function : CurrentMesh
-//purpose :
-//=======================================================================
-Handle_SMESHDS_Mesh SMESHDS_Document::CurrentMesh()
-{
- 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()
+bool SMESHDS_Document::MoreHypothesis()
{
- return myHypothesisIt.More();
+ return myHypothesisIt!=myHypothesis.end();
}
-//=======================================================================
-//function : CurrentMesh
-//purpose :
-//=======================================================================
-SMESHDS_PtrHypothesis SMESHDS_Document::CurrentHypothesis()
-{
- return myHypothesisIt.Value();
-}
-
-