smesh/src/SMESHDS/SMESHDS_Document.cxx

206 lines
6.7 KiB
C++
Raw Normal View History

2014-02-20 18:25:37 +06:00
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
2009-02-17 10:27:49 +05:00
//
2012-08-09 16:03:55 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2009-02-17 10:27:49 +05:00
//
2012-08-09 16:03:55 +06:00
// 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
2014-02-20 18:25:37 +06:00
// version 2.1 of the License, or (at your option) any later version.
2003-07-10 16:13:42 +06:00
//
2012-08-09 16:03:55 +06:00
// 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.
2003-07-10 16:13:42 +06:00
//
2012-08-09 16:03:55 +06:00
// 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
2003-07-10 16:13:42 +06:00
//
2012-08-09 16:03:55 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2003-07-10 16:13:42 +06:00
//
2012-08-09 16:03:55 +06:00
2009-02-17 10:27:49 +05:00
// SMESH SMESHDS : management of mesh data and SMESH document
2003-07-10 16:13:42 +06:00
// File : SMESHDS_Document.cxx
// Author : Yves FRICAUD, OCC
// Module : SMESH
// $Header:
2009-02-17 10:27:49 +05:00
//
#include "SMESHDS_Document.hxx"
#include "utilities.h"
2003-05-19 19:25:06 +06:00
2004-12-01 15:48:31 +05:00
using namespace std;
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 : Destructor
//purpose :
//=======================================================================
SMESHDS_Document::~SMESHDS_Document()
{
InitMeshesIterator();
while ( MoreMesh() )
delete NextMesh();
}
2003-05-19 19:25:06 +06:00
//=======================================================================
//function : NewMesh
//purpose :
//=======================================================================
2013-02-12 20:37:44 +06:00
SMESHDS_Mesh * SMESHDS_Document::NewMesh(bool theIsEmbeddedMode, int MeshID)
2003-05-19 19:25:06 +06:00
{
2013-02-12 20:37:44 +06:00
std::map<int,SMESHDS_Mesh*>::iterator i_m =
myMeshes.insert( make_pair( MeshID, (SMESHDS_Mesh*)0 )).first;
if ( i_m->second )
throw SALOME_Exception("SMESHDS_Document::NewMesh(): ID of existing mesh given");
SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(MeshID,theIsEmbeddedMode);
i_m->second = aNewMesh;
return aNewMesh;
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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +06:00
map<int,SMESHDS_Mesh*>::iterator it=myMeshes.find(MeshID);
if (it!=myMeshes.end())
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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +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
{
2012-08-09 16:03:55 +06:00
return myHypothesisIt!=myHypothesis.end();
2003-05-19 19:25:06 +06:00
}