smesh/src/SMESHDS/SMESHDS_Document.cxx

192 lines
5.9 KiB
C++
Raw Normal View History

2003-07-10 16:13:42 +06:00
// 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:
2003-05-19 19:25:06 +06:00
2003-07-10 16:13:42 +06:00
using namespace std;
#include "SMESHDS_Document.hxx"
#include <utilities.h>
2003-05-19 19:25:06 +06:00
//=======================================================================
//function : Create
//purpose :
//=======================================================================
SMESHDS_Document::SMESHDS_Document(int UserID):myUserID(UserID)
{
}
2003-05-19 19:25:06 +06:00
//=======================================================================
//function : NewMesh
//purpose :
//=======================================================================
int SMESHDS_Document::NewMesh()
2003-05-19 19:25:06 +06:00
{
static int NewMeshID = 0;
NewMeshID++;
SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(NewMeshID);
myMeshes[NewMeshID] = aNewMesh;
return NewMeshID;
2003-05-19 19:25:06 +06:00
}
//=======================================================================
//function : GetMesh
//purpose :
//=======================================================================
SMESHDS_Mesh *SMESHDS_Document::GetMesh(int MeshID)
2003-05-19 19:25:06 +06:00
{
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;
2003-05-19 19:25:06 +06:00
}
//=======================================================================
//function : RemoveMesh
//purpose :
//=======================================================================
void SMESHDS_Document::RemoveMesh(int MeshID)
2003-05-19 19:25:06 +06:00
{
map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
if (it==myMeshes.end())
MESSAGE("SMESHDS_Document::RemoveMesh : ID not found");
myMeshes.erase(it);
2003-05-19 19:25:06 +06:00
}
//=======================================================================
//function : AddHypothesis
//purpose :
//=======================================================================
void SMESHDS_Document::AddHypothesis(SMESHDS_Hypothesis * H)
2003-05-19 19:25:06 +06:00
{
myHypothesis[H->GetID()]=H;
2003-05-19 19:25:06 +06:00
}
//=======================================================================
//function : GetHypothesis
//purpose :
//=======================================================================
SMESHDS_Hypothesis * SMESHDS_Document::GetHypothesis(int HypID)
2003-05-19 19:25:06 +06:00
{
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;
2003-05-19 19:25:06 +06:00
}
//=======================================================================
//function : RemoveHypothesis
//purpose :
//=======================================================================
void SMESHDS_Document::RemoveHypothesis(int HypID)
2003-05-19 19:25:06 +06:00
{
map<int,SMESHDS_Hypothesis*>::iterator it=myHypothesis.find(HypID);
if (it==myHypothesis.end())
MESSAGE("SMESHDS_Document::RemoveHypothesis : ID not found");
myHypothesis.erase(it);
2003-05-19 19:25:06 +06:00
}
//=======================================================================
//function : NbMeshes
//purpose :
//=======================================================================
int SMESHDS_Document::NbMeshes()
2003-05-19 19:25:06 +06:00
{
return myMeshes.size();
2003-05-19 19:25:06 +06:00
}
//=======================================================================
//function : NbHypothesis
//purpose :
//=======================================================================
int SMESHDS_Document::NbHypothesis()
2003-05-19 19:25:06 +06:00
{
return myHypothesis.size();
2003-05-19 19:25:06 +06:00
}
//=======================================================================
//function : InitMeshesIterator
//purpose :
//=======================================================================
void SMESHDS_Document::InitMeshesIterator()
2003-05-19 19:25:06 +06:00
{
myMeshesIt=myMeshes.begin();
2003-05-19 19:25:06 +06:00
}
2003-05-19 19:25:06 +06:00
//=======================================================================
//function : NextMesh
//purpose :
//=======================================================================
SMESHDS_Mesh * SMESHDS_Document::NextMesh()
2003-05-19 19:25:06 +06:00
{
SMESHDS_Mesh * toReturn=(*myMeshesIt).second;
myMeshesIt++;
return toReturn;
2003-05-19 19:25:06 +06:00
}
2003-05-19 19:25:06 +06:00
//=======================================================================
//function : MoreMesh
//purpose :
//=======================================================================
bool SMESHDS_Document::MoreMesh()
2003-05-19 19:25:06 +06:00
{
return myMeshesIt!=myMeshes.end();
2003-05-19 19:25:06 +06:00
}
//=======================================================================
//function : InitHypothesisIterator
//purpose :
//=======================================================================
void SMESHDS_Document::InitHypothesisIterator()
2003-05-19 19:25:06 +06:00
{
myHypothesisIt=myHypothesis.begin();
2003-05-19 19:25:06 +06:00
}
2003-05-19 19:25:06 +06:00
//=======================================================================
//function : NextMesh
//purpose :
//=======================================================================
SMESHDS_Hypothesis * SMESHDS_Document::NextHypothesis()
2003-05-19 19:25:06 +06:00
{
SMESHDS_Hypothesis * toReturn=(*myHypothesisIt).second;
myHypothesisIt++;
return toReturn;
2003-05-19 19:25:06 +06:00
}
2003-05-19 19:25:06 +06:00
//=======================================================================
//function : MoreMesh
//purpose :
//=======================================================================
bool SMESHDS_Document::MoreHypothesis()
2003-05-19 19:25:06 +06:00
{
return myHypothesisIt!=myHypothesis.end();
2003-05-19 19:25:06 +06:00
}