X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHDS%2FSMESHDS_SubMesh.cxx;h=c7ad4c2108231107cbf318c28e282879433f7c03;hp=fab9fba9c8233b32d694b05001af1c62dd31ad69;hb=c3bf92bd87b770fd81631a3853f7f5bb1ac6a4e8;hpb=bef9beee88cac57394b8dc3bc914381c1a2fff83 diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index fab9fba9c..c7ad4c210 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -1,128 +1,131 @@ -using namespace std; -//============================================================================= -// File : SMESH_SubMesh.cxx -// Created : -// Author : Yves FRICAUD, OCC -// Project : SALOME -// Copyright : OCC 2002 -// $Header: -//============================================================================= - -#include "SMESHDS_SubMesh.ixx" -#include "SMDS_MapIteratorOfExtendedMap.hxx" +// 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 : SMESH_SubMesh.cxx +// Author : Yves FRICAUD, OCC +// Module : SMESH +// $Header: -//======================================================================= -//function : SMESHDS_SubMesh -//purpose : -//======================================================================= -SMESHDS_SubMesh::SMESHDS_SubMesh(const Handle(SMDS_Mesh)& M) : myMesh(M) -{ - myListOfEltIDIsUpdate = Standard_False; - myListOfNodeIDIsUpdate = Standard_False; -} +using namespace std; +#include "SMESHDS_SubMesh.hxx" //======================================================================= //function : AddElement //purpose : //======================================================================= -void SMESHDS_SubMesh::AddElement (const Handle(SMDS_MeshElement)& ME) +void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME) { - myElements.Add(ME); - myListOfEltIDIsUpdate = Standard_False; + myElements.insert(ME); } //======================================================================= //function : RemoveElement //purpose : //======================================================================= -void SMESHDS_SubMesh::RemoveElement(const Handle(SMDS_MeshElement)& ME) +bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME) { - myElements.Remove(ME); - myListOfEltIDIsUpdate = Standard_False; + if ( NbElements() ) + return myElements.erase(ME); + + return false; } + //======================================================================= //function : AddNode //purpose : //======================================================================= -void SMESHDS_SubMesh::AddNode (const Handle(SMDS_MeshNode)& N) +void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N) { - myNodes.Add(N); - myListOfNodeIDIsUpdate = Standard_False; + myNodes.insert(N); } //======================================================================= //function : RemoveNode //purpose : //======================================================================= -void SMESHDS_SubMesh::RemoveNode (const Handle(SMDS_MeshNode)& N) +bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N) { - myNodes.Remove(N); - myListOfNodeIDIsUpdate = Standard_False; + if ( NbNodes() ) + return myNodes.erase(N); + + return false; } //======================================================================= //function : NbElements //purpose : //======================================================================= -Standard_Integer SMESHDS_SubMesh::NbElements() +int SMESHDS_SubMesh::NbElements() const { - return myElements.Extent(); + return myElements.size(); } -//======================================================================= -//function : GetElements -//purpose : -//======================================================================= -const SMDS_MapOfMeshElement& SMESHDS_SubMesh::GetElements() -{ - return myElements; -} //======================================================================= //function : NbNodes //purpose : //======================================================================= -Standard_Integer SMESHDS_SubMesh::NbNodes() +int SMESHDS_SubMesh::NbNodes() const { - return myNodes.Extent(); + return myNodes.size(); } -//======================================================================= -//function : GetNodes -//purpose : -//======================================================================= -const SMDS_MapOfMeshElement& SMESHDS_SubMesh::GetNodes() +template class MySetIterator:public SMDS_Iterator { - return myNodes; -} + typedef const set TSet; + typename TSet::const_iterator myIt; + TSet& mySet; -//======================================================================= -//function : GetIDElements -//purpose : -//======================================================================= -const TColStd_ListOfInteger& SMESHDS_SubMesh::GetIDElements() + public: + MySetIterator(const set& s):mySet(s), myIt(s.begin()) + { + } + + bool more() + { + return myIt!=mySet.end(); + } + const T* next() + { + const T* t=*myIt; + myIt++; + return t; + } +}; +/////////////////////////////////////////////////////////////////////////////// +///Return an iterator on the elements of submesh +///The created iterator must be free by the caller +/////////////////////////////////////////////////////////////////////////////// +SMDS_ElemIteratorPtr SMESHDS_SubMesh::GetElements() const { - if (!myListOfEltIDIsUpdate) { - myListOfEltID.Clear(); - for (SMDS_MapIteratorOfExtendedMap it(myElements); it.More(); it.Next()) { - myListOfEltID.Append(it.Key()->GetID()); - } - myListOfEltIDIsUpdate = Standard_True; - } - return myListOfEltID; + return SMDS_ElemIteratorPtr(new MySetIterator(myElements)); } -//======================================================================= -//function : GetIDNodes -//purpose : -//======================================================================= -const TColStd_ListOfInteger& SMESHDS_SubMesh::GetIDNodes() +/////////////////////////////////////////////////////////////////////////////// +///Return an iterator on the nodes of submesh +///The created iterator must be free by the caller +/////////////////////////////////////////////////////////////////////////////// +SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes() const { - if (!myListOfNodeIDIsUpdate) { - myListOfNodeID.Clear(); - for (SMDS_MapIteratorOfExtendedMap it(myNodes); it.More(); it.Next()) { - myListOfNodeID.Append(it.Key()->GetID()); - } - myListOfNodeIDIsUpdate = Standard_True; - } - return myListOfNodeID; + return SMDS_NodeIteratorPtr(new MySetIterator(myNodes)); } +